/* ===== Authenticated app shell (icon rail + content) ===== */
body.app { display: flex; min-height: 100vh; background: var(--bg-2); }

.rail { position: sticky; top: 0; height: 100vh; width: 72px; flex: none;
  background: #2B2B2B; display: flex; flex-direction: column; align-items: center;
  padding: 18px 0; gap: 8px; }
.rail__logo { width: 44px; height: 44px; border-radius: 14px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 700;
  margin-bottom: 14px; }
.rail__nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rail__item { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  color: #9b9b9b; transition: .15s; }
.rail__item svg { width: 22px; height: 22px; }
.rail__item:hover { background: #3a3a3a; color: #fff; }
.rail__item.is-active { background: var(--brand); color: #fff; }
.rail__logout { color: #8a8a8a; }
.rail__logout:hover { background: #3a3a3a; color: #fff; }

.app-main { flex: 1; min-width: 0; padding: 24px 28px 60px; }

/* Banner */
.app-banner { background: #2B2B2B; color: #fff; border-radius: var(--r-lg);
  padding: 28px 32px; display: flex; align-items: center; justify-content: space-between;
  gap: 24px; margin-bottom: 24px; }
.app-banner h1 { font-size: 26px; margin-bottom: 6px; }
.app-banner p { color: #b9b9b9; font-size: var(--fs-sm); max-width: 560px; }

/* Two-column catalog */
.catalog { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.panel { background: #fff; border-radius: var(--r-lg); padding: 24px; }
.panel__title { font-size: 20px; font-weight: 700; margin-bottom: 18px; }

.tabs { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 8px 18px; border-radius: var(--pill); font-size: var(--fs-sm); color: var(--ink-2);
  background: var(--bg-2); }
.tab.is-active { background: var(--brand); color: #fff; }

/* Project row card */
.p-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px;
  margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
.p-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.p-card__head h3 { font-size: 19px; }
.p-card a.p-card__title { color: var(--ink); }
.p-card a.p-card__title:hover { color: var(--brand); }
.badge { font-size: var(--fs-xs); padding: 5px 12px; border-radius: var(--pill); white-space: nowrap; }
.badge--active { background: #EAF7EF; color: #1E8449; }
.badge--paused { background: #FDF3E7; color: #B9770E; }
.badge--done { background: var(--brand-l); color: var(--brand); }
.badge--draft { background: var(--bg-2); color: var(--muted); }
.p-card__desc { color: var(--ink-2); font-size: var(--fs-sm); }
.p-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.p-card__meta { color: var(--muted); font-size: var(--fs-sm); }

/* Friends column */
.friend { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.friend:last-child { border-bottom: 0; }
.friend .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-l); flex: none; }
.friend h4 { font-size: var(--fs-sm); }
.friend small { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 36px 0; }

/* ===== Create wizard ===== */
.wizard { background: #fff; border-radius: var(--r-lg); padding: 40px 48px; max-width: 1000px; }
.wizard h1 { font-size: 32px; margin-bottom: 24px; }
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 32px; flex-wrap: wrap; }
.stepper__node { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-sm); }
.stepper__dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 12px; }
.stepper__node.is-active { color: var(--ink); font-weight: 600; }
.stepper__node.is-active .stepper__dot { border-color: var(--brand); color: var(--brand); }
.stepper__node.is-done .stepper__dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.stepper__line { width: 40px; height: 2px; background: var(--line); }

.wizard label.fl { display: block; font-weight: 600; margin: 0 0 8px; }
.wizard input[type=text], .wizard input[type=number], .wizard input[type=url],
.wizard input[type=email], .wizard textarea {
  width: 100%; padding: 15px 18px; font: inherit; font-size: 16px; border: 1px solid var(--line);
  border-radius: 14px; outline: none; }
.wizard input:focus, .wizard textarea:focus { border-color: var(--brand); }
.wizard textarea { min-height: 180px; resize: vertical; }
.wizard .row { margin-bottom: 24px; }
.map-box { background: var(--bg-2); border-radius: var(--r-md); padding: 22px; margin-bottom: 24px; }
.map-box__head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.switch { position: relative; width: 52px; height: 28px; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; background: #ccc; border-radius: 100px; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; background: #fff;
  border-radius: 50%; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(24px); }
.uploader { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.photo-slot { aspect-ratio: 4/3; border-radius: var(--r-md); background: var(--bg-2);
  border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.wizard__foot { display: flex; justify-content: space-between; margin-top: 8px; }
.charcount { float: right; color: var(--muted); font-size: var(--fs-sm); }

/* ===== Project detail ===== */
.detail { max-width: 1000px; }
.detail__cover { height: 360px; border-radius: var(--r-lg); overflow: hidden; background: var(--bg-2);
  margin-bottom: 24px; }
.detail__cover img { width: 100%; height: 100%; object-fit: cover; }
.detail__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  margin-bottom: 8px; }
.detail h1 { font-size: 34px; }
.detail__author { color: var(--muted); margin-bottom: 24px; }
.detail__section { background: #fff; border-radius: var(--r-lg); padding: 28px; margin-bottom: 20px; }
.detail__section h2 { font-size: 22px; margin-bottom: 12px; }
.detail__gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.detail__gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--r-md); }
.fund-bar { height: 12px; background: var(--bg-2); border-radius: var(--pill); overflow: hidden; margin: 14px 0; }
.fund-bar > span { display: block; height: 100%; background: var(--brand); }

@media (max-width: 1000px) { .catalog { grid-template-columns: minmax(0, 1fr); } .photo-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px) { .rail { width: 56px; } .app-main { padding: 16px; } .wizard, .panel { padding: 22px; } }

/* ===== Group chat ===== */
.chat { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 420px; padding: 0; }
.chat__feed { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 12px; max-width: 80%; }
.msg--me { flex-direction: row-reverse; align-self: flex-end; }
.msg__avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-l); flex: none; }
.msg__name { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 4px; }
.msg--me .msg__name { text-align: right; }
.msg__bubble { background: var(--bg-2); padding: 12px 16px; border-radius: 16px; font-size: var(--fs-sm); }
.msg--me .msg__bubble { background: var(--brand); color: #fff; }
.chat__input { display: flex; gap: 12px; padding: 18px 24px; border-top: 1px solid var(--line); }
.chat__input input { flex: 1; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; font: inherit; outline: none; }
.chat__input input:focus { border-color: var(--brand); }

/* ===== Map page ===== */
.map-page { display: grid; grid-template-columns: 1fr 320px; grid-template-rows: auto 1fr;
  gap: 16px; height: calc(100vh - 48px); }
.map-page__bar { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.map-layers { display: flex; gap: 10px; }
.map-layer { padding: 10px 20px; border-radius: var(--pill); border: 1px solid var(--line);
  background: #fff; font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.map-layer.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.map-filter { padding: 10px 18px; border: 1px solid var(--line); border-radius: var(--pill);
  font: inherit; min-width: 260px; outline: none; }
#big-map { border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); min-height: 420px; }
.map-aside { background: #fff; border-radius: var(--r-lg); padding: 20px; overflow-y: auto; }
.map-row { padding: 12px; border-radius: var(--r-sm); cursor: pointer; border-bottom: 1px solid var(--line); }
.map-row:hover { background: var(--bg-2); }
.map-row small { color: var(--muted); }
@media (max-width: 1000px) { .map-page { grid-template-columns: 1fr; height: auto; } #big-map { height: 60vh; } }

/* ===== Marketplace ===== */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.prod-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px;
  display: flex; flex-direction: column; gap: 8px; transition: .15s; color: var(--ink); }
.prod-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.prod-card__img { aspect-ratio: 1; border-radius: var(--r-md); background: var(--bg-2); overflow: hidden; }
.prod-card__img img { width: 100%; height: 100%; object-fit: cover; }
.prod-card__name { font-weight: 600; font-size: var(--fs-sm); }
.prod-card__price { font-weight: 700; font-size: var(--fs-h3); }
.prod-detail { display: grid; grid-template-columns: 440px 1fr; gap: 40px; align-items: start; }
.prod-detail__img { aspect-ratio: 1; border-radius: var(--r-lg); background: var(--bg-2); overflow: hidden; }
.prod-detail__img img { width: 100%; height: 100%; object-fit: cover; }
.prod-detail__price { font-size: 32px; font-weight: 700; color: var(--brand); }
@media (max-width: 800px) { .prod-detail { grid-template-columns: 1fr; } }

/* ===== Profile / settings / notifications ===== */
.profile-head { display: flex; gap: 24px; align-items: center; background: #fff;
  border-radius: var(--r-lg); padding: 28px; }
.profile-avatar { width: 96px; height: 96px; border-radius: 50%; background: var(--brand-l);
  color: var(--brand); display: grid; place-items: center; font-size: 40px; font-weight: 700;
  flex: none; overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { flex: 1; }
.profile-info h1 { font-size: 28px; }
.blog-post { border-bottom: 1px solid var(--line); padding: 18px 0; }
.blog-post:last-child { border-bottom: 0; }
.blog-post h3 { font-size: 20px; }
.notif { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--r-md);
  color: var(--ink); border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: 0; }
.notif__dot { width: 9px; height: 9px; border-radius: 50%; background: transparent; flex: none; }
.notif--unread { background: var(--brand-l); }
.notif--unread .notif__dot { background: var(--brand); }

/* ===== Mobile fixes: section banners ===== */
@media (max-width: 720px) {
  .app-banner { flex-direction: column; align-items: stretch; gap: 16px; padding: 22px; }
  .app-banner h1 { font-size: 22px; }
  .app-banner p { max-width: none; }
  .app-banner > a.btn { width: 100%; }
  .app-banner > div:last-child { display: flex; flex-direction: column; gap: 10px; width: 100%; }
  .app-banner > div:last-child .btn { width: 100%; }
  .app-banner > div:last-child form { width: 100%; }
  .app-banner > div:last-child form .btn { width: 100%; }
}

/* ===== Avatar crop ===== */
.avatar-preview { width: 88px; height: 88px; border-radius: 50%; background: var(--brand-l);
  color: var(--brand); display: grid; place-items: center; font-size: 36px; font-weight: 700;
  overflow: hidden; flex: none; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.crop-modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 20px; }
.crop-modal.is-open { display: flex; }
.crop-box { background: #fff; border-radius: var(--r-lg); padding: 24px; width: 460px; max-width: 95vw; }
.crop-box h3 { margin-bottom: 16px; }
.crop-stage { max-height: 60vh; }
.crop-stage img { max-width: 100%; display: block; }
.crop-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 18px; }

/* ===== Mobile: clean vertical stepper + no horizontal scroll ===== */
.app-main { overflow-x: clip; }
@media (max-width: 720px) {
  .stepper { flex-direction: column; align-items: flex-start; gap: 12px; }
  .stepper__line { display: none; }
  .avatar-preview { width: 72px; height: 72px; font-size: 28px; }
}

/* ===== Wallet ===== */
.wallet-balance { background: var(--brand); color: #fff; border-radius: var(--r-md);
  padding: 16px 28px; display: flex; flex-direction: column; align-items: center; }
.wallet-balance__num { font-size: 34px; font-weight: 800; line-height: 1; }
.wallet-balance__cur { font-size: 13px; opacity: .85; }
.ledger-row { display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0; border-bottom: 1px solid var(--line); }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row__reason { font-weight: 500; }
.ledger-row__delta { font-weight: 700; font-size: 18px; }
.ledger-row__delta.is-plus { color: var(--ok); }
.ledger-row__delta.is-minus { color: #C0392B; }

/* ===== Mobile fixes: detail header, chat input, map controls ===== */
@media (max-width: 720px) {
  /* project / product detail header */
  .detail__head { flex-direction: column; align-items: stretch; gap: 12px; }
  .detail h1 { font-size: 24px; }
  .detail__head > div:nth-child(2) { display: flex; flex-direction: column; gap: 10px; }
  .detail__head > div:nth-child(2) > * { width: 100%; }
  .detail__head > div:nth-child(2) .btn { width: 100%; }
  .detail__head > form { width: 100%; }
  .detail__head > form .btn { width: 100%; }
  .detail__section { padding: 20px; }
  .detail__section form { flex-wrap: wrap; }
  .detail__section form input { min-width: 0; flex: 1 1 100% !important; }
  .detail__section form .btn { width: 100%; }
  .prod-detail__price { font-size: 26px; }

  /* group chat input fits */
  .chat { height: calc(100vh - 260px); }
  .chat__input { padding: 12px; gap: 8px; }
  .chat__input input { padding: 12px 14px; min-width: 0; }
  .chat__input .btn { padding: 12px 16px; flex: none; }
  .msg { max-width: 92%; }

  /* map controls wrap / fit */
  .map-page { height: auto; }
  .map-page__bar { flex-direction: column; align-items: stretch; }
  .map-layers { flex-wrap: wrap; }
  .map-layer { white-space: nowrap; }
  .map-filter { min-width: 0; width: 100%; }
  #big-map { height: 56vh; }
}
