/* ================= Theme ================= */
:root {
  --bg: #f6f2ec; --bg-2: #eee7de; --card: #ffffff; --text: #1e1a24; --muted: #7b7385; --line: #ebe4da;
  --accent: #6b4eff; --accent-soft: #efeaff; --accent-ink: #ffffff;
  --grad: linear-gradient(135deg, #6b4eff 0%, #a64dff 52%, #ff6f91 100%);
  --ok: #1f8a4c;   --ok-bg: #e3f5ea;
  --due: #1769c2;  --due-bg: #e2eefc;
  --warn: #b85a00; --warn-bg: #fff0dc;
  --rest: #6a46d1; --rest-bg: #efe9fd;
  --bad: #d03a3a;  --bad-bg: #fde8e8;
  --shadow-sm: 0 1px 2px rgba(40, 30, 60, .06);
  --shadow: 0 1px 2px rgba(40, 30, 60, .05), 0 10px 30px -14px rgba(40, 30, 60, .2);
  --shadow-lg: 0 24px 60px -20px rgba(40, 30, 60, .38);
  --glass: rgba(255, 255, 255, .8);
  --r: 22px; --r-sm: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121015; --bg-2: #221e29; --card: #1c1922; --text: #f2eef7; --muted: #a29bad; --line: #2c2834;
    --accent: #8f78ff; --accent-soft: #29223f;
    --ok: #5fd38d;   --ok-bg: #173323;
    --due: #6fb4ff;  --due-bg: #142a42;
    --warn: #ffb057; --warn-bg: #3a2a14;
    --rest: #b9a1ff; --rest-bg: #2a2244;
    --bad: #ff8080;  --bad-bg: #3b1d1f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
    --glass: rgba(34, 30, 41, .82);
    color-scheme: dark;
  }
  .thumb { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1); }
}

/* Status tones, shared by badges, dots, pills, stats and groups */
.ok   { --c: var(--ok);   --cb: var(--ok-bg); }
.due  { --c: var(--due);  --cb: var(--due-bg); }
.warn { --c: var(--warn); --cb: var(--warn-bg); }
.rest { --c: var(--rest); --cb: var(--rest-bg); }
.bad  { --c: var(--bad);  --cb: var(--bad-bg); }

/* ================= Base ================= */
* { box-sizing: border-box; }
html { background: var(--bg); }
html.sheet-open { overflow: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; }
h2 { font-size: 22px; margin: 0; }
h3 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
h3 .ico { width: 20px; height: 20px; color: var(--accent); }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 13.5px; }
.small { font-size: 12.5px; }
.center { text-align: center; margin: 16px 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.ico {
  width: 1.2em; height: 1.2em; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.ico.inline { width: 1em; height: 1em; vertical-align: -2px; }
.ico.big {
  width: 30px; height: 30px; padding: 12px; box-sizing: content-box; border-radius: 18px;
  color: var(--accent); background: var(--accent-soft);
}
.eyebrow { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ================= Top bar & tabs ================= */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: calc(12px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right)) 12px calc(24px + env(safe-area-inset-left));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.logo { width: 38px; height: 38px; border-radius: 12px; box-shadow: var(--shadow-sm); }
.brand h1 { font-size: 19px; margin: 0; line-height: 1.1; }
#today-label { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }

nav {
  display: flex; gap: 2px; padding: 4px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
nav button {
  display: flex; align-items: center; gap: 7px; border: 0; background: none; cursor: pointer;
  padding: 8px 15px; border-radius: 99px; font-weight: 600; font-size: 14px; color: var(--muted);
  transition: background .2s, color .2s;
}
nav button:hover { color: var(--text); }
nav button.active { background: var(--text); color: var(--card); }

.sync-badge {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 6px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line);
}
.sync-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.sync-badge.off .dot { background: var(--muted); box-shadow: none; }
.sync-badge.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }

main { max-width: 1080px; margin: 0 auto; padding: 8px 24px 48px; }
#view.enter > * { animation: rise .35s both; }
#view.enter > *:nth-child(2) { animation-delay: .04s; }
#view.enter > *:nth-child(3) { animation-delay: .08s; }
#view.enter > *:nth-child(n+4) { animation-delay: .12s; }

/* ================= Buttons & controls ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; border-radius: 99px; padding: 11px 18px; cursor: pointer;
  font-weight: 650; font-size: 14.5px; line-height: 1.2; white-space: nowrap;
  background: var(--bg-2); color: var(--text);
  transition: transform .12s, filter .2s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.04); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 18px -8px rgba(107, 78, 255, .75); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-danger-soft { background: var(--bad-bg); color: var(--bad); }
.btn-hero { background: #fff; color: #5a3df0; font-weight: 700; padding: 12px 22px; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .45); }
.btn-ghost-light { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .4); }
.btn.sm { padding: 8px 13px; font-size: 13px; }
.btn.block { width: 100%; }
.grow { flex: 1; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
label.btn { cursor: pointer; }

.icon-btn {
  width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 50%; cursor: pointer;
  display: inline-grid; place-items: center; background: var(--bg-2); color: var(--text);
  transition: transform .12s, background .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ico { width: 16px; height: 16px; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search] {
  width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: var(--r-sm);
  padding: 12px 14px; outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--bg-2); transition: background .2s; flex-shrink: 0; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: transform .22s cubic-bezier(.3, 1.4, .5, 1);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; gap: 2px; padding: 4px; border-radius: 99px; background: var(--bg); flex-shrink: 0; }
.stepper button {
  width: 34px; height: 34px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); font-size: 18px; font-weight: 600; line-height: 1;
}
.stepper button:active { transform: scale(.9); }
.stepper input[type=number] {
  width: 42px; padding: 0; border: 0; background: none; box-shadow: none; text-align: center;
  font-weight: 700; font-size: 16px; -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* ================= Cards & layout ================= */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head .muted { margin: 4px 0 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 10px 2px 16px; }
.page-head h2 { font-size: 30px; margin-top: 2px; letter-spacing: -.02em; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 2px 14px; }
.pager { display: flex; align-items: center; gap: 6px; }
.hint { text-align: center; font-size: 12.5px; color: var(--muted); margin: 18px 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; color: var(--c); background: var(--cb);
}
.badge .ico { width: 14px; height: 14px; stroke-width: 2.4; }
.alert { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 12px; font-size: 13.5px; }
.empty-state { text-align: center; color: var(--muted); padding: 28px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-state p { margin: 0; max-width: 36ch; }
.empty-state.soft { background: transparent; border: 1.5px dashed var(--line); box-shadow: none; }
.empty-state.wide { grid-column: 1 / -1; }

/* ================= Clothing pictures ================= */
.thumb {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden;
  display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .07);
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .glyph { width: 46%; height: 46%; display: grid; }
.thumb .glyph .ico { width: 100%; height: 100%; stroke-width: 1.3; }
.thumb .cloud { position: absolute; right: 6px; bottom: 5px; width: 16px; height: 16px; color: #fff; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .6)); }
.thumb .cloud .ico { width: 100%; height: 100%; }
.thumb.sm { width: 52px; height: 52px; border-radius: 13px; flex-shrink: 0; }
.thumb.xs { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; }
.thumb.sm .cloud, .thumb.xs .cloud { display: none; }

.piece { min-width: 0; }
.pname { font-weight: 650; font-size: 13.5px; line-height: 1.25; margin-top: 7px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pmeta { display: flex; align-items: center; gap: 5px; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.sdot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.look-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px; }
.scroller {
  display: grid; grid-auto-flow: column; grid-auto-columns: 112px; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  margin: 0 -18px; padding: 2px 18px 4px;
}
.scroller::-webkit-scrollbar, .occ-row::-webkit-scrollbar, .chip-row::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; }

/* ================= Today ================= */
.hero {
  position: relative; overflow: hidden; color: #fff; background: var(--grad);
  border-radius: 28px; padding: 24px; margin-bottom: 16px;
  box-shadow: 0 22px 44px -22px rgba(107, 78, 255, .7);
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none; background: rgba(255, 255, 255, .12);
}
.hero::before { width: 240px; height: 240px; right: -70px; top: -90px; }
.hero::after { width: 140px; height: 140px; left: -50px; bottom: -70px; background: rgba(255, 255, 255, .08); }
.hero h2 { font-size: 28px; line-height: 1.12; margin-top: 4px; max-width: 18ch; }
.hero .eyebrow { color: rgba(255, 255, 255, .8); }
.hero-sub { position: relative; color: rgba(255, 255, 255, .9); max-width: 46ch; margin: 10px 0 0; }
.hero-row { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero-row.bottom { align-items: center; margin-top: 18px; }
.hero-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero .switch .track { background: rgba(255, 255, 255, .28); }
.hero .switch input:checked + .track { background: #fff; }
.hero .switch input:checked + .track::after { background: #6b4eff; }

.date-chip {
  position: relative; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 8px 13px; border-radius: 99px; font-weight: 650; font-size: 13.5px; white-space: nowrap;
  background: rgba(255, 255, 255, .18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}
.date-chip input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.occ-row {
  position: relative; z-index: 1; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 20px -24px 0; padding: 2px 24px 4px;
}
.occ {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 9px 15px; border: 0; border-radius: 99px; font-weight: 650; color: #fff;
  background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .32);
  transition: background .2s, transform .12s;
}
.occ:active { transform: scale(.95); }
.occ.on { background: #fff; color: #5a3df0; box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .45); }

.looks { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; margin-bottom: 14px; }
.look { margin: 0; display: flex; flex-direction: column; gap: 14px; animation: rise .4s both; animation-delay: var(--d, 0ms); }
.look .card-head { margin: 0; align-items: center; }
.look .btn { margin-top: auto; }
.swatches { display: inline-flex; padding-left: 4px; }
.swatches i { width: 16px; height: 16px; border-radius: 50%; margin-left: -5px; box-shadow: 0 0 0 2.5px var(--card); }
.look-notes { margin: 0; padding: 10px 14px 10px 30px; border-radius: 14px; background: var(--bg); color: var(--muted); font-size: 13px; }
.planned { border: 0; box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.planned .look-items { margin-bottom: 14px; }

.install { display: flex; align-items: flex-start; gap: 14px; background: var(--accent-soft); border-color: transparent; }
.install > div { flex: 1; }
.install p { margin: 2px 0 0; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.step { position: relative; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.step > .ico { width: 28px; height: 28px; color: var(--accent); margin-bottom: 8px; }
.step-n { position: absolute; top: 14px; right: 16px; font: 700 13px var(--font-display); color: var(--muted); opacity: .6; }

/* Collapsible cards */
.fold summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after {
  content: ""; width: 9px; height: 9px; flex-shrink: 0; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-3px); transition: transform .2s;
}
.fold[open] summary::after { transform: rotate(-135deg) translateX(-2px); }
.fold[open] summary { margin-bottom: 10px; }
.fold-title { display: flex; align-items: center; gap: 8px; font: 650 16px var(--font-display); margin-right: auto; }
.fold-title > .ico { color: var(--accent); }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 12px 0 14px; }
.pick {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; cursor: pointer;
  border-radius: 16px; border: 1.5px solid var(--line); transition: border-color .2s, background .2s;
}
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick .pname { margin: 0; font-size: 13px; flex: 1; }
.pick .tick { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; color: transparent; flex-shrink: 0; }
.pick .tick .ico { width: 14px; height: 14px; stroke-width: 3; }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick:has(input:checked) .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.pick.off { opacity: .4; cursor: not-allowed; }

/* ================= Week ================= */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(440px, 100%), 1fr)); gap: 12px; }
.day { display: flex; gap: 14px; margin: 0; padding: 14px; }
.day-date {
  width: 54px; flex-shrink: 0; align-self: flex-start; padding: 9px 0;
  display: flex; flex-direction: column; align-items: center; border-radius: 16px; background: var(--bg);
}
.dow { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dnum { font: 700 22px/1.1 var(--font-display); }
.day.is-today { border-color: transparent; box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.day.is-today .day-date { background: var(--grad); color: #fff; }
.day.is-today .dow { color: rgba(255, 255, 255, .85); }
.day.is-past:not(.is-today) .day-date { opacity: .6; }
.day-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.day-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; min-height: 40px; }
.day-top .occ-select { flex: 1 1 130px; max-width: 220px; }
.day-actions { display: flex; align-items: center; gap: 6px; }
.day-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.day-items .pname { font-size: 12.5px; }
.day-note { margin: 0; }
.occ-select {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%;
  padding-left: 12px; border-radius: 99px; background: var(--bg); font-weight: 650; cursor: pointer;
}
.occ-select::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; pointer-events: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg);
}
.occ-select select {
  appearance: none; -webkit-appearance: none; border: 0; background: none; cursor: pointer;
  padding: 9px 32px 9px 0; font-weight: 650; min-width: 0; width: 100%; text-overflow: ellipsis;
}
.occ-select select:disabled { cursor: default; opacity: .8; }

/* ================= Closet ================= */
.closet-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 16px; min-width: 0;
  border-radius: 99px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--muted);
}
.search input[type=search] { border: 0; background: none; box-shadow: none; padding: 12px 0; color: var(--text); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.select-pill {
  appearance: none; -webkit-appearance: none; cursor: pointer; font-weight: 600; max-width: 45%;
  padding: 0 34px 0 16px; border-radius: 99px; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b7385' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
}
.chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -24px 16px; padding: 2px 24px 4px; }
.chip-row.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-weight: 650; font-size: 13.5px; transition: background .2s, color .2s;
}
.chip-btn .n { font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.chip-btn.on { background: var(--text); border-color: var(--text); color: var(--card); }
.chip-btn.on .n { background: rgba(127, 127, 127, .25); color: inherit; }

.closet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.cloth {
  position: relative; display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer;
  padding: 8px 8px 13px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card);
  color: var(--text); box-shadow: var(--shadow); transition: transform .18s, box-shadow .2s;
}
.cloth:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.cloth:active { transform: scale(.98); }
.cloth .thumb { margin-bottom: 9px; }
.cname { padding: 0 5px; font-weight: 650; font-size: 14px; line-height: 1.25; }
.cmeta { padding: 0 5px; font-size: 12px; color: var(--muted); }
.status-pill {
  position: absolute; top: 16px; left: 16px; max-width: calc(100% - 32px);
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 99px;
  color: var(--c); background: var(--cb); box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ================= Add / edit sheet ================= */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 14, 30, .45);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade .2s both;
}
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(580px, 100%);
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up .34s cubic-bezier(.2, .9, .3, 1) both;
}
.sheet-grab { width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sheet-body { display: flex; flex-direction: column; gap: 18px; }
.sheet-actions { display: flex; gap: 10px; padding-top: 4px; }

.photo-pick {
  display: flex; align-items: center; gap: 14px; padding: 10px; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: 20px; transition: border-color .2s, background .2s;
}
.photo-pick:hover { border-color: var(--accent); background: var(--accent-soft); }
.photo-preview { width: 84px; flex-shrink: 0; }
.photo-empty { width: 84px; height: 84px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.photo-empty .ico { width: 30px; height: 30px; }
.photo-text { display: flex; flex-direction: column; gap: 2px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.field.row { flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; }
.field.row > span { display: flex; flex-direction: column; gap: 2px; }
.field.row small { font-weight: 500; }

.type-pick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.type-pick label, .swatch-pick label, .chip-check { position: relative; cursor: pointer; }
.type-pick input, .swatch-pick input, .chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.type-pick span {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px;
  border-radius: 16px; border: 1.5px solid var(--line); font-size: 12.5px; font-weight: 650; transition: all .2s;
}
.type-pick .ico { width: 26px; height: 26px; stroke-width: 1.6; }
.type-pick input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.swatch-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch-pick i {
  display: block; width: 34px; height: 34px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); transition: transform .15s, box-shadow .15s;
}
.swatch-pick input:checked + i { transform: scale(1.08); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 0 0 3px var(--card), 0 0 0 5px var(--accent); }
.chip-check span {
  display: inline-flex; padding: 8px 13px; border-radius: 99px; border: 1.5px solid var(--line);
  font-weight: 650; font-size: 13.5px; transition: all .2s;
}
.chip-check input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.type-pick input:focus-visible + span, .swatch-pick input:focus-visible + i, .chip-check input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ================= Laundry ================= */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat {
  display: flex; flex-direction: column; gap: 3px; padding: 16px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.stat .ico { width: 34px; height: 34px; padding: 7px; border-radius: 12px; color: var(--c); background: var(--cb); margin-bottom: 8px; }
.stat b { font: 700 28px/1 var(--font-display); }
.stat span { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.group h3 .ico { color: var(--c); }
.count {
  margin-left: 2px; padding: 2px 8px; border-radius: 99px; font: 700 12px var(--font);
  color: var(--c, var(--muted)); background: var(--cb, var(--bg));
}
.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.rows .row-item:first-child { border-top: 0; padding-top: 0; }
.ri-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ri-main b { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-sub { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.ri-next { font-size: 12px; font-weight: 650; color: var(--c); }
.wear-dots { display: inline-flex; gap: 3px; }
.wear-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--bg-2); }
.wear-dots i.on { background: var(--accent); }
.wear-count { font-weight: 650; }

.timeline { display: flex; flex-direction: column; gap: 16px; }
.tl-date { margin-bottom: 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tl-entry {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "occ items undo" "names names names";
  align-items: center; gap: 6px 12px; padding: 10px 12px; margin-bottom: 6px; border-radius: 16px; background: var(--bg);
}
.occ-tag { grid-area: occ; font-weight: 650; font-size: 13.5px; white-space: nowrap; }
.tl-items { grid-area: items; display: flex; }
.tl-items .thumb { margin-left: -7px; box-shadow: 0 0 0 2.5px var(--bg); }
.tl-items .thumb:first-child { margin-left: 0; }
.tl-entry .icon-btn { grid-area: undo; background: var(--card); color: var(--muted); }
.tl-names { grid-area: names; font-size: 12.5px; }

/* ================= Settings ================= */
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.card-head + .setting-row { border-top: 0; padding-top: 0; }
.setting-row > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.setting-row .muted { font-size: 12.5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 13px; border-radius: 99px;
  background: var(--bg); font-weight: 650; font-size: 13.5px;
}
.chip .x { width: 24px; height: 24px; border: 0; border-radius: 50%; cursor: pointer; display: grid; place-items: center; background: var(--card); color: var(--muted); }
.chip .x .ico { width: 12px; height: 12px; stroke-width: 2.6; }
.add-row { display: flex; gap: 8px; margin-top: 14px; }
.auth { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.account { display: flex; align-items: center; gap: 12px; }
.account > div { display: flex; flex-direction: column; min-width: 0; }
.account b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; font: 700 19px var(--font-display); }

/* ================= Toast ================= */
#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60; max-width: 90vw; text-align: center;
  padding: 12px 20px; border-radius: 99px; background: var(--text); color: var(--card);
  font-weight: 650; font-size: 14px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transform: translate(-50%, 16px) scale(.96); transition: opacity .25s, transform .3s cubic-bezier(.2, .9, .3, 1.2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ================= Motion ================= */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: translateY(-46%) scale(.96); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= Desktop sheet: centred dialog ================= */
@media (min-width: 761px) {
  .sheet { top: 50%; bottom: auto; transform: translateY(-50%); border-radius: 28px; max-height: 88vh; padding: 20px 24px 24px; animation-name: pop; animation-duration: .25s; }
  .sheet-grab { display: none; }
}

/* ================= Phone layout ================= */
@media (max-width: 900px) {
  nav button span { display: none; }
  nav button { padding: 9px 13px; }
  nav button .ico { width: 21px; height: 21px; }
}
@media (max-width: 760px) {
  /* No backdrop-filter here: it would turn the bar into the containing block of the fixed tab bar */
  .topbar {
    padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 10px calc(16px + env(safe-area-inset-left));
    background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .logo { width: 34px; height: 34px; border-radius: 10px; }
  main { padding: 6px 16px calc(108px + env(safe-area-inset-bottom)); }

  /* Floating tab bar at the bottom, like a native iPhone app */
  nav {
    position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    justify-content: space-around; padding: 6px; border-radius: 26px;
    background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8);
    box-shadow: var(--shadow-lg);
  }
  nav button { flex: 1; flex-direction: column; gap: 3px; padding: 7px 0 6px; border-radius: 20px; font-size: 10.5px; }
  nav button span { display: block; }
  nav button .ico { width: 23px; height: 23px; }
  nav button.active { background: var(--accent-soft); color: var(--accent); }
  html.sheet-open nav { display: none; }

  /* iOS zooms into inputs under 16px */
  input, select, textarea { font-size: 16px !important; }

  .hero { padding: 20px; border-radius: 26px; }
  .hero h2 { font-size: 24px; }
  .occ-row { margin: 18px -20px 0; padding: 2px 20px 4px; }
  .page-head h2 { font-size: 26px; }
  .card { padding: 16px; border-radius: 20px; }
  .scroller { margin: 0 -16px; padding: 2px 16px 4px; grid-auto-columns: 104px; }
  .chip-row { margin: 0 -16px 14px; padding: 2px 16px 4px; }
  .looks, .days { grid-template-columns: minmax(0, 1fr); }
  .closet-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .pick-grid { grid-template-columns: 1fr 1fr; }
  .type-pick { gap: 6px; }
  .type-pick span { padding: 10px 2px; font-size: 11.5px; }
  .swatch-pick { gap: 9px; }
  .swatch-pick i { width: 32px; height: 32px; }
  .day { gap: 12px; padding: 12px; }
  .day-date { width: 48px; }
  #toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .sync-badge { font-size: 0; gap: 0; padding: 8px; }
  .look-items { grid-template-columns: repeat(3, 1fr); }
}
