/* Timewalked — "Nightfall" design tokens and base styles. */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=Figtree:wght@400;500;600;700&display=swap");

/* Mana symbol font -- npm package mana-font v1.18.0, font under SIL OFL
   1.1, CSS under MIT. Glyph codes: see .mana-pip below and the
   MANA_GLYPHS mapping wherever pips are rendered server-side. */
@font-face {
  font-family: "Mana";
  src: url("../fonts/mana.woff2") format("woff2");
  font-display: block;
}

:root {
  /* Light mode (derived from Nightfall; not yet mocked up) */
  --bg: #f1ebe3;
  --surface: #faf6ef;
  --surface-sunk: #ece5dc;
  --line: #d6cbdc;
  --line-strong: #b9aac4;
  --text: #1c1726;
  --text-muted: #5a4f68;
  --accent: #b4461a;          /* ember, darkened for contrast on light */
  --on-accent: #ffffff;
  --link: #9c3c16;
  --flag-gc: var(--accent);   /* Game Changer */
  --flag-warm: #8a6a1c;       /* Tutor, Fast mana */
  --flag-cool: #3f6b52;       /* Extra turn, Turn skip */
  --flag-danger: #a93a3a;     /* Mass land denial, Banned */

  /* Atmosphere (light defaults -- daylight sky, not yet visually reviewed) */
  --sky-1: #fdeccd; --sky-2: #f7dfb0; --sky-3: #ecd9be; --sky-4: #f1ebe3;
  --sky-q1: #fdeccd; --sky-q2: #f3ddb8; --sky-q3: #ecd9be;
  --atmo-star-color: #d8cfe0;
  --atmo-star-opacity: 0;
  --atmo-cloud-opacity: 1;
  --atmo-hill-1: #c9a869; --atmo-hill-2: #b98f5a; --atmo-hill-3: #8fae7a;
  --atmo-hill-4: #6f9463; --atmo-hill-5: #4f6b4a;
  --atmo-sundial-shadow: #8a7550; --atmo-sundial-base: #fff8ec;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;

  --radius-sm: 4px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 28px;
  --tap: 44px;                /* minimum touch target */

  /* Mana (light) -- deck builder handoff, 2026-09-28. Used only for
     mana costs/pips/sources, never as general chart or UI colors. */
  --mana-w: #d9c690; --mana-u: #7fa6c9; --mana-b: #7d7089;
  --mana-r: #c96a47; --mana-g: #6f9660; --mana-c: #b3aabd;
  --on-mana: #1a0f0a;
  --mana-outline: #5a4f68;
  --scrim: rgba(28, 23, 38, 0.55);

  /* Facelift 2026-09-30 */
  --surface-raised: #fffdf8;
  --sky-glow-1: rgba(201, 168, 105, 0.22);
  --sky-glow-2: rgba(143, 174, 122, 0.16);
  --container: 1240px;
  --gutter: 32px;
  --radius-control: 10px;
  --radius-panel: 18px;
  --control-h: 40px;
}

/* Dark mode = the approved Nightfall mockups */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #130f1d;
    --surface: #221b2d;
    --surface-sunk: #1b1625;
    --line: #3e3350;
    --line-strong: #5d4f6a;
    --text: #efe6da;
    --text-muted: #b9aec4;
    --accent: #e0662e;
    --on-accent: #1a0f0a;
    --link: #e8804f;
    --flag-gc: var(--accent);
    --flag-warm: #c9a24a;
    --flag-cool: #8fb39a;
    --flag-danger: #e07a7a;

    --sky-1: #241c33; --sky-2: #170f26; --sky-3: #130f1d; --sky-4: #0d0a15;
    --sky-q1: #1c1c30; --sky-q2: #15121f; --sky-q3: #130f1d;
    --atmo-star-color: #d8cfe0;
    --atmo-star-opacity: 1;
    --atmo-cloud-opacity: 0;
    --atmo-hill-1: #5a4a60; --atmo-hill-2: #46394f; --atmo-hill-3: #4a6356;
    --atmo-hill-4: #36493f; --atmo-hill-5: #1b2420;
    --atmo-sundial-shadow: #2c2438; --atmo-sundial-base: #e8dcc0;

    /* Mana (dark) */
    --mana-w: #e8dcc0; --mana-u: #a9c4dc; --mana-b: #9b8fa6;
    --mana-r: #de8a68; --mana-g: #93b483; --mana-c: #cdc6d3;
    --on-mana: #1a0f0a;
    --mana-outline: transparent;
    --scrim: #0b0911;
    --surface-raised: #2b2238;
    --sky-glow-1: rgba(74, 56, 110, 0.55);
    --sky-glow-2: rgba(40, 30, 62, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #130f1d;
  --surface: #221b2d;
  --surface-sunk: #1b1625;
  --line: #3e3350;
  --line-strong: #5d4f6a;
  --text: #efe6da;
  --text-muted: #b9aec4;
  --accent: #e0662e;
  --on-accent: #1a0f0a;
  --link: #e8804f;
  --flag-gc: var(--accent);
  --flag-warm: #c9a24a;
  --flag-cool: #8fb39a;
  --flag-danger: #e07a7a;

  --sky-1: #241c33; --sky-2: #170f26; --sky-3: #130f1d; --sky-4: #0d0a15;
  --sky-q1: #1c1c30; --sky-q2: #15121f; --sky-q3: #130f1d;
  --atmo-star-color: #d8cfe0;
  --atmo-star-opacity: 1;
  --atmo-cloud-opacity: 0;
  --atmo-hill-1: #5a4a60; --atmo-hill-2: #46394f; --atmo-hill-3: #4a6356;
  --atmo-hill-4: #36493f; --atmo-hill-5: #1b2420;
  --atmo-sundial-shadow: #2c2438; --atmo-sundial-base: #e8dcc0;

  /* Mana (dark) */
  --mana-w: #e8dcc0; --mana-u: #a9c4dc; --mana-b: #9b8fa6;
  --mana-r: #de8a68; --mana-g: #93b483; --mana-c: #cdc6d3;
  --on-mana: #1a0f0a;
  --mana-outline: transparent;
  --scrim: #0b0911;
  --surface-raised: #2b2238;
  --sky-glow-1: rgba(74, 56, 110, 0.55);
  --sky-glow-2: rgba(40, 30, 62, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }

/* A later class rule with equal specificity (e.g. display:flex on an
   element that also toggles [hidden]) beats the UA default [hidden]
   { display: none } otherwise -- this bit the old /rate page once
   already (both answer-option groups showed at once). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--link); }
h1, h2, .display { font-family: var(--font-display); font-weight: 500; line-height: 1.1; }
img { max-width: 100%; height: auto; }

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* One button system (facelift): .btn--primary / --secondary / --ghost / --danger.
   Every control is --control-h tall (44px on touch),
   content centered, link-buttons never underlined. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: 0 var(--space-4);
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 28%, transparent);
}
.btn--secondary { background: var(--surface-raised); border-color: var(--line-strong); color: var(--text); }
.btn--ghost { background: transparent; color: var(--text); }
.btn--danger { background: transparent; border-color: color-mix(in srgb, var(--flag-danger) 50%, transparent); color: var(--flag-danger); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
a.btn, a.btn:hover { text-decoration: none; }
@media (pointer: coarse) { :root { --control-h: 44px; } }
@media (max-width: 720px) { :root { --gutter: 16px; } }
.btn:focus-visible, .icon-btn:focus-visible, .account-btn:focus-visible, .primary-nav a:focus-visible,
.primary-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.flag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
}
.flag-gc { color: var(--flag-gc); }
.flag-tu, .flag-fm { color: var(--flag-warm); }
.flag-xt, .flag-sk, .flag-fi { color: var(--flag-cool); }
.flag-ld, .flag-ban, .flag-nc { color: var(--flag-danger); }

/* Layer 2's per-card delta number -- deliberately NOT styled like .flag
   (no bordered box) per Chris's stated preference to avoid Layer 2
   turning into more badge-wall clutter: a small plain number instead of
   another letter code, see docs/layer2-design-decisions.md. */
.card-delta {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* Mana cost/pip/source symbol -- deck builder, 2026-09-28. A colored
   circle with the real Mana-font glyph, never a letter in a circle.
   The inset outline is invisible in dark and keeps pale fills (white,
   colorless) readable against the light-mode paper background --
   see docs/deck-builder-handoff/deck-builder-claude-code-handoff.md
   section 7. Wrap costs/pip groups in one element with role="img" and
   a readable aria-label; mark individual .mana-pip spans aria-hidden. */
.mana-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-family: "Mana";
  font-size: 11px;
  line-height: 1;
  color: var(--on-mana);
  box-shadow: inset 0 0 0 1px var(--mana-outline);
}
.mana-pip--lg { width: 18px; height: 18px; font-size: 13px; }
.mana-pip--w { background: var(--mana-w); }
.mana-pip--u { background: var(--mana-u); }
.mana-pip--b { background: var(--mana-b); }
.mana-pip--r { background: var(--mana-r); }
.mana-pip--g { background: var(--mana-g); }
.mana-pip--c { background: var(--mana-c); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Layout shell ---------- */

/* One page width: a 1240px container with 32px side padding (16px on
   phone). The header and footer use the same container so edges line up.
   .page--narrow is for single-column forms and legal text. */
.container, .page {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.page { padding-bottom: var(--space-6); flex: 1 0 auto; }
.page--narrow { max-width: calc(720px + 2 * var(--gutter)); }
.page--wide, .page--xwide, .page--builder { max-width: var(--container); }

/* Library and builder fill the screen: a much wider container, gutters that grow
   with the window, and (below) grids that add columns instead of stretching. */
.site-wrap--wide { --container: 2200px; --gutter: clamp(16px, 2.5vw, 56px); }
.site-wrap { position: relative; min-height: 100vh; display: flex; flex-direction: column; overflow-x: clip; }

/* Wizards of the Coast Fan Content Policy requires this notice on
   every page that uses mana symbols or other WotC materials -- see
   docs/deck-builder-handoff/deck-builder-claude-code-handoff.md
   section 7d. Verified against the policy's own published wording. */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
}
.site-footer__row {
  padding-top: var(--space-5);
  padding-bottom: var(--space-5);
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
  font-size: 12px;
  color: var(--text-muted);
}
.site-footer__brand { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; color: var(--text); text-decoration: none; }
.site-footer__brand .brand__mark { width: 24px; height: 24px; }
.site-footer__brand .brand__name { font-size: 18px; }
.site-footer p { margin: 0; flex: 1 1 auto; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.site-footer-links { display: flex; gap: var(--space-4); flex-shrink: 0; font-size: 13px; }
.site-footer-links a { color: var(--text-muted); text-decoration: underline; padding: var(--space-1) 0; }
.site-footer-links a:hover { color: var(--accent); }
@media (max-width: 720px) { .site-footer__row { flex-direction: column; gap: var(--space-3); } }

/* ---------- Legal pages (privacy, terms) ---------- */
.legal-panel { max-width: 720px; margin: var(--space-6) auto 0; line-height: 1.6; }
.legal-panel h1 { margin: var(--space-1) 0 var(--space-1); }
.legal-panel h2 { font-size: 18px; margin: var(--space-5) 0 var(--space-2); }
.legal-panel p, .legal-panel ul { margin: 0 0 var(--space-3); }
.legal-panel ul { padding-left: var(--space-4); }
.legal-panel li { margin-bottom: var(--space-2); }
.legal-updated { color: var(--text-muted); font-size: 14px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { text-align: left; padding: var(--space-2); border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { color: var(--text-muted); font-weight: 600; }

/* ---------- Header / nav (facelift: one row, shared container) ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.site-header__row { height: 68px; display: flex; align-items: center; gap: var(--space-6); }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; flex-shrink: 0; }
.brand__mark { width: 30px; height: 30px; flex-shrink: 0; }
.brand__name { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

.primary-nav { flex-grow: 1; display: flex; justify-content: center; }
.primary-nav ul { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; }
.primary-nav a, .primary-nav .nav-submenu-toggle {
  display: flex; align-items: center; min-height: var(--control-h); padding: 0 14px;
  border: none; border-radius: var(--radius-pill); background: transparent;
  color: var(--text-muted); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.primary-nav a:hover, .primary-nav .nav-submenu-toggle:hover { color: var(--text); }
.primary-nav a[aria-current="page"], .primary-nav .nav-submenu-toggle[data-active="true"] {
  background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--line); color: var(--text);
}
.nav-theme-item { display: none; }

/* "Rate a card" dropdown */
.nav-item-submenu { position: relative; }
.nav-submenu { list-style: none; margin: 0; }
.nav-submenu[hidden] { display: none; }
.primary-nav .nav-submenu {
  display: block; position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 200px; padding: 6px;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.primary-nav .nav-submenu a { min-height: 40px; border-radius: var(--radius-control); white-space: nowrap; }
.primary-nav .nav-submenu a:hover { background: var(--surface-sunk); }

.header-actions { position: relative; display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; margin-left: auto; }
.header-signout-form { display: contents; }

.icon-btn {
  width: var(--control-h); height: var(--control-h); flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-control); border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-raised) 60%, transparent);
  color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); }

/* Account button + menu (replaces the separate Admin / Account / Sign out buttons) */
.account-btn {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-h); padding: 0 10px 0 4px;
  border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-raised) 60%, transparent);
  color: var(--text); font: 600 14px/1 var(--font-body); cursor: pointer;
}
.account-btn__name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--flag-warm)); color: var(--on-accent); font-weight: 700;
}
.account-menu {
  position: absolute; right: 0; top: 52px; width: 260px; padding: var(--space-2); z-index: 50;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--line-strong); border-radius: var(--radius-panel);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.account-menu__who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-weight: 600; }
.account-menu__who small { display: block; color: var(--text-muted); font-size: 13px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.account-menu a, .account-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 0 12px;
  border: none; border-radius: var(--radius-control); background: transparent; color: var(--text);
  font: 500 15px/1 var(--font-body); text-decoration: none; text-align: left; cursor: pointer;
}
.account-menu a:hover, .account-menu button:hover, .account-menu :focus-visible { background: var(--surface-sunk); }
.account-menu form { margin: 0; }
.staff-tag {
  margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--flag-warm);
  border: 1px solid color-mix(in srgb, var(--flag-warm) 50%, transparent); border-radius: var(--radius-pill); padding: 2px 8px;
}

/* Under 1100px the centered nav collapses into the hamburger menu. */
#nav-toggle { display: none; }
@media (max-width: 1100px) {
  #nav-toggle { display: inline-flex; }
  .primary-nav { display: none; }
  .header-actions { margin-left: auto; }
  .primary-nav.is-open {
    display: block; position: absolute; top: 68px; left: 0; right: 0; z-index: 45;
    padding: var(--space-2) var(--gutter) var(--space-4);
    background: var(--surface); border-bottom: 1px solid var(--line);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3);
  }
  .primary-nav.is-open ul { flex-direction: column; gap: var(--space-1); }
  .primary-nav.is-open a, .primary-nav.is-open .nav-submenu-toggle { width: 100%; min-height: var(--tap); border-radius: var(--radius-control); }
  .primary-nav.is-open .nav-submenu { position: static; min-width: 0; margin: 2px 0 0 var(--space-4); padding: 0; background: none; border: none; box-shadow: none; }
}
/* Phones: logo, avatar, hamburger. Theme toggle moves into the menu. */
@media (max-width: 720px) {
  .site-header__row { gap: var(--space-3); }
  .account-btn { padding: 0; border: none; background: none; }
  .account-btn__name, .account-btn svg { display: none; }
  .avatar { width: var(--tap); height: var(--tap); }
  .header-actions > .header-theme-btn { display: none; }
  .nav-theme-item { display: block; }
  .nav-theme-item button { width: 100%; }
  .account-menu { position: fixed; top: 72px; right: var(--gutter); }
  .icon-btn { width: var(--tap); height: var(--tap); }
}

/* ---------- Buttons ---------- */

.btn--primary:hover { background: var(--link); border-color: var(--link); }
.btn--secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ---------- Segmented toggle ---------- */

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 4px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.segmented--block { display: grid; width: 100%; }
.segmented button {
  min-height: 38px;
  padding: 0 var(--space-4);
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--line); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }

/* ---------- Panel ---------- */

.panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 92%, transparent), color-mix(in srgb, var(--surface) 92%, transparent));
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 5%, transparent), 0 16px 40px rgba(0, 0, 0, 0.28);
  padding: var(--space-5);
}
:root[data-theme="light"] .panel { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 28px rgba(60, 40, 80, 0.10); }

/* ---------- Flags ---------- */

.flag-list { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.flag-legend { margin: var(--space-3) 0 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }

/* ---------- Backdrop (facelift) ----------
   One fixed layer covers the viewport at every scroll position, so the
   stars never cut off (the old absolutely-positioned .atmo box stopped at
   100vh / 844px). background-attachment: fixed is avoided on purpose: iOS
   Safari ignores it. Hills are an ordinary <img class="horizon"> placed at
   the bottom of a page, never behind content. */

body::before {
  content: "";
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(1100px 520px at 72% -8%, var(--sky-glow-1), transparent 70%),
    radial-gradient(900px 500px at 8% 0%, var(--sky-glow-2), transparent 70%),
    url("../img/bg/bg-stars-tile.svg") repeat,
    var(--bg);
}
body::after {             /* subtle grain for depth; purely decorative */
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url("../img/bg/grain.png"); opacity: 0.5;
}
/* Light theme: dark "inverted" stars on paper (approved 2026-10-06).
   The stars sit on their own fixed layer (html::after) so their strength can
   be tuned with --day-star-opacity (intended range 0.6 to 1). */
:root { --day-star-opacity: 0.6; }
:root[data-theme="light"] body::before {
  background:
    radial-gradient(1100px 520px at 72% -8%, var(--sky-glow-1), transparent 70%),
    radial-gradient(900px 500px at 8% 0%, var(--sky-glow-2), transparent 70%),
    var(--bg);
}
:root[data-theme="light"]::after {
  content: "";
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: url("../img/bg/bg-stars-tile-day.svg") repeat;
  opacity: var(--day-star-opacity);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) body::before {
    background:
      radial-gradient(1100px 520px at 72% -8%, var(--sky-glow-1), transparent 70%),
      radial-gradient(900px 500px at 8% 0%, var(--sky-glow-2), transparent 70%),
      var(--bg);
  }
  :root:not([data-theme="dark"])::after {
    content: "";
    position: fixed; inset: 0; z-index: -2; pointer-events: none;
    background: url("../img/bg/bg-stars-tile-day.svg") repeat;
    opacity: var(--day-star-opacity);
  }
}

.horizon {
  display: block; width: 100%; height: 180px; object-fit: cover; object-position: center bottom;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 45%, #000 75%, transparent 100%);
          mask-image: linear-gradient(180deg, transparent 0%, #000 45%, #000 75%, transparent 100%);
  pointer-events: none;
}
/* Two images are rendered (see _horizon.html); the theme picks one. */
.horizon--light { display: none; }
:root[data-theme="light"] .horizon--dark { display: none; }
:root[data-theme="light"] .horizon--light { display: block; }

/* The moon is decoration plus a shortcut to the theme toggle (the header
   always has one too). It sits in a small positioned box that scrolls
   with the top of the page. */
.backdrop-wrap > .page { position: relative; z-index: 1; }
.atmo { position: absolute; top: 0; left: 0; width: 100%; height: 100vh; max-height: 844px; z-index: 0; pointer-events: none; }
.atmo--hero { height: 170px; max-height: none; }
@media (min-width: 720px) { .atmo--hero { height: 280px; } }

.atmo-toggle {
  position: absolute; z-index: 2; background: none; border: none;
  padding: 16px; margin: -16px; cursor: pointer; border-radius: 50%;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.atmo-toggle:hover { background: rgba(255, 255, 255, .06); }
.atmo-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.atmo-icon { position: absolute; inset: 16px; transition: opacity .5s ease, transform .5s ease; }
.atmo-icon-moon { opacity: 1; transform: scale(1) rotate(0deg); }
.atmo-icon-sun  { opacity: 0; transform: scale(.4) rotate(-90deg); }
:root[data-theme="light"] .atmo-icon-moon { opacity: 0; transform: scale(.4) rotate(90deg); }
:root[data-theme="light"] .atmo-icon-sun  { opacity: 1; transform: scale(1) rotate(0deg); }

.atmo--home        .atmo-toggle { top: 10%; right: 12%; width: 44px; height: 44px; }
.atmo--rate        .atmo-toggle { top: 104px; right: 7%; width: 96px; height: 96px; }
.atmo--leaderboard .atmo-toggle { top: 8%; left: 50%; width: 96px; height: 96px; margin-left: -48px; }
@media (max-width: 600px) {
  .atmo--rate        .atmo-toggle { width: 70px; height: 70px; }
  .atmo--leaderboard .atmo-toggle { width: 56px; height: 56px; }
  .atmo--home        .atmo-toggle { width: 40px; height: 40px; }
}

/* Header toggle -- present on every page. */
.header-theme-btn { position: relative; overflow: hidden; }
.header-theme-btn .atmo-icon { inset: 8px; }

/* ---------- Hero (decklist classifier) ---------- */

.hero {
  position: relative;
  padding-top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { margin: 0; font-size: 34px; max-width: 26ch; }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.field textarea,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  box-sizing: border-box;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
}
.field textarea { resize: vertical; }
.field textarea:focus,
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.commander-input-row { display: flex; gap: var(--space-4); flex-wrap: wrap; }

.auth-panel { max-width: 420px; margin: var(--space-6) auto 0; }
.auth-divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0; color: var(--text-muted); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex-grow: 1; height: 1px; background: var(--line); }
.auth-error-panel { border-color: var(--flag-danger); color: var(--flag-danger); }
.commander-input-group { flex: 1 1 240px; position: relative; display: flex; flex-direction: column; gap: var(--space-2); }
.commander-autocomplete {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  max-height: 260px;
  overflow-y: auto;
}
.commander-autocomplete li { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; }
.commander-autocomplete li:hover,
.commander-autocomplete li.is-active { background: var(--surface-sunk); color: var(--accent); }

.commander-flag-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.commander-flag-list li { color: var(--accent); font-size: 14px; font-weight: 600; }

/* ---------- Verdict panel ---------- */

.verdict {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}
.verdict-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 72px;
  line-height: 0.85;
  color: var(--accent);
}
.verdict.is-illegal .verdict-number { color: var(--flag-danger); font-size: 40px; }
.verdict-name { font-family: var(--font-display); font-size: 24px; font-weight: 500; }
.verdict-secondary { display: flex; align-items: baseline; gap: var(--space-2); }
.verdict-number-secondary {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  line-height: 0.85;
  color: var(--text);
}
.verdict-name-secondary { font-size: 14px; color: var(--text-muted); }
.verdict ul, .panel ul.reasons {
  margin: var(--space-4) 0 0;
  padding: 0 0 0 1.1em;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 15px;
  line-height: 1.45;
  width: 100%;
}

/* ---------- Stat tiles ---------- */

.stats-grid {
  margin: var(--space-4) 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}
.stat-tile {
  padding: var(--space-3) var(--space-2);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-tile-n { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; }
.stat-tile-label { font-size: 12px; line-height: 1.25; color: var(--text-muted); }

/* ---------- Card list ---------- */

.card-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: var(--space-6) 0 var(--space-3);
}
.card-list-header h2 { margin: 0; font-size: 22px; }

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border-bottom: 1px solid var(--line);
}
.card-list li:last-child .card-row { border-bottom: none; }
.card-thumb {
  flex-shrink: 0;
  width: 40px;
  height: 56px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--line) center/cover no-repeat;
  object-fit: cover;
}
.card-row-body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.card-row-top { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
.card-row-name { font-size: 16px; font-weight: 600; }
.card-row-cost { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-row-type { font-size: 13px; color: var(--text-muted); margin-right: 2px; }
.card-row.not-found { color: var(--text-muted); font-style: italic; }

/* Desktop: return to a real table */
@media (min-width: 720px) {
  .card-list--table { display: table; width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface-sunk); }
  .card-list--table .card-row { display: table-row; padding: 0; }
  .card-list--table .card-row > * { display: table-cell; padding: 10px var(--space-3); vertical-align: middle; }
}

/* ---------- Rate: player status bar ---------- */

.status-bar { display: flex; align-items: center; gap: var(--space-3); }
.status-bar-main { display: flex; flex-direction: column; gap: 6px; flex-grow: 1; min-width: 0; }
.status-bar-row { display: flex; justify-content: space-between; font-size: 14px; gap: var(--space-2); }
.status-bar-row .name { font-weight: 700; }
.status-bar-row .muted { color: var(--text-muted); font-weight: 500; }
.xp-track { height: 8px; background: var(--line); border-radius: var(--radius-pill); overflow: hidden; }
.xp-fill { height: 100%; background: var(--accent); border-radius: var(--radius-pill); transition: width 0.6s ease; }
.streak-block { flex-shrink: 0; padding-left: var(--space-3); border-left: 1px solid var(--line); text-align: center; }
.streak-number { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1; }
.streak-label { font-size: 11px; color: var(--text-muted); }
.name-form { margin-top: var(--space-3); display: flex; gap: var(--space-2); }
.name-form input {
  flex-grow: 1; min-width: 0; min-height: var(--control-h); font: inherit; font-size: 14px; padding: 0 var(--space-3);
  background: var(--surface-sunk); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-control);
}
.name-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Rate: card stage ---------- */

.card-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-6);
  min-height: 420px;
}
.prompt { text-align: center; margin: 0 0 var(--space-3); font-family: var(--font-display); font-size: 32px; line-height: 1.15; font-weight: 600; max-width: 22ch; }
#answer-controls, #vote-form { width: 100%; }
.card-glow { position: relative; filter: drop-shadow(0 30px 50px rgba(0, 0, 0, 0.55)); }
.card-glow::before {          /* soft glow behind the card */
  content: ""; position: absolute; inset: -60px; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--mana-w) 22%, transparent), transparent);
}
.calibration-note { text-align: center; font-size: 13px; color: var(--text-muted); margin: 0; }

.card-image-btn {
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
}
.card-image-btn:disabled { cursor: default; }
.card-image-btn:not(:disabled):hover .card-image,
.card-image-btn:focus-visible .card-image { outline: 2px solid var(--accent); outline-offset: 3px; }
.card-image {
  display: block;
  width: 250px;
  max-width: 70vw;
  border-radius: 4.75% / 3.4%;
  background: var(--surface-sunk);
}
.flip-hint { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text-muted); }

.card-name { text-align: center; font-family: var(--font-display); font-size: 20px; font-weight: 500; margin: var(--space-2) 0; }
.example-decklist-wrap { margin: 0 0 var(--space-2); }

.answer-block { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.bracket-group {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 5px; border-radius: 14px;
  background: color-mix(in srgb, var(--surface-sunk) 85%, transparent); border: 1px solid var(--line);
}
.bracket-group label {
  position: relative; min-height: 64px; border-radius: 10px; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.bracket-group label:hover { background: color-mix(in srgb, var(--line) 60%, transparent); }
.bracket-group label strong { font-family: var(--font-display); font-size: 24px; line-height: 1; }
.bracket-group label span { font-size: 12px; font-weight: 600; opacity: 0.85; }
.bracket-group--plain label { min-height: 52px; }
.bracket-group input, .any-option input { position: absolute; opacity: 0; pointer-events: none; }
.bracket-group label:has(input:checked) { background: var(--accent); color: var(--on-accent); }
.bracket-group label:has(input:focus-visible), .any-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.any-option {
  position: relative; display: flex; align-items: center; justify-content: center; min-height: var(--control-h); cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface-raised);
  font-size: 14px; font-weight: 600;
}
.any-option:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.scale-caption { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); padding: 0 var(--space-2); }
.rate-actions { justify-content: center; }
@media (max-width: 480px) {
  .bracket-group label span { font-size: 10px; }
  .bracket-group label strong { font-size: 20px; }
}

.notes-field textarea { min-height: 64px; }
.notes-field label { font-size: 14px; font-weight: 600; }

/* ---------- Rate: result banner ---------- */

.result-banner {
  position: relative;
  padding: var(--space-4) var(--space-5) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.result-points {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}
.result-points-row { display: flex; align-items: baseline; gap: var(--space-2); }
.result-points-unit { font-size: 15px; font-weight: 600; color: var(--text-muted); }
.result-message { margin: 0; font-size: 16px; line-height: 1.45; }
.result-dist { display: flex; height: 8px; border-radius: var(--radius-pill); overflow: hidden; gap: 2px; }
.result-dist span { display: block; background: var(--line); }
.result-dist span.is-majority { background: var(--accent); }
.result-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.result-hint { font-size: 13px; color: var(--text-muted); }
.result-calibration { font-size: 13px; color: var(--flag-warm); margin: 0; }

.spark {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 20;
  animation: spark-burst 0.7s ease-out forwards;
}
@keyframes spark-burst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}
.result-points.pop { animation: points-pop 0.5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes points-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); }
}
.level-up-flash { animation: flash 1s ease; }
@keyframes flash {
  0% { color: var(--flag-warm); transform: scale(1.4); display: inline-block; }
  100% { color: inherit; transform: scale(1); display: inline-block; }
}

/* ---------- Help popover ---------- */

.help-popover {
  position: fixed;
  top: 64px;
  right: var(--space-4);
  width: min(320px, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-size: 14px;
  z-index: 30;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.help-popover[hidden] { display: none; }
.help-popover p { margin: 0 0 var(--space-3); line-height: 1.4; }
.help-popover p:last-child { margin-bottom: 0; }
.help-popover strong, .intro-panel strong { color: var(--accent); }

/* ---------- Commander lookup ---------- */

.commander-header { display: flex; gap: var(--space-5); align-items: flex-start; flex-wrap: wrap; }
.commander-header img { width: 160px; border-radius: var(--radius); flex-shrink: 0; }
.commander-name { font-family: var(--font-display); font-size: 26px; font-weight: 500; margin: 0; }
.commander-type { color: var(--text-muted); margin: var(--space-1) 0; }
.commander-sample-size { color: var(--text-muted); font-size: 14px; }
.commander-common-bracket { color: var(--accent); font-size: 14px; font-weight: 600; margin: var(--space-1) 0 0; }
.commander-links { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-top: var(--space-2); }
.back-to-rating { font-weight: 600; }

.bracket-bars { list-style: none; padding: 0; margin: var(--space-3) 0 0; }
.bracket-bars li { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); font-size: 14px; }
.bar-track { background: var(--line); border-radius: var(--radius-sm); height: 10px; overflow: hidden; }
.bar-fill { display: block; background: var(--line-strong); height: 100%; }
.bar-fill.is-max { background: var(--accent); }

.category-block { margin-top: var(--space-5); }
.category-block h2 { font-size: 18px; margin: 0 0 var(--space-1); }
.card-pct-list { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px var(--space-5); }
.card-pct-list li { display: flex; justify-content: space-between; gap: var(--space-2); font-size: 14px; border-bottom: 1px dotted var(--line); padding-bottom: 3px; }
.card-pct-list .pct { color: var(--text-muted); white-space: nowrap; }
.card-image-grid { display: none; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--space-3) var(--space-2); margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.card-image-item { text-align: center; font-size: 13px; }
.card-image-item img { width: 100%; border-radius: 4.5% / 3.5%; display: block; }
.card-image-item .thumb-wrap { width: 100%; }
.card-image-item .thumb-zoom { width: 280px; max-width: 65vw; border-radius: var(--radius); }
.card-image-item .card-image-name { margin-top: 5px; line-height: 1.2; }
.card-image-item .card-image-pct { color: var(--text-muted); }
body[data-view="images"] .card-pct-list { display: none; }
body[data-view="images"] .card-image-grid { display: grid; }

@media (max-width: 600px) {
  .card-pct-list { grid-template-columns: 1fr; }
  .commander-header { flex-direction: column; }
}

/* ---------- Leaderboard ---------- */

.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th, .leaderboard-table td { padding: var(--space-3); text-align: left; border-bottom: 1px solid var(--line); }
.leaderboard-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.leaderboard-table .rank { font-family: var(--font-display); font-size: 18px; font-weight: 700; width: 2.5em; }
.leaderboard-table .rank.top-three { color: var(--accent); }
.leaderboard-table .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .leaderboard-table .col-longest { display: none; }
}

/* ---------- Intro ---------- */

.intro-panel { max-width: 520px; margin: var(--space-6) auto 0; text-align: left; }
.intro-panel .eyebrow { text-align: center; display: block; }
.intro-panel h1 { text-align: center; margin: var(--space-2) 0 var(--space-4); }
.intro-lede { text-align: center; color: var(--text-muted); margin: 0 0 var(--space-5); }

/* ---------- Misc ---------- */

.not-found-msg { color: var(--flag-danger); font-weight: 600; }
.page--xwide { max-width: 1120px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); text-decoration: none; }
.back-link:hover { color: var(--text); }
.back-link svg { width: 14px; height: 14px; }

/* ---------- Insights: stat tiles ---------- */

.stat-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-tile { background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; line-height: 1.25; color: var(--text-muted); }

.section-head { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); max-width: 640px; }
.section-head h2 { margin: 0; font-size: 22px; }
@media (min-width: 720px) { .section-head h2 { font-size: 28px; } }
.muted-panel { background: var(--surface-sunk); border-style: dashed; }

/* ---------- Insights: VoteSpread (new 8th component -- per-card dot plot of
   individual votes across 1-5 plus a separate "any" count; DistributionBar
   is only built for a single aggregate percentage, not a raw spread) ---- */

.vote-card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
@media (min-width: 860px) { .vote-card-list { grid-template-columns: repeat(2, 1fr); } }
.vote-card { background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); }
.vote-card-head { display: flex; align-items: center; gap: var(--space-3); }
.vote-card-name { font-weight: 600; font-size: 15px; flex: 1 1 auto; }
.spread-badge { flex: none; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; padding: 3px 7px; border-radius: var(--radius-sm); border: 1px solid var(--flag-danger); color: var(--flag-danger); }
.vote-card.is-agreed .spread-badge { border-color: var(--flag-cool); color: var(--flag-cool); }
.vote-card-meta { font-size: 12px; color: var(--text-muted); margin: 0; }

.thumb-wrap { flex: none; position: relative; padding: 0; margin: 0; border: none; background: none; cursor: zoom-in; border-radius: var(--radius-sm); display: block; }
.thumb { display: block; width: 56px; height: 78px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.thumb-zoom { position: absolute; top: 0; left: calc(100% + 10px); z-index: 30; width: 280px; max-width: 65vw; height: auto; display: block; border-radius: var(--radius); border: 1px solid var(--line-strong); box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5); opacity: 0; visibility: hidden; transform: translateX(-6px); pointer-events: none; transition: opacity 0.12s ease, transform 0.12s ease; }
.thumb-wrap:hover .thumb-zoom, .thumb-wrap:focus-visible .thumb-zoom, .thumb-wrap:focus-within .thumb-zoom { opacity: 1; visibility: visible; transform: translateX(0); }
.thumb-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 700px) {
  .thumb-zoom { top: calc(100% + 10px); left: 0; transform: translateY(-6px); }
  .thumb-wrap:hover .thumb-zoom, .thumb-wrap:focus-visible .thumb-zoom, .thumb-wrap:focus-within .thumb-zoom { transform: translateY(0); }
}

.vote-spread { display: flex; align-items: flex-end; gap: var(--space-3); }
.vs-track { flex: 1 1 auto; display: flex; align-items: flex-end; gap: 6px; height: 52px; }
.vs-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; }
.vs-dots { display: flex; flex-direction: column-reverse; align-items: center; gap: 3px; }
.vs-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.is-agreed .vs-dot { background: var(--flag-cool); }
.vs-baseline { width: 100%; height: 1px; background: var(--line); }
.vs-num { font-size: 11px; color: var(--text-muted); }
.vs-any { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 8px; border-radius: var(--radius); border: 1px dashed var(--line-strong); }
.vs-any-count { font-size: 13px; font-weight: 700; }
.vs-any-label { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-muted); text-transform: uppercase; }

.view-all-link { margin-top: var(--space-4); }

/* ---------- Insights: category comparison ---------- */

.category-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.category-row { display: grid; grid-template-columns: 128px 1fr auto; align-items: center; gap: var(--space-3); }
.category-name { font-size: 14px; font-weight: 600; }
.category-track { height: 10px; border-radius: var(--radius-pill); background: var(--surface-sunk); border: 1px solid var(--line); overflow: hidden; }
.category-fill { display: block; height: 100%; background: var(--line-strong); border-radius: var(--radius-pill); }
.category-fill.is-top { background: var(--accent); }
.category-value { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.category-avg { font-size: 15px; font-weight: 700; }
.category-row.is-top .category-avg, .category-row.is-top .category-name { color: var(--accent); }
.category-n { font-size: 12px; color: var(--text-muted); }
@media (max-width: 560px) {
  .category-row { grid-template-columns: 1fr; gap: var(--space-1); }
  .category-value { order: 2; }
}

/* ---------- Insights: bar charts + votes-over-time ---------- */

.charts-row { display: grid; gap: var(--space-5); }
@media (min-width: 780px) { .charts-row { grid-template-columns: 1fr 1fr; } }
.chart-block { display: flex; flex-direction: column; gap: var(--space-2); }
.chart-block svg { width: 100%; height: auto; }
.chart-title { margin: 0 0 var(--space-1); font-size: 18px; }
.time-chart { display: flex; flex-direction: column; gap: var(--space-2); }
.time-chart svg { width: 100%; max-width: 420px; height: auto; }
.muted-note { color: var(--text-muted); font-size: 13px; }

/* ---------- Insights: calibration bar ---------- */

.calibration-bar { display: flex; height: 8px; border-radius: var(--radius-pill); overflow: hidden; gap: 2px; margin-top: var(--space-3); max-width: 220px; }
.calibration-bar span { display: block; height: 100%; background: var(--surface); }
.calibration-bar span.is-filled { background: var(--flag-cool); }

/* ---------- Insights/cards: sortable table ---------- */

.table-scroll { overflow: auto; max-height: 70vh; }
table.ratings { width: 100%; border-collapse: collapse; min-width: 520px; }
table.ratings th, table.ratings td { padding: var(--space-3); text-align: left; border-bottom: 1px solid var(--line); }
table.ratings thead th { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; position: sticky; top: 0; z-index: 5; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
table.ratings tbody tr:hover { background: var(--surface-sunk); }
th.is-sortable { padding: 0; }
.sort-btn { width: 100%; height: 100%; padding: var(--space-3); border: none; background: none; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); }
.sort-btn:hover { color: var(--text); }
.sort-arrow { width: 10px; height: 10px; opacity: 0; flex: none; }
.sort-btn[aria-sort="ascending"] .sort-arrow, .sort-btn[aria-sort="descending"] .sort-arrow { opacity: 1; color: var(--accent); }
.sort-btn[aria-sort="ascending"] .sort-arrow { transform: rotate(180deg); }

.row-card { display: flex; align-items: center; gap: var(--space-3); }
.row-thumb { display: block; flex: none; width: 32px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); overflow: hidden; background: var(--surface-sunk); }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.row-name { font-weight: 600; }
.num-cell { font-variant-numeric: tabular-nums; }
.any-cell { color: var(--text-muted); }

/* ---------- Deck Builder: /decks (library + new-deck flow) ---------- */
/* Step 2 of docs/deck-builder-handoff/deck-builder-claude-code-handoff.md's
   build order -- desktop layout matches mockups/decks-library.html. */

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.decks-hero { position: relative; display: flex; align-items: flex-end; gap: var(--space-6); padding: 56px 0 88px; flex-wrap: wrap; }
.decks-hero .horizon {      /* full-bleed, sits behind the hero text, fades out before the cards */
  position: absolute; bottom: 0; left: 50%; width: 100vw; max-width: none; height: 150px; margin-left: -50vw; z-index: 0;
}
.decks-hero > :not(.horizon) { position: relative; z-index: 1; }
.decks-hero__text { flex: 1 1 360px; display: flex; flex-direction: column; gap: 10px; }
.decks-hero h1 { margin: 0; font-size: 60px; line-height: 1; font-weight: 600; letter-spacing: -0.015em; }
.decks-hero__sync { margin: 0; font-size: 16px; color: var(--text-muted); }
.decks-hero__sync svg { color: var(--flag-cool); vertical-align: -2px; margin-right: var(--space-2); }
.decks-hero__actions { display: flex; gap: 10px; }
@media (max-width: 720px) {
  .decks-hero { padding: 32px 0 72px; }
  .decks-hero h1 { font-size: 40px; }
}

.decks-body { position: relative; margin-top: -40px; z-index: 1; }
#new-deck-inline { max-width: 560px; }
#new-deck-inline .deck-new-panel { padding: var(--space-5); }
#new-deck-inline:not(:empty) { margin-bottom: var(--space-6); }
.deck-new-panel { display: flex; flex-direction: column; gap: var(--space-4); }
.deck-new-panel h2 { margin: 0; }
.deck-tab-panel[hidden] { display: none; }

dialog.dialog--newdeck { max-width: 520px; padding: var(--space-6) var(--space-5) var(--space-5); background: linear-gradient(180deg, var(--surface-raised), var(--surface)); }
dialog.dialog--newdeck::backdrop { background: color-mix(in srgb, var(--bg) 60%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.dialog__close { position: absolute; top: var(--space-3); right: var(--space-3); }

.deck-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--space-6); margin: 0; padding: 0; list-style: none; }
@media (max-width: 640px) { .deck-library { gap: var(--space-4); } }
.deck-library > li { position: relative; }
.deck-card { display: flex; flex-direction: column; height: 100%; padding: 0; }
.deck-card__art {
  position: relative; height: 168px; border-radius: var(--radius-panel) var(--radius-panel) 0 0; overflow: hidden;
  background: linear-gradient(160deg, var(--line), var(--surface-sunk) 70%) center / cover no-repeat;
}
.deck-card__art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, color-mix(in srgb, var(--surface) 95%, transparent)); }
.deck-card__menu-wrap { position: absolute; top: 12px; right: 12px; z-index: 2; }
.deck-card__menu {
  width: 40px; height: 40px; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center;
  border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: var(--text); cursor: pointer;
}
.deck-card__body { padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 6px; flex-grow: 1; }
.deck-card__name { margin: 0; font-family: var(--font-display); font-size: 24px; line-height: 1.15; font-weight: 600; }
.deck-card__name a { color: var(--text); text-decoration: none; }
.deck-card__name a:hover { color: var(--link); }
.deck-card__name a::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: var(--radius-panel); }   /* whole card is the link */
.deck-card__commander { margin: 0; display: flex; align-items: center; gap: var(--space-2); font-size: 14px; }
.deck-card__meta { margin: 0; font-size: 13px; color: var(--text-muted); }
.deck-card__meta .is-over { color: var(--flag-danger); font-weight: 600; }
.deck-card__scores { margin-top: auto; padding-top: 14px; display: flex; gap: 10px; }
.deck-score { flex: 1; background: var(--surface-sunk); border-radius: 12px; padding: 10px 12px; }
.deck-score__label { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.deck-score__n { font-family: var(--font-display); font-size: 30px; line-height: 1.05; font-weight: 700; }
.deck-score__n--feels { color: var(--accent); }
.deck-score__n.is-pending { color: var(--text-muted); opacity: 0.6; }
.deck-card__menu-wrap { z-index: 3; }   /* above the whole-card link */

.deck-card--new {
  height: 100%; min-height: 320px; padding: 28px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-panel); background: color-mix(in srgb, var(--surface-sunk) 50%, transparent);
}
.deck-card--new h3 { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.deck-card--new p { margin: 0; max-width: 260px; font-size: 14px; color: var(--text-muted); }
.deck-card--new__plus { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-raised); border: 1px solid var(--line-strong); display: flex; align-items: center; justify-content: center; }
.deck-card--new__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }

.deck-row-menu {
  margin: 0;
  padding: var(--space-1);
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  list-style: none;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  min-width: 160px;
}
.deck-row-menu button {
  width: 100%;
  text-align: left;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.deck-row-menu button:hover { background: var(--surface-sunk); }
.deck-row-menu button.is-danger { color: var(--flag-danger); }
.deck-empty-note { padding: var(--space-4); color: var(--text-muted); font-size: 14px; }

/* ---------- Deck Builder: /decks/<id> header ---------- */

/* ---------- Commander-art deck header (card-detail-handoff, step 7) ----------
   Imagery exception: the banner may show the commander's (or chosen
   deck-image card's) Scryfall art_crop, since it depicts that specific
   card in this specific deck -- never page decoration, always credited
   (see .deck-hero-credit). Falls back to the plain surface color with
   no art loads; never a broken image (renderDeckHero in deck-builder.js). */
.deck-hero {
  position: relative;
  height: 320px;
  box-sizing: border-box;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  /* Neutral until the banner's art and tint are ready; the tint is a separate
     layer (::before) that fades in over this. See docs/deck-banner-handoff. */
  background: linear-gradient(90deg, var(--bg) 0%, var(--surface) 45%, var(--surface-raised) 100%);
  display: flex;
  align-items: flex-end;
}
/* Two colors sampled from the banner's own art (--banner-c1/-c2, set from
   /api/banner-colors) carry it across the width. */
.deck-hero::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 0.5s ease; pointer-events: none;
  background: linear-gradient(90deg, var(--bg) 0%, var(--banner-c1, var(--surface)) 45%, var(--banner-c2, var(--surface-raised)) 100%);
}
.deck-hero.has-tint::before { opacity: 1; }
:root[data-theme="light"] .deck-hero::before {
  background: linear-gradient(90deg, var(--bg) 0%,
    color-mix(in srgb, var(--banner-c1, var(--surface)) 30%, var(--bg)) 45%,
    color-mix(in srgb, var(--banner-c2, var(--surface-raised)) 55%, var(--bg)) 100%);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .deck-hero::before {
    background: linear-gradient(90deg, var(--bg) 0%,
      color-mix(in srgb, var(--banner-c1, var(--surface)) 30%, var(--bg)) 45%,
      color-mix(in srgb, var(--banner-c2, var(--surface-raised)) 55%, var(--bg)) 100%);
  }
}
.deck-hero-bg {
  /* Scryfall's art crop is only ~626px wide, so it keeps its real shape on the
     right (never wider than 760px) and fades in from the left through a mask,
     instead of being stretched across the banner. The crop favors the top third,
     where faces usually are. */
  position: absolute; top: 0; right: 0; bottom: 0; width: min(58%, 760px);
  background-size: cover; background-position: center 30%;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 32%);
          mask-image: linear-gradient(90deg, transparent 0%, #000 32%);
  opacity: 0; transition: opacity 0.5s ease;     /* fades in once the picture has loaded */
}
.deck-hero-bg.is-ready { opacity: 1; }
.deck-hero-scrim { position: absolute; inset: 0; }
.deck-hero-scrim--side { display: none; }
.deck-hero-scrim--bottom {
  background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, var(--bg) 80%, transparent) 100%);
}
.deck-hero-glow { position: absolute; inset: 0; }
.deck-hero-credit {
  position: absolute;
  right: 16px;
  top: 12px;
  font-size: 11px;
  font-weight: 600;
  color: color-mix(in srgb, var(--text) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border-radius: 4px;
  padding: 2px 8px;
}
.deck-hero-content {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 0 var(--space-5) var(--space-5);
  display: flex;
  align-items: flex-end;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.deck-header-info { flex: 1 1 320px; display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.deck-header-info h1 { margin: 0; font-size: 56px; line-height: 1.02; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5); }
.deck-header-info .deck-title-input { font-size: 56px; line-height: 1.1; }
.deck-header-meta { margin: 0; color: var(--text-muted); display: flex; align-items: center; gap: 10px; }
.deck-header-meta strong { color: var(--text); font-weight: 600; }
.deck-hero-verdict { margin: 4px 0 0; font-family: var(--font-display); font-size: 20px; line-height: 1.35; font-style: italic; color: var(--text); }
.deck-header-save-note { margin: 0; font-size: 13px; color: var(--text-muted); }

/* Score tiles and "Check in classifier" sit together, bottom-right of the banner. */
.deck-hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-3); flex-shrink: 0; }

/* Breadcrumb row, sync status and the changed-elsewhere notice above the banner. */
.deck-crumbs { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: var(--space-4) 0 var(--space-3); min-height: 32px; }
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-size: 14px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--flag-cool); flex-shrink: 0; }
.sync-pill.is-error { color: var(--flag-danger); }
.notice {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; margin-bottom: var(--space-4); border-radius: 12px;
  background: color-mix(in srgb, var(--flag-warm) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--flag-warm) 40%, transparent);
}
.notice[hidden] { display: none; }
.notice__icon { display: flex; color: var(--flag-warm); flex-shrink: 0; }
.notice__text { flex-grow: 1; font-size: 14px; font-weight: 500; }

.deck-score-tiles { display: flex; gap: var(--space-3); flex-shrink: 0; }
.deck-score-tile {
  width: 168px;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--text-muted) 25%, transparent);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.deck-score-label { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.deck-score-n { font-family: var(--font-display); font-size: 56px; line-height: 0.9; font-weight: 700; color: var(--line-strong); }
.deck-score-n.is-live { color: var(--accent); }
.deck-score-hint { margin: 0; font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.deck-score-tile.has-hint { cursor: help; }
.deck-score-note { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.deck-score-tile { position: relative; }
.deck-score-roll-box { display: block; overflow: hidden; }
.deck-score-delta {
  position: absolute;
  right: var(--space-4);
  top: 38px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--flag-danger);
  opacity: 0;
  pointer-events: none;
}
.deck-score-delta.is-down { color: var(--text-muted); }

/* ---------- Score motion (card-detail-handoff, step 8) ----------
   "Motion shows cause and effect" -- animate only what changed, in
   order, after a single user edit; never on load, import, undo or a
   batched multi-edit response (see scheduleScoreRecompute's own
   single-edit tracking). Keyframes ported directly from the handoff's
   score-moment-demo.html. */
@keyframes twPop { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes twSlide { 0% { transform: translateY(14px) scale(0.94); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes twRoll { 0% { transform: translateY(45%); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes twFloat { 0% { transform: translateY(8px); opacity: 0; } 15% { transform: none; opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-14px); opacity: 0; } }
@keyframes twGlow { 0% { background-color: color-mix(in srgb, var(--accent) 24%, transparent); } 100% { background-color: transparent; } }
@keyframes twFade { from { opacity: 0; } to { opacity: 1; } }
.tw-pop { animation: twPop 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.tw-slide { animation: twSlide 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.tw-roll { animation: twRoll 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.tw-float { animation: twFloat 1.8s ease-out both; }
.tw-glow { animation: twGlow 1.6s ease-out both; border-radius: 6px; }
.tw-fade { animation: twFade 0.4s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .tw-pop, .tw-slide, .tw-roll, .tw-glow, .tw-fade { animation: none !important; }
  .tw-float { display: none; }
  .ratio-row-fill { transition: none; }
}

@media (max-width: 719px) {
  /* height:auto + min-height rather than a fixed height -- stacking the
     title, commander line, verdict and tiles vertically (below) can run
     taller than 240px, and a fixed height + overflow:hidden would clip
     the title clean off (caught live: "Untitled deck" wasn't rendering
     at all under the fold). */
  .deck-hero { height: auto; min-height: 230px; border-radius: 16px; align-items: stretch; }
  /* The art is a strip across the top that fades downward; the text starts below it.
     (The phone banner grows taller than 230px as its content stacks, so the art is
     sized on its own rather than filling the banner.) */
  .deck-hero-bg {
    bottom: auto; height: 210px; width: 100%;
    -webkit-mask-image: linear-gradient(180deg, #000 25%, transparent 100%);
            mask-image: linear-gradient(180deg, #000 25%, transparent 100%);
  }
  .deck-hero .deck-hero-content { padding-top: 130px; }
  .deck-header-info { flex: 0 0 auto; }
  .deck-hero-side { align-items: stretch; width: 100%; }
  .deck-hero-content { flex-direction: column; align-items: flex-start; gap: var(--space-3); padding: var(--space-4); }
  .deck-header-info h1 { font-size: 30px; line-height: 1.08; }
  .deck-header-info .deck-title-input { font-size: 30px; }
  .deck-hero-verdict { font-size: 16px; }
  .deck-score-tiles { flex-wrap: wrap; width: 100%; }
  .deck-score-tile { width: auto; flex: 1 1 130px; }
}

.deck-builder-body { display: flex; gap: var(--space-6); align-items: flex-start; flex-wrap: wrap; margin-top: var(--space-5); }
.deck-builder-main { flex: 1 1 600px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.deck-builder-sidebar {
  width: 100%; max-width: clamp(340px, 22vw, 460px); flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-3);
  position: sticky; top: 156px; max-height: calc(100vh - 172px); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.deck-sidebar-content { display: flex; flex-direction: column; gap: var(--space-4); min-width: 300px; }
.deck-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
@media (max-width: 1023px) {
  .deck-builder-sidebar { position: static; max-height: none; overflow: visible; max-width: none; }
}
.deck-sidebar-toggle svg { transition: transform 0.15s ease; }

/* Collapsed: shrink to just the toggle button and let the grid reclaim
   the freed width -- the toggle itself stays put so it's always there
   to expand again (section 9's phone-layout pass didn't cover this;
   added per Chris's own review asking for a way to shrink this column). */
.deck-builder-sidebar--collapsed { width: auto; max-width: none; gap: 0; }
.deck-builder-sidebar--collapsed .deck-sidebar-content { display: none; }
.deck-builder-sidebar--collapsed .deck-sidebar-title { display: none; }
.deck-builder-sidebar--collapsed .deck-sidebar-toggle svg { transform: rotate(180deg); }

.deck-search { position: relative; max-width: 520px; }
.deck-search input[type="search"] {
  box-sizing: border-box;
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--space-4) 0 42px;
  background: var(--surface-sunk);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 15px;
}
.deck-search input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.deck-search-icon { position: absolute; left: 14px; top: calc(var(--control-h) / 2 - 9px); color: var(--text-muted); pointer-events: none; }
.deck-search-option { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; }
.deck-search-option-body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.deck-search-option-name { font-weight: 600; }
.deck-search-option-type { font-size: 13px; color: var(--text-muted); }
.deck-search-option-pips { display: flex; gap: 3px; flex-shrink: 0; }
.deck-search-empty { padding: var(--space-3); font-size: 14px; color: var(--text-muted); }

.deck-empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}
.deck-empty-state h2 { margin: 0; }
.deck-empty-state p { margin: 0; max-width: 460px; color: var(--text-muted); }

/* ---------- Deck Builder: grid, step 3 ---------- */

.switch {
  width: 60px;
  height: 44px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
}
.switch-track {
  width: 44px;
  height: 26px;
  box-sizing: border-box;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  border: 1px solid var(--line-strong);
  padding: 2px;
  display: flex;
  justify-content: flex-start;
  transition: background 0.15s ease;
}
.switch-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch[aria-checked="true"] .switch-track { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { background: var(--on-accent); transform: translateX(18px); }

.deck-toolbar {
  position: sticky; top: 80px; z-index: 30; padding: 10px; border-radius: 14px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 97%, transparent), color-mix(in srgb, var(--surface) 97%, transparent));
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.deck-toolbar .deck-search { flex: 1 1 260px; max-width: 420px; }
.deck-toolbar-spacer { flex-grow: 1; }
/* Card weights (Deck settings): the switch hides every card's weight circle and its hover explanation at once. */
.tw-hide-card-weights .deck-card-badge,
.tw-hide-card-weights .deck-card-badge-tooltip { display: none; }
/* Group / Sort: a button that opens a themed menu (select-menu.js). The native
   <select> stays in the DOM, hidden, as the source of truth. */
.toolbar-select {
  position: relative; display: inline-flex; align-items: center; min-height: var(--control-h);
  border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface-raised);
  color: var(--text); font-size: 14px; font-weight: 600;
}
.toolbar-select:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.select-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: calc(var(--control-h) - 2px); padding: 0 12px;
  border: none; background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.select-btn:focus-visible { outline: none; }
.select-btn > span { color: var(--text-muted); font-weight: 600; }
.select-btn__value { font-weight: 600; }
.select-btn svg { color: var(--text-muted); flex-shrink: 0; }
.select-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.select-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 100%; margin: 0; padding: 6px; list-style: none;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.select-menu[hidden] { display: none; }
.select-menu li {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; padding: 0 12px;
  border-radius: var(--radius-control); color: var(--text-muted); font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.select-menu li:hover, .select-menu li:focus-visible { background: var(--surface-sunk); color: var(--text); outline: none; }
.select-menu li[aria-selected="true"] { color: var(--text); }
.select-menu li[aria-selected="true"]::after {
  content: ""; width: 14px; height: 14px; flex-shrink: 0; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* Any remaining native dropdown lists at least pick up the theme colors. */
select option { background: var(--surface); color: var(--text); }
@media (max-width: 720px) {
  /* Wrapped onto several rows it is too tall to pin on a phone. */
  /* Not sticky, but still positioned above the cards so its open menus are not painted over. */
  .deck-toolbar { position: relative; top: auto; z-index: 30; }
  .deck-toolbar .deck-search { max-width: none; flex-basis: 100%; }
  .deck-crumbs { flex-wrap: wrap; row-gap: var(--space-1); }
  .deck-header-meta { display: block; }
}
.deck-card-count { font-size: 15px; }
.deck-card-count.is-over { color: var(--flag-danger); font-weight: 700; }
.deck-card-count-note { display: block; font-size: 13px; font-weight: 600; color: var(--flag-danger); }

.deck-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.deck-group:first-child { margin-top: 0; }
.deck-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: 2px;
}
.deck-group-header h2 { margin: 0; font-size: 24px; font-weight: 600; }
.deck-group-count { font-size: 13px; font-weight: 700; color: var(--text-muted); background: var(--surface-raised); border-radius: var(--radius-pill); padding: 2px 10px; }
.section-head__rule { flex-grow: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.deck-group-collapse {
  width: var(--tap);
  height: var(--tap);
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.deck-group[data-collapsed="true"] .deck-grid { display: none; }
.deck-group[data-collapsed="true"] .deck-group-collapse svg { transform: rotate(180deg); }

.deck-outside-divider { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-6); }
.deck-outside-divider-line { height: 1px; flex-grow: 1; background: var(--line-strong); }
.deck-outside-divider-label { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.deck-outside-divider-eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.deck-outside-divider-note { font-size: 13px; color: var(--text-muted); }

.deck-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  /* Cards get bigger as the window grows: the minimum width scales with the
     viewport (150px on a phone up to 230px on a big monitor) and columns are
     added as they fit. */
  grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 12vw, 230px), 1fr));
  gap: 24px var(--space-4);
}

.deck-card-tile { position: relative; display: flex; flex-direction: column; gap: var(--space-2); }
.deck-card-open { display: block; width: 100%; padding: 0; border: none; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.deck-card-open .deck-card-frame { width: 100%; }
.deck-card-frame {
  position: relative;
  aspect-ratio: 63 / 88;
  box-sizing: border-box;
  border-radius: 4.75% / 3.4%;
  background: url("../img/card-placeholder.svg") center / cover no-repeat, var(--surface-sunk);
  overflow: hidden;
  transition: box-shadow 0.1s ease;
  /* filter, not box-shadow: hover, selection and off-identity rings use the box-shadow slot */
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}
/* The text fallback (no image available) brings its own face; no placeholder art behind it. */
.deck-card-frame:has(.deck-card-placeholder) { background: var(--surface-sunk); }
/* Real Scryfall images carry the card's own printed border. White-bordered cards (old frames, some
   showcase treatments) used to get a dark inset vignette here; it read as a black halo around the
   card, so the card is now shown as printed, clipped to the card's own corner radius. */
.deck-card-tile:hover .deck-card-frame,
.deck-card-tile.is-jump-highlight .deck-card-frame,
.deck-card-open:focus-visible .deck-card-frame { box-shadow: 0 0 0 2px var(--text-muted); }
/* Bulk multi-select (ctrl/cmd+click) -- a stronger accent ring than plain
   hover/focus, plus a checkmark badge, so it reads as a distinct sticky
   state rather than momentary hover. */
.deck-card-tile.is-selected .deck-card-frame { box-shadow: 0 0 0 3px var(--accent); }
.deck-card-select-check {
  display: none;
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  align-items: center;
  justify-content: center;
}
.deck-card-tile.is-selected .deck-card-select-check { display: flex; }
.deck-card-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.deck-card-placeholder {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 10px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.deck-card-placeholder-name { font-family: var(--font-display); font-size: 13px; line-height: 1.2; font-weight: 500; display: block; }
.deck-card-placeholder-mana { display: flex; gap: 2px; min-height: 16px; margin-top: 6px; }
.deck-card-placeholder-type { font-size: 11px; line-height: 1.3; color: var(--text-muted); }

.deck-card-remove {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}
/* Remove sits on the card art. When the tile also has a quantity row (the
   +/- stepper, or the placeholder that reserves its height) below the art,
   lift Remove above that row -- it used to sit at the tile's bottom edge,
   which put it directly on top of the +/- buttons (caught in QA
   2026-09-30: tapping + on a basic land removed the card instead). */
.deck-card-tile.has-qty-row .deck-card-remove { bottom: calc(8px + var(--tap) + 2px + var(--space-2)); }

/* The hover-reveal only exists where there is real hover. On touch, a tap
   leaves a sticky :hover behind, which used to arm an invisible destructive
   button on the card; touch users remove cards from the card-detail dialog
   ("Remove from deck") instead. */
@media (hover: hover) {
  .deck-card-tile:hover .deck-card-remove { opacity: 1; pointer-events: auto; }
}
.deck-card-remove:focus,
.deck-card-tile.is-selected .deck-card-remove { opacity: 1; pointer-events: auto; }

.deck-card-badge {
  position: absolute;
  top: -13px;
  right: -13px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.deck-card-badge-circle {
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--flag-danger);
  color: var(--on-accent);
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
}

.deck-card-qty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.deck-card-qty button {
  width: var(--tap);
  height: var(--tap);
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.deck-card-qty button:disabled { color: var(--line-strong); cursor: default; }
.deck-card-qty-n { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.deck-card-qty-placeholder { height: var(--tap); }

/* ---------- Card detail dialog (card-detail-handoff, steps 2+) ---------- */

/* Facelift: the page stays visible behind the dialog, blurred, with a soft glow
   in the card's first color (--card-glow, set from JS). */
dialog.dialog.dialog--card { max-width: 1000px; }
dialog.dialog.card-detail {
  width: min(1000px, calc(100vw - 48px)); max-width: none; padding: 24px 28px 22px; box-sizing: border-box;
  border: 1px solid var(--line-strong); border-radius: 22px; color: var(--text);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card-glow, var(--mana-c)) 10%, transparent), transparent 140px),
    linear-gradient(180deg, var(--surface-raised), var(--surface));
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6), inset 0 1px 0 color-mix(in srgb, var(--text) 8%, transparent);
}
dialog.dialog.card-detail::backdrop {
  background:
    radial-gradient(640px 520px at 34% 52%, color-mix(in srgb, var(--card-glow, var(--mana-c)) 20%, transparent), transparent 70%),
    color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

.cd-header { display: flex; align-items: center; gap: var(--space-3); border-bottom: 1px solid var(--line); padding-bottom: var(--space-3); margin-bottom: var(--space-4); flex-wrap: nowrap; }
.cd-header-title { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cd-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-header-title h2 { margin: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 30px; line-height: 1.15; font-weight: 600; }
.cd-mana-cost { display: inline-flex; gap: 3px; flex-shrink: 0; }
.cd-mana-cost .mana-pip { width: 22px; height: 22px; font-size: 15px; }

/* One row that never wraps: the name may wrap, the buttons never do. */
.card-detail__head { flex-wrap: nowrap; align-items: flex-start; }
.card-detail__head .cd-header-title { min-width: 0; }
.card-detail__nav { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.card-detail__divider { width: 1px; height: 24px; margin: 0 4px; background: var(--line-strong); }
.cd-nav-phone { display: none; }
.cd-body { display: flex; gap: var(--space-6); }
.cd-body--printings { display: flex; flex-direction: column; flex-wrap: nowrap; gap: var(--space-4); }
.card-detail__body { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 36px; }
.cd-left { display: flex; flex-direction: column; gap: var(--space-4); width: 320px; }
.cd-image-col { width: 320px; flex-shrink: 0; position: relative; }
.cd-image-col .deck-card-frame { width: 320px; height: 447px; border-radius: 4.75% / 3.4%; filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.55)); }
.cd-image-btn {
  position: relative; display: block; padding: 0; border: none; background: none; color: inherit; cursor: pointer;
  border-radius: 4.75% / 3.4%;
}
.cd-image-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.cd-image-btn::after {            /* hint that the card opens its printings */
  content: "Change printing"; position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%) translateY(4px);
  padding: 6px 12px; border-radius: var(--radius-pill); white-space: nowrap; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 82%, transparent); color: var(--text); font-size: 13px; font-weight: 600;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.15s ease, transform 0.15s ease;
}
.cd-image-btn:hover::after, .cd-image-btn:focus-visible::after { opacity: 1; transform: translateX(-50%); }
@media (hover: none) { .cd-image-btn::after { display: none; } }   /* touch has no hover, and the printing dropdown below the card does the same job */
.cd-image-col::after {      /* faint sheen across the face */
  content: ""; position: absolute; inset: 0; border-radius: 4.75% / 3.4%; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.16) 48%, transparent 60%);
}
.cd-fields { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-5); }
.cd-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); align-items: stretch; }
.cd-field { display: flex; flex-direction: column; gap: 6px; }
.cd-field--grow { flex-grow: 1; }
.fact-box { background: var(--surface-sunk); border-radius: 14px; padding: 14px 16px; }
.cd-field-label { font-size: 14px; font-weight: 600; }
.cd-field-value { min-height: var(--tap); display: flex; align-items: center; font-size: 14px; color: var(--text-muted); }
.cd-field-help { font-size: 13px; line-height: 1.4; color: var(--text-muted); }
#cd-copies-area .deck-card-qty { width: 100%; max-width: 170px; }

.cd-cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cd-cat-chip { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); box-sizing: border-box; padding: 0 4px; background: var(--line); border-radius: var(--radius-pill); }
.cd-cat-chip-star { width: var(--tap); height: var(--tap); display: flex; align-items: center; justify-content: center; color: var(--text-muted); background: none; border: none; cursor: pointer; }
.cd-cat-chip-star.is-primary { color: var(--text); cursor: default; }
.cd-cat-chip-name { font-size: 14px; font-weight: 600; padding: 0 2px; }
.cd-cat-chip-remove { width: var(--tap); height: var(--tap); border: none; border-radius: 50%; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cd-cat-chip--suggested { background: transparent; border: 1px dashed var(--line-strong); padding: 0 4px 0 12px; gap: 6px; }
.cd-cat-chip-pin { display: flex; color: var(--text-muted); }
.cd-cat-chip-suggested-label { font-size: 12px; color: var(--text-muted); }
.cd-cat-chip-add { width: var(--tap); height: var(--tap); border: none; border-radius: 50%; background: var(--line); color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cd-cat-input { width: 100%; height: var(--tap); box-sizing: border-box; background: var(--surface-sunk); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 14px; color: var(--text); font: inherit; font-size: 15px; }
.cd-cat-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.cd-cat-quick button { min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.cd-cat-quick button.is-added { opacity: 0.45; cursor: default; }
.cd-cat-manage-btn { margin-top: 6px; padding: 4px 0; border: none; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: var(--tap); }
.cat-tpl-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.cat-tpl-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--tap); padding: 0 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.cat-tpl-list li:last-child { border-bottom: none; }
.cat-tpl-empty { color: var(--text-muted); font-size: 14px; padding: 4px 2px; }

.cd-print-row { display: flex; gap: 8px; }
#cd-print-select {
  flex-grow: 1;
  min-width: 0;
  height: var(--tap);
  box-sizing: border-box;
  background: var(--surface-sunk);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
#cd-print-select:disabled { color: var(--text-muted); }
.cd-print-all-btn { flex-shrink: 0; }

.cd-pg-controls { display: flex; gap: 10px; align-items: center; }
.cd-pg-filter-wrap { position: relative; flex-grow: 1; }
.cd-pg-filter-icon { position: absolute; left: 14px; top: 13px; color: var(--text-muted); }
#cd-pg-filter { width: 100%; height: var(--tap); box-sizing: border-box; background: var(--surface-sunk); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 14px 0 42px; color: var(--text); font: inherit; font-size: 15px; }
#cd-pg-sort { min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.cd-pg-status { margin: 0; font-size: 13px; color: var(--text-muted); }
.cd-pg-empty { margin: var(--space-4) 0; color: var(--text-muted); font-size: 14px; }

.cd-pg-grid { margin: 0; padding: 14px 4px 4px; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px 20px; max-height: 55vh; overflow-y: auto; }
.cd-pg-item { display: flex; flex-direction: column; gap: 8px; }
.cd-pg-tile-btn { position: relative; padding: 0; border: none; background: transparent; cursor: pointer; display: block; width: 100%; border-radius: 8px; }
.cd-pg-frame { position: relative; aspect-ratio: 63 / 88; box-sizing: border-box; border-radius: 4.75% / 3.4%; background: var(--surface-sunk); overflow: hidden; }
.cd-pg-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cd-pg-item.is-selected .cd-pg-tile-btn { box-shadow: 0 0 0 3px var(--accent); border-radius: 8px; }
.cd-pg-pill { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); white-space: nowrap; background: var(--accent); color: var(--on-accent); border-radius: var(--radius-pill); padding: 2px 12px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.cd-pg-meta { display: flex; flex-direction: column; gap: 1px; }
.cd-pg-set-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.cd-pg-set-code { font-size: 12px; color: var(--text-muted); }

@media (max-width: 719px) {
  .cd-pg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.cd-more { display: flex; flex-wrap: wrap; gap: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-4); }
.cd-remove-btn { border-color: var(--flag-danger); color: var(--flag-danger); margin-left: auto; }
.cd-remove-btn:hover { border-color: var(--flag-danger); color: var(--flag-danger); opacity: 0.8; }

.cd-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-3); margin-top: var(--space-4); }
.cd-footer-note { font-size: 13px; color: var(--text-muted); }

/* ---------- Set as commander confirmation (step 5) ---------- */

dialog.dialog--card .cd-body--confirm { display: flex; flex-direction: column; gap: var(--space-4); max-width: 480px; }
.cd-cc-compare { display: flex; align-items: center; gap: 14px; background: var(--surface-sunk); border-radius: var(--radius); padding: 12px 14px; }
.cd-cc-compare-side { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cd-cc-compare-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.cd-cc-compare-name { font-weight: 600; }
.cd-cc-compare-pips { display: flex; gap: 3px; margin-top: 2px; }
.cd-cc-fieldset { margin: 0; padding: 0; border: none; display: flex; flex-direction: column; gap: 4px; }
.cd-cc-fieldset legend { padding: 0; margin-bottom: 6px; }
.cd-cc-radio { min-height: var(--tap); display: flex; align-items: center; gap: 10px; font-size: 15px; }
.cd-cc-radio input { width: 20px; height: 20px; margin: 0; accent-color: var(--text-muted); }
.cd-cc-partner-note { font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.cd-cc-warning { border: 1px solid var(--flag-danger); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px; }
.cd-cc-warning-icon { width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; background: var(--flag-danger); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.cd-cc-warning-text { font-size: 14px; line-height: 1.45; color: var(--text-muted); }
.cd-cc-actions { display: flex; justify-content: flex-end; gap: 10px; }

.deck-card-tile.is-off-identity .deck-card-frame { box-shadow: 0 0 0 2px var(--flag-danger); }

/* ---------- Add to another deck (step 6) ---------- */

dialog.dialog--card .cd-body--addother { display: flex; flex-direction: column; gap: var(--space-3); max-width: 560px; }
.cd-ao-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.cd-ao-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--surface-sunk); border-radius: var(--radius); }
.cd-ao-info { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cd-ao-name { font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.cd-ao-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.cd-ao-meta .mana-pip { flex-shrink: 0; }
.cd-ao-status { min-height: var(--tap); display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.cd-ao-status.is-added { color: var(--flag-cool); }
.cd-ao-empty { color: var(--text-muted); font-size: 14px; padding: var(--space-3) 0; }

@media (max-width: 900px) {
  .cd-body { flex-wrap: wrap; }
  .cd-image-col { width: 200px; }
  .cd-image-col .deck-card-frame { width: 200px; height: 279px; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  z-index: 40;
  max-width: 420px;
  width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 4px 6px 4px var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.toast-message { flex-grow: 1; font-size: 14px; font-weight: 600; }

.select-bar {
  position: fixed;
  left: var(--space-5);
  bottom: var(--space-5);
  z-index: 40;
  max-width: calc(100% - 32px);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.select-bar-count { font-size: 14px; font-weight: 700; white-space: nowrap; }
.select-bar-actions { display: flex; gap: var(--space-2); }
@media (max-width: 719px) {
  .select-bar { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); flex-wrap: wrap; }
}
.toast button {
  min-height: 44px;
  padding: 0 var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--bg);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

dialog.dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 420px;
}
dialog.dialog::backdrop {
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
/* Section 8: dialogs become full-width bottom sheets under 720px --
   native <dialog> already gives modal behavior, a backdrop and focus
   trapping for free, so this only needs to reposition it. */
@media (max-width: 719px) {
  dialog.dialog {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    max-width: none;
    max-height: 85vh;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    overflow-y: auto;
  }
  /* dialog.dialog.dialog--card's own max-width (940px, needed at desktop
     widths so the card-detail dialog has room for the image + fields
     side by side) outranks the plain dialog.dialog rule above on
     specificity alone, regardless of media query nesting -- confirmed
     live, it was pinning the dialog to 940px on a 375px viewport instead
     of collapsing to the bottom sheet. Matching specificity here to
     actually override it. */
  dialog.dialog.dialog--card { max-width: none; }
  dialog.dialog.card-detail {
    width: 100%; border-radius: 22px 22px 0 0; padding: 18px 16px 16px; border-bottom: none;
  }
  .card-detail__head .cd-header-title h2 { font-size: 22px; }
  .card-detail__head .card-detail__nav > #cd-prev-btn,
  .card-detail__head .card-detail__nav > #cd-next-btn,
  .card-detail__head .card-detail__divider { display: none; }
  .card-detail__body { grid-template-columns: 1fr; gap: var(--space-4); }
  .cd-left { width: 100%; align-items: center; }
  .cd-image-col, .cd-image-col .deck-card-frame { width: 210px; }
  .cd-image-col .deck-card-frame { height: 293px; }
  .cd-left .cd-field { align-self: stretch; }
  .cd-nav-phone { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); align-self: stretch; }
  .cd-nav-phone .btn { min-width: 0; min-height: var(--tap); }
  .cd-nav-phone .btn span { overflow: hidden; text-overflow: ellipsis; }
  .cd-row { grid-template-columns: 1fr; }
}
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.dialog-header h2 { margin: 0; }
.dialog-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
}
.dialog-row:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.dialog-row-info { flex-grow: 1; display: flex; flex-direction: column; gap: 4px; }
.dialog-row-title { font-size: 15px; font-weight: 600; }
.dialog-row-help { font-size: 13px; line-height: 1.4; color: var(--text-muted); }

/* ---------- Deck Builder: scoring, step 4 ---------- */

.deck-score-n.is-updating { opacity: 0.45; }
.deck-score-tile.is-illegal .deck-score-n { color: var(--flag-danger); }

.deck-card-badge-tooltip {
  position: absolute;
  top: -14px;
  left: calc(100% + 14px);
  width: 300px;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 5;
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}
.deck-card-badge:hover ~ .deck-card-badge-tooltip,
.deck-card-badge:focus ~ .deck-card-badge-tooltip,
.deck-card-badge-tooltip:hover {
  opacity: 1;
  pointer-events: auto;
}
.deck-card-badge-tooltip-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 600; }
.deck-card-badge-tooltip-total span:last-child { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--flag-danger); }
.deck-card-badge-tooltip ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.deck-card-badge-tooltip li { display: flex; gap: var(--space-2); }
.deck-card-badge-tooltip li .amount { flex-shrink: 0; width: 44px; font-weight: 700; color: var(--flag-danger); }
.deck-card-badge-tooltip li.is-gc { border-top: 1px solid var(--line); padding-top: var(--space-2); color: var(--text-muted); }
.deck-card-badge-tooltip li.is-gc .amount { color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; font-size: 11px; width: auto; height: 20px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

.why-line { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) 0; border-top: 1px solid var(--line); font-size: 14px; }
.why-line:first-child { border-top: none; }
.why-line-main { display: flex; justify-content: space-between; gap: var(--space-3); }
.why-line-amount { font-weight: 700; }
.why-line-amount.is-danger { color: var(--flag-danger); }
.why-line-amount.is-muted { color: var(--text-muted); }
.why-line-detail { font-size: 13px; line-height: 1.4; color: var(--text-muted); }

/* ---------- Deck Builder: card ratios, step 5 ---------- */

.ratio-row-plain {
  min-height: var(--tap);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.ratio-row-plain span:last-child { font-family: var(--font-display); font-size: 18px; font-weight: 700; }

.ratio-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.ratio-row-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.ratio-row-count { color: var(--text-muted); }
.ratio-row-count strong { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--text); }
.ratio-row-track { flex-grow: 1; height: 6px; border-radius: var(--radius-pill); background: var(--surface-sunk); overflow: hidden; }
.ratio-row-fill { height: 6px; border-radius: var(--radius-pill); transition: width 0.6s ease, background-color 0.6s ease; }
.ratio-row-fill.tw-no-transition { transition: none; }
.ratio-row-fill.is-met { background: var(--flag-cool); }
.ratio-row-fill.is-close { background: var(--flag-warm); }
.ratio-row-fill.is-short { background: var(--flag-danger); }
.ratio-row-note { margin-top: 4px; font-size: 12px; color: var(--text-muted, #a79fbd); }
.ratio-row-bottom { display: flex; align-items: center; gap: 10px; }
.ratio-row-status { width: 64px; flex-shrink: 0; display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.ratio-row-status.is-met { color: var(--flag-cool); justify-content: flex-end; }
.ratio-row-status.is-close { color: var(--flag-warm); justify-content: flex-end; text-align: right; }
.ratio-row-status.is-short { color: var(--flag-danger); justify-content: flex-end; text-align: right; }

.ratio-finisher-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-top: 6px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}
.ratio-finisher-row span:last-child { font-size: 13px; font-weight: 500; }

.ratio-tpl-row {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border-top: 1px solid var(--line);
}
.ratio-tpl-row label { font-size: 15px; font-weight: 600; }
.ratio-tpl-row label span { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.ratio-tpl-stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-sunk); }
.ratio-tpl-stepper button { width: var(--tap); height: var(--tap); border: none; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ratio-tpl-stepper input {
  width: 48px;
  height: 44px;
  box-sizing: border-box;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

/* ---------- Deck Builder: combos, step 6 ---------- */

.combo-card {
  background: var(--surface-sunk);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.combo-card + .combo-card { margin-top: var(--space-2); }
.combo-card-top { display: flex; justify-content: space-between; gap: var(--space-3); align-items: flex-start; }
.combo-card-cards { font-size: 14px; font-weight: 600; }
.combo-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  border-radius: 4px;
  padding: 1px 5px;
  border: 1px solid var(--flag-cool);
}
.combo-tag.is-danger { border-color: var(--flag-danger); }
.combo-tag.is-warm { border-color: var(--flag-warm); }
.combo-card-description { font-size: 13px; color: var(--text-muted); }

.combos-status-row { display: flex; align-items: center; gap: var(--space-3); padding-top: 2px; }
.combos-status-text { flex-grow: 1; font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.combos-empty { font-size: 14px; color: var(--text-muted); }

.combos-loading { display: flex; align-items: center; gap: var(--space-3); }
.combos-spinner {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: combos-spin 0.8s linear infinite;
}
@keyframes combos-spin { to { transform: rotate(360deg); } }

/* ---------- Deck Builder: Mana section, step 7 ---------- */

.mana-section { margin-top: var(--space-4); }
.mana-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.mana-header h2 { margin: 0; font-size: 26px; line-height: 1.1; }
.mana-header-note { flex-shrink: 0; font-size: 13px; font-weight: 500; color: var(--text-muted); }

.mana-row { display: flex; gap: var(--space-6); align-items: stretch; margin-top: var(--space-5); flex-wrap: wrap; }
.mana-pips-sources { width: 540px; max-width: 100%; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.mana-pips-sources h3 { margin: 0; font-size: 14px; }

.mana-stat-block { display: flex; flex-direction: column; gap: 6px; }
.mana-stat-label-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.mana-stacked-bar { height: 32px; border-radius: 8px; overflow: hidden; display: flex; }
.mana-stacked-bar-segment {
  color: var(--on-mana);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: inset 0 0 0 1px var(--mana-outline);
  overflow: hidden;
  white-space: nowrap;
}
.mana-stacked-bar-segment .mana-glyph { font-family: "Mana"; font-size: 15px; font-weight: 400; }

.mana-color-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.mana-color-card { background: var(--surface-sunk); border-radius: var(--radius); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.mana-color-card-head { display: flex; align-items: center; gap: 8px; }
.mana-color-card-head .mana-pip { width: 24px; height: 24px; font-size: 15px; }
.mana-color-card-head span:last-child { font-size: 14px; font-weight: 600; }
.mana-color-stat-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.mana-color-stat-n { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.1; }
.mana-color-stat-detail { font-size: 12px; color: var(--text-muted); }

.mana-curve-col { flex-grow: 1; min-width: 320px; display: flex; flex-direction: column; gap: var(--space-3); border-left: 1px solid var(--line); padding-left: var(--space-6); }
.mana-curve-col-head { display: flex; justify-content: space-between; align-items: baseline; }
.mana-curve-col-head h3 { margin: 0; font-size: 14px; }
.mana-curve-col-head .mana-curve-avg { font-size: 14px; color: var(--text-muted); }
.mana-curve-col-head .mana-curve-avg strong { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--text); }
.mana-curve-col-head .mana-curve-total { margin-left: 10px; }

.mana-curve-chart { flex-grow: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.mana-curve-bars {
  height: 230px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}
.mana-curve-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mana-curve-bar-n { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.mana-curve-bar { width: 100%; max-width: 56px; border-radius: 4px 4px 0 0; background: var(--text-muted); }
.mana-curve-bar.is-tallest { background: var(--accent); }
.mana-curve-axis { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 14px; padding-top: 6px; }
.mana-curve-axis span { text-align: center; font-size: 14px; font-weight: 700; }

.mana-split { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--space-3); }
.mana-split-head { display: flex; align-items: center; gap: 12px; }
.mana-split-head h3 { margin: 0; flex-grow: 1; font-size: 14px; }
.mana-split-head select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.mana-split-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.mana-split-card { background: var(--surface-sunk); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.mana-split-card-head { display: flex; align-items: center; gap: 8px; }
.mana-split-card-head .mana-pip { width: 22px; height: 22px; font-size: 14px; }
.mana-split-card-head span:nth-child(2) { flex-grow: 1; font-size: 14px; font-weight: 600; }
.mana-split-card-head span:last-child { font-size: 13px; color: var(--text-muted); }
.mana-split-bars {
  height: 110px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}
.mana-split-bar-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mana-split-bar-n { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.mana-split-bar { width: 100%; border-radius: 3px 3px 0 0; box-shadow: inset 0 0 0 1px var(--mana-outline); }
.mana-split-axis { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.mana-split-axis span { text-align: center; font-size: 12px; font-weight: 700; }

.mana-empty { padding: var(--space-4); color: var(--text-muted); font-size: 14px; }

@media (max-width: 900px) {
  .mana-curve-col { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: var(--space-5); }
}
@media (max-width: 480px) {
  .mana-color-grid { grid-template-columns: 1fr; }
}

.admin-subhead { font-size: 15px; margin: var(--space-3) 0 var(--space-2); }
.admin-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.admin-actions .btn { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.admin-search { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); }
.admin-search input { flex: 1; max-width: 320px; }
.admin-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
.admin-tile { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.admin-tile-value { font-size: 26px; font-weight: 600; line-height: 1.1; }
.admin-tile-label { font-size: 13px; color: var(--text-muted); }
.admin-tile-note { font-size: 12px; color: var(--text-muted); }
.admin-bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.admin-bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.admin-bar { display: block; width: 100%; min-height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0.85; }
.admin-bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin: var(--space-1) 0 var(--space-3); }
.admin-details { margin-top: var(--space-2); font-size: 13px; color: var(--text-muted); }
.admin-details summary { cursor: pointer; color: var(--text); }

.auth-divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0 var(--space-3); color: var(--text-muted); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn-google { width: 100%; display: flex; align-items: center; justify-content: center; gap: var(--space-2); background: #fff; color: #1f1f1f; border: 1px solid #dadce0; min-height: 44px; font-weight: 500; }
.btn-google:hover { background: #f8f9fa; border-color: #c6c9cc; color: #1f1f1f; }
.btn-google:disabled { opacity: 0.6; cursor: default; }

/* Phone touch targets: anything you tap reaches 44px. */
@media (max-width: 720px) {
  .brand, .site-footer__brand { min-height: var(--tap); }
  .site-footer-links a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-1); }
  .deck-card__menu { width: var(--tap); height: var(--tap); }
}

@media (min-width: 1600px) {
  .site-wrap--wide .deck-header-info h1 { font-size: 68px; }
  .site-wrap--wide .deck-header-info .deck-title-input { font-size: 68px; }
  .site-wrap--wide .deck-score-tile { width: 196px; }
  .site-wrap--wide .deck-score-n { font-size: 68px; }
}

.auth-diag { margin: calc(-1 * var(--space-2)) 0 var(--space-3); font-size: 12px; color: var(--text-muted); word-break: break-word; }

/* Card dialog: the header and footer stay in view and only the middle scrolls, so
   the footer (and Done) is never off-screen on a short window. */
dialog.dialog.card-detail[open] { display: flex; flex-direction: column; max-height: calc(100vh - 32px); overflow: hidden; }
dialog.dialog.card-detail .cd-header, dialog.dialog.card-detail .cd-footer { flex-shrink: 0; }
dialog.dialog.card-detail .cd-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px 4px 2px 0; }
@media (max-width: 719px) { dialog.dialog.card-detail[open] { max-height: 88vh; } }

/* "On paper" shows a range ("1 or 2") as text, smaller than the single big number. */
.deck-score-n.is-range { font-size: 30px; line-height: 1.1; }

/* ---------- Deck visibility (deck settings) and the Share button ---------- */
.deck-crumbs__right { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.btn--small { min-height: 34px; padding: 0 12px; font-size: 13px; }
#share-btn[data-visibility="unlisted"], #share-btn[data-visibility="public"] { border-color: var(--accent); color: var(--accent); }
.dialog-row--stack { flex-direction: column; align-items: stretch; gap: var(--space-3); }
.share-link-box { display: flex; gap: var(--space-2); }
.share-link-box input {
  flex: 1 1 auto; min-width: 0; min-height: var(--control-h); padding: 0 var(--space-3); font: inherit; font-size: 14px;
  background: var(--surface-sunk); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-control);
}
.share-error { color: var(--flag-danger); }
@media (max-width: 720px) { .deck-crumbs__right { flex: 1 1 100%; flex-shrink: 1; min-width: 0; flex-wrap: wrap; justify-content: flex-start; } }

/* ---------- Shared deck page (public, read-only) ---------- */
.shared-intro { margin: var(--space-4) 0 var(--space-3); }
.shared-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-5) 0 var(--space-4); }
.shared-qty {
  position: absolute; right: 8px; top: 8px; z-index: 2; padding: 2px 9px; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--bg) 80%, transparent); color: var(--text); font-size: 13px; font-weight: 700;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.shared-hero .deck-hero-side { justify-content: flex-end; }

/* Deck name: click to rename in place */
.deck-title-edit { cursor: text; border-radius: 8px; width: fit-content; max-width: 100%; }
.deck-title-edit:hover { background: color-mix(in srgb, var(--text) 8%, transparent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--text) 8%, transparent); }
.deck-title-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.deck-title-input { display: block; width: min(100%, 640px); box-sizing: border-box; margin: 0; padding: 0 8px; border: 1px solid var(--accent); border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--text); font: inherit; font-family: var(--font-display); font-size: inherit; font-weight: inherit; line-height: inherit; }
.deck-title-input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }

/* Group by Category: a card in a second category shows dimmed there; its main home shows it in full */
.deck-card-tile.is-secondary .deck-card-frame { opacity: 0.5; filter: grayscale(0.65); transition: opacity 120ms ease, filter 120ms ease; }
.deck-card-tile.is-secondary:hover .deck-card-frame, .deck-card-tile.is-secondary:focus-within .deck-card-frame { opacity: 0.9; filter: none; }

/* Suggested cards: a strip beside the commander (EDHREC's most common cards for it that the deck lacks) */
.deck-suggest { list-style: none; min-width: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.deck-suggest--note { color: var(--text-muted); font-size: 14px; align-self: center; }
.deck-suggest__head { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.deck-suggest__head h3 { margin: 0; font-size: 22px; font-weight: 600; }
.deck-suggest__note { color: var(--text-muted); font-size: 13px; }
.deck-suggest__toggle { margin-left: auto; border: none; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: 8px; min-height: 36px; }
.deck-suggest__toggle:hover, .deck-suggest__toggle:focus-visible { color: var(--text); background: var(--line); outline: none; }
/* one row of tiles: as many as fit beside the commander (fitSuggestions() hides the rest) */
.deck-suggest__grid {
  margin: 0; padding: 0 0 14px; list-style: none; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 12vw, 230px), 1fr));
  gap: 0 var(--space-4);
}
.deck-suggest__grid > li[hidden] { display: none; }
.deck-suggest__pct { position: absolute; top: 6px; right: 6px; z-index: 2; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 82%, transparent); color: var(--text);
  font: 700 12px/1.4 var(--font-body); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
.deck-suggest__actions { display: flex; align-items: center; gap: 8px; }
.deck-suggest__actions .btn { flex: 1; padding-left: 8px; padding-right: 8px; }
@media (max-width: 720px) {
  .deck-suggest { grid-column: 1 / -1 !important; }
  .deck-suggest__grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 150px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
  .deck-suggest__grid > li { scroll-snap-align: start; }
  .deck-suggest__actions .btn { min-height: 44px; }
}

/* ==========================================================================
   Decklist classifier (/classifier): input, summary bar, verdict, panels, cards
   ========================================================================== */
.cl-hero { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 48px; align-items: start; padding: 56px 0 64px; }
.cl-hero__copy { display: flex; flex-direction: column; gap: var(--space-3); }
.cl-hero h1 { margin: 0; font-family: var(--font-display); font-size: 56px; line-height: 1.02; font-weight: 600; letter-spacing: -0.015em; }
.cl-hero__lede { margin: 0; font-size: 17px; color: var(--text-muted); max-width: 460px; }
.cl-gets { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.cl-gets li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; color: var(--text-muted); }
.cl-gets b { font-family: var(--font-display); font-size: 30px; line-height: 1; color: var(--accent); min-width: 36px; }
.cl-gets strong { color: var(--text); }
.cl-form { padding: 24px 26px; display: flex; flex-direction: column; gap: 16px; }
.cl-form__title { margin: 0; font-size: 22px; }
.cl-form textarea { width: 100%; box-sizing: border-box; min-height: 300px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface-sunk); color: var(--text); font: 14px/1.55 var(--font-body); resize: vertical; }
.cl-form input[type="url"] { width: 100%; box-sizing: border-box; }
.cl-form__meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.cl-form__hint, .cl-form__hint-block { font-weight: 500; color: var(--text-muted); font-size: 13px; }
.cl-form__hint-block { margin: 0 0 8px; }
.cl-form__cmd { display: flex; gap: 12px; flex-wrap: wrap; }
.cl-form__actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.cl-form__example { font-size: 14px; font-weight: 600; }
.cl-form .btn--primary { min-height: 48px; padding: 0 24px; font-size: 15px; }
.cl-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.cl-tabs [role="tab"] { min-height: 44px; padding: 0 14px; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--text-muted); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; }
.cl-tabs [role="tab"]:hover { color: var(--text); }
.cl-tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.cl-decks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.cl-decks__none { font-size: 14px; color: var(--text-muted); }
.cl-deck { width: 100%; min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; text-align: left;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-sunk); color: var(--text); font: inherit; cursor: pointer; }
.cl-deck:hover { border-color: var(--line-strong); }
.cl-deck span { font-size: 13px; color: var(--text-muted); }
@media (max-width: 900px) {
  .cl-hero { grid-template-columns: 1fr; gap: 24px; padding: 28px 0 40px; }
  .cl-hero h1 { font-size: 38px; }
  .cl-form { padding: 18px 16px; }
  .cl-form .btn--primary { width: 100%; }
}

.cl-summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 18px; border-radius: 16px; margin-bottom: var(--space-4); }
.cl-summary__deck { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cl-summary__name { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.cl-summary__meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--text-muted); }
.cl-summary .btn { min-height: 44px; }
@media (max-width: 720px) { .cl-summary { flex-wrap: wrap; } .cl-summary__deck { flex-basis: 100%; } }

.cl-verdict { margin-bottom: var(--space-5); }
.cl-verdict__bracket { display: flex; align-items: flex-end; gap: 18px; }
.cl-verdict__num { font: 700 120px/0.8 var(--font-display); color: var(--accent); text-shadow: 0 6px 30px color-mix(in srgb, var(--accent) 30%, transparent); }
.cl-verdict__name { font: 600 48px/1 var(--font-display); padding-bottom: 6px; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5); }
.cl-verdict__line { margin: var(--space-2) 0 0; font: italic 500 22px/1.35 var(--font-display); text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5); }
.cl-context-chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 999px; margin-top: var(--space-2);
  background: color-mix(in srgb, var(--surface) 72%, transparent); border: 1px solid color-mix(in srgb, var(--text-muted) 25%, transparent);
  color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; }
.cl-context-chip:hover { border-color: var(--text-muted); }
.cl-feels .deck-score-n { color: var(--accent); }
@media (max-width: 720px) {
  .cl-verdict__num { font-size: 76px; } .cl-verdict__name { font-size: 30px; } .cl-verdict__line { font-size: 17px; }
}

.cl-results { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; margin-bottom: var(--space-5); }
.cl-main, .cl-side { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
@media (max-width: 1000px) { .cl-results { grid-template-columns: 1fr; } }
.cl-panel { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.cl-panel .section-head { margin-bottom: 0; max-width: none; }
.cl-panel__sub { font-size: 14px; color: var(--text-muted); }
.cl-why-toggle { align-self: flex-start; }
.cl-why[hidden] { display: none; }
.cl-panel__note { margin: 0; font-size: 13px; color: var(--text-muted); }
.cl-side__h { margin: 0; font-size: 18px; }
.cl-why { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.cl-reasons { margin: 0; padding-left: 18px; font-size: 14px; }
.why-line__sub { font-size: 13px; line-height: 1.45; color: var(--text-muted); }

.cl-found { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.cl-found li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--surface-sunk); border: 1px solid var(--line); }
.cl-found__n { font: 700 34px/1 var(--font-display); min-width: 26px; }
.cl-found__label { font-weight: 700; }
.cl-found__cards { font-size: 13px; }
.cl-found__note { font-size: 12px; color: var(--text-muted); }
.cl-found__more { display: none; align-self: flex-start; min-height: 44px; background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.cl-none { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cl-none > span:first-child { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-right: 4px; }
.cl-none__chip { font-size: 12px; color: var(--text-muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
@media (max-width: 720px) {
  .cl-found { grid-template-columns: 1fr; }
  .cl-found li.is-extra { display: none; }
  .cl-found.is-expanded li.is-extra { display: flex; }
  .cl-found__more { display: inline-block; }
  .cl-none { display: none; }
  .cl-found.is-expanded ~ .cl-none { display: flex; }
}

.cl-combos { display: flex; flex-direction: column; gap: 12px; }
.cl-combo { padding: 14px 16px; border-radius: 14px; background: var(--surface-sunk); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.cl-combo__cards { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cl-combo__plus { color: var(--text-muted); font-weight: 700; }
.cl-combo__spacer { flex: 1; }
.cl-combo__card { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--surface-raised); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.cl-combo__card img { width: 22px; border-radius: 3px; }
.cl-combo__tag { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--text); border: 1px solid var(--flag-warm); border-radius: 4px; padding: 1px 6px; }
.cl-combo__tag--danger { border-color: var(--flag-danger); }
.cl-combo__tag--cool { border-color: var(--flag-cool); }
.cl-combo__value { position: static; }
.cl-combo__result { margin: 0; font-size: 14px; }
.cl-combo__needs { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-muted); }
.cl-combo__steps { margin: 6px 0 0; font-size: 13px; color: var(--text-muted); white-space: pre-line; }
.cl-combo details > summary { cursor: pointer; min-height: 32px; font-size: 14px; font-weight: 600; }

.cl-comp { list-style: none; margin: 0; padding: 0; }
.cl-comp li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.cl-comp li:first-child { border-top: 0; }
.cl-note { margin: 0; font-size: 14px; color: var(--text-muted); }
.cl-note strong { color: var(--text); }
.cl-limits { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; gap: 8px; }
.cl-panel details > summary { cursor: pointer; min-height: 32px; font-weight: 600; }
.cl-next { display: flex; flex-direction: column; gap: 8px; }
.cl-next .btn { min-height: 44px; justify-content: center; }

.cl-cards { padding: 22px 24px 26px; display: flex; flex-direction: column; gap: 22px; }
.cl-cards__head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cl-cards__head h2 { margin: 0; flex: 1 1 auto; font: 600 28px/1.1 var(--font-display); }
.cl-filter { flex: 0 1 260px; }
.cl-group { display: flex; align-items: center; gap: 8px; }
.cl-group__label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.cl-group__select { min-height: 44px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-sunk); color: var(--text); font: inherit; padding: 0 10px; }
.cl-unmatched { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.cl-unmatched > div { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.cl-unmatched .btn { min-height: 44px; }
.cl-qty { position: absolute; left: 8px; bottom: 44px; padding: 1px 8px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(0, 0, 0, 0.72); color: #fff; }
.cl-empty { margin: 0; font-size: 14px; color: var(--text-muted); }
.cl-cards .deck-group-header h3 { margin: 0; font-size: 24px; font-weight: 600; }
.cl-cards .deck-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
@media (max-width: 1100px) { .cl-cards .deck-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .cl-cards { padding: 16px 14px 20px; }
  .cl-cards .deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cl-filter { flex-basis: 100%; max-width: none; order: 5; }
}

.cl-flag-row { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-top: 1px solid var(--line); }
.cl-flag-row:first-child { border-top: 0; }
.cl-flag-row img { width: 96px; border-radius: 5px; flex-shrink: 0; }
.cl-flag-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cl-flag-row__top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cl-flag-row__type { font-size: 13px; color: var(--text-muted); }
.cl-flag-row__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cl-flag-row .deck-card-badge-circle { position: static; flex-shrink: 0; }
.cl-tag { font-size: 11px; font-weight: 700; color: var(--text); border-radius: 999px; padding: 2px 8px; white-space: nowrap;
  border: 1px solid var(--tag-c, var(--line)); background: color-mix(in srgb, var(--tag-c, var(--line)) 14%, transparent); }
.cl-tag--gc { --tag-c: var(--accent); }
.cl-tag--tutor, .cl-tag--fast { --tag-c: var(--flag-warm); }
.cl-tag--notable, .cl-tag--banned { --tag-c: var(--flag-danger); }
.cl-tag--combo { --tag-c: var(--flag-cool); }
.cl-tag--extra, .cl-tag--mld, .cl-tag--skip, .cl-tag--free { --tag-c: var(--flag-warm); }
@media (max-width: 720px) {
  .cl-cards__head .segmented button, .cl-context-chip { min-height: 44px; }
}
.cl-form input[type="url"] { padding: var(--space-3) var(--space-4); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); font: inherit; font-size: 15px; }
.cl-form input[type="url"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.cl-form textarea { background: var(--surface-sunk); }
.cl-hover-zoom { position: fixed; z-index: 200; width: 300px; border-radius: 14px; pointer-events: none; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); border: 1px solid var(--line-strong); }
.cl-hover-zoom[hidden] { display: none; }
.cl-flag-row { padding: 14px; }
.cl-flag-row__top strong { font-size: 16px; }
@media (max-width: 720px) { .cl-flag-row img { width: 72px; } }
/* Used on its own inside a column (the import form's "which commander?" ask), the group's flex-basis of
   240px became a 240px height and left a gap between the input and its suggestions. */
.field > .commander-input-group { flex: 0 0 auto; }
.commander-input-row, .cl-form__cmd { align-items: flex-start; }
.partner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.partner-actions .btn { min-height: 44px; }

/* The group only grows to fill a row when it sits in one (the create and classifier forms); on its own
   in a column (the import ask, the partner row in deck settings) its flex-basis became a 240px height. */
.commander-input-group { flex: 0 0 auto; }
.commander-input-row > .commander-input-group, .cl-form__cmd > .commander-input-group { flex: 1 1 240px; }
.deck-suggest__tile img.deck-card-image, .shared-deck img.deck-card-image { cursor: zoom-in; }
.deck-group img.deck-card-image { cursor: zoom-in; }
dialog.card-lightbox { width: min(92vw, 420px); background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 16px; padding: 16px; text-align: center; }
dialog.card-lightbox::backdrop { background: rgba(5, 4, 12, 0.72); }
.card-lightbox__img { display: block; width: 100%; max-height: 78vh; object-fit: contain; border-radius: 12px; }
.card-lightbox__name { margin: 10px 0; font-weight: 600; }
.card-lightbox .btn { min-height: 44px; }
/* On a phone .cd-body wraps (the card and its fields stack). The column views of this dialog must not:
   a wrapping column that runs out of height starts a second column off to the right, which pushed the
   printings grid out of sight. */
.cd-body.cd-body--printings, .cd-body.cd-body--confirm, .cd-body.cd-body--addother { flex-wrap: nowrap; }

/* shared deck page: actions row, the form button sits in line with the others, and the Why panel */
.shared-actions { flex-wrap: wrap; }
.shared-classify { display: inline-flex; margin: 0; }
.shared-why { margin-bottom: var(--space-5); }
.shared-why .section-head { max-width: none; }
.deck-card-tile .deck-card-badge { z-index: 2; }

/* "Add a card" docked to the bottom of the screen while the deck is scrolled past its toolbar */
.deck-search.is-docked {
  position: fixed; z-index: 45; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  width: min(560px, calc(100vw - 24px)); max-width: none; flex: none;
  padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.deck-search.is-docked input[type="search"] { margin: 0; }
.deck-search.is-docked .deck-search-icon { left: 20px; top: calc(6px + var(--control-h) / 2 - 9px); }
.deck-search.is-docked .commander-autocomplete { top: auto; bottom: calc(100% + 6px); max-height: min(50vh, 360px); }
body:has(.select-bar) .deck-search.is-docked { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
/* the pips and the commander's name: room between them where the line is a block (phones) */
@media (max-width: 720px) { .deck-header-meta > span[role="img"] { margin-right: 8px; vertical-align: middle; } }

/* badge explanations (tag-tips.js) */
[data-tip] { cursor: help; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
[data-tip]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tw-tip { position: fixed; z-index: 400; padding: 10px 12px; border-radius: 10px; background: var(--surface-raised); color: var(--text);
  border: 1px solid var(--line-strong); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5); font-size: 13px; line-height: 1.45; font-weight: 500;
  letter-spacing: normal; text-transform: none; pointer-events: none; }
.tw-tip[hidden] { display: none; }

/* leaderboard: your own row, and your rank when you are outside the top 20 */
.leaderboard-table tr.is-me td { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 700; }
.leaderboard-table tr.is-me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.you-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-left: 6px; }
.leaderboard-table .your-rank__gap td { text-align: center; color: var(--text-muted); padding: 2px 0; letter-spacing: 0.3em; }
.leaderboard-note { margin-top: var(--space-3); font-size: 13px; color: var(--text-muted); }

/* deck settings: version history */
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-sunk); }
.history-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.history-row__text small { font-size: 12px; color: var(--text-muted); }
.history-row .btn { min-height: 44px; flex-shrink: 0; }

.cd-flip-btn {      /* a round icon on the card's right edge, mostly off the card so its text stays readable */
  position: absolute; right: -14px; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.cd-flip-btn:hover { background: var(--surface-sunk); }
.cd-flip-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* ---------- Filter this deck (toolbar) ---------- */
.deck-filter { display: flex; align-items: center; gap: var(--space-2); flex: 0 1 260px; min-width: 160px; }
.deck-filter input[type="search"] {
  width: 100%; min-height: var(--control-h); padding: 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-sunk); color: var(--text); font: inherit;
}
.deck-filter input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.deck-filter-note { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.deck-filter-note[hidden] { display: none; }

/* Category headings take the color of where they stand against the card ratio targets. */
.deck-group-header.ratio-met h2 { color: var(--flag-cool); }
.deck-group-header.ratio-close h2 { color: var(--flag-warm); }
.deck-group-header.ratio-short h2 { color: var(--flag-danger); }
.deck-group-header.ratio-met .deck-group-count { color: var(--flag-cool); background: color-mix(in srgb, var(--flag-cool) 16%, transparent); }
.deck-group-header.ratio-close .deck-group-count { color: var(--flag-warm); background: color-mix(in srgb, var(--flag-warm) 18%, transparent); }
.deck-group-header.ratio-short .deck-group-count { color: var(--flag-danger); background: color-mix(in srgb, var(--flag-danger) 16%, transparent); }

/* Typing a quantity: the number between - and + is a button that turns into a small box. */
.deck-card-qty-n.is-editable { cursor: text; border-radius: 6px; padding: 0 4px; min-width: 24px; text-align: center; }
.deck-card-qty-n.is-editable:hover { background: var(--surface-sunk); }
.deck-card-qty-n.is-editable:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.deck-card-qty-input {
  width: 56px; min-height: 32px; padding: 0 6px; text-align: center; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--surface-sunk); color: var(--text); font: 700 16px/1 var(--font-display);
}

/* ---------- Scrollbars that match the rest of the site (thin, quiet, on the dark surface) ---------- */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-muted) 55%, transparent) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 45%, transparent); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text-muted) 75%, transparent); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }
.deck-builder-sidebar { padding-right: 4px; }

/* ---------- Deck health panels: drag to reorder, eye to hide ---------- */
.panel.has-tools { position: relative; }
.panel-tools { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s ease; z-index: 2; }
.panel.has-tools:hover .panel-tools, .panel-tools:focus-within, .panel.is-dragging .panel-tools { opacity: 1; }
@media (hover: none) { .panel-tools { opacity: 0.55; } }
.panel-tool { width: 32px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: none; border-radius: 8px; background: transparent; color: var(--text-muted); cursor: pointer; }
.panel-tool:hover { background: var(--surface-sunk); color: var(--text); }
.panel-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.panel-grip { cursor: grab; touch-action: none; }
.panel.is-dragging { opacity: 0.85; box-shadow: 0 0 0 2px var(--accent), 0 18px 40px rgba(0, 0, 0, 0.45); }
body.is-reordering, body.is-reordering * { cursor: grabbing !important; user-select: none; }
.sidebar-restore { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.sidebar-restore[hidden] { display: none; }

/* ---------- Commander lookup: tabs, the average decklist, Start from here ---------- */
.cl-tabs { display: inline-flex; }
.category-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.avg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin: var(--space-5) 0 var(--space-4); }
.avg-sub { margin: var(--space-1) 0 0; max-width: 640px; font-size: 14px; color: var(--text-muted); }
.avg-grid .deck-card-frame { position: relative; }
.avg-pct {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px;
  font: 700 13px/1.4 var(--font-body); color: var(--text); background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid var(--line-strong); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}

/* ---------- Commander lookup: pick your own cards ---------- */
.pick-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.pick-box { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.card-pct-list li.is-picked > .pick-row span { color: var(--text); font-weight: 600; }
.card-image-item, .deck-card-tile[data-card] { position: relative; }
.pick-btn {
  position: absolute; top: 6px; left: 6px; z-index: 3; width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid var(--line-strong); background: color-mix(in srgb, var(--bg) 78%, transparent); color: transparent; cursor: pointer;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.pick-btn:hover { border-color: var(--text); }
.pick-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pick-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.card-image-item.is-picked img:not(.thumb-zoom), .deck-card-tile.is-picked .deck-card-frame { box-shadow: 0 0 0 3px var(--accent), 0 0 22px color-mix(in srgb, var(--accent) 45%, transparent); }
#panel-average .deck-card-tile[data-card] { cursor: pointer; }
.pick-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: var(--radius-panel); border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, var(--surface-raised), var(--surface)); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.pick-bar[hidden] { display: none; }
.pick-bar__count { font-size: 14px; font-weight: 600; }
body.has-pick-bar { padding-bottom: 96px; }

/* ---------- Commander lookup on the wide layout: larger type and pictures, bars kept to a readable length ---------- */
@media (min-width: 1000px) {
  .site-wrap--wide .commander-header { gap: var(--space-6); }
  .site-wrap--wide .commander-header img { width: 230px; }
  .site-wrap--wide .commander-name { font-size: 40px; }
  .site-wrap--wide .commander-type { font-size: 18px; }
  .site-wrap--wide .commander-sample-size, .site-wrap--wide .commander-common-bracket, .site-wrap--wide .commander-links { font-size: 16px; }
  .site-wrap--wide .category-block h2 { font-size: 26px; }
  .site-wrap--wide .bracket-bars { max-width: 1100px; }
  .site-wrap--wide .bracket-bars li { font-size: 17px; margin-bottom: var(--space-3); }
  .site-wrap--wide .bar-track { height: 14px; }
  .site-wrap--wide .card-pct-list { gap: 6px var(--space-6); }
  .site-wrap--wide .card-pct-list li { font-size: 16px; padding-bottom: 5px; }
  .site-wrap--wide .card-image-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-4) var(--space-3); }
  .site-wrap--wide .card-image-item { font-size: 15px; }
}
@media (min-width: 1700px) {
  .site-wrap--wide .card-image-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* Optimize lands dialog */
.land-opt-resize { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); font-size: 14px; }
.land-opt-sections { max-height: 58vh; overflow-y: auto; margin: var(--space-3) 0; padding-right: var(--space-2); }
.land-opt-sections .deck-group { margin-top: var(--space-5); }
.land-opt-sections .deck-group:first-child { margin-top: 0; }
.land-opt-sections .deck-group-header h2 { font-size: 18px; }
.land-opt-sections .deck-grid { grid-template-columns: repeat(auto-fill, minmax(clamp(92px, 9vw, 128px), 1fr)); gap: 14px var(--space-3); }
.land-opt-section--remove .deck-card-frame { filter: grayscale(0.6) drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35)); opacity: 0.7; box-shadow: 0 0 0 2px var(--flag-danger); }
.land-opt-section--keep .deck-card-frame { opacity: 0.85; }
.land-opt-qty { position: absolute; top: 6px; right: 6px; z-index: 2; min-width: 22px; padding: 1px 7px; border-radius: var(--radius-pill); background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; text-align: center; }
.land-opt-empty { margin: 0; font-size: 14px; color: var(--text-muted); }
.land-budget-field { display: flex; align-items: center; gap: var(--space-1); }
.land-budget-field input { width: 84px; }
.land-opt-price { position: absolute; left: 6px; bottom: 6px; z-index: 2; padding: 1px 7px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--text); font-size: 12px; font-weight: 600; }
.land-budget-field { margin: var(--space-2) 0; font-size: 14px; }
.land-budget-field input { padding: 6px 10px; border-radius: var(--radius-input, 8px); border: 1px solid var(--line-strong); background: var(--surface-sunk); color: var(--text); font: inherit; }
/* No browser spinner arrows on the land limit box; type a number (arrow keys still step it) */
.land-budget-field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.land-budget-field input[type="number"]::-webkit-outer-spin-button,
.land-budget-field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Back to top (deck builder): bottom right, above the docked add-a-card box on a phone */
.back-to-top {
  position: fixed; z-index: 44; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface-raised); color: var(--text);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45); cursor: pointer;
}
.back-to-top:hover { background: var(--surface); }
.back-to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 720px) { .back-to-top { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }

/* Card ratios: the collapsed "Tags" section of plain counts */
.ratio-tags { margin-top: var(--space-2); list-style: none; }
.ratio-tags summary { cursor: pointer; padding: 10px 2px; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.ratio-tags summary:hover { color: var(--text); }
.ratio-tags ul { margin: 0; padding: 0; list-style: none; }

/* Import cards dialog */
.import-text { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: var(--radius-input, 8px); border: 1px solid var(--line-strong); background: var(--surface-sunk); color: var(--text); font: inherit; font-size: 14px; resize: vertical; }
.import-controls { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-3) 0; }
.land-opt-section--skip .deck-card-frame { opacity: 0.45; filter: grayscale(0.7) drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35)); }
.land-opt-section--add .deck-card-tile.is-off-identity .deck-card-frame { box-shadow: 0 0 0 2px var(--flag-danger); }
.import-flag { position: absolute; left: 6px; bottom: 6px; z-index: 2; padding: 1px 7px; border-radius: var(--radius-pill); background: var(--flag-danger); color: var(--on-accent); font-size: 11px; font-weight: 700; }
.import-tags { position: absolute; left: 6px; top: 6px; z-index: 2; max-width: calc(100% - 44px); padding: 1px 7px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--text); font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-notfound { margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--text-muted); }

/* Import from Archidekt (decks page) */
.btn-link { background: none; border: none; padding: 0; font: inherit; font-size: 14px; color: var(--link); text-decoration: underline; cursor: pointer; }
.btn-link:hover { color: var(--text); }
.acct-find { display: flex; gap: var(--space-2); margin: var(--space-2) 0 var(--space-3); }
.acct-find input { flex: 1; min-width: 0; padding: 8px 12px; border-radius: var(--radius-input, 8px); border: 1px solid var(--line-strong); background: var(--surface-sunk); color: var(--text); font: inherit; }
.acct-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-3) 0 var(--space-2); }
.acct-toolbar__buttons { display: flex; gap: var(--space-3); }
.acct-list { margin: 0; padding: 0; list-style: none; max-height: 42vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.acct-row:last-child { border-bottom: none; }
.acct-row label { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; }
.acct-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.acct-row__text { display: flex; flex-direction: column; min-width: 0; }
.acct-row__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-row__meta { font-size: 13px; color: var(--text-muted); }
.acct-row__tag { font-size: 12px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--line-strong); border-radius: var(--radius-pill); padding: 1px 8px; white-space: nowrap; }
.acct-row.is-done { opacity: 0.6; }
.acct-progress { height: 6px; margin: var(--space-3) 0; border-radius: var(--radius-pill); background: var(--surface-sunk); overflow: hidden; }
.acct-progress__bar { height: 6px; width: 0; background: var(--accent); transition: width 0.3s ease; }
.acct-results { margin: 0 0 var(--space-3); padding: 0; list-style: none; font-size: 14px; }
.acct-results .is-failed { color: var(--flag-danger); padding: 2px 0; }

/* ---------- "On paper" popup: Game Changers and combo breakdown ---------- */
#bracket-tile { cursor: pointer; transition: border-color 0.15s ease; }
#bracket-tile:hover, #bracket-tile:focus-visible { border-color: var(--accent); }
dialog.paper-dialog {
  width: min(900px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 48px); padding: 24px 28px 26px; box-sizing: border-box;
  border: 1px solid var(--line-strong); border-radius: 22px; color: var(--text); overflow-y: auto;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 160px), linear-gradient(180deg, var(--surface-raised), var(--surface));
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6), inset 0 1px 0 color-mix(in srgb, var(--text) 8%, transparent);
}
dialog.paper-dialog::backdrop { background: color-mix(in srgb, var(--bg) 60%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.paper-body { display: flex; flex-direction: column; gap: var(--space-5); }
.paper-summary { display: flex; gap: var(--space-4); align-items: center; padding: var(--space-3) var(--space-4); border-radius: 16px; background: var(--surface-sunk); border: 1px solid var(--line); }
.paper-summary__n { font-family: var(--font-display); font-size: 56px; line-height: 0.9; font-weight: 700; color: var(--accent); }
.paper-summary p { margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.paper-section__head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.paper-section__head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.paper-section__count { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-sunk); border: 1px solid var(--line); color: var(--text-muted); }
.paper-empty { margin: 0; font-size: 14px; color: var(--text-muted); }
.paper-cards { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.paper-card { margin: 0; width: 150px; display: flex; flex-direction: column; gap: 6px; text-align: center; font-size: 12px; font-weight: 600; }
.paper-card img { width: 100%; display: block; border-radius: 9px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
.paper-card__blank { aspect-ratio: 5 / 7; display: flex; align-items: center; justify-content: center; padding: 8px; border-radius: 9px; background: var(--surface-sunk); border: 1px solid var(--line); }
.paper-cards--small .paper-card { width: 104px; }
.paper-combo { padding: var(--space-4); border-radius: 16px; background: var(--surface-sunk); border: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--space-3); }
.paper-combo + .paper-combo { margin-top: var(--space-3); }
.paper-combo__top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.paper-combo__title { font-size: 15px; font-weight: 600; }
.paper-combo__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.paper-combo__col { padding: var(--space-3) var(--space-4); border-radius: 12px; background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line); }
.paper-combo__col--wide { grid-column: 1 / -1; }
.paper-combo__col h4 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.paper-combo__col ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.paper-combo__steps { margin: 0; font-size: 13px; line-height: 1.5; white-space: pre-line; }
@media (max-width: 640px) {
  dialog.paper-dialog { padding: 18px 16px 20px; }
  .paper-combo__cols { grid-template-columns: 1fr; }
  .paper-card { width: 104px; }
  .paper-cards--small .paper-card { width: 84px; }
}

/* ---------- /decks: search and filters ---------- */
.deck-filter-bar { display: flex; flex-direction: column; gap: 8px; margin-top: var(--space-3); max-width: 640px; }
.deck-filter-row { display: flex; align-items: center; gap: 10px; }
.deck-filter-search { position: relative; flex: 1 1 auto; min-width: 0; }
.deck-filter-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.deck-filter-search input { width: 100%; box-sizing: border-box; min-height: 46px; padding: 0 14px 0 42px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-sunk) 85%, transparent); color: var(--text); font: inherit; font-size: 15px; }
.deck-filter-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.deck-filter-btnwrap { position: relative; flex-shrink: 0; }
.deck-filter-btn { position: relative; width: 46px; height: 46px; }
.deck-filter-btn.is-active { border-color: var(--accent); color: var(--accent); }
.deck-filter-badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font: 700 12px/20px var(--font-body); text-align: center; }
.deck-filter-panel { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: min(420px, calc(100vw - 32px)); max-height: min(70vh, 640px); overflow-y: auto; padding: var(--space-4);
  border-radius: 14px; border: 1px solid var(--line-strong); background: linear-gradient(180deg, var(--surface-raised), var(--surface)); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; gap: var(--space-4); }
.deck-filter-panel[hidden] { display: none; }
.df-section { display: flex; flex-direction: column; gap: 8px; }
.df-section__title { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.df-section__note { margin: 0; font-size: 13px; color: var(--text-muted); }
.df-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.df-chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-sunk); color: var(--text); font: 600 14px/1 var(--font-body); cursor: pointer; }
.df-chip:hover { border-color: var(--text-muted); }
.df-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
.df-chip--color { min-width: 44px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; }
.df-chip__color { display: inline-flex; align-items: center; }
.df-chip__dot { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: #c9c2b8; color: #1a1010; font: 800 12px/1 var(--font-body); }
.df-mode { align-self: flex-start; }
.df-card { flex: 0 0 auto; }
.df-card input { min-height: 42px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface-sunk); color: var(--text); font: inherit; font-size: 14px; }
.df-actions { display: flex; justify-content: flex-end; }
.deck-filter-count { margin: 0; font-size: 14px; color: var(--text-muted); }
.deck-filter-clear { align-self: flex-start; }
.deck-filter-none { grid-column: 1 / -1; padding: var(--space-6) var(--space-4); text-align: center; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.deck-filter-none p { margin: 0; font-size: 18px; color: var(--text); }
/* while the filter panel is open the hero (and so the panel) sits above the deck cards */
.decks-hero:has(.deck-filter-panel:not([hidden])) { z-index: 30; }
.decks-hero__text:has(.deck-filter-panel:not([hidden])) { z-index: 5; }   /* above the Import and New deck buttons beside it */
