/* PhaseCollector — design tokens (light) */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: rgba(11, 11, 11, 0.10);
  --grid: #e1e0d9;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --meter-track: #cde2fb;
  --meter-fill: #2a78d6;
  --danger: #d03b3b;
  --shadow: 0 1px 3px rgba(11, 11, 11, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: rgba(255, 255, 255, 0.10);
    --grid: #2c2c2a;
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --meter-track: #0d366b;
    --meter-fill: #3987e5;
    --danger: #e66767;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0.4em 0; }
h2 { font-size: 1.2rem; margin: 1.6em 0 0.5em; }
h3 { font-size: 1rem; margin: 0 0 0.3em; }
.wrap { max-width: 1600px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }

/* header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  display: flex; align-items: center; gap: 18px;
  min-height: 56px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px;
}
.brand {
  font-weight: 700; font-size: 1.1rem; color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 1.2rem; }
.site-nav { display: flex; gap: 14px; }
.site-nav a { color: var(--ink-2); font-weight: 500; }
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.search { flex: 1 1 160px; max-width: 340px; margin-left: auto; }
.search input {
  width: 100%; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--hairline); background: var(--page); color: var(--ink);
}
.user-menu { display: flex; align-items: center; gap: 10px; }
.username { color: var(--ink-2); font-weight: 600; }

/* buttons & chips */
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--hairline); background: transparent; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.lg { padding: 10px 20px; font-size: 1rem; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--hairline); color: var(--ink-2);
  font-size: 0.78rem; font-weight: 600; vertical-align: middle;
}
.chip.subtle { color: var(--muted); font-weight: 500; }

/* rarity tiers — icons are traced from tcgcollector.com's own rarity
   symbols (see RARITY_ICONS in views.py); most carry no color of their
   own and inherit this muted text color the same way tcgcollector's
   plain-black icons read against its white background, while a few
   tiers (ultra/secret gold, illustration/hyper orange, ACE SPEC pink,
   amazing's rainbow) bake in their own accent and ignore this. */
.rarity-icon { font-size: 0.95em; vertical-align: -1px; color: var(--muted); }
.rarity-icon svg { height: 0.85em; width: auto; vertical-align: -0.05em; }

.flash {
  background: var(--accent-soft); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 10px 14px; margin: 14px 0;
}
.flash p { margin: 0; }
.crumbs { margin: 16px 0 4px; color: var(--muted); font-size: 0.9rem; }

/* landing */
.hero { text-align: center; padding: 56px 0 30px; }
.hero h1 { font-size: 2.3rem; margin-bottom: 12px; }
.hero-sub { max-width: 620px; margin: 0 auto 22px; color: var(--ink-2); font-size: 1.05rem; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.feature-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px; margin: 34px 0;
}
.feature {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
}
.feature p { margin: 0; color: var(--ink-2); }

/* games */
.game-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; margin: 18px 0;
}
.game-card {
  display: block; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 18px; color: var(--ink); box-shadow: var(--shadow);
}
.game-card:hover { text-decoration: none; border-color: var(--accent); }
.game-fan {
  display: flex; justify-content: center; height: 110px; margin: 2px 0 14px;
}
.game-fan img {
  width: 76px; border-radius: 5px; object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.game-fan img:nth-child(1) { transform: rotate(-8deg) translate(10px, 4px); }
.game-fan img:nth-child(2) { transform: translateY(-2px); z-index: 1; }
.game-fan img:nth-child(3) { transform: rotate(8deg) translate(-10px, 4px); }
.game-logo {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  height: 110px; margin: 2px 0 14px;
}
.game-logo img { max-height: 100%; max-width: 46%; object-fit: contain; }
.game-logo img:only-child { max-width: 82%; }
.game-section { margin-top: 26px; }
.game-name { font-weight: 700; font-size: 1.1rem; }
.game-meta { color: var(--muted); font-size: 0.9rem; }
.game-counts { color: var(--ink-2); margin: 6px 0 10px; }

/* meters (fill + lighter track of the same ramp) */
.meter {
  height: 6px; border-radius: 999px; background: var(--meter-track);
  overflow: hidden; max-width: 340px;
}
.meter.wide { max-width: none; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--meter-fill); }
.progress-note { color: var(--muted); font-size: 0.85rem; }

/* expansion list */
.series-group { margin-bottom: 8px; }
.series-title { margin: 1.4em 0 0.2em; font-size: 1.05rem; }
.expansion-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
/* set-browsing views (games/<slug> and the dashboard's per-game panel) opt
   into two columns on wide screens via .two-col — lists/uploads pages
   share .expansion-list but hold single-line rows that don't need it. */
@media (min-width: 900px) {
  .expansion-list.two-col {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px;
  }
}
.expansion-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 12px 18px 12px 12px; color: var(--ink); box-shadow: var(--shadow);
}
.expansion-row:hover { text-decoration: none; border-color: var(--accent); }
.expansion-body { flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; }
.set-thumb {
  flex: none; width: 92px; height: 48px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.set-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.set-thumb.card-thumb img { object-fit: cover; object-position: top; border-radius: 4px; height: 100%; }
/* fixed box, not just fixed height: symbol art varies from wide
   text-badge designs (base1 is 38x19, ~2:1) to tall narrow glyphs
   (base6/col1 are 21x38, ~0.55:1) — nearly 4x apart in aspect ratio.
   object-fit: contain letterboxes each into the same footprint so
   symbols line up consistently across sets instead of some being
   visibly wider or narrower than others. */
.set-symbol { height: 32px; width: 32px; object-fit: contain; vertical-align: -2px; }
.set-symbol.lg { height: 44px; width: 44px; }
/* fixed height, not max-height: logos vary wildly in aspect ratio
   (roughly 1.3:1 to 5:1) — a shared max-height + max-width box lets
   whichever bound is hit first win, so wide banner-style logos render
   noticeably shorter than squarer ones. Pinning height keeps every set's
   logo the same visual scale; max-width is just a safety cap for
   pathologically wide images. */
.set-logo { height: 56px; width: auto; max-width: 320px; object-fit: contain; }
.expansion-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.expansion-name { font-weight: 700; }
.expansion-side { display: flex; gap: 14px; align-items: center; font-size: 0.9rem; }
.expansion-progress {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px;
}
.expansion-progress .meter { flex: 1; }
.expansion-progress .progress-note { white-space: nowrap; }

/* set page */
.set-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; flex-wrap: wrap; margin-bottom: 8px;
}
.set-header h1 { margin-bottom: 2px; }
.set-header p { margin: 0; }
.set-progress { flex: 1 1 320px; max-width: 480px; }
.set-progress .progress-note { display: block; margin-top: 5px; }
.login-note { color: var(--ink-2); }

/* card grid */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px; margin: 20px 0 40px;
}
.card-tile {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.card-tile.owned { border-color: var(--accent); }
.card-art { position: relative; aspect-ratio: 63 / 88; background: var(--page); }
.card-art img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; padding: 8px;
}
.card-placeholder {
  position: absolute; inset: 8px; border-radius: 10px;
  border: 1px dashed var(--grid);
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 30% 25%, var(--accent-soft), transparent 60%),
    var(--surface);
}
.card-placeholder span { font-size: 3rem; font-weight: 700; color: var(--muted); }
/* once art has actually loaded, drop the letter so it can't peek through
   transparent images; a failed load removes the img and brings it back */
.card-art.img-loaded .card-placeholder { display: none; }
.card-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.card-title { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-name { font-weight: 700; }
.card-number { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* variants */
.variants { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.variant {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--hairline); border-radius: 8px; padding: 4px 6px 4px 10px;
  font-size: 0.85rem; color: var(--ink-2);
}
.variant.have {
  background: var(--accent-soft); border-color: var(--accent); color: var(--ink);
}
.vname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.variant.has-image .vname { cursor: pointer; }
.variant.has-image .vname:hover { text-decoration: underline; }
.variant.showing-image { border-color: var(--accent); }
.vprice { color: var(--muted); font-size: 0.85em; white-space: nowrap; }
.qty-controls { display: inline-flex; align-items: center; gap: 2px; }
.qty {
  min-width: 24px; text-align: center; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.qty-btn {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--hairline);
  background: var(--surface); color: var(--ink); font-size: 0.95rem; line-height: 1;
  cursor: pointer;
}
.qty-btn:hover { border-color: var(--accent); color: var(--accent); }
.qty-btn:disabled { opacity: 0.5; cursor: wait; }

/* bulk edit */
.bulk-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 14px 0 4px;
}
.bulk-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 8px 12px;
}
.bulk-count { color: var(--ink-2); font-size: 0.9rem; }
.bulk-field { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--ink-2); }
.bulk-actions input[type="number"] {
  width: 64px; padding: 5px 8px; border-radius: 6px;
  border: 1px solid var(--hairline); background: var(--page); color: var(--ink);
}
.bulk-actions select {
  padding: 5px 8px; border-radius: 6px; border: 1px solid var(--hairline);
  background: var(--page); color: var(--ink); font: inherit;
}
.btn.sm { padding: 5px 10px; font-size: 0.85rem; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.bulk-pick {
  display: none; position: absolute; top: 10px; left: 10px; z-index: 2;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 6px; cursor: pointer; box-shadow: var(--shadow);
}
.bulk-mode .bulk-pick { display: block; }
.bulk-pick input { width: 18px; height: 18px; display: block; cursor: pointer; }
.card-tile.bulk-selected { outline: 2px solid var(--accent); outline-offset: -1px; }

/* dashboard */
.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero-stat { text-align: center; padding: 26px 0 8px; }
.hero-figure { font-size: 56px; font-weight: 650; line-height: 1.05; }
.hero-label { color: var(--muted); }
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin: 22px 0;
}
.stat-tile {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow);
}
.stat-label { color: var(--ink-2); font-size: 0.85rem; }
.stat-value { font-size: 1.6rem; font-weight: 600; }
.dash-game h3 { margin-bottom: 2px; }
.dash-game h3 a { color: var(--ink); }
.dash-game p { margin-top: 0; }
.recent-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; margin-bottom: 40px; }
.recent-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.recent-list a { font-weight: 600; }

/* search */
.search-results { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 40px; }
.search-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 10px 14px; color: var(--ink);
}
.search-row:hover { text-decoration: none; border-color: var(--accent); }
.owned-badge {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--hairline); color: var(--muted); font-size: 0.8rem;
}
.owned-badge.yes { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.note-mark { color: var(--accent); font-size: 0.8em; }

/* forms */
.auth-card {
  max-width: 380px; margin: 48px auto; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 14px; padding: 26px 28px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin-top: 0; font-size: 1.35rem; }
.auth-card form, .import-form { display: flex; flex-direction: column; gap: 6px; }
.auth-card label, .import-form label { font-weight: 600; font-size: 0.9rem; margin-top: 8px; }
.auth-card input, .import-form input, .import-form select {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--hairline);
  background: var(--page); color: var(--ink); font: inherit;
}
.auth-card .btn, .import-form .btn { margin-top: 16px; }
.hp-field { position: absolute; left: -9999px; top: -9999px; }
.auth-alt { text-align: center; color: var(--ink-2); }
.auth-card.wide { max-width: 640px; }
.auth-card .api-key {
  display: block; word-break: break-all; background: var(--page);
  border: 1px solid var(--hairline); border-radius: 8px; padding: 8px 10px;
  font-size: 0.85rem;
}

.import-form {
  max-width: 480px; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 20px 24px; box-shadow: var(--shadow); margin: 18px 0;
}
.import-form fieldset { border: none; margin: 10px 0 0; padding: 0; }
.admin-columns {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px; align-items: start; margin: 18px 0;
}
.admin-columns .import-form { margin: 0; max-width: none; }
.import-form legend { font-weight: 600; font-size: 0.9rem; padding: 0; }
.radio { display: block; font-weight: 400; margin-top: 6px; }
.import-help { margin-bottom: 40px; }

/* tables */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--grid); }
th { color: var(--ink-2); font-size: 0.85rem; }

/* variant edit + grading */
.variant-edit {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--hairline);
  background: var(--surface); color: var(--muted); font-size: 0.8rem; line-height: 1;
  cursor: pointer; margin-left: 2px;
}
.variant-edit:hover { border-color: var(--accent); color: var(--accent); }
.chip.grade {
  display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; vertical-align: middle;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
}
.browse-link { margin: 2px 0 14px; }

/* variant edit dialog */
.variant-dialog {
  border: 1px solid var(--hairline); border-radius: 14px; padding: 20px 24px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  max-width: 380px; width: 90vw;
}
.variant-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.variant-dialog h3 { margin-top: 0; }
.dialog-subtitle { margin-top: -6px; }
.variant-dialog form { display: flex; flex-direction: column; gap: 4px; }
.variant-dialog label { font-weight: 600; font-size: 0.9rem; margin-top: 8px; }
.variant-dialog input, .variant-dialog textarea {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--hairline);
  background: var(--page); color: var(--ink); font: inherit; resize: vertical;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* browse cards: filter bar + pagination */
.filter-bar {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  margin: 16px 0; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 14px 18px;
}
.filter-bar label {
  display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem;
  font-weight: 600; color: var(--ink-2);
}
.filter-bar select, .filter-bar input {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--hairline);
  background: var(--page); color: var(--ink); font: inherit; min-width: 150px;
}
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 10px 0 40px;
}

/* dashboard collection breakdown */
.dash-head-actions { display: flex; gap: 10px; }
.breakdown-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px; margin: 22px 0;
}
.breakdown {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 14px 18px; box-shadow: var(--shadow);
}
.breakdown h3 { margin-top: 0; }
.breakdown-row-item {
  display: grid; grid-template-columns: 100px 1fr 50px; align-items: center;
  gap: 10px; margin: 7px 0; font-size: 0.85rem;
}
.breakdown-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.site-footer {
  border-top: 1px solid var(--hairline); color: var(--muted);
  padding: 18px 0; margin-top: 30px; font-size: 0.9rem;
}

@media (max-width: 640px) {
  .header-inner { gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .hero h1 { font-size: 1.7rem; }
  .hero-figure { font-size: 42px; }
}

/* CSS-only tabs (dashboard's Trading Card Games / Video Games split) */
.tab-input { position: absolute; opacity: 0; pointer-events: none; }
.tab-labels {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--hairline);
}
.tab-label {
  padding: 10px 16px; cursor: pointer; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-panel { display: none; }
#tab-tcg:checked ~ #panel-tcg,
#tab-video:checked ~ #panel-video { display: block; }
#tab-tcg:checked ~ .tab-labels label[for="tab-tcg"],
#tab-video:checked ~ .tab-labels label[for="tab-video"] {
  color: var(--ink); border-bottom-color: var(--accent);
}

/* Per-game sub-tabs nested inside each tab-panel above (JS-toggled, since
   the game list is dynamic per install unlike the two static parent tabs) */
.subtab-labels {
  display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 20px;
  border-bottom: 1px solid var(--hairline);
}
.subtab-label {
  font: inherit; padding: 8px 14px; cursor: pointer; color: var(--muted);
  font-weight: 600; background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subtab-label.active { color: var(--ink); border-bottom-color: var(--accent); }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }
