/* ============================================================
   Wardrobe — warm editorial palette, iOS-native structure
   ============================================================ */
:root {
  --paper:      #faf8f5;
  --surface:    #ffffff;
  --surface-2:  #f2eee7;
  --ink:        #1b1a17;
  --ink-2:      #46433d;
  --muted:      #8d867a;
  --line:       #e9e3d9;
  --accent:     #1b1a17;
  --on-accent:  #faf8f5;
  --clay:       #b0603a;
  --sea:        #4a6f83;
  --danger:     #b23b32;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 26px;
  --shadow-1: 0 1px 2px rgba(27,26,23,.05), 0 6px 16px -10px rgba(27,26,23,.22);
  --shadow-2: 0 2px 6px rgba(27,26,23,.07), 0 20px 42px -18px rgba(27,26,23,.34);
  --tabbar-h: 62px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}
/* Dark palette. Applied when the OS asks for dark AND the user hasn't pinned
   light, or when the user has pinned dark outright - so the account-setup
   toggle wins in both directions and "System" follows the OS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --paper:     #111110;
  --surface:   #1a1917;
  --surface-2: #24221f;
  --ink:       #f1ede6;
  --ink-2:     #cbc5ba;
  --muted:     #8b8479;
  --line:      #2d2a26;
  --accent:    #f1ede6;
  --on-accent: #16150f;
  --clay:      #d4885d;
  --sea:       #7fa8bd;
  --danger:    #e0736a;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 6px 16px -10px rgba(0,0,0,.7);
  --shadow-2: 0 2px 6px rgba(0,0,0,.45), 0 20px 42px -18px rgba(0,0,0,.8);
  }
}
:root[data-theme="dark"] {
  --paper:     #111110;
  --surface:   #1a1917;
  --surface-2: #24221f;
  --ink:       #f1ede6;
  --ink-2:     #cbc5ba;
  --muted:     #8b8479;
  --line:      #2d2a26;
  --accent:    #f1ede6;
  --on-accent: #16150f;
  --clay:      #d4885d;
  --sea:       #7fa8bd;
  --danger:    #e0736a;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 6px 16px -10px rgba(0,0,0,.7);
  --shadow-2: 0 2px 6px rgba(0,0,0,.45), 0 20px 42px -18px rgba(0,0,0,.8);
}
:root[data-theme="neko"] {
  --paper:     #fff7f4;
  --surface:   #fffdfb;
  --surface-2: #fff0ec;
  --ink:       #261d1c;
  --ink-2:     #5d4745;
  --muted:     #a08683;
  --line:      #f1ddd9;
  --accent:    #6e5651;
  --on-accent: #fff8f5;
  --clay:      #d88573;
  --sea:       #7da5a7;
  --danger:    #c45d56;
  --shadow-1: 0 1px 2px rgba(52,28,24,.05), 0 10px 24px -16px rgba(110,86,81,.22);
  --shadow-2: 0 2px 8px rgba(52,28,24,.08), 0 24px 44px -24px rgba(110,86,81,.24);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The `hidden` attribute only works through the UA rule [hidden]{display:none},
   which ANY author rule setting `display` silently overrides. Everything below
   (.scrim, .btn, .rail, .fab …) sets display, so this guard must stay. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
  overscroll-behavior-y: none;
}
html[data-theme="neko"] body {
  background:
    radial-gradient(circle at 14% 12%, rgba(216,133,115,.12), transparent 18%),
    radial-gradient(circle at 84% 10%, rgba(125,165,167,.12), transparent 20%),
    radial-gradient(circle at 50% 100%, rgba(110,86,81,.07), transparent 28%),
    linear-gradient(180deg, rgba(255,255,255,.45), rgba(255,255,255,0)),
    var(--paper);
}

svg.ic    { width: 20px; height: 20px; }
svg.ic-lg { width: 28px; height: 28px; }
svg.ic-xl { width: 46px; height: 46px; }
svg[class^="ic"] {
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; flex: none;
}

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar.stuck { border-bottom-color: var(--line); }
html[data-theme="neko"] .topbar {
  background: color-mix(in srgb, var(--paper) 84%, rgba(255,255,255,.55));
}
.bar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 14px 20px 10px;
}
.titles h1 {
  font-family: var(--serif);
  font-size: 30px; font-weight: 600; letter-spacing: -.02em;
  margin: 0; line-height: 1.1;
  transition: font-size .18s ease;
}
.topbar.stuck .titles h1 { font-size: 21px; }
.titles p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.ai-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  padding: 5px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.ai-chip svg { width: 13px; height: 13px; }
.ai-chip.local { color: var(--sea); border-color: color-mix(in srgb, var(--sea) 30%, var(--line)); }
html[data-theme="neko"] .ai-chip.local {
  background: color-mix(in srgb, var(--surface-2) 80%, white);
}

/* ---------------- horizontal pill rail ---------------- */
.rail {
  display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 20px 12px; scroll-padding: 20px;
}
.rail.flush { padding: 0 0 4px; margin-bottom: 4px; }
.rail::-webkit-scrollbar { display: none; }

.pill {
  flex: none; font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line); white-space: nowrap;
  transition: background .14s, color .14s, border-color .14s;
}
.pill.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.pill:active { transform: scale(.97); }

main { padding: 4px 20px 0; max-width: 900px; margin: 0 auto; }
/* the FAB floats over the bottom-right corner; without this the last row of
   cards hides underneath it */
#fits, #wardrobe { padding-bottom: 62px; }
.tab { display: none; }
/* No entry animation on tab switch. An animation attached to an element that
   is display:none can fail to start, leaving the tab stuck at opacity 0 -
   an invisible screen is a far worse trade than a missing 0.2s fade. */
.tab.active { display: block; }

h2.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 26px 0 12px;
}

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  padding: 11px 18px; border-radius: var(--r-md); cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line);
  transition: transform .1s;
}
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.block   { width: 100%; }
.btn.lg      { padding: 14px 18px; font-size: 15.5px; border-radius: var(--r-md); }
.btn.tiny    { padding: 6px 12px; font-size: 12.5px; font-weight: 600; border-radius: 999px; text-transform: none; letter-spacing: 0; }
.btn:active  { transform: scale(.985); }
.btn:disabled { opacity: .5; pointer-events: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex: none;
  border-radius: var(--r-md); cursor: pointer;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line);
}
.icon-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.icon-btn:active { transform: scale(.94); }

/* ---------------- item grid ---------------- */
.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 780px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card {
  position: relative; cursor: pointer;
  border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  transition: transform .14s ease, box-shadow .14s ease;
}
.card:active { transform: scale(.975); box-shadow: var(--shadow-1); }
html[data-theme="neko"] .card,
html[data-theme="neko"] .panel,
html[data-theme="neko"] .fit,
html[data-theme="neko"] .setting {
  border-color: color-mix(in srgb, var(--line) 88%, white);
}
.card .thumb {
  display: block; width: 100%; aspect-ratio: 1/1; object-fit: cover;
  background: var(--surface-2);
}
.card .thumb.ph {
  display: flex; align-items: center; justify-content: center;
  color: color-mix(in srgb, var(--muted) 55%, transparent);
}
.card .meta { padding: 9px 11px 11px; }
.card .name {
  font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .sub {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--muted); margin-top: 2px; text-transform: capitalize;
  min-width: 0;
}
.card .sub span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot-colour {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  /* an inset ring so white and black swatches still read as swatches */
  box-shadow: inset 0 0 0 1px rgba(128,128,128,.45);
}
.flag {
  position: absolute; top: 9px; right: 9px;
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px; color: #fff;
  backdrop-filter: blur(8px); box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.flag.worn    { background: color-mix(in srgb, var(--clay) 92%, transparent); }
.flag.in_wash { background: color-mix(in srgb, var(--sea)  92%, transparent); }

/* ---------------- fit feed ---------------- */
.feed {
  display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr);
  margin-top: 4px;
}
@media (min-width: 600px) { .feed { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
.fit {
  position: relative; cursor: pointer; overflow: hidden;
  border-radius: var(--r-lg); background: var(--surface-2);
  aspect-ratio: 3/4; box-shadow: var(--shadow-1);
  transition: transform .14s ease;
}
.fit:active { transform: scale(.975); }
.fit img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fit .veil {
  position: absolute; inset: auto 0 0 0; padding: 26px 12px 11px;
  background: linear-gradient(to top, rgba(12,10,8,.78), rgba(12,10,8,.28) 55%, transparent);
  color: #fff; pointer-events: none;
}
.fit .veil b {
  display: block; font-size: 13px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.fit .veil span { font-size: 11px; opacity: .82; }
.fit .n {
  position: absolute; top: 9px; right: 9px;
  background: rgba(12,10,8,.55); backdrop-filter: blur(8px);
  color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
}

/* ---------------- garment picker (inside fit sheet) ---------------- */
.picker {
  display: grid; gap: 8px; grid-template-columns: repeat(4, 1fr);
  max-height: 236px; overflow-y: auto; padding: 2px; margin-bottom: 4px;
}
@media (min-width: 460px) { .picker { grid-template-columns: repeat(5, 1fr); } }
.pick {
  position: relative; cursor: pointer; border-radius: var(--r-sm);
  overflow: hidden; aspect-ratio: 1/1; background: var(--surface-2);
  border: 2px solid transparent; transition: border-color .13s;
}
.pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick .ph {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 9.5px; text-align: center; padding: 3px;
  line-height: 1.2; overflow: hidden;
}
.pick.on { border-color: var(--accent); }
.pick.on::after {
  content: ""; position: absolute; inset: 0;
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}
.pick .tick {
  position: absolute; top: 3px; right: 3px; z-index: 2;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: none; align-items: center; justify-content: center;
}
.pick .tick svg { width: 12px; height: 12px; stroke-width: 2.6; }
.pick.on .tick { display: flex; }

.count {
  display: inline-block; background: var(--surface-2); color: var(--ink-2);
  border-radius: 999px; padding: 1px 7px; font-size: 11px; margin-left: 5px;
  border: 1px solid var(--line);
}

.toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  margin: 16px 0 4px; font-size: 14px; color: var(--ink-2);
}
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* ---------------- fit viewer ---------------- */
.scrim.dark { background: rgba(10,9,7,.9); align-items: stretch; padding: 0; }
.viewer {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--paper);
}
.viewer-top {
  position: absolute; z-index: 3; left: 0; right: 0;
  top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; justify-content: space-between; padding: 0 14px;
}
.icon-btn.glass {
  background: rgba(20,18,15,.42); border-color: transparent; color: #fff;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.icon-btn.glass.danger { color: #ff9e94; }
#viewPhoto { width: 100%; display: block; background: var(--surface-2); }
.viewer-info { padding: 18px 20px calc(28px + env(safe-area-inset-bottom, 0px)); }
.viewer-info h3 {
  font-family: var(--serif); font-size: 23px; font-weight: 600;
  margin: 0 0 3px; letter-spacing: -.015em;
}
.viewer-info p { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); text-transform: capitalize; }
.grid.tight { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.grid.tight .card .meta { padding: 6px 8px 8px; }
.grid.tight .card .name { font-size: 11.5px; }
.grid.tight .card .sub { display: none; }

/* ---------------- panel / outfit ---------------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 16px 16px 16px;
  box-shadow: var(--shadow-1); margin-top: 8px;
}
.field-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 8px;
}
.panel > .field-label:first-child { margin-top: 2px; }

.look {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 16px; margin-top: 14px;
  box-shadow: var(--shadow-1);
}
.look-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
}
.look-head b { font-family: var(--serif); font-size: 18px; font-weight: 600; text-transform: capitalize; }
.look-head span { font-size: 11.5px; color: var(--muted); }
.rationale {
  font-family: var(--serif); font-size: 15px; line-height: 1.55; color: var(--ink-2);
  border-left: 2px solid var(--line); padding: 2px 0 2px 13px; margin: 0 0 14px;
}
.rationale em { font-style: normal; font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); display: block; margin-top: 6px;
  font-family: -apple-system, system-ui, sans-serif; }
.look .grid { grid-template-columns: repeat(3, 1fr); gap: 9px; }
@media (min-width: 560px) { .look .grid { grid-template-columns: repeat(4, 1fr); } }
.look-acts { display: flex; gap: 8px; margin-top: 14px; }
.look-acts .btn { flex: 1; }

.thinking { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14px; padding: 22px 4px; }
.spin { width: 15px; height: 15px; border: 2px solid var(--line); border-top-color: var(--muted);
  border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------------- stats ---------------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 12px; text-align: center; box-shadow: var(--shadow-1);
}
.stat b { display: block; font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1; }
.stat span { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.stat.worn b { color: var(--clay); }
.stat.wash b { color: var(--sea); }

/* ---------------- empty states ---------------- */
.empty { text-align: center; padding: 54px 24px; color: var(--muted); }
.empty svg { color: color-mix(in srgb, var(--muted) 50%, transparent); margin-bottom: 14px; }
.empty h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--ink); margin: 0 0 5px; }
.empty p { margin: 0 0 18px; font-size: 14px; }
.empty.small { padding: 24px; font-size: 13.5px; }
.empty.small p { margin: 0; }

/* ---------------- FAB ---------------- */
.fab {
  position: fixed; right: 18px; z-index: 25;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 54px; height: 54px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent); border: none;
  box-shadow: var(--shadow-2);
  transition: transform .14s;
}
.fab svg { width: 24px; height: 24px; stroke-width: 2; }
.fab:active { transform: scale(.92); }

/* ---------------- tab bar ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  position: relative; flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
  transition: color .15s;
}
.tabbar button.active { color: var(--ink); }
.tabbar button.active svg { stroke-width: 1.9; }
.tabbar .dot {
  position: absolute; top: 9px; left: 50%; margin-left: 7px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--clay);
  border: 1.5px solid var(--paper);
}

/* Entry animations are deliberately absent on everything that goes from
   [hidden] to shown (.scrim, .sheet, .viewer, .toast). An animation attached
   to a display:none element can fail to start and then holds its from-state,
   which renders the whole overlay invisible. Not worth the risk. */
/* ---------------- sheet ---------------- */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20,18,15,.42);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 500px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  max-height: 93vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-2);
}
@media (min-width: 540px) {
  .scrim { align-items: center; padding: 20px; }
  .sheet { border-radius: var(--r-xl); max-height: 88vh; }
}
.grip {
  width: 36px; height: 4px; border-radius: 999px; background: var(--line);
  margin: 9px auto 0; flex: none;
}
@media (min-width: 540px) { .grip { display: none; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px 8px; flex: none;
}
.sheet-head h2 { font-family: var(--serif); font-size: 21px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.sheet-body { overflow-y: auto; padding: 4px 18px 8px; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  display: flex; gap: 9px; align-items: center; flex: none;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--surface);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

.dropzone {
  display: flex; align-items: center; justify-content: center;
  min-height: 190px; border-radius: var(--r-lg); cursor: pointer; overflow: hidden;
  background: var(--surface-2); border: 1.5px dashed var(--line);
  margin-bottom: 12px; transition: border-color .15s;
}
.dropzone:active { border-color: var(--muted); }
.dropzone.tall { min-height: 300px; }
.dropzone img { width: 100%; max-height: 300px; object-fit: contain; }
.dropzone.tall img { max-height: 420px; }
#photoPlaceholder {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--muted); text-align: center; padding: 20px;
}
#photoPlaceholder b { font-size: 14.5px; color: var(--ink-2); font-weight: 600; }
#photoPlaceholder small { font-size: 12px; }

.field { display: block; margin: 14px 0 0; }
.field .field-label { margin: 0 0 7px; }
.field input {
  width: 100%; font: inherit; font-size: 15px; padding: 12px 14px;
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink);
  transition: border-color .15s, background .15s;
}
.field input:focus {
  outline: none; border-color: var(--muted); background: var(--surface);
}
.field input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }

.note { font-size: 12.5px; color: var(--muted); margin: 8px 2px 0; line-height: 1.45; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; min-width: 0; }

/* web image search results */
.results {
  display: grid; gap: 8px; grid-template-columns: repeat(4, 1fr);
  margin-top: 10px;
}
.results .hit {
  position: relative; aspect-ratio: 1/1; cursor: pointer; overflow: hidden;
  border-radius: var(--r-sm); background: var(--surface-2);
  border: 2px solid transparent; transition: border-color .13s, opacity .13s;
}
.results .hit img { width: 100%; height: 100%; object-fit: cover; display: block; }
.results .hit:active { opacity: .6; }
.results .hit.busy { border-color: var(--accent); opacity: .5; }
.results .msg { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 22px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--paper);
  padding: 10px 12px 10px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-2);
}
#toastAct {
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  padding: 6px 13px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--paper) 22%, transparent);
  color: var(--paper); border: 0;
}
#toastAct:active { opacity: .7; }

/* ---------------- setting row ---------------- */
.setting {
  display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 14px; margin-top: 10px;
  box-shadow: var(--shadow-1);
}
.setting input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.setting b { display: block; font-size: 14px; font-weight: 600; }
.setting small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- assistant chat ---------------- */
#ask { display: none; }
#ask.active { display: flex; flex-direction: column; min-height: calc(100vh - 190px); }
.chat { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 6px 0 12px; }
/* with no messages the log must not grow, or it pushes the empty state and its
   suggestions down past the fold */
.chat:empty { flex: none; padding: 0; }
.bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: 14.5px;
  line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}
.bubble.me {
  align-self: flex-end; background: var(--accent); color: var(--on-accent);
  border-bottom-right-radius: 6px;
}
.bubble.bot {
  align-self: flex-start; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow-1);
}
.bubble.err { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); color: var(--danger); }
.did {
  align-self: flex-start; display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 2px;
}
.did span {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  padding: 3px 9px; border-radius: 999px;
}
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 14px 16px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.3s infinite both;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

.suggest { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.suggest button {
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  padding: 11px 14px; border-radius: var(--r-md);
}
.composer {
  position: sticky; z-index: 6;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px);
  display: flex; gap: 8px; align-items: center; padding: 8px 0 4px;
  background: linear-gradient(to top, var(--paper) 72%, transparent);
}
.composer input {
  flex: 1; min-width: 0; font: inherit; font-size: 15px; padding: 12px 16px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.composer input:focus { outline: none; border-color: var(--muted); }
.icon-btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }


/* ---------------- explanatory text ---------------- */
.hint { font-size: 12.5px; line-height: 1.5; color: var(--muted); margin: 14px 2px 0; }
#styleHint { margin: 18px 4px 0; }
#chatHint { margin-top: 16px; text-align: left; }

/* ---------------- keyboard focus ---------------- */
/* :focus-visible only fires for keyboard and assistive input, so this never
   shows up mid-tap on a phone. */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn:focus-visible, .pill:focus-visible, .icon-btn:focus-visible,
.fab:focus-visible, .tabbar button:focus-visible, .suggest button:focus-visible {
  outline-offset: 3px;
}
.btn:disabled, .icon-btn:disabled { opacity: .38; }

/* ---------------- garments attached to a chat reply ---------------- */
.strip {
  align-self: flex-start; max-width: 100%;
  display: flex; gap: 9px; overflow-x: auto;
  padding: 2px 0 6px; margin-top: -2px; scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.chip-item { flex: none; width: 82px; cursor: pointer; }
.chip-item img, .chip-item .swatch {
  display: block; width: 82px; height: 98px; object-fit: cover;
  border-radius: var(--r-md); background: var(--surface-2);
  border: 1px solid var(--line);
}
.chip-item b {
  display: block; margin-top: 5px; color: var(--ink-2);
  font-size: 11px; font-weight: 600; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-item:active { opacity: .6; }

/* ---------------- ask: empty state sits higher ---------------- */
#chatEmpty { padding: 30px 4px 24px; text-align: left; }
#chatEmpty svg { margin-bottom: 10px; }
#chatEmpty h3, #chatEmpty p { text-align: left; }
#chatEmpty p { margin-bottom: 14px; }
.suggest button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  transition: border-color .14s, background .14s;
}
.suggest button::after { content: "\2192"; color: var(--muted); font-size: 15px; }
.suggest button:active { background: var(--surface-2); border-color: var(--muted); }


/* ---------------- weather ---------------- */
.wx-row { margin: 2px 0 4px; }
.wx-chip {
  display: flex; align-items: center; gap: 7px; width: 100%;
  font: inherit; font-size: 13.5px; font-weight: 500; text-align: left;
  padding: 10px 13px; border-radius: var(--r-md); cursor: pointer;
  background: var(--surface-2); color: var(--muted);
  border: 1px dashed var(--line);
}
.wx-chip.set {
  color: var(--ink); border-style: solid; font-weight: 600;
  background: var(--surface);
}
.wx-chip:active { border-color: var(--muted); }
.wx-edit { display: flex; gap: 7px; align-items: center; }
.wx-edit input {
  flex: 1; min-width: 0; font: inherit; font-size: 14.5px; padding: 10px 13px;
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.wx-edit input:focus { outline: none; border-color: var(--muted); }


/* ---------------- batch add ---------------- */
.batch-progress { padding: 14px 2px 6px; }
.batch-progress .bar {
  height: 6px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; border: 1px solid var(--line);
}
.batch-progress .bar i {
  display: block; height: 100%; width: 0; background: var(--accent);
  transition: width .2s ease;
}
.batch-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.batch-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 8px;
}
.batch-thumb {
  width: 48px; height: 58px; flex: none; object-fit: cover;
  border-radius: var(--r-sm); background: var(--surface);
}
.batch-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.batch-meta { display: flex; align-items: center; gap: 7px; }
.batch-meta small { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.mini-input, .mini-select {
  font: inherit; font-size: 14px; padding: 7px 10px; min-width: 0;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.mini-input { width: 100%; }
.mini-select { flex: none; padding-right: 6px; }
.mini-input:focus, .mini-select:focus { outline: none; border-color: var(--muted); }
.mini-drop {
  flex: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--muted);
}
.mini-drop svg { width: 15px; height: 15px; }
.mini-drop:active { color: var(--danger); }


/* ============================================================
   AI motion
   Every animation below decorates something that is already visible.
   Nothing here gates display or opacity on the animation running: if the
   clock never advances - reduced motion, a stalled frame, a paused tab -
   every element is still fully visible in its resting state. That rule is
   not stylistic; breaking it is what once rendered whole tabs blank.
   ============================================================ */

/* a photo being read */
.dropzone { position: relative; }
.dropzone.scanning::after {
  content: ""; position: absolute; left: 0; right: 0; height: 36%;
  background: linear-gradient(to bottom, transparent 0%,
    color-mix(in srgb, var(--sea) 28%, transparent) 50%, transparent 100%);
  animation: sweep 1.15s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sweep { 0% { top: -36%; } 100% { top: 100%; } }

.dropzone.scanning::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--sea) 55%, transparent);
  animation: breathe 1.15s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* a field the assistant just filled in */
@keyframes settled {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sea) 55%, transparent); }
  to   { box-shadow: 0 0 0 8px transparent; }
}
.just-set { animation: settled .75s ease-out; }

/* the badge, while any of this is in flight */
.ai-chip.busy { animation: breathe 1.2s ease-in-out infinite; }
.ai-chip.busy svg { animation: spin-slow 2.4s linear infinite; }
@keyframes spin-slow { to { transform: rotate(360deg); } }

/* things arriving in a reply or a look. The class is added per element from
   JS rather than staggered with animation-delay, because a delayed animation
   with a backwards fill would hold its from-state - invisible - until it
   starts. At rest these elements are simply visible. */
@keyframes arrive { from { opacity: 0; transform: translateY(7px); } }
.arriving { animation: arrive .3s ease-out; }


/* ---------------- receipt ---------------- */
.field textarea {
  width: 100%; font: inherit; font-size: 14px; line-height: 1.45;
  padding: 12px 14px; border-radius: var(--r-md); resize: vertical;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.field textarea:focus { outline: none; border-color: var(--muted); background: var(--surface); }
.batch-thumb.blank {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); color: var(--muted);
}
.batch-thumb.blank svg { width: 18px; height: 18px; }
.batch-price { font-size: 11.5px; color: var(--muted); }


/* ============================================================
   Accounts & friends
   ============================================================ */

/* ---- login gate ---- */
.gate {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--paper);
}
.gate-card {
  width: 100%; max-width: 360px; text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-card > svg { color: var(--muted); align-self: center; }
.gate-card h1 { font-family: var(--serif); font-size: 28px; font-weight: 600; margin: 0; }
.gate-card > p { margin: -4px 0 6px; font-size: 14px; color: var(--muted); }
.gate-card input {
  width: 100%; font: inherit; font-size: 16px; padding: 13px 15px;
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink);
}
.gate-card input:focus { outline: none; border-color: var(--muted); background: var(--surface); }
.gate-err { margin: 0; font-size: 13px; color: var(--danger); }
.gate-swap {
  background: none; border: 0; color: var(--ink-2); font: inherit; font-size: 13.5px;
  cursor: pointer; padding: 6px; text-decoration: underline;
}

/* ---- "you" card + account panel ---- */
.me-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow-1);
  margin-top: 10px;
}
.me-id b { display: block; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.me-id span { font-size: 12.5px; color: var(--muted); }
.acct-panel {
  display: flex; flex-direction: column; gap: 10px; margin-top: 10px;
}
.acct-panel .setting { margin-top: 0; }

.composer.flat { position: static; background: none; padding: 14px 0 4px; }

/* ---- friend requests ---- */
.req {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 10px 12px;
}
.req .who { flex: 1; min-width: 0; }
.req .who b { font-size: 14px; font-weight: 600; }
.req .who span { font-size: 12px; color: var(--muted); }
.req .btn { padding: 7px 12px; }

/* ---- friends list ---- */
.friend-list { display: flex; flex-direction: column; gap: 8px; }
.friend-row {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--shadow-1);
}
.friend-row .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--ink-2);
  font-family: var(--serif); font-size: 16px; font-weight: 600;
}
.friend-row .who { flex: 1; min-width: 0; }
.friend-row .who b { display: block; font-size: 14.5px; font-weight: 600; }
.friend-row .who span { font-size: 12px; color: var(--muted); }
.friend-row .tags { display: flex; gap: 5px; }
.friend-row .tags i {
  font-size: 10px; font-style: normal; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px;
}

/* ---- segmented control ---- */
.seg { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 5px 12px; background: var(--surface); color: var(--muted); border: 0;
  text-transform: none; letter-spacing: 0;
}
.seg button.on { background: var(--accent); color: var(--on-accent); }
.seg.wide { display: flex; width: 100%; margin-bottom: 12px; }
.seg.wide button { flex: 1; padding: 9px; font-size: 13px; }

/* ---- outfit-idea cards ---- */
.idea {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 13px 14px; margin-top: 10px;
  box-shadow: var(--shadow-1);
}
.idea.unseen { border-color: color-mix(in srgb, var(--clay) 45%, var(--line)); }
.idea-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.idea-top b { font-size: 14px; font-weight: 600; }
.idea-top span { font-size: 11.5px; color: var(--muted); }
.idea-note {
  font-family: var(--serif); font-size: 15px; line-height: 1.5; color: var(--ink-2);
  margin: 0 0 10px;
}
.idea .strip { margin: 0; }
.idea-acts { display: flex; gap: 8px; margin-top: 10px; }
.idea-acts .btn { flex: 1; padding: 8px; font-size: 13px; }


/* ---- clothes indexing ---- */
.hangno {
  position: absolute; top: 9px; left: 9px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 78%, transparent); color: var(--paper);
  backdrop-filter: blur(6px);
}
.washloc {
  font-size: 11px; color: var(--muted); padding: 6px 11px 9px;
  border-top: 1px solid var(--line);
}
.idx-row { display: flex; gap: 10px; }
.idx-row .idx-hanger { flex: none; width: 84px; }
.idx-row .idx-loc { flex: 1; min-width: 0; }
#indexFields { margin-top: 4px; }


/* ---- sign in with Google / Apple ---- */
.gate-oauth { display: flex; flex-direction: column; gap: 10px; }
.gate-or {
  display: flex; align-items: center; gap: 12px; color: var(--muted);
  font-size: 12px; margin: 2px 0;
}
.gate-or::before, .gate-or::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.oauth-btn {
  gap: 10px; font-size: 14.5px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.oauth-btn svg { width: 18px; height: 18px; }
.gate-oauth-note { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

.connect-row {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 10px 12px;
}
.connect-row .who { flex: 1; min-width: 0; }
.connect-row .who b { font-size: 13.5px; font-weight: 600; text-transform: capitalize; }
.connect-row .who span { display: block; font-size: 11.5px; color: var(--muted); }
.connect-row .btn { padding: 6px 12px; font-size: 12.5px; }


/* ---- logo ---- */
.logo-mark {
  width: 52px; height: 52px; align-self: center;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  color: var(--ink);
}
.logo-mark rect { fill: var(--surface-2); }

/* ---- FAB add menu ---- */
.fab.open { transform: rotate(45deg); }
.add-menu {
  position: fixed; right: 18px; z-index: 26;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 82px);
  width: min(244px, calc(100vw - 36px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); overflow: hidden;
}
.add-menu button {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 13px 15px; background: none; border: 0; cursor: pointer;
  font: inherit; color: var(--ink); border-bottom: 1px solid var(--line);
}
.add-menu button:last-child { border-bottom: 0; }
.add-menu button:active { background: var(--surface-2); }
.add-menu svg { width: 20px; height: 20px; flex: none; color: var(--ink-2); }
.add-menu b { display: block; font-size: 14px; font-weight: 600; }
.add-menu small { display: block; font-size: 11.5px; color: var(--muted); }


/* ---- admin panel ---- */
.admin-users { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.admin-user {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 10px 12px;
}
.admin-user .who { flex: 1; min-width: 0; }
.admin-user .who b { font-size: 13.5px; font-weight: 600; }
.admin-user .who b .you { color: var(--muted); font-weight: 500; }
.admin-user .who span { display: block; font-size: 11px; color: var(--muted); }
.admin-user .roles { display: flex; gap: 6px; align-items: center; }
.admin-user .chip {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px;
  cursor: pointer; color: var(--muted); background: none;
}
.admin-user .chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.admin-user .del {
  width: 30px; height: 30px; flex: none; border: 0; background: none; cursor: pointer;
  color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.admin-user .del svg { width: 15px; height: 15px; }
.admin-user .del:active { color: var(--danger); }


/* ============================================================
   Neko: a few quiet cat touches, nothing that shouts
   ============================================================ */

/* the sleeping cat in the empty Fits state gets a little more room */
.empty svg.catnap { width: 82px; height: 56px; }

/* a paw that breathes while the stylist thinks */
.thinking .paw-pad {
  width: 15px; height: 15px; color: var(--clay); opacity: .75;
  fill: currentColor; stroke: none;
  animation: paw-step 1.4s ease-in-out infinite;
}
@keyframes paw-step {
  0%, 100% { opacity: .30; transform: translateY(0) rotate(-6deg); }
  50%      { opacity: .85; transform: translateY(-2px) rotate(4deg); }
}

/* the logo's ears sit outside the square, so let them breathe */
.logo-mark { overflow: visible; }

/* worn flag: a paw print instead of a bare dot feels like the cat's been at it */
.flag.worn::before {
  content: ""; display: inline-block; width: 9px; height: 9px;
  margin-right: 4px; vertical-align: -1px;
  background: currentColor;
  -webkit-mask: var(--paw) center/contain no-repeat;
  mask: var(--paw) center/contain no-repeat;
}
:root {
  --paw: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23000'%3E%3Cellipse cx='12' cy='15.4' rx='4.3' ry='3.6'/%3E%3Cellipse cx='6.2' cy='10.6' rx='1.9' ry='2.4'/%3E%3Cellipse cx='17.8' cy='10.6' rx='1.9' ry='2.4'/%3E%3Cellipse cx='9.4' cy='6.6' rx='1.8' ry='2.3'/%3E%3Cellipse cx='14.6' cy='6.6' rx='1.8' ry='2.3'/%3E%3C/g%3E%3C/svg%3E");
}

.gate-swap.inline {
  display: inline; padding: 0 0 0 2px; font-size: 13px; color: var(--ink-2);
}
