:root {
  --bg: #0d0d12; --panel: #16161e; --panel2: #1e1e28; --line: #2a2a36;
  --ink: #f0f0ff; --dim: #a3a3b8; --faint: #6d6d82;
  --gold: #E8B54A; --gold-ink: #1a1408; --good: #5fd39a; --bad: #ff7a7a;
  --r: 14px; --tabs: 64px;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Space Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(var(--tabs) + env(safe-area-inset-bottom)); overflow-x: hidden; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }

/* ---------- top + tabs */
.top { display: flex; align-items: baseline; gap: 12px; padding: 14px 16px 6px; max-width: 1100px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; text-decoration: none; letter-spacing: -.02em; }
.logo img { width: 26px; height: 26px; align-self: center; }
.tag { color: var(--faint); font: 12px var(--mono); }
@media (max-width: 420px) { .tag { display: none; } }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(13,13,18,.94); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
.tabs a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px;
  text-decoration: none; color: var(--dim); font-size: 12px; font-weight: 600; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tabs a.on { color: var(--gold); }

main { max-width: 1100px; margin: 0 auto; padding: 4px 16px 24px; }
h1 { font-size: 26px; line-height: 1.15; letter-spacing: -.02em; margin: 10px 0 6px; }
h2 { font-size: 19px; margin: 22px 0 10px; letter-spacing: -.01em; }
.sub { color: var(--dim); margin: 0 0 14px; }
.hint { color: var(--faint); font-size: 13px; margin: 8px 0; }
.mono { font-family: var(--mono); }
.money { font-family: var(--mono); font-weight: 700; }

/* ---------- buttons + chips */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel2); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--dim); font-weight: 600; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
select.chip { appearance: none; padding-right: 14px; }

/* ---------- look cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.lcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; text-decoration: none; display: flex; flex-direction: column; position: relative; }
.collage { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; aspect-ratio: 1; background: var(--line); }
.collage img { width: 100%; height: 100%; object-fit: cover; background: var(--panel2); }
.collage.n3 img:first-child { grid-row: span 2; }
.lcard .meta { padding: 10px 12px 12px; }
.lcard b { display: block; font-size: 14px; line-height: 1.25; }
.lcard .line2 { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; margin-top: 4px; }
.badge { position: absolute; top: 8px; left: 8px; padding: 4px 9px; border-radius: 999px; font: 700 11px var(--mono); background: rgba(13,13,18,.86); color: var(--ink); }
.badge.paid { background: var(--good); color: #062014; }

/* ---------- one look */
.back { display: inline-flex; color: var(--dim); text-decoration: none; font-size: 14px; margin: 6px 0 2px; }
.look-head { display: grid; gap: 16px; }
@media (min-width: 760px) { .look-head { grid-template-columns: 380px 1fr; align-items: start; } }
.look-head .collage { border-radius: var(--r); overflow: hidden; }
.pieces { display: grid; gap: 10px; margin-top: 8px; }
.piece { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.piece img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--panel2); }
.piece b { display: block; font-size: 14px; line-height: 1.25; }
.piece span { color: var(--dim); font-size: 12px; }
.ftc { color: var(--faint); font-size: 12px; margin-top: 12px; }

/* ---------- builder */
.slots { display: grid; gap: 10px; }
.slot { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; min-height: 80px; background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 8px; }
.slot.full { border-style: solid; }
.slot .ph { width: 64px; height: 64px; border-radius: 8px; background: var(--panel2); display: grid; place-items: center; color: var(--faint); font-size: 22px; }
.slot img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.slot .lbl { font: 11px var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.slot b { display: block; font-size: 14px; line-height: 1.25; }
.total-bar { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; padding: 12px 14px; background: var(--panel); border-radius: 12px; border: 1px solid var(--line); }
.tips { display: grid; gap: 10px; margin-top: 10px; }
.tip { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; background: #1f1a0e; border: 1px solid #4a3a16; border-radius: 12px; padding: 8px; }
.tip img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.tip span { color: var(--dim); font-size: 12px; display: block; }

/* ---------- picker */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 10px; max-height: 58vh; overflow-y: auto; }
.pick { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 0; cursor: pointer; text-align: left; overflow: hidden; }
.pick img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.pick div { padding: 6px 8px 8px; font-size: 12px; line-height: 1.25; }
.pick small { color: var(--dim); display: block; margin-top: 2px; }

/* ---------- trade up */
.hero { background: linear-gradient(160deg, #1d1810, var(--panel)); border: 1px solid #3a2f16; border-radius: 18px; padding: 18px 16px; }
.hero .big { font: 700 40px/1 var(--mono); color: var(--gold); margin: 6px 0; }
.hero .split { color: var(--dim); font-size: 13px; }
.pile { display: grid; gap: 10px; margin-top: 10px; }
.pitem { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.pitem img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--panel2); }
.pitem b { display: block; font-size: 14px; line-height: 1.25; }
.pitem .state { font: 12px var(--mono); color: var(--dim); }
.pitem .state.sold { color: var(--good); }
.pitem .row { margin-top: 8px; }
.sold-in { width: 90px; min-height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }

/* ---------- sheet (bottom drawer) */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; background: var(--panel); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border: 1px solid var(--line); }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }
.sheet-card h2 { margin-top: 0; }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field > span { font-size: 13px; color: var(--dim); font-weight: 600; }
.field input, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.field textarea { min-height: 120px; resize: vertical; }
.search { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.preview { width: 100%; max-height: 300px; object-fit: contain; border-radius: 12px; background: var(--bg); }
.range { font: 700 32px/1 var(--mono); color: var(--gold); margin: 8px 0 4px; }
.copybox { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font-size: 14px; margin: 6px 0; }
.ptabs { display: flex; gap: 6px; margin-top: 14px; }
.working { display: flex; align-items: center; gap: 12px; padding: 18px 0; color: var(--dim); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 28px 12px; color: var(--dim); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r); }
.empty .btn { margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px); text-align: center; }
