:root {
  --bg: #ffffff; --surface: #f4f4f4; --line: #e2e2e2; --text: #111111; --muted: #6b6b6b;
  --accent: #111111; --on-accent: #ffffff; --chart: #2b2b2b;
  --good: #16794a; --good-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fbefd5; --bad: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --surface: #141414; --line: #2a2a2a; --text: #f2f2f2; --muted: #9a9a9a;
    --accent: #f2f2f2; --on-accent: #000000; --chart: #d6d6d6;
    --good: #5fd39a; --good-bg: #0f2a1c; --warn: #f0b84a; --warn-bg: #2e2208; --bad: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
a { color: inherit; }
button, input { font: inherit; color: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand { font-weight: 700; letter-spacing: .04em; font-size: 20px; }
.me { font-size: 14px; color: var(--muted); }
.me button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.banner { margin: 0 16px 8px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }
main { padding: 0 16px 16px; max-width: 720px; margin: 0 auto; }
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); z-index: 10; }
.bar a, .bar .back { flex: 1; text-align: center; text-decoration: none; padding: 12px 6px; border-radius: 12px; font-weight: 600; min-height: 48px; }
.bar a.on { background: var(--surface); }
.bar .back { flex: 1.2; border: 0; background: var(--accent); color: var(--on-accent); cursor: pointer; }

.add { display: flex; gap: 8px; margin-bottom: 14px; }
.add input { flex: 1; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; min-height: 48px; }
.btn.ghost { background: var(--surface); color: var(--text); }
.btn.danger { background: none; color: var(--bad); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }

.card { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; text-decoration: none; background: var(--bg); position: relative; }
.card img { width: 84px; height: 84px; object-fit: contain; border-radius: 10px; background: #fff; flex: none; }
.card .body { min-width: 0; flex: 1; }
.card .name { font-weight: 600; overflow-wrap: anywhere; }
.card .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card.faded { opacity: .55; }
.dot { position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.price { font-weight: 700; font-size: 17px; margin-top: 4px; }
.strike { text-decoration: line-through; color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--surface); color: var(--text); }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warning { background: var(--warn-bg); color: var(--warn); }
.chip.bad { color: var(--bad); }

.hero { display: grid; gap: 12px; }
.hero > img { width: 100%; max-height: 320px; object-fit: contain; background: #fff; border-radius: 14px; }
.big { font-size: 28px; font-weight: 700; }
.verdict { padding: 12px; border-radius: 12px; background: var(--surface); }
.verdict.good { background: var(--good-bg); color: var(--good); }
.verdict.warning { background: var(--warn-bg); color: var(--warn); }
.verdict b { display: block; font-size: 16px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg > * { flex: 1; }
.seg button { min-height: 44px; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.sizes button { flex: 0 0 auto; min-width: 48px; }
.sizes button.out { text-decoration: line-through; color: var(--muted); }
.sizes button.want { outline: 2px solid var(--accent); outline-offset: 1px; }

.chart { position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.chart svg { width: 100%; height: 170px; display: block; touch-action: pan-y; }
.chart .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); }
.axis { fill: var(--muted); font-size: 11px; }

.sugg { display: grid; gap: 10px; }
.sugg .actions { display: flex; gap: 8px; margin-top: 8px; }
.sugg .actions .btn { flex: 1; padding: 10px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 12px; border-radius: 12px; background: var(--surface); }
.stat .v { font-size: 26px; font-weight: 700; }

.center { min-height: 60vh; display: grid; place-content: center; gap: 12px; text-align: center; }
.who { display: flex; gap: 10px; }
.who .btn { flex: 1; min-width: 120px; font-size: 18px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; z-index: 20; }
.spin { opacity: .6; }
