:root {
  --bg: #f4f3ef; --surface: #ffffff; --ink: #1b1d21; --muted: #646a73; --line: #e1e0da;
  --accent: #e8a317; --accent-ink: #1b1d21; --accent-soft: #fbefd2; --ok: #2f6b4f; --err: #b3361f;
  --serif: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --r: 14px; --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 8px 24px rgba(40, 30, 20, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121417; --surface: #1b1e23; --ink: #eef0f2; --muted: #9aa1ab; --line: #2c3037; --accent: #f0b429; --accent-ink: #15171a; --accent-soft: #3a3020; --shadow: none; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.15rem; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--accent); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px max(16px, env(safe-area-inset-left)); background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand h1 { font-size: 1.2rem; line-height: 1; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.mark { width: 36px; height: 36px; max-width: none; border-radius: 9px; }
.mark.big { width: 64px; height: 64px; border-radius: 16px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 8px 14px; border-radius: 999px; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--ink); color: var(--bg); }
.tabs button[data-tab="add"] { color: var(--ink); font-weight: 600; }
.tabs button[data-tab="add"].on { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 720px) {
  .top { backdrop-filter: none; background: var(--bg); }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .tabs button { flex: 1; padding: 10px 6px; }
}
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.icon { border: 0; background: none; font-size: 1.25rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: var(--muted); }
.icon:hover { background: var(--accent-soft); }

.primary, .btn, label.file { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 999px; padding: 10px 18px; cursor: pointer; text-decoration: none; font-weight: 500; white-space: nowrap; }
.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.btn, label.file { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
label.file.primary { background: var(--accent); color: var(--accent-ink); }
label.file input { display: none; }
.primary:disabled { opacity: .5; cursor: default; }
.big { padding: 14px 28px; font-size: 1.05rem; }
.danger { color: var(--err); }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }

.status { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 20; margin: 0; padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.status[data-kind="error"] { background: var(--err); color: #fff; }

.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px 0; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; text-transform: capitalize; }
.chip small { color: var(--muted); margin-left: 2px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.on small { color: inherit; opacity: .7; }
@media (max-width: 720px) { .bar { flex-wrap: wrap; } .bar .primary { position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 6; box-shadow: var(--shadow); } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.card { text-align: left; border: 0; padding: 0; background: none; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.ph { position: relative; aspect-ratio: 4 / 5; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; display: grid; place-items: center; border: 1px solid var(--line); }
.ph img { width: 100%; height: 100%; object-fit: contain; }
.swatch { width: 60%; aspect-ratio: 1; border-radius: 50%; }
.fav { position: absolute; top: 8px; right: 10px; color: var(--accent); }
.meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.meta strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card small { color: var(--muted); }
.dots { display: inline-flex; gap: 3px; flex: none; }
.dots i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15); }

.empty { text-align: center; max-width: 440px; margin: 10vh auto; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
form.panel { display: grid; gap: 14px; margin-bottom: 20px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: .85rem; }
input, select { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 12px; color: var(--ink); font-size: 1rem; min-width: 0; }
input[type=color] { width: 40px; height: 32px; padding: 2px; }
input[type=range] { padding: 0; accent-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
.row.tight { display: flex; gap: 8px; align-items: center; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0; }
.scale { display: flex; justify-content: space-between; font-size: .75rem; }
.seasons { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.seasons legend { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; flex-direction: row; color: var(--ink); text-transform: capitalize; font-size: .9rem; }

dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: 20px; width: min(720px, calc(100% - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(20, 15, 10, .45); backdrop-filter: blur(2px); }
.sheet { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sheet > header h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet > section, .sheet > .pick, .sheet > .hint, #review { padding: 0 20px; }
.sheet > section { padding-top: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.sheet > section p { margin: 4px 0; }
.sheet > footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.pick { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 16px !important; }
#review { overflow: auto; flex: 1; }
.scan { border-top: 1px solid var(--line); padding: 12px 0; }
.scan-head { display: flex; align-items: center; gap: 10px; color: var(--muted); flex-wrap: wrap; }
.scan-head img, .ph-mini { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--line); }
.err { color: var(--err); }
.found { display: grid; grid-template-columns: 24px 72px 1fr; gap: 10px; align-items: center; padding: 8px 0; }
.found.off { opacity: .45; }
.found img { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 10px; border: 1px solid var(--line); }
.fields { display: grid; gap: 6px; }
.fields small { color: var(--muted); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(1turn); } }

.item-body { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 20px; padding: 20px; overflow: auto; }
.item-photo img { width: 100%; border-radius: var(--r); background: #fff; border: 1px solid var(--line); }
.item-fields { display: grid; gap: 12px; align-content: start; }
.colours { display: flex; gap: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 600px) { .item-body { grid-template-columns: 1fr; } .item-photo img { max-height: 40vh; object-fit: contain; margin: 0 auto; } }

#suggestions, #outfits { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
@media (max-width: 400px) { #suggestions, #outfits { grid-template-columns: 1fr; } }
.outfit { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); display: grid; gap: 10px; align-content: start; }
.outfit header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.outfit p { margin: 0; }
.tag { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.palette { display: flex; height: 8px; border-radius: 4px; overflow: hidden; }
.palette i { flex: 1; }
.pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.piece { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; display: grid; gap: 4px; }
.piece img { width: 100%; aspect-ratio: 4 / 5; object-fit: contain; background: #fff; border-radius: 10px; border: 1px solid var(--line); }
.piece small { font-size: .72rem; color: var(--muted); line-height: 1.2; }
.tip { color: var(--muted); }
.tip b { color: var(--accent); font-weight: 600; margin-right: 4px; }
.gaps { grid-column: 1 / -1; }
.gaps p { margin: 6px 0 0; }
.keys { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.secret code { word-break: break-all; background: var(--accent-soft); padding: 4px 6px; border-radius: 6px; display: inline-block; margin-top: 4px; }

.locked { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.locked .panel { text-align: center; display: grid; gap: 12px; justify-items: center; max-width: 360px; }

/* Where's My Stuff? */
.brand p { display: none; }
.search { display: flex; gap: 8px; position: sticky; top: 70px; z-index: 4; }
.search input { flex: 1; font-size: 1.1rem; padding: 14px 16px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.search input:focus { outline: 2px solid var(--accent); }
@media (max-width: 720px) { .search { top: 64px; } }
#answer { background: var(--accent-soft); border-radius: var(--r); padding: 12px 16px; margin: 12px 0; font-size: 1.05rem; }
#answer p { margin: 0; }
.results { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.result { width: 100%; display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 8px 8px; cursor: pointer; }
.result:hover { border-color: var(--accent); }
.thumb { width: 56px; height: 56px; border-radius: 8px; background: var(--bg); overflow: hidden; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.what { display: grid; min-width: 0; }
.what strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.where { display: grid; justify-items: end; gap: 2px; font-size: .82rem; color: var(--muted); max-width: 42vw; text-align: right; }
.out { color: var(--err); font-weight: 600; font-size: .8rem; }
@media (max-width: 560px) { .result { grid-template-columns: 48px 1fr; } .thumb { width: 48px; height: 48px; } .where { grid-column: 2; justify-items: start; text-align: left; max-width: none; } }
.none { color: var(--muted); padding: 12px 4px; }
.bar h2 { margin-right: auto; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 18px; border-left: 2px solid var(--line); padding-left: 10px; }
.node { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 4px 0; cursor: pointer; text-align: left; }
.node span { font-weight: 600; }
.node small { color: var(--muted); }
#add .panel { display: grid; gap: 12px; margin-bottom: 16px; }
#add .pick { padding: 0 !important; display: flex; gap: 10px; flex-wrap: wrap; }
.scan.panel { margin-bottom: 12px; padding: 12px 16px; }
.scan.panel .scan-head img { width: 64px; height: 64px; }
.found input[type=number] { width: 80px; }
.savebar { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); display: flex; justify-content: center; padding: 8px 0; }
@media (min-width: 721px) { .savebar { bottom: 16px; } }
.sheet .body { padding: 16px 20px 20px; overflow: auto; display: grid; grid-auto-rows: max-content; gap: 12px; }
.sheet .body h3 { margin-top: 8px; }
.sheet .body p { margin: 0; }
.where-big { font-size: 1.1rem; font-weight: 600; }
.scene-wrap { position: relative; border-radius: var(--r); overflow: hidden; }
.scene { width: 100%; max-height: 50vh; object-fit: contain; border-radius: var(--r); background: var(--bg); }
.scene-wrap .scene { max-height: none; border-radius: 0; }
.outline { position: absolute; border: 3px solid var(--accent); border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); animation: pulse 1.6s ease-in-out 2; }
@keyframes pulse { 50% { border-color: #fff; } }
.compact .result { grid-template-columns: 44px 1fr; } .compact .thumb { width: 44px; height: 44px; } .compact .where { display: none; }
.qty { color: var(--muted); font-weight: 500; }
