/* «Гардероб» design system — see docs/design-brief.html#ds.
   Layout: mobile column with bottom tab bar; ≥1024px a left sidebar and a wider content well.
   Editorial screens (wardrobe, result, collection, outfit) get display type and air; work screens stay single-column and plain. */
:root {
  --bg: #F7F4EE; --surface: #FFFFFF; --backdrop: #EFEBE3;
  --ink: #141412; --muted: #6B665E; --disabled: #9A948A;
  --divider: #E3DED4; --field: #8E887E;
  --accent: #6E1F2F; --error: #B3261E; --success: #2E6B47;
  --display: "Geologica", "Helvetica Neue", Arial, sans-serif;
  --text: "Golos Text", "Helvetica Neue", Arial, sans-serif;
  --r-card: 12px; --r-ctl: 10px; --r-tag: 6px;
  --pad: 20px; --btn-h: 52px;
  --shadow: 0 8px 24px rgba(20, 20, 18, .08);
  color-scheme: light;
}
@media (min-width: 1024px) { :root { --pad: 48px; --btn-h: 44px; } }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 400 16px/24px var(--text); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Type ---------- */
.display { font: 400 40px/40px var(--display); letter-spacing: -.03em; margin: 0; text-wrap: balance; }
.heading { font: 400 28px/32px var(--display); letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.title { font: 500 20px/26px var(--display); letter-spacing: -.01em; margin: 0; }
.small { font-size: 14px; line-height: 20px; }
.muted { color: var(--muted); }
.label { font: 500 12px/16px var(--text); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
@media (min-width: 1024px) {
  .display { font-size: 64px; line-height: 64px; }
  .heading { font-size: 40px; line-height: 44px; }
  .title { font-size: 22px; line-height: 28px; }
}

/* ---------- Shell ---------- */
.app { min-height: 100vh; }
.view { padding: calc(20px + env(safe-area-inset-top, 0px)) var(--pad) calc(96px + env(safe-area-inset-bottom, 0px)); max-width: 1180px; margin: 0 auto; display: grid; gap: 24px; align-content: start; }
.view.editorial { gap: 32px; }
.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--divider); padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 10px 4px 8px; text-decoration: none; color: var(--muted); font-size: 12px; line-height: 16px; min-height: 56px; }
.nav a.on { color: var(--accent); }
.nav .brand { display: none; }
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 248px 1fr; }
  .nav { position: sticky; top: 0; height: 100vh; flex-direction: column; border-top: 0; border-right: 1px solid var(--divider); padding: 32px 16px; gap: 4px; }
  .nav .brand { display: block; padding: 0 12px 24px; }
  .nav .brand b { font: 400 24px/28px var(--display); letter-spacing: -.02em; display: block; }
  .nav a { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-ctl); font-size: 15px; min-height: 44px; }
  .nav a.on { background: var(--surface); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }
  .view { padding-top: 48px; padding-bottom: 64px; }
}
.icon { width: 24px; height: 24px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 18px; height: 18px; }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.top > div { display: grid; gap: 6px; min-width: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 14px; background: none; border: 0; padding: 0; min-height: 32px; }
.section { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--btn-h); padding: 0 22px; border-radius: var(--r-ctl); border: 1px solid var(--ink); background: var(--ink); color: #fff; font-weight: 500; text-decoration: none; white-space: nowrap; transition: opacity .15s; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.text { background: none; border-color: transparent; color: var(--ink); padding: 0 8px; }
.btn.danger { background: none; border-color: transparent; color: var(--error); padding: 0; height: 44px; }
.btn.block { width: 100%; }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; }
.btn.square { width: var(--btn-h); padding: 0; background: transparent; color: var(--ink); }

.field { display: grid; gap: 6px; }
.input { width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--field); border-radius: var(--r-ctl); background: var(--surface); }
textarea.input { resize: vertical; min-height: 88px; }
.input[readonly] { background: var(--backdrop); border-color: transparent; color: var(--muted); }
.hint { font-size: 14px; line-height: 20px; color: var(--muted); }
.hint.warn { color: var(--accent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--pad)); padding: 2px var(--pad); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--field); background: var(--surface); font-size: 14px; font-weight: 500; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.segmented { display: grid; gap: 8px; }
.option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 52px; padding: 12px 16px; border-radius: var(--r-ctl); border: 1px solid var(--field); background: var(--surface); text-align: left; }
.option[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.option small { display: block; color: var(--muted); font-size: 14px; line-height: 20px; }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-tag); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.own { background: var(--ink); color: #fff; }
.tag.new { border: 1px dashed var(--accent); color: var(--accent); }
.tag.occasion { background: var(--backdrop); color: var(--ink); }

/* ---------- Photos and items ---------- */
.photo { background: var(--backdrop); border-radius: var(--r-card); overflow: hidden; aspect-ratio: 3 / 4; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo.large { aspect-ratio: 4 / 5; }
.photo.large img { object-fit: contain; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.item { display: grid; gap: 8px; text-decoration: none; background: none; border: 0; padding: 0; text-align: left; position: relative; min-width: 0; }
.item .name { font-weight: 500; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 14px; line-height: 20px; color: var(--muted); }
.item .check { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.item:not(.sel) .check { display: none; }
.item.sel .photo { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Outfit collage: pieces laid out by body zone ---------- */
.collage { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; background: var(--backdrop); border-radius: var(--r-card); position: relative; }
.collage .cell { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface); display: grid; place-items: center; }
.collage .cell img { width: 100%; height: 100%; object-fit: cover; }
.collage .cell.new { background: transparent; border: 1px dashed var(--accent); color: var(--accent); font-size: 13px; line-height: 18px; padding: 10px; text-align: center; }
.collage .cell.gone { color: var(--disabled); font-size: 13px; }
.collage .cell.hero { grid-row: span 2; aspect-ratio: auto; }
.collage.lg { gap: 8px; padding: 8px; }
.collage .badge { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); color: var(--accent); display: grid; place-items: center; }

.pieces { display: grid; gap: 0; }
.piece { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--divider); background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%; }
.piece .thumb { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--backdrop); display: grid; place-items: center; }
.piece .thumb img { width: 100%; height: 100%; object-fit: cover; }
.piece .thumb.new { background: transparent; border: 1px dashed var(--accent); color: var(--accent); }
.piece b { font-weight: 500; display: block; }
.piece .row { gap: 6px; margin-top: 4px; }

.note { border-left: 2px solid var(--accent); padding: 2px 0 2px 16px; display: grid; gap: 6px; max-width: 62ch; }
.note p { margin: 0; font-size: 17px; line-height: 26px; }
@media (min-width: 1024px) { .note p { font-size: 18px; line-height: 28px; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--r-card); padding: 16px; display: grid; gap: 12px; text-decoration: none; border: 0; text-align: left; width: 100%; }
.choice { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center; padding: 16px; }
.choice .art { aspect-ratio: 1; border-radius: var(--r-ctl); background: var(--backdrop); display: grid; place-items: center; color: var(--ink); }
.choice.alt { background: var(--backdrop); }
.choice.alt .art { background: var(--surface); }

/* Collection: two offset columns, like a magazine spread */
.spread { columns: 2; column-gap: 12px; }
.spread > * { break-inside: avoid; margin-bottom: 12px; }
@media (min-width: 900px) { .spread { columns: 3; column-gap: 20px; } .spread > * { margin-bottom: 20px; } }
.look { display: grid; gap: 10px; padding: 8px 8px 14px; background: var(--surface); border-radius: var(--r-card); text-decoration: none; }
.look .title { padding: 0 6px; font-size: 18px; line-height: 22px; }
.look .tag { margin: 0 6px; justify-self: start; }

/* ---------- Add-item rows ---------- */
.addrow { background: var(--surface); border-radius: var(--r-card); padding: 12px; display: grid; gap: 16px; }
.addrow.collapsed { grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; cursor: pointer; }
.addrow.collapsed .photo { aspect-ratio: 1; width: 48px; border-radius: 8px; }
.ai-line { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; background: var(--backdrop); border-radius: var(--r-ctl); padding: 8px; }
.ai-line .photo { aspect-ratio: 1; border-radius: 8px; }
.ai-line p { margin: 0; font: 500 16px/22px var(--display); }
.drop { border: 1px dashed var(--field); border-radius: var(--r-card); background: var(--backdrop); min-height: 240px; display: grid; place-items: center; text-align: center; gap: 8px; padding: 24px; cursor: pointer; }
.drop .plus { width: 56px; height: 56px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; margin: 0 auto; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--disabled); }
.status.ok::before { background: var(--success); }
.status.busy::before { background: var(--accent); animation: pulse 1s infinite alternate; }
.actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
@keyframes pulse { to { opacity: .3; } }

.skeleton { background: linear-gradient(90deg, var(--backdrop), #f4f0e8, var(--backdrop)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: var(--r-ctl); height: 44px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Waiting for the stylist ---------- */
.wait { display: grid; gap: 24px; padding-top: 24px; max-width: 520px; }
.progress { height: 2px; background: var(--divider); overflow: hidden; border-radius: 2px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .6s ease-out; }
.steps { display: grid; gap: 14px; list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 20px 1fr; gap: 12px; color: var(--disabled); }
.steps li::before { content: ""; width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; border: 1px solid currentColor; }
.steps li.done, .steps li.now { color: var(--ink); }
.steps li.done::before { background: var(--ink); border-color: var(--ink); }
.steps li.now::before { border-color: var(--accent); background: var(--accent); animation: pulse 1s infinite alternate; }

/* ---------- Empty / error states ---------- */
.empty { display: grid; gap: 16px; justify-items: start; padding: 32px 0; max-width: 420px; }
.empty .art { width: 96px; height: 96px; border-radius: var(--r-card); background: var(--backdrop); display: grid; place-items: center; }
.empty.error .art { color: var(--error); }

/* ---------- Sheet (bottom on mobile, centred modal on desktop) ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(20, 20, 18, .35); display: flex; align-items: flex-end; }
.sheet { background: var(--bg); width: 100%; max-height: 88vh; border-radius: 20px 20px 0 0; box-shadow: var(--shadow); display: grid; grid-template-rows: auto auto 1fr auto; gap: 14px; padding: 10px var(--pad) calc(16px + env(safe-area-inset-bottom, 0px)); animation: up .22s ease-out; }
.sheet .grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--divider); justify-self: center; }
.sheet .body { overflow-y: auto; }
.sheet .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sheet .item .name, .sheet .item .meta { display: none; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 1024px) {
  .scrim { align-items: center; justify-content: center; }
  .sheet { width: 760px; border-radius: 16px; padding: 24px 32px; }
  .sheet .grabber { display: none; }
  .sheet .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.modal { border: 0; border-radius: 16px; padding: 24px; width: min(360px, calc(100% - 32px)); background: var(--bg); color: var(--ink); box-shadow: var(--shadow); text-align: center; display: grid; gap: 12px; justify-items: center; }
.modal:not([open]) { display: none; }
.modal::backdrop { background: rgba(20, 20, 18, .35); }
.modal .art { color: var(--error); }
.modal form { width: 100%; }
.confirm { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--r-ctl); background: var(--surface); border: 1px solid var(--error); }

.toast { position: fixed; z-index: 50; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-ctl); font-size: 14px; box-shadow: var(--shadow); width: max-content; max-width: calc(100% - 32px); }
@media (min-width: 1024px) { .toast { left: auto; right: 32px; transform: none; bottom: 32px; } }

/* ---------- Two-column layouts on desktop ---------- */
@media (min-width: 1024px) {
  .split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; align-items: start; }
  .split > :first-child { position: sticky; top: 48px; }
  .form-narrow { max-width: 640px; }
  .choices { grid-template-columns: 1fr 1fr; }
}
.choices { display: grid; gap: 12px; }

/* ---------- Вход ---------- */
.signed-out .nav { display: none; }
.signed-out .app { display: block; }
.login { display: grid; gap: 32px; align-content: center; justify-items: start; min-height: calc(100vh - 160px); max-width: 440px; margin: 0 auto; width: 100%; }
.login-art { width: 96px; height: 96px; border-radius: var(--r-card); background: var(--surface); color: var(--accent); display: grid; place-items: center; box-shadow: var(--shadow); }
.login-art .icon { width: 40px; height: 40px; stroke-width: 1.25; }
.login p { margin: 0; font-size: 17px; line-height: 26px; }
.gsi { min-height: 44px; }
.account { border-top: 1px solid var(--divider); padding-top: 24px; margin-top: 8px; }
.account img { border-radius: 50%; }
