:root {
  --bg: #14161c;
  --panel: #1d2028;
  --panel-2: #262a34;
  --line: #333845;
  --text: #f1f2f5;
  --muted: #9aa1b1;
  --accent: #ffcb05;
  --red: #e3350d;
  --good: #3ecf7a;
  --ok: #f0b429;
  --bad: #ff6b5b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
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: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--bad); }

.top {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
}
.top h1 { font-size: 1.3rem; margin: 0; flex: 1; letter-spacing: 0.02em; }
.top h1::before { content: ""; display: inline-block; width: 0.8em; height: 0.8em; margin-right: 8px; border-radius: 50%; background: linear-gradient(var(--red) 45%, var(--bg) 45% 55%, #fff 55%); vertical-align: -0.05em; }
.net { background: var(--ok); color: #000; border-radius: 99px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.icon-btn { background: var(--panel); border: 0; border-radius: 10px; width: 40px; height: 40px; font-size: 1.3rem; }

.tabs { display: flex; gap: 6px; padding: 0 16px 10px; position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 2; background: var(--bg); }
.tabs button { flex: 1; padding: 10px; border: 0; border-radius: 10px; background: var(--panel); color: var(--muted); font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--accent); color: #111; }
.pill { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 99px; background: rgba(0,0,0,.25); font-size: 0.8rem; }
.pill:empty { display: none; }

main { padding: 0 16px 40px; max-width: 720px; margin: 0 auto; }
input, select, textarea {
  width: 100%; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); min-height: 46px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.primary, .secondary, .danger {
  border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 700; min-height: 46px; cursor: pointer;
}
.primary { background: var(--accent); color: #111; }
.secondary { background: var(--panel-2); }
.danger { background: transparent; color: var(--bad); padding-left: 0; }
.link { background: none; border: 0; color: var(--accent); padding: 8px 0; font-weight: 600; cursor: pointer; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar input { flex: 2; }
.toolbar select { flex: 1; }
.banner { background: #3a3215; color: #ffe69a; border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; }
.empty { text-align: center; padding: 40px 0; color: var(--muted); }

.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.card { background: var(--panel); border-radius: 14px; padding: 12px; }
.card.is-found { opacity: 0.6; }
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.thumb { width: 64px; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 4px; background: var(--panel-2); flex: none; }
.thumb.placeholder { display: grid; place-items: center; color: var(--muted); font-size: 1.5rem; }
.meta { flex: 1; min-width: 0; }
.name { margin: 0; font-size: 1.05rem; }
.sub, .want { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.want { color: var(--text); }
.found-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--line); background: transparent; color: var(--muted); font-size: 1.2rem; font-weight: 700;
}
.found-btn[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #062; }

.deal { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.deal label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; }
.deal input { width: 110px; min-height: 40px; padding: 8px 10px; }
.verdict { font-weight: 700; font-size: 0.9rem; }
.verdict.good { color: var(--good); }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }

.prices { margin-top: 10px; }
.hero { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.hero .label { font-size: 0.85rem; color: var(--muted); }
.hero strong { font-size: 1.4rem; color: var(--accent); }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 6px 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; }
tr.is-target td { color: var(--accent); font-weight: 700; }
.card-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.card-actions .age { flex: 1; }

.search { display: grid; gap: 8px; }
.results { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.results button { width: 100%; display: grid; gap: 6px; padding: 8px; border: 0; border-radius: 12px; background: var(--panel); text-align: left; cursor: pointer; }
.results img { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; background: var(--panel-2); }
.results strong { display: block; font-size: 0.95rem; }
.results small { color: var(--muted); }
.results .on-list button { outline: 2px solid var(--good); }
.results .on-list strong::after { content: " ✓ on list"; color: var(--good); font-size: 0.75rem; }
.manual { margin-top: 20px; }
.manual form { display: grid; gap: 8px; margin-top: 8px; }

dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { display: grid; gap: 12px; padding: 18px; }
dialog h2 { margin: 0; font-size: 1.15rem; }
dialog label { display: grid; gap: 4px; color: var(--muted); font-size: 0.9rem; }
dialog label.check { display: flex; align-items: center; gap: 8px; }
dialog label.check input { width: auto; min-height: 0; }
.dlg-actions { display: flex; gap: 8px; align-items: center; }
.dlg-actions span { flex: 1; }
.file-btn { display: flex !important; align-items: center; justify-content: center; color: var(--text) !important; font-weight: 700; font-size: 1rem !important; cursor: pointer; }

.seg { display: flex; background: var(--panel); border-radius: 10px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; border-radius: 8px; padding: 9px; background: none; color: var(--muted); font-weight: 600; }
.seg button[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
#setFilter, #cardFilter { margin-bottom: 8px; }
.series h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 8px; }
.sets { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sets button { width: 100%; height: 100%; display: grid; gap: 6px; justify-items: center; padding: 10px 8px; border: 0; border-radius: 12px; background: var(--panel); text-align: center; cursor: pointer; }
.sets img { height: 40px; max-width: 100%; object-fit: contain; }
.sets strong { font-size: 0.9rem; }
.sets small { color: var(--muted); font-size: 0.75rem; }
.set-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.set-head img { height: 36px; max-width: 90px; object-fit: contain; }
.set-head img[src=""] { display: none; }
.set-head p { margin: 0; }

.auth { display: none; max-width: 420px; margin: 0 auto; padding: 8px 16px 40px; }
.signed-out .auth { display: block; }
.signed-out .tabs, .signed-out main, .signed-out #menuBtn { display: none; }
.auth .lead { font-size: 1.05rem; margin: 8px 0 20px; }
.auth form { display: grid; gap: 12px; }
.auth label { display: grid; gap: 4px; color: var(--muted); font-size: 0.9rem; }
.auth-msg { margin: 0; min-height: 1.2em; color: var(--ok); font-size: 0.9rem; }
.auth-msg:empty { display: none; }
.auth h2 { margin: 0; font-size: 1.15rem; }
#forgotLink { margin-top: 4px; }
.signed-out #notice { display: none; }
.dlg-actions { position: sticky; bottom: 0; background: var(--panel); padding: 10px 0 14px; margin-bottom: -18px; }
