/* Collector Room — dark, warm-amber, thumb-first. Built to be readable in a dim
   convention hall and operable with one thumb while the other hand holds a Funko. */

:root {
  --bg: #1c1917;          /* stone-900 */
  --card: #292524;        /* stone-800 */
  --card-2: #33302d;
  --line: #44403c;        /* stone-700 */
  --text: #f5f5f4;        /* stone-100 */
  --muted: #a8a29e;       /* stone-400 */
  --amber: #f59e0b;
  --amber-deep: #b45309;
  --have: #16a34a;
  --preorder: #d97706;
  --want: #dc2626;
  --dupe: #2563eb;
  --forsale: #9333ea;
  --announced: #14b8a6;
  --gold: #fbbf24;
  --danger: #ef4444;
  --radius: 14px;
  --tap: 48px;            /* minimum touch target */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: rgba(28, 25, 23, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .2px; }
.top-status { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--have); display: inline-block; }
.dot.off { background: var(--danger); }
.pill {
  background: var(--amber); color: #1c1917; font-weight: 700; font-size: 13px;
  border: 0; border-radius: 999px; padding: 6px 12px; min-height: 32px;
}

/* ── Main / views ────────────────────────────────────────────────────────── */
#view { flex: 1; padding: 14px 14px calc(env(safe-area-inset-bottom, 0px) + 92px); max-width: 640px; width: 100%; margin: 0 auto; }
h1 { font-size: 22px; margin: 6px 2px 14px; }
h2 { font-size: 16px; margin: 18px 2px 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }

/* ── Bottom nav ──────────────────────────────────────────────────────────── */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  background: rgba(28, 25, 23, .96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 6px);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; color: var(--muted); min-height: 56px; border-radius: 12px;
}
.nav-btn.active { color: var(--amber); }
.nav-ico { font-size: 22px; line-height: 1; }
.nav-lbl { font-size: 11px; }
.nav-add .nav-ico {
  background: var(--amber); color: #1c1917; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 26px;
  margin-top: -14px; box-shadow: 0 4px 14px rgba(245, 158, 11, .4);
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.input, select.input, textarea.input {
  width: 100%; background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; min-height: var(--tap); color: var(--text);
}
.input:focus { outline: 2px solid var(--amber); outline-offset: 0; border-color: transparent; }
textarea.input { min-height: 80px; resize: vertical; }
label.fld { display: block; margin-bottom: 10px; }
label.fld > span { display: block; font-size: 13px; color: var(--muted); margin: 0 2px 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--amber); color: #1c1917; font-weight: 700;
  border: 0; border-radius: 12px; padding: 12px 18px; min-height: var(--tap); width: 100%;
}
.btn:disabled { opacity: .5; }
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { width: auto; min-height: 38px; padding: 8px 14px; font-size: 14px; }

/* ── Search screen ───────────────────────────────────────────────────────── */
#search-box {
  width: 100%; font-size: 19px; padding: 16px; min-height: 56px;
  background: var(--card); border: 2px solid var(--line); border-radius: 16px; color: var(--text);
}
#search-box:focus { border-color: var(--amber); outline: none; }
.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 10px 14px; min-height: 40px; font-size: 14px; font-weight: 600;
}
.chip.active { border-color: var(--amber); color: var(--amber); }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filter-row select { min-height: 44px; font-size: 14px; }
.result-count { color: var(--muted); font-size: 13px; margin: 4px 2px 10px; }

/* ── Item rows ───────────────────────────────────────────────────────────── */
.item-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; min-height: 64px; color: var(--text);
}
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.type-chip { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }

.badge {
  flex-shrink: 0; color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .4px;
  border-radius: 10px; padding: 9px 12px; min-width: 74px; text-align: center;
}
.badge.have { background: var(--have); }
.badge.preorder { background: var(--preorder); }
.badge.want { background: var(--want); }
.badge.dupe { background: var(--dupe); }
.badge.forsale { background: var(--forsale); }
.badge.announced { background: var(--announced); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 15px; }

/* ── Item card (detail) ──────────────────────────────────────────────────── */
.detail-title { font-size: 20px; font-weight: 800; margin: 2px 0 2px; }
.detail-sub { color: var(--muted); margin-bottom: 12px; }
.paid-line { background: var(--card-2); border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-size: 15px; }
.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.status-btn {
  border: 2px solid var(--line); background: var(--card-2); color: var(--muted);
  border-radius: 10px; padding: 10px 2px; font-size: 11px; font-weight: 800; min-height: var(--tap);
}
.status-btn.on.have { background: var(--have); border-color: var(--have); color: #fff; }
.status-btn.on.preorder { background: var(--preorder); border-color: var(--preorder); color: #fff; }
.status-btn.on.want { background: var(--want); border-color: var(--want); color: #fff; }
.status-btn.on.dupe { background: var(--dupe); border-color: var(--dupe); color: #fff; }
.status-btn.on.forsale { background: var(--forsale); border-color: var(--forsale); color: #fff; }
.status-btn.on.announced { background: var(--announced); border-color: var(--announced); color: #fff; }

.qty-row { display: flex; align-items: center; gap: 14px; margin: 12px 0; }
.qty-btn { width: var(--tap); height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); font-size: 22px; font-weight: 700; }
.qty-num { font-size: 18px; font-weight: 700; min-width: 34px; text-align: center; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; min-height: var(--tap); }
.switch { position: relative; width: 54px; height: 32px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; }
.switch .knob { position: absolute; inset: 0; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; transition: background .15s; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: var(--muted); border-radius: 50%; transition: transform .15s, background .15s; }
.switch input:checked + .knob { background: var(--forsale); border-color: var(--forsale); }
.switch input:checked + .knob::after { transform: translateX(22px); background: #fff; }

details.editor { margin: 14px 0; }
details.editor summary { color: var(--amber); font-weight: 700; min-height: var(--tap); display: flex; align-items: center; cursor: pointer; }

.inline-prompt { background: var(--card-2); border: 1px solid var(--amber); border-radius: 12px; padding: 12px; margin: 10px 0; }
.inline-prompt .row2 { margin-bottom: 10px; }
.btn-pair { display: flex; gap: 8px; }
.btn-pair .btn { flex: 1; }

/* ── Checklists ──────────────────────────────────────────────────────────── */
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 12px 4px; min-height: var(--tap); font-weight: 700; font-size: 14px; }
.seg button.active { background: var(--amber); color: #1c1917; }

.group-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 14px; min-height: 64px; }
.group-name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count { color: var(--muted); font-size: 13px; flex-shrink: 0; }
.complete-flair { color: var(--have); font-weight: 800; font-size: 13px; flex-shrink: 0; }
.bar { height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; margin: 0 14px 12px; }
.bar > div { height: 100%; background: var(--have); border-radius: 99px; }
.group-items { padding: 0 10px 10px; }

/* ── Lists / review / settings ───────────────────────────────────────────── */
.list-head { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; margin: 16px 4px 8px; }
.review-raw { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--card-2); border-radius: 8px; padding: 8px 10px; margin: 8px 0; word-break: break-word; }
.kv { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrap { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login-logo { font-size: 56px; margin-bottom: 6px; }
.login-wrap h1 { margin-bottom: 4px; }
.login-tag { color: var(--muted); margin-bottom: 22px; }
.login-wrap form { text-align: left; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 104px);
  transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px;
  border-radius: 999px; padding: 12px 20px; max-width: 86vw;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

.err { color: var(--danger); font-size: 14px; margin: 8px 2px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 2px; }

/* ── Item card extras (grail / hunt / release) ───────────────────────────── */
.title-row { display: flex; align-items: flex-start; gap: 8px; }
.title-row .detail-title { flex: 1; min-width: 0; }
.star-btn {
  flex-shrink: 0; width: var(--tap); height: var(--tap); border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line); font-size: 22px; color: var(--muted);
}
.star-btn.on { color: var(--gold); border-color: var(--gold); background: rgba(251, 191, 36, .1); }
.release-fld { margin-top: 4px; }
.grail-check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 600; margin-bottom: 10px; }
.grail-check input { width: 22px; height: 22px; accent-color: var(--gold); }

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.lens-row {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 6px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.lens-row::-webkit-scrollbar { display: none; }
.lens-row .chip { flex-shrink: 0; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font-size: 24px; font-weight: 800; padding: 14px 6px 10px; min-height: 76px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tile span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.tile-pct { color: var(--amber); }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 430px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card { margin-bottom: 12px; padding: 14px; }
.chart-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.chart-foot { color: var(--muted); font-size: 13px; text-align: center; margin-top: 6px; }

.donut { display: block; width: 150px; max-width: 100%; margin: 0 auto; }
.donut-track { fill: none; stroke: var(--card-2); stroke-width: 14; }
.donut-fg { fill: none; stroke: var(--have); stroke-width: 14; stroke-linecap: round; transition: stroke-dasharray .9s ease; }
.donut-pct { fill: var(--text); font-size: 24px; font-weight: 800; text-anchor: middle; }
.donut-sub { fill: var(--muted); font-size: 11px; text-anchor: middle; }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin-bottom: 10px; }
.bar-label { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-num { font-size: 13px; color: var(--muted); font-weight: 700; }
.bar-svg { grid-column: 1 / -1; width: 100%; height: 8px; display: block; }
.bar-track { fill: var(--card-2); }
.bar-fill { fill: var(--amber); }

.milestone-card { margin-top: 2px; }
.milestone-line { font-size: 16px; margin-bottom: 10px; }
.milestone-cheer { color: var(--gold); font-weight: 800; margin-bottom: 8px; }
.milestone-card .bar { margin: 0; }

.grail-wrap .item-row { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }

.hunt-row {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px;
}
.rank-num {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--amber);
  color: #1c1917; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.hunt-main { flex: 1; min-width: 0; background: none; border: 0; text-align: left; color: var(--text); padding: 6px 0; }
.hunt-main .item-name, .hunt-main .item-sub { display: block; }
.hunt-ctl { display: flex; gap: 4px; flex-shrink: 0; }
.mini-btn {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font-size: 15px;
}
.mini-btn:disabled { opacity: .3; }

.mini-picker { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-top: 8px; }
.pick-row {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--line); color: var(--text); padding: 12px 6px; min-height: var(--tap); font-weight: 600;
}
.pick-row:last-child { border-bottom: 0; }

.quest-card .quest-row { display: flex; gap: 8px; }
.quest-card .quest-row .input { flex: 1; }
.quest-card .quest-row .btn { width: auto; flex-shrink: 0; }
.fld-label { display: block; font-size: 13px; color: var(--muted); margin: 0 2px 6px; }
.featured-wrap { margin-bottom: 8px; }

.log-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); padding: 10px 12px; margin-bottom: 6px; min-height: 52px;
}
.log-when { flex-shrink: 0; color: var(--muted); font-size: 12px; min-width: 64px; }
.log-what { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row .badge { min-width: 0; padding: 6px 8px; font-size: 10px; }
