/* ── Токены ───────────────────────────────────────────────────────────────
   Прохладный нейтральный фон, чтобы цвета одежды на фото читались честно.
   Один акцент (петроль) — фокус, прогресс и голос стилиста. Остальное — чернила. */
:root {
  color-scheme: light dark;

  --bg:        oklch(0.970 0.004 250);
  --surface:   oklch(1.000 0 0);
  --surface-2: oklch(0.945 0.005 250);
  --ink:       oklch(0.225 0.012 260);
  --ink-soft:  oklch(0.400 0.012 260);
  --muted:     oklch(0.520 0.012 260);
  --line:      oklch(0.898 0.006 260);
  --line-soft: oklch(0.935 0.005 260);
  --accent:    oklch(0.505 0.098 210);
  --accent-ink: oklch(0.380 0.085 210);
  --accent-wash: oklch(0.955 0.020 210);
  --danger:    oklch(0.545 0.160 25);
  --on-accent: oklch(0.99 0 0);

  --shadow-1: 0 1px 2px oklch(0.25 0.02 260 / 0.06);
  --shadow-2: 0 2px 4px oklch(0.25 0.02 260 / 0.05), 0 12px 28px oklch(0.25 0.02 260 / 0.09);
  --shadow-3: 0 1px 3px oklch(0.25 0.02 260 / 0.10), -24px 0 60px oklch(0.25 0.02 260 / 0.14);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --tap: 44px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 140ms; --base: 200ms;

  --z-sticky: 100; --z-drawer: 200; --z-dialog: 300;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        oklch(0.185 0.006 260);
    --surface:   oklch(0.232 0.007 260);
    --surface-2: oklch(0.268 0.007 260);
    --ink:       oklch(0.955 0.004 260);
    --ink-soft:  oklch(0.820 0.008 260);
    --muted:     oklch(0.700 0.010 260);
    --line:      oklch(0.320 0.008 260);
    --line-soft: oklch(0.285 0.007 260);
    --accent:    oklch(0.760 0.095 205);
    --accent-ink: oklch(0.840 0.080 205);
    --accent-wash: oklch(0.300 0.035 205);
    --danger:    oklch(0.700 0.140 25);
    --on-accent: oklch(0.180 0.010 260);
    --shadow-1: 0 1px 2px oklch(0 0 0 / 0.35);
    --shadow-2: 0 2px 6px oklch(0 0 0 / 0.4), 0 14px 32px oklch(0 0 0 / 0.35);
    --shadow-3: -24px 0 60px oklch(0 0 0 / 0.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 ui-sans-serif, -apple-system, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-feature-settings: "cv02", "ss01";
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
h1 { margin: 0; font-size: 1.0625rem; font-weight: 640; letter-spacing: -0.012em; }
button { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

:where(a, button, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: var(--z-dialog);
  background: var(--ink); color: var(--bg); padding: 10px 14px;
  border-radius: var(--r-sm); text-decoration: none; font-size: 13px;
  transition: top var(--fast) var(--ease);
}
.skip:focus { top: 12px; }

/* ── Верхняя панель ──────────────────────────────────────────────────── */
.topbar {
  padding: 12px clamp(14px, 3vw, 28px) 6px;
  padding-top: max(12px, env(safe-area-inset-top));
}

/* блок управления: поиск + фильтры + вкладки; на десктопе липнет сверху,
   на телефоне переезжает вниз, под большой палец — дизайн элементов тот же */
.controls {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line-soft);
  padding: 8px clamp(14px, 3vw, 28px) 10px;
}
.topbar__head { display: flex; align-items: center; gap: 16px; min-height: 26px; flex-wrap: wrap; }
.topbar__title { flex: 0 0 auto; }

.tabs {
  display: flex; gap: 2px; padding: 2px; background: var(--surface-2); border-radius: var(--r-md);
  width: max-content; margin: 8px 0 0;
}
.tabs [role="tab"] {
  border: 0; background: none; cursor: pointer;
  padding: 6px 13px; border-radius: 10px; font-size: 13.5px; color: var(--muted);
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] {
  background: var(--surface); color: var(--ink); font-weight: 590; box-shadow: var(--shadow-1);
}

.meter { display: flex; align-items: center; gap: 10px; min-width: 0; }
.meter__track {
  width: clamp(80px, 18vw, 180px); height: 4px; border-radius: var(--r-pill);
  background: var(--line); overflow: hidden;
}
.meter__fill {
  height: 100%; width: 0; border-radius: inherit; background: var(--accent);
  transition: width 400ms var(--ease);
}
.meter__label { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }

.search { position: relative; flex: 1 1 240px; min-width: 200px; max-width: 380px; }
.search:not([hidden]) ~ .plusbtn, .toolbar:has(.search:not([hidden])) .plusbtn { flex: 0 0 auto; }
.search__icon {
  position: absolute; left: 11px; top: 50%; translate: 0 -50%;
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 34px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 14.5px; transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.search input::placeholder { color: var(--muted); }
.search input:hover { border-color: color-mix(in oklab, var(--line) 55%, var(--ink)); }
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.6); }

/* Кнопки в шапке: переключалка фона (текстом) и добавление вещи */
.headactions { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.textbtn {
  height: 34px; padding: 0 13px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; color: var(--ink-soft); font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.textbtn:hover { color: var(--ink); border-color: var(--muted); }
.iconbtn--head {
  width: 34px; height: 34px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; color: var(--muted);
}
.iconbtn--head:hover { background: var(--surface); border-color: var(--muted); color: var(--ink); }
.iconbtn--head[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.iconbtn--accent { color: var(--accent-ink); border-color: color-mix(in oklab, var(--accent) 45%, var(--line)); }
.iconbtn--accent:hover { color: var(--accent-ink); border-color: var(--accent); }

/* Фильтры-выпадашки (телефон) — в шапке, под заголовком */
.filterbar { display: none; gap: 8px; margin-top: 10px; }
.fselect {
  flex: 1; min-width: 0; height: 38px; padding: 0 30px 0 12px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="%23888" stroke-width="1.6" stroke-linecap="round"><path d="M6 8.5l4 4 4-4"/></svg>') no-repeat right 9px center / 16px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  appearance: none; -webkit-appearance: none;
}

/* Фильтры */
.segmented { display: flex; gap: 2px; padding: 2px; background: var(--surface-2); border-radius: var(--r-md); }
.segmented button {
  border: 0; background: none; cursor: pointer;
  padding: 7px 11px; border-radius: 10px; font-size: 13px; color: var(--muted);
  white-space: nowrap; transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: 560;
  box-shadow: var(--shadow-1);
}
.segmented .count { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 5px; font-weight: 400; }

.catrow { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.catrow button {
  border: 1px solid var(--line); background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: var(--r-pill); font-size: 13px; color: var(--muted);
  white-space: nowrap; transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.catrow button:hover { color: var(--ink); border-color: var(--muted); }
.catrow button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* до загрузки скрипта: вкладка из адреса без мигания сеткой */
body[data-tab="looks"] #grid, body[data-tab="shop"] #grid,
body[data-tab="looks"] #filterbarTop, body[data-tab="shop"] #filterbarTop,
body[data-tab="looks"] #searchWrap, body[data-tab="shop"] #searchWrap { display: none; }

/* ── Сетка вещей ─────────────────────────────────────────────────────── */
.content { padding: clamp(14px, 3vw, 28px); padding-bottom: 64px; }
.grid {
  display: grid; gap: clamp(12px, 1.6vw, 20px);
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
  transition: translate var(--base) var(--ease);
}
.card__media {
  position: relative; overflow: hidden; border-radius: var(--r-lg);
  background: var(--surface-2); box-shadow: var(--shadow-1);
  aspect-ratio: 3 / 4;
}
.card__media::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 0 0 1px oklch(0.25 0.02 260 / 0.07); pointer-events: none;
}
.card img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity 320ms var(--ease), scale var(--base) var(--ease), filter var(--base) var(--ease);
}
.card img.ready { opacity: 1; }
.card:hover img { scale: 1.025; }
.card[data-verdict="убрать"] img { filter: grayscale(0.85) contrast(0.95); opacity: 0.65; }
.card[data-verdict="убрать"]:hover img { opacity: 0.85; }
.card[aria-current="true"] .card__media { outline: 2px solid var(--ink); outline-offset: 2px; }
.card[data-filled="no"] .card__media { border: 1px dashed var(--line); }

.card__open {
  position: absolute; inset: 0; z-index: 1;
  border: 0; padding: 0; background: none; cursor: pointer; border-radius: inherit;
}
.card__cap { cursor: pointer; }

.badge {
  position: absolute; left: 8px; bottom: 8px; z-index: 1; pointer-events: none;
  padding: 4px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 560; letter-spacing: 0.005em;
  background: oklch(0.20 0.01 260 / 0.72); color: oklch(0.99 0 0);
  backdrop-filter: blur(6px);
}
.badge--think { background: oklch(0.99 0 0 / 0.86); color: oklch(0.25 0.01 260); }
.badge--out { background: oklch(0.20 0.01 260 / 0.5); }
.badge--count { left: auto; right: 8px; background: oklch(0.99 0 0 / 0.85); color: oklch(0.3 0.01 260); }
.dot-stylist {
  position: absolute; right: 8px; top: 8px; z-index: 1; pointer-events: none;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px oklch(1 0 0 / 0.55);
}

.quick {
  position: absolute; inset: auto 8px 8px; z-index: 2;
  display: flex; gap: 4px; opacity: 0; translate: 0 6px;
  transition: opacity var(--fast) var(--ease), translate var(--fast) var(--ease);
}
.card:hover .quick, .card:focus-within .quick { opacity: 1; translate: 0; }
.quick button {
  flex: 1; border: 0; cursor: pointer; padding: 7px 4px; border-radius: 9px;
  font-size: 11.5px; font-weight: 560;
  background: oklch(1 0 0 / 0.9); color: oklch(0.25 0.01 260);
  backdrop-filter: blur(8px); transition: background var(--fast) var(--ease);
}
.quick button:hover { background: oklch(1 0 0); }
.quick button[aria-pressed="true"] { background: oklch(0.20 0.01 260 / 0.92); color: oklch(0.99 0 0); }
@media (hover: none) { .quick { display: none; } }

.card__cap { display: grid; gap: 2px; padding: 0 2px; }
.card__name {
  font-size: 14px; font-weight: 560; letter-spacing: -0.006em; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card[data-filled="no"] .card__name { color: var(--muted); font-weight: 400; }
.card__sub {
  font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Скелетон и пустые состояния */
.skeleton .card__media { background: var(--surface-2); }
.skeleton .card__media::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, oklch(1 0 0 / 0.35), transparent);
  animation: shimmer 1.4s infinite;
}
.skeleton .card__cap span { height: 10px; border-radius: 4px; background: var(--surface-2); display: block; }
.skeleton .card__cap span:last-child { width: 60%; }
@keyframes shimmer { from { translate: -100% 0; } to { translate: 100% 0; } }

.state {
  max-width: 46ch; margin: clamp(40px, 12vh, 120px) auto; text-align: center;
  color: var(--muted); font-size: 14.5px; line-height: 1.6;
}
.state h2 { font-size: 1.0625rem; color: var(--ink); margin: 0 0 8px; font-weight: 600; }
.state code {
  font: 500 13px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--surface-2); color: var(--ink-soft);
  padding: 2px 6px; border-radius: 6px;
}
.state pre {
  margin: 14px 0 0; padding: 12px 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  font: 500 12.5px/1.7 ui-monospace, "SF Mono", Menlo, monospace; color: var(--ink-soft);
  overflow-x: auto;
}
.state button {
  margin-top: 16px; border: 1px solid var(--line); background: var(--surface);
  padding: 9px 16px; border-radius: var(--r-md); cursor: pointer; font-size: 14px;
}
.state button:hover { border-color: var(--muted); }

/* ── Панель вещи ─────────────────────────────────────────────────────── */
.drawer {
  position: fixed; inset: 0 0 0 auto; z-index: var(--z-drawer);
  width: min(440px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  animation: slide-in var(--base) var(--ease);
  /* карточка — одна прокручиваемая страница: фото уезжает вместе с контентом */
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
@keyframes slide-in { from { translate: 24px 0; opacity: 0.4; } to { translate: 0; opacity: 1; } }

.drawer__bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
}
.drawer__pos { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.saved { flex: 1; font-size: 12.5px; color: var(--accent-ink); opacity: 0; transition: opacity var(--base) var(--ease); }
.saved[data-on="1"] { opacity: 1; }
.saved[data-err="1"] { color: var(--danger); }
.drawer__nav { display: flex; gap: 2px; }
.iconbtn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn:disabled { opacity: 0.35; cursor: default; background: none; }
.iconbtn--close { margin-left: 4px; }

/* фото вещи — горизонтальная лента с плавным прилипанием кадров */
.pswipe {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  background: var(--surface-2); border-bottom: 1px solid var(--line-soft);
}
.pswipe::-webkit-scrollbar { display: none; }
.pswipe__slide {
  flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always;
  border: 0; padding: 0; background: none; cursor: zoom-in;
}
.pswipe__slide img { display: block; width: 100%; height: clamp(200px, 34vh, 340px); object-fit: contain; }

/* полоска фото вещи: главное + дополнительные + добавить */
.pstrip {
  display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto;
  border-bottom: 1px solid var(--line-soft); scrollbar-width: none;
}
.pstrip::-webkit-scrollbar { display: none; }
.pstrip button {
  width: 44px; height: 56px; flex: 0 0 auto; padding: 0;
  border: 2px solid transparent; border-radius: 8px; overflow: hidden;
  background: var(--surface-2); cursor: pointer;
  transition: border-color var(--fast) var(--ease);
}
.pstrip button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pstrip button[aria-pressed="true"] { border-color: var(--ink); }
.pstrip .pstrip__add {
  display: grid; place-items: center; color: var(--accent-ink); font-size: 17px;
  border: 1px dashed color-mix(in oklab, var(--accent) 50%, var(--line)); background: none;
}
.pstrip .pstrip__add:hover { border-color: var(--accent); background: var(--accent-wash); }

.drawer__body { }
.fieldset {
  display: grid; gap: 14px; padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}
.fieldset:last-child { border-bottom: 0; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.field { display: grid; gap: 6px; margin: 0; }
.field__label, .field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 9px 11px; transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: color-mix(in oklab, var(--line) 55%, var(--ink)); }
.input:focus { background: var(--surface); }
textarea.input { resize: none; min-height: 62px; line-height: 1.5; }
.field--stylist label { color: var(--accent-ink); }
.field--stylist .input { border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); background: var(--accent-wash); }

.field__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field__value { font-size: 12.5px; color: var(--ink); }
.hintbtn {
  width: 18px; height: 18px; margin-left: 4px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface);
  color: var(--muted); font-size: 11.5px; font-weight: 600; line-height: 1;
  cursor: pointer; vertical-align: 1px;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.hintbtn:hover, .hintbtn[aria-expanded="true"] { color: var(--ink); border-color: var(--muted); }
.legend {
  font-size: 12.5px; line-height: 1.6; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--r-md);
  padding: 8px 11px;
}
.legend b { color: var(--ink); font-weight: 600; }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button {
  height: 40px; border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  border-radius: 10px; cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.scale button:hover { border-color: var(--muted); color: var(--ink); }
.scale button:active { scale: 0.96; }
.scale button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 560; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  padding: 8px 13px; border-radius: var(--r-pill); cursor: pointer; font-size: 13px;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.chips button:hover { border-color: var(--muted); color: var(--ink); }
.chips button:active { scale: 0.96; }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chips--verdict { display: grid; grid-template-columns: repeat(3, 1fr); }
.chips--verdict button { border-radius: var(--r-md); padding: 12px 8px; font-size: 14px; font-weight: 560; }
.chips--verdict button[aria-pressed="true"][data-v="оставить"] {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); 
}
.chips--verdict button[aria-pressed="true"][data-v="подумать"] {
  background: var(--surface); border-color: var(--ink); color: var(--ink);
}
.chips--verdict button[aria-pressed="true"][data-v="убрать"] {
  background: var(--surface-2); border-color: var(--muted); color: var(--ink-soft);
}

/* Свёрнутые детали */
.details summary {
  cursor: pointer; list-style: none; font-size: 13px; font-weight: 500; color: var(--muted);
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.details summary::-webkit-details-marker { display: none; }
.details summary::before {
  content: ""; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--fast) var(--ease); flex: 0 0 auto;
}
.details[open] summary::before { transform: rotate(45deg); }
.details summary:hover { color: var(--ink); }
.details__hint { font-weight: 400; color: var(--muted); opacity: 0.75; }
.details__body { display: grid; gap: 12px; margin-top: 14px; }

/* ── Страница образа: коллаж по местам ───────────────────────────────── */
/* карточка вещи всегда поверх страницы образа */
#lookPanel { z-index: 199; }   /* calc() в z-index Safari на iOS не понимает */
.lookpage { padding: 14px 16px 32px; display: grid; gap: 16px; }
/* название — крупным текстом, не формой */
.lookpage__title {
  width: 100%; border: 0; background: none; padding: 0;
  font: 650 19px/1.3 inherit; font-family: inherit; color: var(--ink); letter-spacing: -0.014em;
}
.lookpage__title::placeholder { color: var(--muted); font-weight: 500; }
/* фотозона образа: фиксированная высота, без пустых полей */
#lookPanel .pswipe { height: clamp(320px, 46vh, 470px); }
#lookPanel .pswipe__slide { height: 100%; display: flex; align-items: center; justify-content: center; }
#lookPanel .pswipe__slide > img { width: 100%; height: 100%; object-fit: cover; }
/* слайд со схемой — эдж-ту-эдж, как фото */
.pswipe__slide--scheme { cursor: default; padding: 0; }
.pswipe__slide--scheme .lookpage__collage {
  border-radius: 0; width: 100%; height: 100%; align-content: center; overflow: hidden;
}
.pstrip__scheme { display: grid; place-items: center; color: var(--muted); }
.pstrip__scheme svg { width: 20px; height: 20px; }
.pstrip__scheme[aria-pressed="true"] { color: var(--ink); }
.lookpage__collage {
  display: grid; grid-template-columns: 1fr 92px; gap: 10px;
  /* фон = ровно цвет подложки вырезок (#f4f4f6): боксы сливаются без швов */
  background: rgb(244, 244, 246); border-radius: var(--r-lg); padding: 16px 14px;
}
.lookpage__main { display: grid; gap: 6px; justify-items: center; }
.lookpage__row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.lookpage__side { display: flex; flex-direction: column; gap: 8px; align-items: center; }
/* схема: размеры вещей свои, общие правила слайдов не про них */
.lookpage__collage img { display: block; object-fit: contain; width: auto; }
.pswipe .lookpage__collage img { width: auto; height: auto; }
.lookpage__collage button { border: 0; padding: 0; background: none; cursor: pointer; }
.pswipe .lookpage__row--outer img, .lookpage__row--outer img { height: 104px; }
.pswipe .lookpage__row--top img, .lookpage__row--top img { height: 104px; }
.pswipe .lookpage__row--bottom img, .lookpage__row--bottom img { height: 126px; }
.pswipe .lookpage__row--shoes img, .lookpage__row--shoes img { height: 62px; }
.pswipe .lookpage__side img, .lookpage__side img { height: 56px; }
.lookpage__empty { color: var(--muted); font-size: 13.5px; padding: 16px 0; text-align: center; }

/* вещи образа — сквозная лента через всю страницу, с подписями категорий */
.lookitems { display: grid; gap: 8px; }
.lookitems__head { display: flex; justify-content: space-between; align-items: baseline; }
.lookitems__n { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.lookitems__row {
  display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none;
  margin-inline: -16px; padding-inline: 16px;   /* лента уходит за края страницы */
}
.lookitems__row::-webkit-scrollbar { display: none; }
.lookitem { flex: 0 0 auto; width: 76px; display: grid; gap: 5px; justify-items: center; border: 0; background: none; padding: 0; cursor: pointer; }
.lookitem__ph {
  display: block; width: 76px; height: 96px; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px oklch(0.25 0.02 260 / 0.07);
}
.lookitem__ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lookitem__cap {
  max-width: 76px; font-size: 11px; color: var(--muted); text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Модалка подтверждения ───────────────────────────────────────────── */
.confirm {
  border: 0; padding: 20px; width: min(320px, calc(100vw - 48px));
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}
.confirm[open] { animation: confirm-in 180ms var(--ease); }
@keyframes confirm-in { from { opacity: 0; scale: 0.96; } to { opacity: 1; scale: 1; } }
.confirm::backdrop { background: oklch(0.15 0.01 260 / 0.45); }
.confirm__text { margin: 0 0 16px; font-size: 15px; line-height: 1.5; }
.confirm__row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.confirm__row button {
  height: 42px; border-radius: var(--r-md); font-size: 14px; font-weight: 560; cursor: pointer;
  transition: opacity var(--fast) var(--ease);
}
.confirm__row button:active { scale: 0.97; }
.confirm__cancel { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.confirm__cancel:hover { border-color: var(--muted); }
.confirm__ok { border: 0; background: var(--danger); color: var(--on-accent); }
.confirm__ok:hover { opacity: 0.88; }

/* ── Фото во весь экран ──────────────────────────────────────────────── */
.lightbox {
  border: 0; padding: 0; background: none; max-width: 100vw; max-height: 100vh;
  width: 100vw; height: 100vh; cursor: zoom-out;
}
.lightbox:focus { outline: none; }
.lightbox::backdrop { background: oklch(0.12 0.005 260 / 0.94); }
.lightbox img { width: 100%; height: 100%; object-fit: contain; padding: clamp(12px, 3vw, 40px); }
.lightbox[open] { animation: fade-in var(--fast) var(--ease); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Образы ──────────────────────────────────────────────────────────── */
.looks { max-width: 720px; margin: 0 auto; }
/* единая кнопка добавления — в блоке управления, действие зависит от вкладки */
.plusbtn {
  height: 38px; padding: 0 13px; flex: 1 0 auto; white-space: nowrap;
  border: 1px dashed color-mix(in oklab, var(--accent) 50%, var(--line));
  background: none; border-radius: var(--r-md); cursor: pointer;
  color: var(--accent-ink); font-size: 13.5px; font-weight: 560;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.plusbtn:hover { border-color: var(--accent); background: var(--accent-wash); }
.looks__list { display: grid; gap: 12px; }

.look {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px; box-shadow: var(--shadow-1); overflow: hidden;   /* лента вещей режется краями карточки */
}
.look__head { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.look__name { font-weight: 600; font-size: 15px; letter-spacing: -0.008em; }
.look__count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.look__title { flex: 1; font-weight: 600; }
.look__editbtn {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  color: var(--accent-ink); font-size: 13px; padding: 4px 2px;
}
.look__editbtn:hover { text-decoration: underline; }

.look__thumbs {
  display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin-inline: -14px; padding-inline: 14px;
}
.look__thumbs::-webkit-scrollbar { display: none; }
/* свёрнутая карточка: без скролла, лишнее прячется за плиткой «+N» */
.look__thumbs[data-fit] { overflow: hidden; margin-inline: 0; padding-inline: 0; }
.look__more {
  width: 76px; height: 96px; flex: 0 0 auto; border: 0; cursor: pointer;
  border-radius: 10px; background: var(--surface-2); color: var(--ink-soft);
  font-size: 15px; font-weight: 590; font-variant-numeric: tabular-nums;
  transition: background var(--fast) var(--ease);
}
.look__more:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--line)); }
.look__thumb {
  position: relative; width: 76px; height: 96px; flex: 0 0 auto; padding: 0; border: 0; cursor: pointer;
  border-radius: 10px; overflow: hidden; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px oklch(0.25 0.02 260 / 0.07);
}
.look__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.look__x {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
  display: grid; place-items: center; border-radius: 50%;
  background: oklch(0.2 0.01 260 / 0.75); color: #fff; font-size: 10px;
}
.look__hint { color: var(--muted); font-size: 13.5px; padding: 8px 0; }
.look__note { margin-top: 10px; font-size: 13.5px; color: var(--accent-ink); }

.look__edit { display: grid; gap: 12px; margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.look__pickhead { font-size: 12px; color: var(--muted); }
.look__pick {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px;
  max-height: 260px; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 8px;
}
.look__pickone {
  display: block; width: 100%; height: 76px; padding: 0;
  border: 2px solid transparent; border-radius: 8px;
  overflow: hidden; cursor: pointer; background: var(--surface-2); opacity: 0.55;
  transition: opacity var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
/* высота фиксированная на кнопке: авторазмер по картинке кнопки не держат */
.look__pickone img { width: 100%; height: 100%; object-fit: cover; display: block; }
.look__pickone:hover { opacity: 0.85; }
.look__pickone[aria-pressed="true"] { opacity: 1; border-color: var(--accent); }
.look__del {
  justify-self: start; border: 0; background: none; cursor: pointer;
  color: var(--danger); font-size: 13px; padding: 2px 0;
}
.look__del:hover { text-decoration: underline; }

/* ── Покупки ─────────────────────────────────────────────────────────── */
.shop { max-width: 640px; margin: 0 auto; }
.shop__add {
  display: flex; gap: 8px; margin-bottom: 18px;
}
.shop__quick {
  flex: 1; height: 44px; padding: 0 14px; font: inherit; font-size: 15px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--fast) var(--ease);
}
.shop__quick::placeholder { color: var(--muted); }
.shop__quick:hover { border-color: color-mix(in oklab, var(--line) 55%, var(--ink)); }
.shop__addbtn {
  width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center;
  border: 0; border-radius: var(--r-md); background: var(--ink); color: var(--bg); cursor: pointer;
  transition: opacity var(--fast) var(--ease);
}
.shop__addbtn svg { width: 18px; height: 18px; }
.shop__addbtn:hover { opacity: 0.85; }
.shop__addbtn:active { scale: 0.96; }

/* список — один контейнер, строки через волосяные разделители */
.shoplist {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.shoplist:empty { display: none; }
.srow {
  display: flex; gap: 12px; padding: 13px 14px; cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--fast) var(--ease);
}
.srow:last-child { border-bottom: 0; }
.srow:hover { background: color-mix(in oklab, var(--surface) 60%, var(--bg)); }
.srow--open { cursor: default; background: color-mix(in oklab, var(--surface) 60%, var(--bg)); }

.srow__check {
  width: 26px; height: 26px; flex: 0 0 auto; margin-top: 1px;
  border: 1.6px solid var(--line); border-radius: 50%; background: var(--surface);
  color: transparent; cursor: pointer; display: grid; place-items: center;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.srow__check svg { width: 14px; height: 14px; stroke-width: 2; }
.srow__check:hover { border-color: var(--accent); color: var(--accent); }
.srow__check[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.srow__thumb {
  width: 52px; height: 52px; flex: 0 0 auto; object-fit: cover;
  border-radius: 10px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px oklch(0.25 0.02 260 / 0.07);
}
.srow__thumb--icon { object-fit: contain; padding: 13px; }
.srow[data-status="вернул"] .srow__thumb, .srow[data-status="отказ"] .srow__thumb { filter: grayscale(0.8); }
.srow__body { flex: 1; min-width: 0; display: grid; gap: 3px; align-content: start; }
.srow__top { display: flex; align-items: baseline; gap: 12px; }
.srow__title { flex: 1; min-width: 0; font-weight: 560; font-size: 15px; letter-spacing: -0.006em; }
.srow[data-status="куплено"] .srow__title,
.srow[data-status="вернул"] .srow__title,
.srow[data-status="отказ"] .srow__title { color: var(--muted); font-weight: 480; }
.srow__price { color: var(--ink-soft); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.srow__sub {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  font-size: 13px; color: var(--muted);
}
.srow__link { color: var(--accent-ink); text-decoration: none; white-space: nowrap; }
.srow__link:hover { text-decoration: underline; }
.srow__tag { white-space: nowrap; }
.srow__note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow__dot { color: var(--line); }

.srow__edit { display: grid; gap: 12px; margin-top: 12px; cursor: default; }

.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); translate: -50% 0;
  z-index: var(--z-dialog); max-width: min(92vw, 420px);
  background: var(--ink); color: var(--bg); font-size: 13.5px;
  padding: 10px 16px; border-radius: var(--r-pill); box-shadow: var(--shadow-2);
}

/* ── Адаптив ─────────────────────────────────────────────────────────── */
/* На широком экране панель не накрывает сетку, а отодвигает её */
@media (min-width: 1100px) {
  .content { transition: padding-right var(--base) var(--ease); }
  body.has-drawer .content { padding-right: calc(440px + clamp(14px, 3vw, 28px)); }
}
@media (max-width: 900px) {
  .drawer { width: min(400px, 100vw); }
}
@media (max-width: 700px) {
  .topbar { padding-bottom: 8px; }
  .topbar__head { gap: 8px 12px; }
  .meter__track { display: none; }
  .tabs [role="tab"] { flex: 1; text-align: center; }
  .shop__add { grid-template-columns: 1fr 1fr; }
  .shop__price { width: 100%; }
  .toolbar { gap: 8px; }
  .search { max-width: none; flex: 1 1 auto; min-width: 0; }  /* поиск и «＋» — в одну строку */
  /* весь блок управления — вниз, под большой палец; вид элементов не меняется */
  .controls {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0;
    border-bottom: 0; border-top: 1px solid var(--line-soft);
    box-shadow: 0 -6px 24px oklch(0.25 0.02 260 / 0.07);
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .tabs { margin: 8px auto 0; }
  .tabs [role="tab"] { min-height: 40px; }
  .content { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(180px + env(safe-area-inset-bottom)); }
  /* на телефоне вместо горизонтальных лент чипов — две компактные выпадашки */
  .segmented, .catrow { display: none; }
  .filterbar { display: flex; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); }
  .quick { display: none; }   /* на телефоне решение ставится в карточке, а не по ховеру */
  /* открыта карточка — фон под ней не скроллится и не рисует длинный скроллбар */
  body.has-drawer { position: fixed; inset: 0; overflow: hidden; }
  .drawer { width: 100vw; border-left: 0; animation: slide-up 260ms var(--ease); }
  .pswipe__slide img { height: 34vh; }
  .iconbtn { width: var(--tap); height: var(--tap); }
  .chips button { min-height: var(--tap); }
}
@keyframes slide-up { from { translate: 0 6%; opacity: 0.5; } to { translate: 0; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .card:hover img { scale: 1; }
}

/* Вход, выбор гардероба и общий чат. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.primary-btn { min-height: 44px; padding: 10px 20px; border: 0; border-radius: 10px; background: var(--ink); color: var(--bg); cursor: pointer; font-weight: 600; }
button:disabled { opacity: .55; cursor: default; }
.login-page { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 390px); }
.login-eyebrow { color: var(--accent-ink); font-size: 13px; margin: 0 0 12px; }
.login-card h1 { font-size: 36px; letter-spacing: -.04em; }
.login-intro { color: var(--ink-soft); margin: 12px 0 32px; line-height: 1.7; }
.login-card form { display: grid; gap: 8px; }
.login-card label { font-size: 13px; margin-top: 8px; }
.login-card .input { min-height: 48px; font-size: 16px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 6px 0; }
.login-foot { color: var(--muted); font-size: 12px; margin-top: 24px; }
.accountbar { padding: 8px clamp(14px, 3vw, 28px); padding-top: max(8px, env(safe-area-inset-top)); display: flex; gap: 12px; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line-soft); }
.wardrobe-picker { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; }
.wardrobe-picker select { min-height: 44px; max-width: 145px; font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 28px 8px 12px; }
.accountbar__user { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.accountbar .textbtn { min-height: 44px; }
.tabs [role="tab"] { min-height: 44px; }
.chat-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 5px; vertical-align: middle; }
body[data-tab="chat"] .topbar, body[data-tab="chat"] .toolbar { display: none; }
body[data-tab="chat"] .content { padding-top: 0; padding-bottom: 0; }
body[data-tab="chat"] #grid { display: none; }
.chat { max-width: 760px; margin: 0 auto; height: calc(100dvh - 151px); display: flex; flex-direction: column; min-height: 280px; }
.chat-heading { display: flex; justify-content: space-between; align-items: center; padding: 20px 0 14px; gap: 16px; }
.chat-heading h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.chat-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
#chatConnection { color: var(--danger); font-size: 12px; max-width: 180px; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 4px; display: flex; flex-direction: column; gap: 14px; scroll-padding: 16px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 32px 16px; }
.chat-empty__icon { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid var(--line); border-radius: 18px; margin: 0 auto 18px; font-size: 25px; color: var(--accent); background: var(--surface); }
.chat-empty h3 { color: var(--ink); font-size: 17px; font-weight: 600; margin: 0 0 8px; }
.chat-empty p { font-size: 14px; margin: 0; line-height: 1.6; }
.chat-loading { margin: auto; color: var(--muted); }
.chat-message { align-self: flex-start; width: fit-content; max-width: 86%; border: 1px solid var(--line-soft); background: var(--surface); border-radius: 15px 15px 15px 4px; padding: 12px 14px; flex-shrink: 0; }
.chat-message--mine { align-self: flex-end; background: var(--accent-wash); border-color: transparent; border-radius: 15px 15px 4px 15px; }
.chat-message__meta { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; font-size: 11px; color: var(--muted); }
.chat-message__meta strong { color: var(--accent-ink); font-weight: 600; }
.chat-message p { white-space: pre-wrap; margin: 7px 0 0; overflow-wrap: anywhere; }
.chat-message a { color: var(--accent-ink); text-underline-offset: 3px; }
.chat-gallery { display: flex; width: min(320px, 65vw); overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; margin-top: 10px; }
.chat-gallery__slide { display: block; flex: 0 0 100%; min-width: 0; scroll-snap-align: start; }
.chat-gallery img, .chat-gallery video { display: block; width: 100%; height: 240px; object-fit: contain; border-radius: 9px; background: var(--surface-2); }
.chat-media-link { display: block; min-height: 44px; padding: 12px 0 4px; font-size: 12px; }
.chat-compose { flex-shrink: 0; border-top: 1px solid var(--line); background: var(--bg); padding: 12px 0 10px; }
.chat-compose textarea { resize: vertical; min-height: 72px; max-height: 140px; font-size: 16px; }
.chat-compose__actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.chat-compose__actions .textbtn { min-height: 44px; }
.chat-status { min-height: 17px; margin: 6px 0 0; font-size: 11px; color: var(--muted); }
.chat-attachments { display: flex; gap: 8px; overflow-x: auto; }
.chat-attachments:not(:empty) { padding-bottom: 10px; }
.chat-attachment { display: flex; gap: 8px; align-items: center; flex-shrink: 0; padding: 2px 2px 2px 4px; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
.chat-attachment img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }
.chat-attachment button { background: transparent; border: 0; min-width: 44px; min-height: 44px; font-size: 20px; cursor: pointer; }
@media (max-width: 700px) {
  .accountbar { gap: 8px; }
  .wardrobe-picker { gap: 6px; }
  .accountbar__user { gap: 5px; }
  .tabs { width: 100%; }
  .tabs [role="tab"] { padding-inline: 4px; font-size: 12px; }
  body[data-tab="chat"] { position: fixed; left: 0; right: 0; top: var(--visual-top, 0px); height: var(--visual-height, 100dvh); display: flex; flex-direction: column; }
  body[data-tab="chat"] .accountbar { flex-shrink: 0; }
  body[data-tab="chat"] .content { flex: 1; min-height: 0; display: flex; }
  .chat { height: 100%; min-height: 0; width: 100%; }
  .chat-heading { padding: 12px 0 8px; }
  .chat-heading h2 { font-size: 18px; }
  .chat-messages { padding-top: 8px; }
  .chat-compose textarea { min-height: 60px; max-height: 100px; }
  .chat-compose { padding-bottom: 4px; }
  .chat-status { font-size: 10px; }
  body[data-tab="chat"].has-drawer { top: 0; height: 100dvh; }
}
@media (max-width: 360px) { .wardrobe-picker { font-size: 0; gap: 0; } .accountbar__user { font-size: 11px; } }

.chat-gallery-nav { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 11px; color: var(--muted); }
.chat-gallery-nav button { min-width: 44px; min-height: 44px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 22px; }
@media (max-width: 700px) {
  .filterbar:has(#stateSelect option[value="replace"]:checked) { flex-wrap: wrap; }
  .filterbar #stateSelect:has(option[value="replace"]:checked) { flex-basis: 100%; }
}

/* Сообщения: темы внутри переписки владельца со стилистом. */
.chat-overview, .chat-room { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-rooms { overflow-y: auto; overscroll-behavior: contain; padding: 4px 1px 20px; }
.chat-privacy { color: var(--muted); font-size: 12px; margin: 0 0 18px; line-height: 1.6; }
.chat-room-card { display: flex; align-items: center; gap: 14px; padding: 18px 14px; margin-bottom: 10px; min-height: 86px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface); text-decoration: none; color: var(--ink); }
.chat-room-card:hover { border-color: var(--line); }
.chat-room-icon { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border-radius: 13px; background: var(--accent-wash); color: var(--accent-ink); font-size: 20px; }
.chat-room-info { display: grid; gap: 4px; min-width: 0; flex: 1; }
.chat-room-title { font-size: 15px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-room-preview { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room-tail { display: grid; justify-items: end; gap: 10px; font-size: 10px; color: var(--muted); }
.chat-heading--room { justify-content: flex-start; gap: 10px; }
#chatBack { min-width: 44px; min-height: 44px; font-size: 27px; padding: 0; }
.chat-connection:empty { display: none; }
.chat-connection { flex-shrink: 0; margin: 4px 0; }
#newChatDialog { width: min(420px, calc(100vw - 32px)); }
#newChatDialog h2 { font-size: 20px; margin: 0 0 8px; }
#newChatDialog label { display: block; font-size: 13px; margin: 16px 0 8px; }
#newChatDialog .input { min-height: 48px; font-size: 16px; }
@media (max-width: 700px) {
  .tabs [role="tab"] { font-size: 11px; padding-inline: 3px; }
  .chat-room-card { gap: 10px; padding: 14px 12px; }
  .chat-room-icon { flex-basis: 36px; height: 36px; }
  .chat-heading .primary-btn { padding: 10px 14px; font-size: 13px; }
}

.chat-heading--room > div { min-width: 0; flex: 1; }
.chat-heading--room h2 { overflow-wrap: anywhere; }
#newChatDialog .confirm__row button { min-height: 44px; }

/* Единая шапка: гардероб и разделы всегда остаются рядом при прокрутке. */
.site-header { position: sticky; top: 0; z-index: var(--z-sticky); background: color-mix(in oklab, var(--bg) 96%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-1); }
.site-header .accountbar { gap: 24px; min-height: 76px; border: 0; padding-block: 12px; padding-top: max(12px, env(safe-area-inset-top)); }
.header-identity { display: flex; align-items: center; gap: 14px; }
.header-identity h1 { font-size: 19px; letter-spacing: -.6px; }
.site-header .wardrobe-picker select { background-color: transparent; border-color: transparent; padding-left: 8px; }
.site-header .wardrobe-picker select:hover { background-color: var(--surface); border-color: var(--line); }
.site-header .tabs { margin: 0 auto; background: transparent; gap: 3px; padding: 0; }
.site-header .tabs [role="tab"] { white-space: nowrap; padding: 10px 12px; }
.site-header .tabs [aria-selected="true"] { background: var(--accent-wash); color: var(--accent-ink); box-shadow: none; }
.site-header .accountbar__user { flex-shrink: 0; }
.site-header .controls { position: static; padding: 0 clamp(14px, 3vw, 28px) 12px; background: none; border: 0; backdrop-filter: none; box-shadow: none; }
.site-header .toolbar { margin: 0; gap: 10px; }
.site-header .search { flex: 1 1 220px; max-width: 320px; }
.site-header .search input { height: 44px; }
.site-header .plusbtn { min-height: 44px; order: 2; margin-left: auto; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.site-header .segmented { flex: 1 1 auto; background: transparent; padding: 0; overflow-x: auto; }
.site-header .segmented button { min-height: 44px; padding-inline: 9px; }
.site-header .segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.header-lower { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.site-header .catrow { flex: 1; flex-wrap: nowrap; overflow-x: auto; }
.site-header .catrow button { min-height: 44px; border-color: transparent; padding-inline: 11px; }
.site-header .catrow button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.site-header .topbar { display: flex; align-items: center; gap: 18px; padding: 0; flex-shrink: 0; }
.site-header .meter__track { width: 60px; }
.site-header .meter__label { font-size: 11px; }
.site-header .textbtn { min-height: 44px; background: transparent; }
.site-header .headactions { margin: 0; }
body[data-tab="looks"] .header-lower, body[data-tab="shop"] .header-lower,
body[data-tab="chat"] .controls { display: none; }
body[data-tab="looks"] .segmented, body[data-tab="shop"] .segmented { display: none; }
body[data-tab="chat"] .chat { height: calc(100dvh - 77px); }
@media (max-width: 1200px) {
  .header-identity h1 { display: none; }
  .site-header .accountbar { gap: 12px; }
  .site-header .toolbar { display: grid; grid-template-columns: minmax(180px, 1fr) auto; }
  .site-header .search { max-width: none; min-width: 0; }
  .site-header .segmented { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .site-header .meter__track { display: none; }
  body[data-tab="looks"] .toolbar, body[data-tab="shop"] .toolbar { display: flex; }
}
@media (max-width: 800px) {
  .site-header .accountbar { flex-wrap: wrap; padding-bottom: 8px; gap: 8px; }
  .site-header .accountbar__user { margin-left: auto; }
  .site-header .tabs { order: 3; flex-basis: 100%; justify-content: space-between; }
  .site-header .tabs [role="tab"] { flex: 1; padding-inline: 6px; font-size: 12px; }
  body[data-tab="chat"] .chat { height: calc(100dvh - 121px); }
}
@media (max-width: 700px) {
  .site-header { flex-shrink: 0; }
  .site-header .accountbar { min-height: 0; padding-top: max(6px, env(safe-area-inset-top)); }
  .site-header .controls { padding-bottom: 8px; }
  .site-header .segmented, .site-header .catrow { display: none; }
  .site-header .filterbar { margin-top: 8px; }
  .site-header .fselect { height: 44px; font-size: 13px; }
  .header-lower { margin-top: 4px; }
  .site-header .topbar { width: 100%; justify-content: space-between; gap: 8px; }
  .site-header .meter__label { font-size: 11px; }
  .site-header .tabs { width: 100%; }
  .site-header .tabs [role="tab"] { padding-inline: 3px; font-size: 11px; }
  .content { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .toast { bottom: max(18px, env(safe-area-inset-bottom)); }
  body[data-tab="chat"] .chat { height: 100%; }
  body[data-tab="chat"] .site-header { position: static; }
  body[data-tab="chat"] .content { padding-bottom: env(safe-area-inset-bottom); }
}
