/* ==========================================================================
   Olivewood — Design System
   A calm modern studio for Card Vault / MTG Collection: sand-grey neutrals,
   one olive accent, white panels lifted by soft layered shadows, pill chips,
   sliding segmented controls. Outfit (display) + Manrope (UI), self-hosted.
   Reference mockup: showcases/04-olivewood.html.

   Structure: every length is a token (spacing, control/row heights, radii,
   type, elevation). Components read SEMANTIC colour tokens (--bg, --surface,
   --text, --muted, --accent …); the legacy Field Guide names (--white,
   --gray-*, --blue*, --red*, …) are kept as aliases so existing templates,
   inline styles and JS keep working, and map onto the same palette.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. FONTS (self-hosted, OFL-1.1 — see static/vendor/README.md)
   @fontsource/outfit@5.3.0 + @fontsource/manrope@5.3.0, latin + latin-ext.
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("../vendor/fonts/manrope/manrope-latin-400-normal.1589a53d0b0e.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("../vendor/fonts/manrope/manrope-latin-ext-400-normal.e19a7f36dd91.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("../vendor/fonts/manrope/manrope-latin-500-normal.f95b8f975304.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("../vendor/fonts/manrope/manrope-latin-ext-500-normal.8230a231d5bf.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("../vendor/fonts/manrope/manrope-latin-600-normal.58d382c3e448.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("../vendor/fonts/manrope/manrope-latin-ext-600-normal.3b48de0765e1.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("../vendor/fonts/manrope/manrope-latin-700-normal.ed9e261b92db.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("../vendor/fonts/manrope/manrope-latin-ext-700-normal.37a83b63486c.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("../vendor/fonts/outfit/outfit-latin-600-normal.778dd8bec372.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("../vendor/fonts/outfit/outfit-latin-ext-600-normal.d4d74d39456b.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("../vendor/fonts/outfit/outfit-latin-700-normal.6a0674c3b77b.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("../vendor/fonts/outfit/outfit-latin-ext-700-normal.894e73189e94.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS — structure (theme-independent)
   -------------------------------------------------------------------------- */
:root {
  /* Spacing scale (R1): every padding / margin / gap is one of these. */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* Shell (R3/R4): one gutter for topbar + content; the sidebar head is the
     same height as the topbar so the two hairlines are one line. */
  --gutter: var(--s-6);
  --bar-h: 60px;
  --sidebar-width: 248px;
  --ico-box: 24px;
  --sidebar-width-collapsed: calc(var(--s-4) * 2 + var(--ico-box));
  --nav-h: 36px;
  --content-max: none;

  /* One control height (R2) for buttons, inputs, selects, chips, segmented
     controls, tabs and the filter-bar shell; -sm for in-table/pagination,
     -lg for hero CTAs. */
  --control-h: 36px;
  --control-h-sm: 28px;
  --control-h-lg: 44px;
  --control-px: var(--s-4);
  --badge-h: 20px;
  --icon: 16px;

  /* Tables (R5) */
  --row-h: 48px;
  --row-h-sm: 40px;
  --th-h: 40px;
  --dl-h: 30px;

  /* Grids (R7) */
  --grid-gap: var(--s-4);

  /* Radius scale (R8) + semantic aliases */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 999px;
  --r-ctl: var(--r-md);
  --r-chip: var(--r-pill);
  --r-badge: var(--r-pill);
  --r-panel: var(--r-lg);
  --r-modal: var(--r-lg);
  --r-bar: var(--r-sm);

  /* Type (R9): one UI family + a display family, six sizes. */
  --font-ui: Manrope, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: Outfit, Manrope, ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fw-display: 600;
  --fw-btn: 600;
  --ls-display: -0.015em;
  --fs-1: 12px;
  --fs-2: 14px;
  --fs-3: 16px;
  --fs-4: 20px;
  --fs-5: 28px;
  --fs-6: 36px;

  /* Derived colour tokens (resolve against the active theme's base tokens). */
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface));
  --success-soft: color-mix(in srgb, var(--success) 15%, var(--surface));
  --warning-soft: color-mix(in srgb, var(--warning) 15%, var(--surface));
  --danger-soft: color-mix(in srgb, var(--danger) 14%, var(--surface));
  --info-soft: color-mix(in srgb, var(--info) 14%, var(--surface));
  --lp: color-mix(in srgb, var(--success) 55%, var(--warning));
  --hp: color-mix(in srgb, var(--warning) 45%, var(--danger));
  --lp-soft: color-mix(in srgb, var(--lp) 15%, var(--surface));
  --hp-soft: color-mix(in srgb, var(--hp) 15%, var(--surface));
  --hover: color-mix(in srgb, var(--text) 6%, transparent);
  --focus: var(--accent-text);
  --scrim: rgba(20, 12, 6, 0.45);
  /* Fixed dark overlay chips on card art (qty badge, star, clone) — the same
     in both themes because they sit on the card image, not on the page. */
  --on-art-bg: rgba(20, 14, 10, 0.82);
  --on-art-bg-hover: rgba(20, 14, 10, 0.92);
  --on-art-fg: #ffffff;
  /* Filter-bar categories (chip tint + panel/popover titles). */
  --cat-properties: var(--accent-text);
  --cat-stats: var(--info);
  --cat-collection: var(--warning);
  --cat-raw: var(--muted);

  /* Legacy names (Field Guide) → Olivewood. Kept so templates, inline styles
     and JS that reference them keep working; new code uses the semantic
     names above. */
  --white: var(--surface);
  --blue: var(--accent);
  --blue-light: var(--accent-soft);
  --blue-dark: var(--accent-hover);
  --on-accent: var(--accent-ink);
  --red: var(--danger);
  --red-bg: var(--danger-soft);
  --red-text: var(--danger);
  --green: var(--success);
  --green-bg: var(--success-soft);
  --green-text: var(--success);
  --yellow-bg: var(--warning-soft);
  --yellow-text: var(--warning);
  --lime-bg: var(--lp-soft);
  --lime-text: var(--lp);
  --orange-bg: var(--hp-soft);
  --orange-text: var(--hp);
  --amber: var(--warning);
  --accent-alt: var(--info);
  --font: var(--font-ui);
  --radius: var(--r-ctl);
  --radius-sm: var(--r-sm);
}

@media (max-width: 768px) {
  :root { --gutter: var(--s-4); }
}

/* --------------------------------------------------------------------------
   1a. LIGHT THEME (default)
   -------------------------------------------------------------------------- */
:root {
  --bg: #f3f0e9;
  --surface: #fdfcf9;
  --raised: #ffffff;
  --sunken: #ece8de;
  --border: #e2ddd1;
  --border-strong: #c4bdae;
  --text: #23221d;
  --muted: #67624f;
  --accent: #56691c;
  --accent-hover: #465716;
  --accent-ink: #ffffff;
  --accent-text: #4c5e17;
  --success: #1f6c44;
  --warning: #845400;
  --danger: #b23a1f;
  --info: #3a6a91;
  --sb-bg: #f3f0e9;
  --sb-fg: #47443a;
  --sb-label: #686350;
  --sb-active-bg: #ffffff;
  --sb-active-fg: #23221d;
  --topbar-bg: rgba(243, 240, 233, 0.85);
  --input-bg: #ffffff;
  --input-border: #8b8573;
  --btn-bg: #ffffff;
  --btn-border: #d8d2c4;
  --btn-fg: #23221d;
  --btn-hover: #f6f4ee;
  --chip-bg: #ffffff;
  --th-bg: #f8f6f1;
  --row-border: #eeeae1;
  --oracle-bg: #f8f6f0;
  --bar-fill: #7d9330;
  --scrim-bg: rgba(35, 34, 29, 0.28);
  --tooltip-bg: #2a2924;
  --tooltip-fg: #f3f0e9;
  --shadow-1: 0 1px 2px rgba(45, 40, 25, 0.06), 0 1px 1px rgba(45, 40, 25, 0.04);
  --shadow-2: 0 6px 18px rgba(45, 40, 25, 0.10), 0 1px 3px rgba(45, 40, 25, 0.06);
  --shadow-3: 0 20px 48px rgba(45, 40, 25, 0.20);
  --card-shadow: 0 3px 10px rgba(45, 40, 25, 0.22);
  /* MTG colour identity — recognisable on both themes (pips + charts). */
  --mana-w: #f7efcf;
  --mana-w-ink: #3b331d;
  --mana-u: #2b6fae;
  --mana-u-ink: #ffffff;
  --mana-b: #2b2421;
  --mana-b-ink: #f3ebe2;
  --mana-r: #c23b23;
  --mana-r-ink: #ffffff;
  --mana-g: #2c7443;
  --mana-g-ink: #ffffff;
  --mana-c: #d6cfc5;
  --mana-c-ink: #2b2520;
  --mana-m: #d9a72e;
  --mana-m-ink: #2b1d00;
  --mana-w-chart: #eadb9c;
  --mana-u-chart: #2f73b3;
  --mana-b-chart: #3a312d;
  --mana-r-chart: #c94a2e;
  --mana-g-chart: #348050;
  --mana-c-chart: #a39b90;
  --pip-ring: rgba(40, 25, 10, 0.28);
  --rar-c: #2b2520;
  --rar-u: #8d9aa4;
  --rar-r: #c8992c;
  --rar-m: #d8571f;
  --foil-grad: linear-gradient(100deg, #e9b44c, #e7798f, #8ec5a4, #e9b44c);
  --star: #c8992c;
  /* Price-history series */
  --series-normal: #4c5e17;
  --series-foil: #b8860b;

  /* Legacy neutral ramp (light): 50/100 = tints, 200/300 = borders,
     400–900 = text. 400 and 500 are both ≥ 4.5:1 on --surface and --bg. */
  --gray-50: var(--th-bg);
  --gray-100: var(--sunken);
  --gray-200: var(--border);
  --gray-300: var(--border-strong);
  --gray-400: #6f6a55;
  --gray-500: var(--muted);
  --gray-600: #514d40;
  --gray-700: #3d3a31;
  --gray-800: #2e2c25;
  --gray-900: var(--text);
  color-scheme: light;
}

/* --------------------------------------------------------------------------
   1b. DARK THEME
   The head script in base.html always sets data-theme (stored choice, else
   the OS preference); the media block is the no-JS fallback.
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
  --bg: #161512;
  --surface: #1f1e1a;
  --raised: #282722;
  --sunken: #121110;
  --border: #34322c;
  --border-strong: #4d4a41;
  --text: #efece4;
  --muted: #aba593;
  --accent: #bccb6e;
  --accent-hover: #cbd984;
  --accent-ink: #1a1f05;
  --accent-text: #c3d17a;
  --success: #7ccf9c;
  --warning: #e6b65c;
  --danger: #f2907a;
  --info: #9ec2e0;
  --sb-bg: #161512;
  --sb-fg: #cfcabd;
  --sb-label: #9c9686;
  --sb-active-bg: #282722;
  --sb-active-fg: #efece4;
  --topbar-bg: rgba(22, 21, 18, 0.85);
  --input-bg: #121110;
  --input-border: #6f6a5c;
  --btn-bg: #282722;
  --btn-border: #3c3a33;
  --btn-fg: #efece4;
  --btn-hover: #312f29;
  --chip-bg: #1f1e1a;
  --th-bg: #1b1a17;
  --row-border: #2b2a25;
  --oracle-bg: #1b1a17;
  --bar-fill: #a9b95c;
  --scrim-bg: rgba(0, 0, 0, 0.45);
  --tooltip-bg: #efece4;
  --tooltip-fg: #1f1e1a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 240, 0.04);
  --shadow-3: 0 22px 56px rgba(0, 0, 0, 0.6);
  --card-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  --mana-w: #f7efcf;
  --mana-w-ink: #3b331d;
  --mana-u: #3277b8;
  --mana-u-ink: #ffffff;
  --mana-b: #1c1715;
  --mana-b-ink: #efe6dc;
  --mana-r: #c23b23;
  --mana-r-ink: #ffffff;
  --mana-g: #2c7443;
  --mana-g-ink: #ffffff;
  --mana-c: #a39b90;
  --mana-c-ink: #16120f;
  --mana-m: #d9a72e;
  --mana-m-ink: #2b1d00;
  --mana-w-chart: #efe2a8;
  --mana-u-chart: #4b8fd0;
  --mana-b-chart: #7d6c64;
  --mana-r-chart: #e0603f;
  --mana-g-chart: #4f9f69;
  --mana-c-chart: #8f877c;
  --pip-ring: rgba(255, 240, 225, 0.38);
  --rar-c: #e9e0d4;
  --rar-u: #b7c3cc;
  --rar-r: #e2b443;
  --rar-m: #f07a3c;
  --star: #e2b443;
  --series-normal: #c3d17a;
  --series-foil: #e2b443;
  --gray-50: var(--th-bg);
  --gray-100: #2a2924;
  --gray-200: var(--border);
  --gray-300: var(--border-strong);
  --gray-400: #958f7e;
  --gray-500: var(--muted);
  --gray-600: #cfcabd;
  --gray-700: #dcd8cd;
  --gray-800: #e7e3da;
  --gray-900: var(--text);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #161512;
    --surface: #1f1e1a;
    --raised: #282722;
    --sunken: #121110;
    --border: #34322c;
    --border-strong: #4d4a41;
    --text: #efece4;
    --muted: #aba593;
    --accent: #bccb6e;
    --accent-hover: #cbd984;
    --accent-ink: #1a1f05;
    --accent-text: #c3d17a;
    --success: #7ccf9c;
    --warning: #e6b65c;
    --danger: #f2907a;
    --info: #9ec2e0;
    --sb-bg: #161512;
    --sb-fg: #cfcabd;
    --sb-label: #9c9686;
    --sb-active-bg: #282722;
    --sb-active-fg: #efece4;
    --topbar-bg: rgba(22, 21, 18, 0.85);
    --input-bg: #121110;
    --input-border: #6f6a5c;
    --btn-bg: #282722;
    --btn-border: #3c3a33;
    --btn-fg: #efece4;
    --btn-hover: #312f29;
    --chip-bg: #1f1e1a;
    --th-bg: #1b1a17;
    --row-border: #2b2a25;
    --oracle-bg: #1b1a17;
    --bar-fill: #a9b95c;
    --gray-100: #2a2924;
    --gray-400: #958f7e;
    --gray-600: #cfcabd;
    --gray-700: #dcd8cd;
    --gray-800: #e7e3da;
    color-scheme: dark;
  }
}

[data-theme="dark"] img:not(.no-dim) {
  filter: brightness(0.95);
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-2);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-width: 320px;
}

button,
input,
select,
textarea {
  font-family: inherit;
  letter-spacing: inherit;
}

a {
  color: var(--accent-text);
  text-decoration: none;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: var(--accent-soft);
}

img {
  max-width: 100%;
  height: auto;
}

code,
kbd,
samp {
  font-family: var(--mono);
  font-size: 0.9em;
}

/* Tabular, lining figures for anything numeric (R5). */
.num,
.tnum {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  white-space: nowrap;
}

/* Alpine.js cloak */
[x-cloak] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   2b. SKIP LINK
   Visually hidden off-canvas until keyboard focus lands on it (issue #244).
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -48px;
  left: var(--s-2);
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  height: var(--control-h);
  padding: 0 var(--s-4);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 0 0 var(--r-ctl) var(--r-ctl);
  font-size: var(--fs-2);
  font-weight: 600;
}

.skip-link:focus-visible {
  top: 0;
}

/* --------------------------------------------------------------------------
   3. LAYOUT
   -------------------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.main {
  padding: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  padding: var(--s-5) var(--gutter) var(--s-7);
  max-width: var(--content-max);
  min-width: 0;
}

.content h1 {
  font-family: var(--font-display);
  font-size: var(--fs-5);
  font-weight: var(--fw-display);
  letter-spacing: var(--ls-display);
  line-height: 1.15;
  margin-bottom: var(--s-1);
}

.content h2 {
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  line-height: 1.2;
}

.content h3 {
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  line-height: 1.25;
}

.content .subtitle {
  font-size: var(--fs-2);
  color: var(--muted);
  margin-bottom: var(--s-5);
}

.narrow-form {
  max-width: 480px;
}

/* Shared page-header row: h1 (+ optional subtitle) on the left, actions
   (buttons/links) on the right. Wraps + gaps on narrow viewports instead of
   the actions crowding the title (issue #258). Actions sit on the title's
   bottom edge via flex, not on its text baseline (audit #12). */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-4);
  margin-bottom: var(--s-1);
}

.page-header h1 {
  margin-bottom: 0;
}

/* A subtitle inside the header row must not push the title off the
   actions' bottom edge; the header row carries the spacing instead. */
.page-header:has(.subtitle) {
  margin-bottom: var(--s-5);
}

.page-header .subtitle {
  margin-bottom: 0;
}

/* Messages rendered inside page content sit in the content column (the
   global rule indents them by the gutter for the slot under the topbar). */
.content .django-message {
  margin: 0 0 var(--s-4);
}

/* Section heading inside a page (R9: fs-4 display). */
.section-title {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin: var(--s-6) 0 var(--s-3);
  font: var(--fw-display) var(--fs-4) / 1.2 var(--font-display);
}

/* Layout helpers that replace one-off inline styles. */
.row-flex,
.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--s-1); }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--s-1); }
.mb-2 { margin-bottom: var(--s-2); }
.mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); }
.mb-5 { margin-bottom: var(--s-5); }
.ml-auto { margin-left: auto; }
.inline-form { display: inline; margin: 0; }
.text-xs { font-size: var(--fs-1); }
.text-sm { font-size: var(--fs-2); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.nowrap { white-space: nowrap; }
.fw-600 { font-weight: 600; }

/* A white panel lifted off the sand page (Olivewood elevation: 1px ring +
   shadow-1 instead of a hairline border). */
.panel {
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  padding: var(--s-4);
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin: 0 0 var(--s-3);
  font: var(--fw-display) var(--fs-3) / 1.2 var(--font-display);
}

/* --------------------------------------------------------------------------
   4. SIDEBAR
   Rail geometry (R4): every icon sits in a 24px box whose left edge is at
   --s-4, the same x as the brand mark, so collapsing never moves an icon.
   -------------------------------------------------------------------------- */
.sidebar {
  background: var(--sb-bg);
  color: var(--sb-fg);
  padding: 0 0 var(--s-3);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 40;
  scrollbar-width: thin;
}

.sidebar-header {
  flex: none;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 0 var(--s-2) 0 var(--s-4);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  font: var(--fw-display) var(--fs-3) / 1 var(--font-display);
  letter-spacing: var(--ls-display);
}

.sidebar-brand:hover {
  text-decoration: none;
}

/* Brand mark: the five-colour pie in the shared 24px icon box. */
.sidebar-brand .dot {
  width: var(--ico-box);
  height: var(--ico-box);
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--mana-w-chart) 0 20%, var(--mana-u-chart) 0 40%, var(--mana-b-chart) 0 60%, var(--mana-r-chart) 0 80%, var(--mana-g-chart) 0);
  box-shadow: inset 0 0 0 1.5px var(--pip-ring);
}

.sidebar-section-label {
  display: flex;
  align-items: center;
  height: var(--s-6);
  padding: var(--s-2) var(--s-4) 0;
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--sb-label);
  white-space: nowrap;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  position: relative;
  width: calc(100% - var(--s-4));
  height: var(--nav-h);
  margin: 0 var(--s-2) 2px;
  padding: 0 var(--s-2);
  border-radius: var(--r-ctl);
  font-size: var(--fs-2);
  color: var(--sb-fg);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.1s, color 0.1s;
}

/* .sidebar-link is normally an <a>; the theme toggle (issue #259) is a
   <button> so it's a real control instead of a link with no href. Reset the
   browser's button chrome so it matches the anchor styling above. */
button.sidebar-link {
  background: none;
  border: 0;
  font: inherit;
  font-size: var(--fs-2);
  cursor: pointer;
  text-align: left;
}

/* Every leading glyph (Lucide icon, collection initial, deck thumb) fills
   the same 24px box so labels share one left edge. */
.sidebar-link > .icon,
.sidebar-link > .collection-initial,
.sidebar-link > .sidebar-deck-thumb {
  flex: none;
  margin: 0 2px;
}
.sidebar-link > .icon {
  width: 20px;
  height: 20px;
}
/* Starred-deck cover thumbnail — art_crop is a wide strip; object-fit crops
   a centred square of it. */
.sidebar-deck-thumb {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  object-fit: cover;
}
.sidebar-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-link:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}

.sidebar-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.sidebar-link.active {
  background: var(--sb-active-bg);
  color: var(--sb-active-fg);
  font-weight: 600;
  box-shadow: var(--shadow-1);
}

.sidebar-link.active > .icon {
  color: var(--accent-text);
}

/* Muted "+ New Collection" style action row. */
.sidebar-link--muted {
  color: var(--muted);
}

.sidebar-link .badge {
  margin-left: auto;
  height: 18px;
  min-width: 18px;
  padding: 0 6px;
  background: var(--danger);
  color: var(--surface);
  font-size: 11px;
  font-weight: 700;
}

.sidebar-link .badge.badge--gray { background: var(--sunken); color: var(--text); }

.sidebar-spacer {
  flex: 1;
}

.sidebar-footer {
  margin: var(--s-2) var(--s-2) 0;
  padding: var(--s-2) 0 0;
  border-top: 1px solid var(--border);
  font-size: var(--fs-1);
  color: var(--sb-label);
}

.sidebar-footer .sidebar-link {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.sidebar-version {
  display: block;
  padding: var(--s-2) var(--s-2) 0;
  font-size: var(--fs-1);
  color: var(--sb-label);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-version-sha {
  font-family: var(--mono);
}

/* Theme toggle (issue #259): both icons render, CSS shows the one matching
   the current theme — no JS icon swap needed. */
#theme-toggle .icon-sun { display: none; }
[data-theme="dark"] #theme-toggle .icon-moon { display: none; }
[data-theme="dark"] #theme-toggle .icon-sun { display: block; }

.sidebar-pin,
.sidebar-close {
  flex: none;
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--muted);
  cursor: pointer;
  position: relative;
}

.sidebar-pin:hover,
.sidebar-close:hover { color: var(--text); background: var(--hover); }
.sidebar-pin:focus-visible,
.sidebar-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sidebar-pin .icon { width: 16px; height: 16px; transition: transform 0.2s; }

.sidebar-close {
  display: none;
  font-size: 24px;
  line-height: 1;
}

.collection-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Hamburger: an ordinary flex item at the start of the topbar on phones
   (R4) — no fixed positioning, no padding hacks. */
.sidebar-toggle {
  display: none;
  order: -1;
  flex: none;
  width: var(--control-h);
  height: var(--control-h);
  margin-left: calc(-1 * var(--s-2));
  border: 0;
  border-radius: var(--r-ctl);
  background: transparent;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background: var(--hover);
}

.sidebar-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Sidebar overlay for mobile (hidden by default) */
.sidebar-overlay {
  display: none;
}

/* --------------------------------------------------------------------------
   5. TOPBAR
   Height = --bar-h = the sidebar header, so both share one edge (R3).
   -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--bar-h);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  backdrop-filter: saturate(1.2) blur(10px);
  z-index: 30;
  gap: var(--s-3);
}

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--control-h);
  border: 1px solid var(--input-border);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
  transition: border-color 0.1s;
}

.topbar-search:focus-within {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}

.topbar-search-icon {
  display: flex;
  position: absolute;
  left: var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.topbar-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 var(--s-3) 0 calc(var(--s-3) + var(--icon) + var(--s-2));
  font-size: var(--fs-2);
  border: none;
  outline: none;
  font-family: var(--font-ui);
  color: var(--text);
  background: transparent;
}

.topbar-search input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--s-1);
  margin-right: var(--s-2);
  font: 600 var(--fs-1) / 1 var(--font-ui);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  flex-shrink: 0;
}

/* Positioning context so the dropdown anchors to the input wrapper (not the
   sticky topbar), and stays the width of the field rather than the full bar. */
.search-suggest {
  position: relative;
  min-width: 0;
}

.topbar .search-suggest {
  flex: 0 1 360px;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + var(--s-1));
  left: 0;
  right: 0;
  min-width: min(420px, calc(100vw - 2 * var(--gutter)));
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: var(--s-1);
  box-shadow: var(--shadow-2);
  z-index: 20;
}

/* No results → no border/shadow ghost box (issue #236: the 2px topbar hairline). */
.search-suggestions:empty {
  display: none;
}

.search-suggestions-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: var(--control-h);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-ctl);
  font-size: var(--fs-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.search-suggestion:hover,
.search-suggestion.is-active {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}

.search-suggestion.is-active {
  background: var(--accent-soft);
}

.search-suggestion-meta {
  font-size: var(--fs-1);
  color: var(--muted);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   6. BREADCRUMB
   -------------------------------------------------------------------------- */
.breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  font-size: var(--fs-2);
  color: var(--muted);
  /* Keep the trail on a single line. In the flex topbar min-width:0 lets it
     shrink below its content width so a long trail scrolls horizontally
     (scrollbar hidden) instead of wrapping onto several lines on mobile. */
  white-space: nowrap;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}
.breadcrumb::-webkit-scrollbar {
  display: none; /* WebKit/Blink */
}

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.breadcrumb .sep {
  margin: 0 var(--s-2);
  color: var(--border-strong);
}

.breadcrumb .current {
  color: var(--text);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   6b. TABS
   Olivewood tabs: a sunken track with a raised "thumb" (3px inset), so
   track + thumb still equals --control-h.
   -------------------------------------------------------------------------- */
.tab-bar {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: var(--s-1);
  max-width: 100%;
  padding: 3px;
  margin-bottom: var(--s-5);
  background: var(--sunken);
  border-radius: var(--r-ctl);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  height: calc(var(--control-h) - 6px);
  padding: 0 var(--s-4);
  border-radius: calc(var(--r-ctl) - 3px);
  font-size: var(--fs-2);
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.1s, background-color 0.1s;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab.active {
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

/* --------------------------------------------------------------------------
   7. BUTTONS
   Every button is exactly --control-h tall (R2); padding is horizontal only.
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--control-h);
  padding: 0 var(--control-px);
  font-family: var(--font-ui);
  font-size: var(--fs-2);
  font-weight: var(--fw-btn);
  border-radius: var(--r-ctl);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s, color 0.1s;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.btn:hover {
  background: var(--btn-hover);
  text-decoration: none;
}

.btn:active {
  background: var(--sunken);
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn .icon {
  width: var(--icon);
  height: var(--icon);
  flex: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--hover);
}

/* Red outline button for destructive actions (issue #258). */
.btn--danger,
.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: none;
}

.btn--danger:hover,
.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

/* Quiet destructive icon/text action (row "×" remove etc.). */
.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
  box-shadow: none;
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

.btn-sm {
  height: var(--control-h-sm);
  padding: 0 var(--s-2);
  font-size: var(--fs-1);
  gap: var(--s-1);
}

.btn-lg {
  height: var(--control-h-lg);
  padding: 0 var(--s-5);
  font-size: var(--fs-3);
}

.btn-icon {
  width: var(--control-h);
  padding: 0;
}

.btn-sm.btn-icon {
  width: var(--control-h-sm);
}

.btn-block {
  width: 100%;
}

/* --------------------------------------------------------------------------
   8. FORMS
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--s-4);
}

.form-label {
  display: block;
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--s-1);
}

.form-help,
.helptext {
  display: block;
  margin-top: var(--s-1);
  font-size: var(--fs-1);
  color: var(--muted);
}

/* Field validation message, used below a form-group's widget (issue #258). */
.form-error {
  margin-top: var(--s-1);
  font-size: var(--fs-1);
  color: var(--danger);
}

.form-errors-box {
  margin-bottom: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-ctl);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--fs-2);
}

/* Inline checkbox row — the label wraps the checkbox + its text so the
   whole row is one click target, instead of the block label sitting above
   a lone, tiny checkbox that the generic form loop otherwise renders
   (issue #261). */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--control-h);
  font-size: var(--fs-2);
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin: 0;
}

.form-input,
.form-group input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
.form-group select {
  display: block;
  width: 100%;
  min-width: 0;
  height: var(--control-h);
  padding: 0 var(--s-3);
  font-size: var(--fs-2);
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--r-ctl);
  transition: border-color 0.1s;
  line-height: normal;
}

textarea.form-input,
.form-group textarea {
  display: block;
  width: 100%;
  height: auto;
  min-height: 80px;
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-2);
  font-family: var(--font-ui);
  line-height: 1.5;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--r-ctl);
  resize: vertical;
}

.form-group input[type="file"] {
  display: block;
  font-size: var(--fs-2);
  color: var(--muted);
}

input[type="file"]::file-selector-button {
  height: var(--control-h);
  padding: 0 var(--s-4);
  margin-right: var(--s-3);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-ctl);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 600 var(--fs-2) var(--font-ui);
  cursor: pointer;
}

.form-input:focus,
.form-group input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
  border-color: var(--focus);
}

.form-input::placeholder,
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* Small in-table variant (qty cells, inline condition picker): --control-h-sm. */
.form-input--sm {
  height: var(--control-h-sm);
  padding: 0 var(--s-2);
  font-size: var(--fs-2);
  border-radius: var(--r-sm);
}

.form-input--qty {
  width: 64px;
  text-align: right;
}

.form-input--auto {
  width: auto;
  display: inline-block;
}

input[type="number"].form-input,
.form-group input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"].form-input::-webkit-inner-spin-button,
input[type="number"].form-input::-webkit-outer-spin-button,
.form-group input[type="number"]::-webkit-inner-spin-button,
.form-group input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select.form-input,
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2367624f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  background-size: 16px 16px;
  padding-right: calc(var(--s-3) + var(--icon) + var(--s-2));
  cursor: pointer;
}

select.form-input--sm {
  background-position: right var(--s-2) center;
  padding-right: calc(var(--s-2) + var(--icon) + var(--s-1));
}

[data-theme="dark"] select.form-input,
[data-theme="dark"] .form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aba593' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

select[multiple].form-input,
.form-group select[multiple] {
  height: auto;
  min-height: 120px;
  padding: var(--s-1);
  background-image: none;
}

/* Field grid for multi-input forms (R1 gaps). */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--s-3);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

/* Auth / settings card: a narrow form in a panel. */
.auth-card {
  max-width: 420px;
  margin-top: var(--s-4);
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  padding: var(--s-5);
}

.auth-card h1 {
  margin-bottom: var(--s-4);
}

.auth-card .subtitle {
  margin-bottom: var(--s-4);
}

.auth-card .btn-block {
  margin-top: var(--s-1);
}

@media (max-width: 480px) {
  .auth-card {
    margin-top: 0;
    padding: var(--s-4);
  }
}

.auth-alt {
  margin-top: var(--s-4);
  font-size: var(--fs-2);
  color: var(--muted);
}

.auth-alt + .auth-alt {
  margin-top: var(--s-2);
}

/* --------------------------------------------------------------------------
   9. TABLES
   R5: fixed --row-h rows, vertical-align middle, headers inherit their
   column's alignment, numeric columns right-aligned with tabular figures.
   -------------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-2);
}

thead th {
  height: var(--th-h);
  text-align: left;
  padding: 0 var(--s-3);
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
  background: var(--th-bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

tbody td {
  height: var(--row-h);
  padding: 0 var(--s-3);
  border-bottom: 1px solid var(--row-border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

:is(thead th, tbody td):first-child {
  padding-left: var(--s-4);
}

:is(thead th, tbody td):last-child {
  padding-right: var(--s-4);
}

tbody tr {
  transition: background-color 0.08s;
}

/* Neutral hover — never the accent (R10). */
tbody tr:hover {
  background: var(--hover);
}

tbody tr.is-selected {
  background: var(--accent-soft);
}

tbody tr.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Sortable headers: the arrow lives in a fixed 12px slot that is always
   reserved, so a header never changes width when it becomes sorted (audit
   #4). On right-aligned columns the slot sits on the left, away from the
   data edge. */
.sortable-header {
  cursor: pointer;
  user-select: none;
}

.sortable-header:hover {
  color: var(--text);
}

.sortable-header.is-sorted {
  color: var(--text);
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  vertical-align: middle;
}

.sort-ico {
  display: inline-block;
  width: 12px;
  font-size: 9px;
  line-height: 1;
  text-align: center;
  opacity: 0.8;
}

:is(.num, .t-qty, .t-price, .col-qty, .col-price, .col-num, .col-total) > .th-sort {
  flex-direction: row-reverse;
}

/* Column alignment helpers (header + cells). */
:is(th, td):is(.num, .t-qty, .col-qty, .t-price, .col-price, .col-num, .col-total) {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  white-space: nowrap;
}

:is(th, td):is(.ctr, .col-set, .col-lang, .col-foil) {
  text-align: center;
}

:is(th, td).col-actions,
:is(th, td).act {
  text-align: right;
  white-space: nowrap;
}

:is(th, td).nowrap,
:is(th, td).col-added,
:is(th, td).col-mana {
  white-space: nowrap;
}

td.col-added,
td.cell-dim {
  font-size: var(--fs-1);
  color: var(--muted);
}

/* Table cell helpers */
.t-thumb {
  width: 24px;
  height: 34px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

.t-name {
  font-weight: 600;
  color: var(--text);
}

.t-name a {
  color: inherit;
  text-decoration: none;
}

.t-name a:hover {
  color: var(--accent-text);
  text-decoration: underline;
}

.t-set {
  font-size: var(--fs-1);
  color: var(--muted);
}

/* Set symbols are drawn at a fixed box so rows with an icon are no taller
   than rows without (audit #12). */
.t-set .ss {
  display: inline-block;
  font-size: 20px;
  line-height: 24px;
  height: 24px;
  vertical-align: middle;
}

.grid-card-meta .ss {
  font-size: 14px;
  vertical-align: middle;
}

/* On the dark theme's warm-charcoal background, each rarity gets a stroke
   tuned to its fill: light sand for the near-black common, dark steel for
   the silver uncommon, deep gold for the rare, and rust for the mythic.
   .ss (no rarity) gets a neutral mid-sand fallback. */
[data-theme="dark"] .ss {
  -webkit-text-stroke: 1px #958f7e;
}
[data-theme="dark"] .ss-common {
  -webkit-text-stroke: 1px #cfcabd;
}
[data-theme="dark"] .ss-uncommon {
  -webkit-text-stroke: 1px #4d4a41;
}
[data-theme="dark"] .ss-rare {
  -webkit-text-stroke: 1px #7a5a14;
}
[data-theme="dark"] .ss-mythic {
  -webkit-text-stroke: 1px #7a2b0b;
}

.t-qty {
  font-weight: 600;
}

.t-price-unit {
  font-weight: 600;
}

.t-price-total {
  font-weight: 700;
}

/* Table scroll wrapper: the table sits in a white panel. */
.table-scroll {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
}

.table-scroll > table thead th:first-child { border-top-left-radius: var(--r-panel); }
.table-scroll > table thead th:last-child { border-top-right-radius: var(--r-panel); }

/* --------------------------------------------------------------------------
   10. CARDS / GRID
   -------------------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width, 130px), 1fr));
  gap: var(--grid-gap);
}

/* Stack view: each type/category group is one vertical stack where the
   top 30px (name strip) of every underlying card peeks above the next.
   The peek must be CONSTANT regardless of slider size — to guarantee
   that, we pin each stack item's height to image-only (--card-min-width
   × MTG card aspect 88/63 ≈ 1.4) and hide the info/qty-select rows that
   sit below the image in the cards-view layout. Margin-bottom then
   makes the next sibling start 30px below this one's top. The last
   card in each stack still shows fully because we zero out its margin. */
.card-stack-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--grid-gap);
}
.card-stack {
  display: flex;
  flex-direction: column;
  width: var(--card-min-width, 220px);
  max-width: 100%;
  /* Peek is a fraction of card width so the *visible portion* of each
     stacked card stays at the same proportion at every slider size.
     With cards in MTG aspect (height ≈ width × 1.4) a peek of 0.15 ×
     width works out to ~10.7% of card height — title + just enough
     room above to read the mana cost row at all sizes. */
  --stack-peek: calc(var(--card-min-width, 220px) * 0.15);
}
/* Stacks view: lay the type/category piles out side by side, wrapping to use
   the full width — on every screen size, including mobile. Each pile is one
   card wide, so the card-size slider controls how many fit per row (a pile is
   capped to the row width, so a single wide pile never overflows). The
   per-group panel chrome for every view lives in decks.css. */
.deck-groups--stacks {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0 var(--s-5);
}
.deck-groups--stacks > .deck-type-group {
  width: var(--card-min-width, 220px);
  max-width: 100%;
  margin: var(--s-3) 0 0;
}
.card-stack > .grid-card-wrap {
  width: 100%;
  height: calc(var(--card-min-width, 220px) * 1.4);
  margin-bottom: calc(var(--stack-peek) - var(--card-min-width, 220px) * 1.4);
  overflow: hidden;
  /* Explicit base so the delayed z-index drop below is integer→integer (the
     resting order is unchanged: equal z-index falls back to DOM order). */
  z-index: 0;
  /* Animate the reveal: changing this card's margin slides the cards stacked
     on top of it down smoothly (see the .is-hovered/.revealed rule below).
     z-index has a transition DELAY equal to the slide so that when a card
     stops being hovered it keeps its raised stacking until the slide-back
     finishes. Without this, moving the cursor to an EARLIER card in the stack
     (painted under the current one by DOM order) snaps it above the previous
     card instantly while the margins are still animating — a jarring flip. */
  transition: margin-bottom 0.16s ease, z-index 0s linear 0.16s;
}
.card-stack > .grid-card-wrap > .grid-card,
.card-stack > .grid-card-wrap > .grid-card img {
  height: 100%;
  width: 100%;
}
.card-stack > .grid-card-wrap > .grid-card img {
  object-fit: cover;
  object-position: top;
}
/* In stacks view the info row, qty select, AND the action buttons are hidden
   by default — the cards overlap, so buttons would just collide with the
   cards on top. They appear only once a card is revealed (below). */
.card-stack .grid-card-info,
.card-stack .grid-card-qty-select,
.card-stack .grid-card-controls {
  display: none;
}
.card-stack > .grid-card-wrap:last-child {
  margin-bottom: 0;
}
.card-stack > .grid-card-wrap.filter-hidden {
  margin-bottom: 0;
}
/* Reveal a stacked card: drop its negative peek-margin so the cards stacked on
   top of it slide DOWN and it shows in full, lift it above its neighbours
   (overflow visible so the ⋯ menu isn't clipped), and only THEN surface its
   buttons. Driven by JS classes, NOT :hover — `.is-hovered` is applied after a
   short hover-intent delay (see the stack hover-intent script in
   _deck_controls_row.html) so sweeping the cursor across the pile doesn't
   cascade-reveal every card; `.revealed` is the touch (tap) equivalent. */
.card-stack > .grid-card-wrap.is-hovered,
.card-stack > .grid-card-wrap.revealed {
  margin-bottom: 10px;
  overflow: visible;
  z-index: 5;
  /* Raise the newly hovered card to the front immediately (no delay), so it
     reveals on top; the leaving card keeps its z-index for the slide (see the
     delayed z-index transition on the base rule above). */
  transition: margin-bottom 0.16s ease, z-index 0s;
}
.card-stack > .grid-card-wrap.is-hovered .grid-card-controls,
.card-stack > .grid-card-wrap.revealed .grid-card-controls {
  display: flex;
}

/* Deck-value "most expensive cards" list. */
.deck-value-top {
  list-style: none;
  margin: 0 0 var(--s-1);
  padding: 0;
  max-width: 420px;
}
.deck-value-top li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  min-height: 28px;
  border-bottom: 1px solid var(--row-border);
  font-size: var(--fs-2);
}
.deck-value-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-value-price {
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 600;
  white-space: nowrap;
}
.deck-value-mult {
  color: var(--muted);
  font-weight: 400;
  font-size: var(--fs-1);
}

/* Deck color-pip distribution as a single stacked horizontal bar. Each
   segment's width is set inline via flex-grow=<pip count>, so widths are
   proportional with no template-side division. Reusable for the upcoming
   mana-production bar so the two line up for comparison. */
.pip-bar {
  display: flex;
  width: 100%;
  height: 32px;
  border-radius: var(--r-sm);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--pip-ring);
}
.pip-bar-seg {
  flex-basis: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-1);
  font-weight: 700;
}
.pip-bar-seg-label {
  padding: 0 4px;
  white-space: nowrap;
}
.pip-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-3);
  margin-top: var(--s-2);
  font-size: var(--fs-1);
  color: var(--muted);
}
.pip-bar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
}
.pip-bar-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--pip-ring);
}

/* Loading bar for full-area deck re-renders (filter chips, group switch,
   quick-add). htmx adds .htmx-request to the hx-indicator target while the
   request is in flight, so the bar is hidden until then. Lives outside
   #deck-card-area so a morph swap of the area doesn't disturb it. */
.deck-area-progress {
  display: none;
  height: 3px;
  margin: 0 0 var(--s-2);
  border-radius: 2px;
  background: var(--accent-soft);
  position: relative;
  overflow: hidden;
}
.deck-area-progress.htmx-request {
  display: block;
}
.deck-area-progress::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 35%;
  border-radius: 2px;
  background: var(--accent);
  animation: deck-progress-slide 0.9s ease-in-out infinite;
}
@keyframes deck-progress-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}

.card-size-slider {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: var(--control-h);
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}

.card-size-slider input[type="range"] {
  width: 110px;
  accent-color: var(--accent);
}

/* Deck-card annotations: tag chips + notes indicator. Used by both the
   builder (editable) and the read-only deck detail page. */
.deck-tag-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-1);
}

.deck-tag-chip {
  display: inline-flex;
  align-items: center;
  height: 18px;
  font-size: 11px;
  line-height: 1;
  padding: 0 var(--s-2);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-cat-chip {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent);
}

.card-tag-chip {
  display: inline-flex;
  align-items: center;
  height: var(--badge-h);
  padding: 0 var(--s-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-1);
  font-weight: 600;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  vertical-align: middle;
}
.card-tag-chip--sm {
  height: 16px;
  font-size: 11px;
  padding: 0 6px;
}

.grid-card-notes {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--badge-h);
  padding: 0 var(--s-1);
  font-size: var(--fs-1);
  line-height: 1;
  background: var(--on-art-bg);
  color: var(--on-art-fg);
  border-radius: var(--r-sm);
  pointer-events: auto;
  cursor: help;
}

/* When both the owned-count badge and the notes indicator are present,
   shift the notes icon down so they don't overlap. */
.grid-card-own + .grid-card-notes { top: 32px; }

/* One-line strip combining the group picker, tag chips, and the
   name-search input above the card list. Wraps on narrow viewports
   so each control keeps its own intrinsic width. */
.deck-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  margin: var(--s-2) 0;
}
.deck-controls-row > * { margin: 0; }

/* Vertical divider between the view/group/sort pickers and the by-name
   filter in the toolbar row. */
.deck-toolbar-sep {
  width: 1px;
  height: var(--control-h-sm);
  align-self: center;
  background: var(--border);
}
.deck-controls-row .deck-name-filter { width: 200px; }
/* Space between the collapsed/expanded view-controls and the card area
   (tag-filter chips or the cards). */
#deck-card-area { margin-top: 10px; }
@media (max-width: 768px) {
  .deck-controls-row .deck-name-filter { width: 100%; }
  .deck-toolbar-sep { display: none; }
}

/* Collapsible "View & filters" tools (shared by builder + detail). On
   desktop the body is always shown and the toggle is hidden; on mobile the
   body collapses behind the toggle so the card list isn't buried under the
   control rows. */
.deck-tools-toggle {
  display: none;
  width: 100%;
  height: var(--control-h);
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin: var(--s-3) 0 0;
  padding: 0 var(--s-3);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-ctl);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: var(--shadow-1);
  font-size: var(--fs-2);
  font-weight: 600;
  cursor: pointer;
}
.deck-tools-toggle .chevron { transition: transform 0.15s ease; }
.deck-tools.is-open .deck-tools-toggle .chevron { transform: rotate(180deg); }

@media (max-width: 768px) {
  .deck-tools-toggle { display: flex; }
  .deck-tools-body { display: none; }
  .deck-tools.is-open .deck-tools-body { display: block; }
  .deck-tools-body .deck-controls-row { margin-top: 10px; gap: 10px 12px; }
  /* The tag-filter chip strips render inside #deck-card-area (their active
     states re-render with the area), but on mobile they should collapse
     with the "View & filters" toggle (issue #161). The detail page has
     .deck-tools as a direct preceding sibling of the area; the builder
     wraps it in the sticky .builder-toolbar, hence the :has() variant. */
  .deck-tools:not(.is-open) ~ #deck-card-area .deck-tag-filter,
  .builder-toolbar:has(.deck-tools:not(.is-open)) ~ #deck-card-area .deck-tag-filter {
    display: none;
  }
}

/* Deck tag-filter strip above the card area. Toggleable chips + Clear. */
.deck-tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
  margin: 0 0 var(--s-3);
}

.deck-tag-filter-label {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
  margin-right: var(--s-1);
}

.deck-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  height: var(--control-h-sm);
  padding: 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  font-size: var(--fs-1);
  font-weight: 500;
  color: var(--text);
  background: var(--chip-bg);
  text-decoration: none;
  white-space: nowrap;
}

.deck-filter-chip:hover {
  border-color: var(--input-border);
  text-decoration: none;
}
.deck-filter-chip.is-active {
  background: var(--accent-soft);
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.deck-filter-chip.is-untagged { font-style: italic; }

.deck-filter-clear {
  font-size: var(--fs-1);
  color: var(--muted);
  text-decoration: underline;
  margin-left: var(--s-1);
}

.deck-group-picker {
  margin: var(--s-2) 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.deck-group-label {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}

/* Builder title + a "⋯" actions dropdown (Import / Statistics) next to the
   deck name, so those actions don't take space in the add bar. */
.builder-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.builder-title h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.deck-actions-menu { position: relative; }
.deck-actions-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-h);
  height: var(--control-h);
  padding: 0 var(--s-2);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-ctl);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: var(--shadow-1);
  font-size: var(--fs-4);
  line-height: 1;
}
.deck-actions-summary::-webkit-details-marker { display: none; }
.deck-actions-summary:hover { background: var(--gray-100); }
.deck-actions-items {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: var(--s-1);
  /* Above the sticky .builder-toolbar (z-index:40) — they share the page-root
     stacking context, so an open menu would otherwise be painted over by the
     quick-add bar below it. Stays under the nav (100) and modals (150+). */
  z-index: 50;
  min-width: 180px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: var(--s-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.deck-actions-item {
  display: flex;
  align-items: center;
  min-height: var(--control-h);
  background: none;
  border: 0;
  text-align: left;
  padding: 0 var(--s-3);
  font-size: var(--fs-2);
  color: var(--text);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
}
.deck-actions-item:hover { background: var(--gray-100); }

/* Quick-add bar: a unified search box with the MB/SB target toggle living
   inside it (looks like one input), plus a compact skip toggle. The board
   value is a hidden input the toggle flips. Full-width search on mobile. */
.deck-add-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  margin: var(--s-3) 0 0;
}
.deck-add-input-group {
  position: relative;
  display: flex;
  align-items: stretch;
  flex: 1 1 280px;
  min-width: 0;
  max-width: 520px;
  height: var(--control-h);
  border: 1px solid var(--input-border);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
}
.deck-add-input-group:focus-within {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}
.deck-add-input-group input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  padding: 0 var(--s-3);
  font-size: var(--fs-2);
  color: var(--text);
  border-radius: var(--r-ctl);
}
.deck-add-input-group input[type="text"]:focus { outline: none; }
/* Main/Side segmented control inside the quick-add box (issue #165):
   states the target board instead of encoding it in a lone "MB" button. */
.deck-add-board-seg {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin: 3px;
  padding: 2px;
  background: var(--sunken);
  border-radius: calc(var(--r-ctl) - 3px);
}
.deck-add-board-seg button {
  border: 0;
  border-radius: calc(var(--r-ctl) - 5px);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-1);
  padding: 0 var(--s-2);
  cursor: pointer;
}
.deck-add-board-seg button:hover {
  color: var(--text);
}
.deck-add-board-seg button.is-active {
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.deck-add-input-group #suggest-dropdown {
  position: absolute;
  top: calc(100% + var(--s-1));
  left: 0;
  width: 100%;
  min-width: min(420px, calc(100vw - 2 * var(--gutter)));
  z-index: 10;
}
@media (max-width: 768px) {
  .deck-add-input-group { flex: 1 1 100%; max-width: none; }
}

/* Horizontal strip of card-printing thumbnails inside the card-edit
   modal. Each thumb is a button; the current printing is disabled and
   ringed in blue. */
.printing-strip {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  max-width: 100%;
  padding: var(--s-1) 2px;
  margin: 0 -2px;
}

.printing-thumb {
  flex: 0 0 auto;
  width: 76px;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  border-radius: var(--r-sm);
}

.printing-thumb-img {
  position: relative;
  display: block;
}

.printing-thumb img {
  width: 76px;
  height: 106px;
  object-fit: cover;
  border-radius: 4.75% / 3.4%;
  border: 2px solid transparent;
  transition: border-color 0.1s;
}

.printing-thumb:hover img { border-color: var(--gray-400); }
.printing-thumb.is-current { cursor: default; }
.printing-thumb.is-current img { border-color: var(--blue); }

/* "N owned" badge on a printing thumbnail (market card-detail picker only —
   see mtg/services.py build_printings_picker_context owned_by_uuid). */
.printing-thumb-owned {
  position: absolute;
  top: var(--s-1);
  right: var(--s-1);
  min-width: 16px;
  height: 16px;
  padding: 0 var(--s-1);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.printing-thumb-set {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.printing-thumb.is-current .printing-thumb-set { color: var(--blue); font-weight: 600; }

/* Lazy printings picker (deck/collection/scan modals). */
.printings-collapsible > summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--s-1);
  min-height: var(--control-h-sm);
  font-size: var(--fs-2);
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
.printings-collapsible > summary::-webkit-details-marker { display: none; }
.printings-collapsible > summary::before { content: "▸ "; color: var(--gray-500); }
.printings-collapsible[open] > summary::before { content: "▾ "; }
.printings-picker { margin-top: 8px; }
.printings-filter { width: 100%; margin-bottom: 8px; }
.printings-more-note {
  font-size: var(--fs-1);
  color: var(--muted);
  margin: var(--s-2) 0 0;
}

/* Tag-chip toggle pills used inside the card-edit modal. */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  height: var(--control-h-sm);
  padding: 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  font-size: var(--fs-1);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  background: var(--chip-bg);
  color: var(--text);
}

.tag-chip:hover { border-color: var(--gray-400); }
.tag-chip input { margin: 0; cursor: pointer; }
.tag-chip:has(input:checked) {
  background: var(--accent-soft);
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.tag-chip.category-chip {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: transparent;
}
.tag-chip.category-chip input:checked ~ span {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 1px var(--s-2);
  border-radius: var(--r-pill);
}

/* --------------------------------------------------------------------------
   Card-edit modal layout primitives.
   Shared by the editable and read-only branches of _card_edit_form.html;
   factored out of repeated inline styles to keep the htmx-swapped payload
   small and restyling in one place.
   -------------------------------------------------------------------------- */
/* The card-edit form swaps into <dialog id="deck-modal" class="paste-dialog">,
   so `dialog.paste-dialog h2` / `p.hint` (above) would otherwise win on
   specificity over a plain class and shift the heading/subtitle margins.
   Scope these to the same dialog so they reproduce the original inline
   values exactly (h2 margin 4px, sub margin 14px) instead of the
   paste-dialog defaults (8px / 10px). */
dialog.paste-dialog h2.card-edit-title { font-size: var(--fs-3); margin: 0 0 4px; }
dialog.paste-dialog p.hint.card-edit-sub { font-size: var(--fs-1); color: var(--gray-500); margin: 0 0 14px; }

.card-edit-fieldset {
  border: 0; padding: 0; margin: 0 0 var(--s-4);
}
/* Last fieldset before the footer gets a touch more breathing room. */
.card-edit-fieldset--last { margin-bottom: 16px; }

.card-edit-legend {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--s-2);
}

/* Wrapping row of tag/category chips. */
.card-edit-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}
/* Read-only branch: no add-row below, so no bottom margin. */
.card-edit-chip-group--flush { margin-bottom: 0; }

/* "Add new tag/category" input + button row. */
.card-edit-add-row {
  display: flex;
  gap: var(--s-2);
  align-items: center;
}
.card-edit-add-row-input {
  flex: 1;
  min-width: 0;
  height: var(--control-h-sm);
  padding: 0 var(--s-2);
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--fs-2);
}
.card-edit-add-row-btn { padding: 6px 12px; font-size: var(--fs-2); }

/* Footer: market link on the left, action buttons on the right. */
.card-edit-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}
.card-edit-footer-link {
  font-size: var(--fs-1);
  color: var(--muted);
  text-decoration: underline;
}
.card-edit-footer-actions {
  display: flex; gap: var(--s-2);
}

/* --------------------------------------------------------------------------
   Modal dialogs (shared by paste-decklist and per-card edit dialogs).
   -------------------------------------------------------------------------- */
dialog.paste-dialog {
  /* Native <dialog> centers in modal mode, but only when no positioning
     props are overridden. Setting `width` knocks `margin: auto` off-track
     in some engines, so we pin the dialog ourselves: fixed + inset: 0 +
     margin: auto centers horizontally and vertically at any viewport. */
  position: fixed;
  inset: 0;
  margin: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-modal);
  padding: var(--s-5);
  width: min(560px, calc(100vw - 2 * var(--s-4)));
  max-height: calc(100vh - 2 * var(--s-4));
  overflow: auto;
  /* Keep scrolling inside the dialog — don't chain to the page behind it
     when you hit the top/bottom (background cards scrolling on mobile). */
  overscroll-behavior: contain;
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow-3);
}
dialog.paste-dialog::backdrop { background: rgba(0,0,0,0.4); }

/* Sticky close bar for modal content that has no other close affordance
   (the statistics modal) — essential on touch, where there's no Esc key. */
.deck-stats-topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--s-1);
  background: var(--raised);
}
.deck-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  font-size: var(--fs-4);
  line-height: 1;
  color: var(--muted);
  padding: 0;
}
.deck-modal-close:hover {
  color: var(--text);
  background: var(--hover);
}
dialog.paste-dialog h2 { font-size: var(--fs-3); margin: 0 0 8px; }
dialog.paste-dialog p.hint { font-size: var(--fs-1); color: var(--gray-500); margin: 0 0 10px; }
dialog.paste-dialog textarea {
  width: 100%; min-height: 220px;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font: var(--fs-2) / 1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--gray-900);
  background: var(--white);
  resize: vertical;
}
dialog.paste-dialog .actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 12px;
}

.grid-card {
  cursor: pointer;
  transition: transform 0.1s;
  text-decoration: none;
  color: inherit;
}

.grid-card:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.grid-card img {
  width: 100%;
  display: block;
  /* MTG card ratio (63×88mm): reserves the image box before the lazy-loaded
     image arrives, so the grid doesn't reflow / shift layout (issue #147).
     The stacks view overrides this with an explicit height. */
  aspect-ratio: 63 / 88;
  /* Proportional radius (~ the real MTG card corner) so it scales with the
     card-size slider; soft layered shadow lifts it off the sand page. */
  border-radius: 4.75% / 3.4%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: var(--card-shadow);
  background: var(--sunken);
}

.grid-card-info {
  padding-top: var(--s-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.grid-card-name {
  font-size: var(--fs-1);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-card-meta {
  font-size: var(--fs-1);
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-1);
}

/* --------------------------------------------------------------------------
   11. BADGES
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1);
  height: var(--badge-h);
  padding: 0 var(--s-2);
  border-radius: var(--r-badge);
  background: var(--sunken);
  color: var(--text);
  font-size: var(--fs-1);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.badge--red {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--gray {
  background: var(--sunken);
  color: var(--text);
}

.badge--blue,
.badge--accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.cond-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: var(--badge-h);
  padding: 0 var(--s-2);
  border-radius: var(--r-badge);
  background: var(--sunken);
  color: var(--text);
  font-size: var(--fs-1);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.cond-badge--nm {
  background: var(--success-soft);
  color: var(--success);
}

.cond-badge--lp {
  background: var(--lp-soft);
  color: var(--lp);
}

.cond-badge--mp {
  background: var(--warning-soft);
  color: var(--warning);
}

.cond-badge--hp {
  background: var(--hp-soft);
  color: var(--hp);
}

.cond-badge--dmg {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Foil gets its own badge (R10): a warm iridescent edge, never the NM
   condition colours (audit #11). */
.badge--foil {
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--foil-grad) border-box;
  border: 1px solid transparent;
  color: var(--text);
}

.badge--ok { background: var(--success-soft); color: var(--success); }
.badge--warn { background: var(--warning-soft); color: var(--warning); }
.badge--muted { background: var(--sunken); color: var(--muted); }
.badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); }

/* Set code tag (e.g. "MH3"). */
.set-code-tag {
  display: inline-flex;
  align-items: center;
  height: var(--badge-h);
  padding: 0 var(--s-1);
  border: 1px solid var(--border);
  border-radius: var(--r-badge);
  font: 600 var(--fs-1) / 1 var(--font-ui);
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

/* Badge rendered as a <button> (editable rows): strip UA button chrome so it
   looks identical to the span badge; tap reveals the condition select. */
.cond-badge-btn {
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

/* --------------------------------------------------------------------------
   12. FILTERS & VIEW TOGGLE
   -------------------------------------------------------------------------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-4);
  gap: var(--s-3) var(--s-4);
}

.controls-left {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1);
  height: var(--control-h);
  padding: 0 var(--s-3);
  font-size: var(--fs-2);
  font-weight: 500;
  font-family: var(--font-ui);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  background: var(--chip-bg);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.1s, background-color 0.1s;
}

.filter-btn:hover {
  border-color: var(--input-border);
  text-decoration: none;
}

.filter-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.filter-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
  font-weight: 600;
}

.view-toggle {
  display: inline-flex;
  flex: none;
  height: var(--control-h);
  padding: 3px;
  gap: 3px;
  border-radius: var(--r-ctl);
  background: var(--sunken);
}

.view-toggle button,
.view-toggle a {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 100%;
  padding: 0 var(--s-3);
  font-size: var(--fs-2);
  font-weight: 500;
  font-family: var(--font-ui);
  border: none;
  border-radius: calc(var(--r-ctl) - 3px);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.1s, color 0.1s;
}

.view-toggle :is(button, a):hover {
  color: var(--text);
  text-decoration: none;
}

.view-toggle :is(button, a).active {
  background: var(--raised);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-1);
}

.view-toggle :is(button, a):hover:not(.active) {
  background: var(--hover);
}

.view-toggle :is(button, a):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* --------------------------------------------------------------------------
   13. CARD DETAIL
   -------------------------------------------------------------------------- */
.card-detail {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: var(--s-6);
  align-items: start;
}

.card-detail img {
  width: 100%;
  border-radius: 4.75% / 3.4%;
  display: block;
  box-shadow: var(--shadow-3);
}

.card-foil {
  position: relative;
  overflow: hidden;
  border-radius: 4.75% / 3.4%;
}

.card-foil img {
  border-radius: 0;
}

.card-foil::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 40, 140, 0.30) 0%,
    rgba(0, 200, 255, 0.35) 20%,
    rgba(180, 100, 255, 0.30) 35%,
    rgba(255, 220, 0, 0.25) 50%,
    rgba(0, 255, 160, 0.35) 65%,
    rgba(80, 80, 255, 0.30) 80%,
    rgba(255, 40, 140, 0.30) 100%
  );
  mix-blend-mode: color;
  pointer-events: none;
  z-index: 1;
}

.card-foil::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    220deg,
    transparent 10%,
    rgba(255, 255, 255, 0.18) 25%,
    rgba(255, 255, 255, 0.40) 42%,
    rgba(255, 255, 255, 0.18) 58%,
    transparent 75%
  );
  pointer-events: none;
  z-index: 2;
}

.card-detail h2 {
  font-family: var(--font-display);
  font-size: var(--fs-5);
  font-weight: var(--fw-display);
  letter-spacing: var(--ls-display);
  line-height: 1.15;
  margin-bottom: var(--s-1);
}

.card-detail .type-line {
  font-size: var(--fs-3);
  color: var(--muted);
  margin: var(--s-2) 0 var(--s-4);
}

.card-detail .oracle {
  position: relative;
  padding: var(--s-4);
  margin-bottom: var(--s-4);
  background: var(--oracle-bg);
  border-radius: var(--r-panel);
  box-shadow: 0 0 0 1px var(--border);
  font-size: var(--fs-3);
  line-height: 1.55;
  max-width: 64ch;
  color: var(--text);
}

.detail-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.detail-field {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-height: var(--row-h-sm);
  padding: var(--s-1) 0;
  border-bottom: 1px solid var(--row-border);
}

.detail-field:nth-child(odd) {
  padding-right: var(--s-4);
  border-right: 1px solid var(--row-border);
}

.detail-field:nth-child(even) {
  padding-left: var(--s-4);
}

.detail-field .label {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
  min-width: 80px;
}

.detail-field .val {
  font-weight: 600;
  font-size: var(--fs-2);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}

.detail-divider {
  border-top: 1px solid var(--border);
  margin: var(--s-6) 0 var(--s-5);
  padding-top: var(--s-5);
}

/* Uppercase eyebrow label above a card-detail section (issue #258). */
.section-label {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}

/* Flavor-text blockquote styling, shared by the two card-detail pages
   (issue #258). */
.flavor-text {
  font-style: italic;
  color: var(--muted);
  max-width: 64ch;
}

/* components/card_prices.html — one row per vendor (issue #252). Replaces
   19 inline style= attrs that were previously copy-pasted per vendor. */
.price-caption {
  font-weight: 400;
  color: var(--muted);
}

.price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--s-4);
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  min-height: 32px;
  font-size: var(--fs-2);
  border-bottom: 1px solid var(--row-border);
}

.price-row-name {
  color: var(--muted);
}

.price-row-name a {
  color: inherit;
  text-decoration: none;
}

.price-row-name a:hover {
  text-decoration: underline;
}

.price-row-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}

.price-row-foil {
  color: var(--muted);
  font-weight: 400;
}

/* --------------------------------------------------------------------------
   14. INLINE STATS
   -------------------------------------------------------------------------- */
.inline-stats {
  font-size: var(--fs-2);
  color: var(--muted);
  margin-bottom: var(--s-4);
}

.inline-stats strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.inline-stats .sep {
  margin: 0 var(--s-3);
  color: var(--border-strong);
}

/* --------------------------------------------------------------------------
   15. PAGINATION
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-4);
  font-size: var(--fs-2);
  color: var(--muted);
}

.pagination-info {
  font-size: var(--fs-2);
  color: var(--muted);
}

.pagination-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1);
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-h-sm);
  height: var(--control-h-sm);
  padding: 0 var(--s-2);
  font-size: var(--fs-1);
  font-weight: 600;
  border: 1px solid var(--btn-border);
  border-radius: var(--r-ctl);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.1s;
}

.pagination-link:hover {
  background: var(--btn-hover);
  text-decoration: none;
}

.pagination-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.pagination-link.current {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-h-sm);
  height: var(--control-h-sm);
  font-size: var(--fs-1);
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   16. EMPTY STATE
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-2);
  margin-top: var(--s-4);
  padding: var(--s-7) var(--s-4);
  border: 1px dashed var(--input-border);
  border-radius: var(--r-panel);
  color: var(--muted);
  font-size: var(--fs-2);
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: var(--fs-4);
  font-weight: var(--fw-display);
  color: var(--text);
  margin: 0;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  max-width: 48ch;
}

/* --------------------------------------------------------------------------
   17. DJANGO MESSAGES
   -------------------------------------------------------------------------- */
.django-message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-4) var(--gutter) 0;
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  font-size: var(--fs-2);
  line-height: 1.35;
  border-radius: var(--r-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.django-message--success {
  border-left-color: var(--success);
}

.django-message--error {
  border-left-color: var(--danger);
}

.django-message--warning {
  border-left-color: var(--warning);
}

.django-message .close-btn {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  font-size: var(--fs-4);
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  line-height: 1;
}

.django-message .close-btn:hover {
  color: var(--text);
  background: var(--hover);
}

/* --------------------------------------------------------------------------
   18. LANDING PAGE
   -------------------------------------------------------------------------- */
.landing-hero {
  text-align: center;
  padding: var(--s-7) 0 var(--s-6);
  max-width: 600px;
  margin: 0 auto;
}

.landing-hero h1 {
  font-family: var(--font-display);
  font-size: var(--fs-6);
  font-weight: var(--fw-display);
  letter-spacing: var(--ls-display);
  margin-bottom: var(--s-2);
}

.landing-hero p {
  font-size: var(--fs-3);
  color: var(--muted);
  margin-bottom: var(--s-5);
  line-height: 1.6;
}

.landing-search {
  max-width: 440px;
  margin: 0 auto var(--s-5);
}

.landing-search input.form-input,
.landing-search input {
  height: var(--control-h-lg);
  padding: 0 var(--s-4);
  font-size: var(--fs-3);
  box-shadow: var(--shadow-1);
}

.landing-search input::placeholder {
  color: var(--muted);
}

.landing-search button {
  height: var(--control-h-lg);
  padding: 0 var(--s-5);
  font-size: var(--fs-2);
  font-weight: 600;
  font-family: var(--font-ui);
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  cursor: pointer;
  transition: background 0.1s;
}

.landing-search button:hover {
  background: var(--accent-hover);
}

.landing-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: center;
  flex-wrap: wrap;
}

/* Fanned strip of popular card art above the search box (#256). Decorative:
   a "hand of cards" read via slight per-card rotation + overlap. The hover
   lift is a transition, so the global reduced-motion rule already tames it. */
.landing-hero-strip {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 200px;
  margin: 0 auto var(--s-6);
  padding-top: var(--s-2);
}

.landing-hero-card {
  position: relative;
  width: 94px;
  height: auto;
  aspect-ratio: 146 / 204;
  object-fit: cover;
  margin-inline: -13px;
  border-radius: 4.75% / 3.4%;
  background: var(--sunken);
  box-shadow: var(--card-shadow);
  transform-origin: bottom center;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.landing-hero-card:nth-child(1) { transform: rotate(-9deg) translateY(6px); }
.landing-hero-card:nth-child(2) { transform: rotate(-5deg) translateY(1px); }
.landing-hero-card:nth-child(3) { transform: rotate(-1.5deg); }
.landing-hero-card:nth-child(4) { transform: rotate(1.5deg); }
.landing-hero-card:nth-child(5) { transform: rotate(5deg) translateY(1px); }
.landing-hero-card:nth-child(6) { transform: rotate(9deg) translateY(6px); }

.landing-hero-card:hover {
  transform: translateY(-10px) rotate(0deg);
  box-shadow: var(--shadow-3);
  z-index: 2;
}

.landing-features {
  list-style: none;
  margin: var(--s-6) auto 0;
  padding: 0;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  text-align: left;
}

.landing-feature {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-2);
  color: var(--text);
}

.landing-feature .icon {
  flex-shrink: 0;
  color: var(--accent-text);
}

@media (max-width: 768px) {
  .landing-hero-strip { min-height: 150px; }
  .landing-hero-card { width: 68px; margin-inline: -10px; }
}

/* Market blank-browse zero-state: set shortcuts + a random sample (#256). */
.market-discovery {
  margin-top: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}

.market-discovery-heading {
  font-family: var(--font-display);
  font-size: var(--fs-3);
  font-weight: var(--fw-display);
  color: var(--text);
  margin-bottom: var(--s-3);
}

.market-discovery-headrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
}

.market-discovery-headrow .market-discovery-heading { margin-bottom: 0; }

.market-set-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.market-set-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: var(--control-h);
  padding: 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  background: var(--chip-bg);
  font-size: var(--fs-2);
  color: var(--text);
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease;
}

.market-set-chip:hover {
  border-color: var(--input-border);
  background: var(--chip-bg);
  text-decoration: none;
}

.market-set-chip-name {
  font-weight: 600;
}

.market-set-chip-code {
  display: inline-flex;
  align-items: center;
  height: var(--badge-h);
  padding: 0 var(--s-1);
  border: 1px solid var(--border);
  border-radius: var(--r-badge);
  font: 600 var(--fs-1) / 1 var(--font-ui);
  letter-spacing: 0.04em;
  color: var(--muted);
}

.market-sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--grid-gap);
}

/* --------------------------------------------------------------------------
   20. UTILITIES
   -------------------------------------------------------------------------- */
.text-dim {
  color: var(--muted);
}

/* Screen-reader-only text — visually hidden, still exposed to assistive
   tech (issue #248's loading-bar status text needs this and field-guide.css
   is the one stylesheet loaded on every page; filter-bar.css keeps its own
   copy too since not every page loads it). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --------------------------------------------------------------------------
   21. FOCUS & KEYBOARD ACCESSIBILITY (global)
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Remove default outline for mouse clicks */
:focus:not(:focus-visible) {
  outline: none;
}

/* --------------------------------------------------------------------------
   21b. TOUCH TARGETS (pointer: coarse)
   Bumps hit areas toward the ~44px mobile touch-target guideline on coarse
   pointers only, leaving the compact desktop/mouse density untouched
   (issue #244).
   -------------------------------------------------------------------------- */
@media (pointer: coarse) {
  .sidebar-link {
    height: 44px;
  }

  .pagination-link {
    height: 44px;
    min-width: 44px;
  }

  /* Invisible ::after hit-area expansion — keeps the visible close glyph
     compact while enlarging the tappable region. */
  .django-message .close-btn::after {
    content: "";
    position: absolute;
    inset: -14px;
  }

  /* The "/" keyboard shortcut hint has no meaning on a touch device — there
     is no physical "/" key to press (issue #261). */
  .search-shortcut {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   X. DECK + COLLECTION CARDS (shared by My Decks, dashboard, etc.)
   .deck-* and .collection-* are visually identical card/grid primitives —
   merged via :is() (issue #258). Genuinely deck-only (star toggle, mosaic)
   or collection-only (summary panel) declarations stay separate below.
   -------------------------------------------------------------------------- */
:is(.deck-grid, .collection-grid) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--grid-gap);
  margin: var(--s-2) 0 var(--s-5);
}

:is(.deck-card, .collection-card) {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  overflow: hidden;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
:is(.deck-card, .collection-card):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2), 0 0 0 1px var(--border);
  text-decoration: none;
}

/* Favorite (star) toggle overlaid on a deck card. It's a sibling of the card
   anchor (a button can't nest in an <a>); .deck-card-wrap anchors its position.
   Always visible so it's tappable on touch. */
.deck-card-wrap { position: relative; }
.deck-star {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  padding: 0;
  border: none;
  border-radius: var(--r-pill);
  background: var(--on-art-bg);
  color: var(--on-art-fg);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}
.deck-star:hover {
  background: var(--on-art-bg-hover); transform: scale(1.05);
}
.deck-star:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.deck-star .icon {
  width: var(--icon); height: var(--icon);
}
/* Active = filled gold star; the icon's fill="none" presentation attr loses to this CSS. */
.deck-star.is-active {
  color: #e2b443;
}
.deck-star.is-active .icon {
  fill: #e2b443;
}

/* Watch-price (eye) toggle — inline sibling of .deck-star's overlay style,
   used on the market card page and watchlist rows. */
.watch-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  border: 1px solid var(--btn-border);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--muted);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}
.watch-toggle:hover {
  background: var(--btn-hover); color: var(--text);
}
.watch-toggle:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.watch-toggle .icon {
  width: var(--icon); height: var(--icon);
}
.watch-toggle.is-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* Watchlist page rows */
.watchlist { max-width: 720px; }
.watchlist-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--row-border);
}
.watchlist-thumb {
  width: 48px; border-radius: 4.75% / 3.4%; display: block; box-shadow: var(--card-shadow);
}
.watchlist-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.watchlist-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watchlist-set {
  font-size: var(--fs-1); color: var(--muted);
}
.watchlist-foil {
  color: var(--warning);
}
.watchlist-prices {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-variant-numeric: tabular-nums;
}
.watchlist-price { font-weight: 600; }
.watchlist-delta { font-size: var(--fs-1); }
.delta-up {
  color: var(--success);
}
.delta-down {
  color: var(--danger);
}
.delta-flat {
  color: var(--muted);
}
.watchlist-empty {
  color: var(--muted);
}

/* Clone action overlaid on a public-browse deck card — same sibling-of-anchor
   technique as .deck-star (a <form>/<button> can't nest in the card's <a>).
   Bottom-right so it never collides with a top-right star (the two never
   render on the same card today, but keep them non-overlapping regardless). */
.deck-card-clone {
  position: absolute;
  bottom: var(--s-2);
  right: var(--s-2);
  z-index: 2;
  margin: 0;
}
.deck-card-clone-btn {
  display: inline-flex;
  align-items: center;
  height: var(--control-h-sm);
  padding: 0 var(--s-3);
  font-size: var(--fs-1);
  font-weight: 600;
  border: none;
  border-radius: var(--r-pill);
  background: var(--on-art-bg);
  color: var(--on-art-fg);
  cursor: pointer;
  transition: background 120ms ease;
}
.deck-card-clone-btn:hover {
  background: var(--on-art-bg-hover);
}
.deck-card-clone-btn:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}

.deck-mosaic {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 1;
  gap: 1px;
  background: var(--border);
}
.deck-mosaic-tile {
  overflow: hidden;
  background: var(--sunken);
}
.deck-mosaic-tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.deck-mosaic-tile--empty {
  background: var(--sunken);
}
.deck-mosaic-placeholder {
  grid-column: 1 / -1; grid-row: 1 / -1;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 64px; font-weight: 600;
  color: var(--border-strong);
  background: var(--sunken);
}
.deck-mosaic--composite { display: block; }
.deck-mosaic--composite img {
  display: block; width: 100%; height: 100%; object-fit: cover;
}

:is(.deck-card-meta, .collection-card-meta) {
  padding: var(--s-3) var(--s-4) var(--s-4);
}
:is(.deck-card-name-row, .collection-card-name-row) {
  display: flex; align-items: center; gap: var(--s-2);
  justify-content: space-between;
  min-width: 0;
}
:is(.deck-card-name, .collection-card-name) {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-3); font-weight: var(--fw-display); color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
:is(.deck-card-sub, .collection-card-sub) {
  margin: var(--s-1) 0 0;
  font-size: var(--fs-1); color: var(--muted);
}
/* Author byline — public browse only (My Decks omits it; every card there
   is already yours or a collaborator's). */
.deck-card-owner {
  margin: 2px 0 0;
  font-size: var(--fs-1); color: var(--muted);
}

:is(.format-chip, .game-chip) {
  display: inline-flex;
  align-items: center;
  height: var(--badge-h);
  padding: 0 var(--s-2);
  font-size: var(--fs-1); font-weight: 600;
  line-height: 1;
  border-radius: var(--r-badge);
  background: var(--sunken);
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.format-chip--pauper    { background: var(--blue-light); color: var(--blue-dark); }
.format-chip--commander { background: var(--yellow-bg);  color: var(--yellow-text); }

/* --------------------------------------------------------------------------
   4b-pre. COLLECTION CARDS + DASHBOARD
   -------------------------------------------------------------------------- */
.collection-summary {
  aspect-ratio: 1;
  background: var(--th-bg);
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s-3);
}
.collection-set-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-2);
  color: var(--text);
}
.collection-set-row .ss { font-size: var(--fs-4); line-height: 1; }
.collection-set-row .set-code {
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}
.collection-set-row .set-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: var(--fs-1);
}
.collection-set-row--empty {
  color: var(--muted);
  text-align: center;
  grid-template-columns: 1fr;
}
.collection-summary-placeholder {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 64px; font-weight: 600;
  color: var(--border-strong);
}

.dashboard-section {
  margin-bottom: var(--s-6);
}
.dashboard-section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-1) 0 var(--s-3);
}
.dashboard-section-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-4); font-weight: var(--fw-display);
}
.dashboard-view-all {
  font-size: var(--fs-2); color: var(--muted); text-decoration: none;
}
.dashboard-view-all:hover {
  color: var(--text);
}
.dashboard-empty {
  grid-column: 1 / -1;
  padding: var(--s-6); text-align: center;
  border: 1px dashed var(--input-border); border-radius: var(--r-panel);
  color: var(--muted);
}
.dashboard-empty .btn {
  margin-top: var(--s-3);
}

/* --------------------------------------------------------------------------
   4b. SIDEBAR — COLLAPSED RAIL (desktop only)
   Collapsed width = 2 × --s-4 + --ico-box, so icons keep their x (R4).
   -------------------------------------------------------------------------- */
@media (min-width: 769px) {
  html.sidebar-collapsed .layout {
    grid-template-columns: var(--sidebar-width-collapsed) minmax(0, 1fr);
  }
  /* Keep labels in the DOM + accessibility tree but visually hide them.
     Screen readers still announce each link's name when collapsed. */
  html.sidebar-collapsed .sidebar-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  html.sidebar-collapsed .sidebar-footer > .sidebar-version {
    display: none;
  }
  html.sidebar-collapsed .sidebar-section-label {
    height: var(--s-4);
    padding: 0 var(--s-4);
    font-size: 0;
    color: transparent;
  }
  html.sidebar-collapsed .sidebar-section-label::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
  }
  /* The rail keeps a small logo mark: the brand pie sits above the expand
     button, both centred on the 24px icon column (x = --s-4 … --s-4 + 24). */
  html.sidebar-collapsed .sidebar-header {
    flex-direction: column;
    justify-content: center;
    gap: var(--s-2);
    height: auto;
    min-height: var(--bar-h);
    padding: var(--s-3) 0 var(--s-1);
  }
  html.sidebar-collapsed .sidebar-brand {
    gap: 0;
  }
  html.sidebar-collapsed .sidebar-brand .dot {
    width: 20px;
    height: 20px;
  }
  html.sidebar-collapsed .sidebar-pin .icon { transform: rotate(180deg); }

  /* Unread badge shrinks to a corner dot when collapsed */
  html.sidebar-collapsed .sidebar-link .badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 8px;
    width: 8px;
    height: 8px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    margin-left: 0;
  }

  /* CSS-only tooltip — only active while collapsed */
  html.sidebar-collapsed .sidebar-link[data-tooltip]:hover::after,
  html.sidebar-collapsed .sidebar-link[data-tooltip]:focus-visible::after,
  html.sidebar-collapsed .sidebar-pin[data-tooltip]:hover::after,
  html.sidebar-collapsed .sidebar-pin[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + var(--s-2));
    top: 50%;
    transform: translateY(-50%);
    background: var(--tooltip-bg);
    color: var(--tooltip-fg);
    padding: var(--s-1) var(--s-2);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-2);
    font-size: var(--fs-1);
    font-weight: 600;
    white-space: nowrap;
    z-index: 300;
    pointer-events: none;
  }
  .layout { transition: grid-template-columns 0.18s; }
}

/* --------------------------------------------------------------------------
   22. MOBILE (max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Reset layout to single column */
  .layout,
  html.sidebar-collapsed .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  /* On mobile, ignore desktop collapsed state — drawer always shows full sidebar */
  html.sidebar-collapsed .sidebar-pin { display: none; }

  /* Sidebar: an off-canvas drawer, slides in with .open */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 85vw);
    height: 100vh;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-102%);
    transition: transform 0.2s;
    background: var(--surface);
  }

  .sidebar.open {
    transform: none;
    box-shadow: var(--shadow-3);
  }

  /* Show hamburger toggle (an ordinary topbar flex item) */
  .sidebar-toggle {
    display: inline-flex;
  }

  /* Drawer mode: swap desktop collapse-pin for a close button */
  .sidebar-pin { display: none; }
  .sidebar-close { display: inline-flex; }

  /* Dark overlay behind sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 150;
  }

  .sidebar.open ~ .sidebar-overlay,
  .sidebar-overlay.active {
    display: block;
  }

  /* Topbar: hamburger + breadcrumb share the first row; the search takes a
     full row of its own underneath. Same --gutter as the content. */
  .topbar {
    flex-wrap: wrap;
    row-gap: var(--s-2);
    padding-block: var(--s-2);
  }

  .topbar .breadcrumb {
    flex: 1 1 0;
    min-height: var(--control-h);
  }

  .topbar .search-suggest {
    order: 5;
    flex: 1 1 100%;
  }

  .content h1 {
    font-size: var(--fs-4);
  }

  /* Card detail stacks vertically */
  .card-detail {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-5);
  }

  /* Cap the foil wrapper together with the img: its ::before/::after
     overlay layers size to the wrapper (inset: 0), so a full-width
     wrapper paints the foil sheen past the card onto the page. */
  .card-detail img,
  .card-detail .card-foil {
    max-width: 260px;
  }

  .card-detail .card-detail-image {
    margin: 0 auto;
  }

  /* Detail fields single column */
  .detail-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-field:nth-child(odd) {
    padding-right: 0;
    border-right: none;
  }

  .detail-field:nth-child(even) {
    padding-left: 0;
  }

  /* Controls stack on small screens */
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  /* Pagination stacks */
  .pagination {
    flex-direction: column;
    gap: var(--s-2);
    align-items: center;
  }

  /* Card grid: smaller columns, same scale gutter */
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min-width, 130px), 136px), 1fr));
    gap: var(--s-3);
  }

  /* Narrow form full width on mobile */
  .narrow-form {
    max-width: 100%;
  }
}

/* --------------------------------------------------------------------------
   Deck cover picker
   -------------------------------------------------------------------------- */
.cover-picker { margin-top: 1.5rem; max-width: 720px; }
.cover-picker__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem;
}
.cover-picker__title { font-size: var(--fs-3); font-weight: 600; margin: 0; }
.cover-picker__meta { display: flex; align-items: center; gap: 0.75rem; }
.cover-picker__counter { font-size: var(--fs-1); color: var(--gray-500); }
.cover-picker__reset {
  background: transparent; border: 1px solid var(--gray-300);
  border-radius: var(--radius); padding: 4px 10px; font-size: var(--fs-1);
  cursor: pointer; color: var(--gray-700);
}
.cover-picker__reset:hover { background: var(--gray-100); }
.cover-picker__hint {
  font-size: var(--fs-1); color: var(--amber); margin: 0.25rem 0 0.75rem;
}
.cover-picker__preview {
  width: 240px; height: 240px; margin-bottom: 1rem;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  overflow: hidden;
}
.cover-picker__auto-label {
  position: absolute; left: 4px; top: 2px;
  font-size: var(--fs-1); color: var(--white); background: rgba(0, 0, 0, 0.5);
  padding: 1px 4px; border-radius: 3px;
}
.cover-picker__board {
  font-size: var(--fs-1); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--gray-500);
  margin: 1rem 0 0.5rem;
}
.cover-picker__gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 4px;
  max-height: 260px; overflow-y: auto;
  padding: 4px; margin: 0 -4px;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
}
.cover-picker__card {
  position: relative; padding: 0; border: 1px solid var(--gray-200);
  border-radius: var(--radius); background: var(--white);
  cursor: pointer; overflow: hidden; text-align: left;
}
.cover-picker__card:hover { border-color: var(--blue); }
.cover-picker__card--picked { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-light); }
.cover-picker__card img { display: block; width: 100%; height: 40px; object-fit: cover; }
.cover-picker__name {
  display: block; padding: 2px 4px;
  font-size: var(--fs-1); color: var(--gray-700); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cover-picker__badge {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px;
  background: var(--blue); color: var(--on-accent);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-1); font-weight: 600;
  z-index: 1;
}
.cover-picker__intro {
  margin: 0 0 0.5rem;
  font-size: var(--fs-1);
  color: var(--gray-600);
}
.cover-picker__slot-wrap {
  position: relative;
  background: var(--gray-100);
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.cover-picker__slot {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: opacity 0.15s ease;
}
.cover-picker__slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-picker__preview:not(.cover-picker__preview--has-armed) .cover-picker__slot--auto img {
  opacity: 0.55;
}
.cover-picker__preview--has-armed .cover-picker__slot:not(.is-armed) {
  opacity: 0.35;
}
.cover-picker__slot.is-armed {
  box-shadow: inset 0 0 0 4px var(--blue);
}
.cover-picker__clear {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  padding: 0;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--on-art-bg);
  color: #fff;
  font-size: var(--fs-4);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-picker__clear:hover {
  background: var(--danger);
}
.cover-picker__clear:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.cover-picker__hint--transient {
  background: var(--blue-light);
  border: 1px solid var(--blue);
  color: var(--gray-900);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: var(--fs-2);
  margin: 0 0 0.5rem;
}

/* --------------------------------------------------------------------------
   Toast (issue #259)
   Global feedback for htmx errors + non-error notices (deck-card skip/
   remove-undo, brainstorm checkout). Positioning/shadow/z-index are
   theme-agnostic; .toast--error / .toast--info supply the token color pair
   so the JS only ever toggles classes, never touches inline style.
   -------------------------------------------------------------------------- */
.toast {
  display: none;
  position: fixed;
  bottom: var(--s-5);
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-panel);
  background: var(--raised);
  color: var(--text);
  font-size: var(--fs-2);
  line-height: 1.35;
  box-shadow: var(--shadow-2);
  z-index: 1000;
  max-width: min(420px, calc(100vw - 2 * var(--s-4)));
}

.toast.is-visible {
  display: flex;
}

.toast--error {
  border-left-color: var(--danger);
}

.toast--info {
  border-left-color: var(--accent);
}

/* The optional Undo action (issue #167) inherits the toast's own text
   color, which is already a verified-readable pair against that toast's
   background in both variants and both themes; var(--blue) is not (it
   fails contrast against --gray-700 in light mode and against --red-bg /
   --gray-700 in dark mode — checked against both toast--error and
   toast--info in both themes). Opacity + underline supply the "it's a
   button" affordance instead. */
.toast-action {
  flex: none;
  margin-left: auto;
  height: var(--control-h-sm);
  padding: 0 var(--s-2);
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.toast-action:hover {
  background: var(--hover);
}

/* --------------------------------------------------------------------------
   24. REDUCED MOTION (issue #244, WCAG 2.3.3)
   Applies site-wide, across every stylesheet: collapses CSS animations/
   transitions to effectively instant for users who've asked the OS for
   reduced motion. The JS-driven fly-to-cart clone (brainstorm.js) isn't a
   CSS animation, so it has its own matchMedia guard.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Move-quantity slider (#314 Phase B) — the split interstitial. Compact inline
   in a collection-row cell; a proper modal on the card-detail page. */
.move-slider__title { font-size: var(--fs-3); font-weight: 600; margin: 0 0 4px; }
.move-slider__hint { font-size: var(--fs-1); color: var(--gray-500); margin: 0 0 16px; }
.move-slider__control { display: flex; align-items: center; gap: 12px; }
.move-slider__range { flex: 1; min-width: 120px; accent-color: var(--blue); }
.move-slider__count { font-size: var(--fs-2); white-space: nowrap; }
.move-slider--modal .move-slider__count { font-size: var(--fs-4); }
.move-slider--modal .move-slider__control { margin-bottom: 18px; }
.move-slider__actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.move-slider--modal .move-slider__actions { justify-content: flex-end; margin-top: 0; }

/* Pull-confirm ("move to deck X?") — the same modal treatment on detail. */
.pull-confirm--modal .pull-confirm__q { font-size: var(--fs-2); margin: 0 0 16px; }
.pull-confirm--modal .pull-confirm__actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Switch — visual-only restyle for a LONE boolean checkbox (spec 2026-07-19).
   Apply class="switch" directly to the <input type="checkbox">; markup,
   native semantics (keyboard, form posting, htmx change triggers) and the
   accessible checkbox role stay untouched. Checkbox GROUPS (tags, filters,
   column lists) deliberately keep the plain checkbox idiom. */
input[type="checkbox"].switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 36px;
  height: 20px;
  margin: 0;
  position: relative;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  background: var(--sunken);
  cursor: pointer;
  vertical-align: middle;
  transition: background-color 150ms ease, border-color 150ms ease;
}
input[type="checkbox"].switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 150ms ease, background-color 150ms ease;
}
/* Dark theme: the flipped grays leave an unchecked thumb nearly invisible on
   its track — lift it to the mid-gray. Scoped to :not(:checked) so it can
   never fight the checked thumb color, regardless of rule order. */
[data-theme="dark"] input[type="checkbox"].switch:not(:checked)::before {
  background: var(--muted);
}
input[type="checkbox"].switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"].switch:checked::before {
  transform: translateX(16px);
  background: var(--accent-ink);
}
input[type="checkbox"].switch:hover:not(:checked):not(:disabled) {
  border-color: var(--text);
}
input[type="checkbox"].switch:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
input[type="checkbox"].switch:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
@media (prefers-reduced-motion: reduce) {
  input[type="checkbox"].switch,
  input[type="checkbox"].switch::before {
    transition: none;
  }
}

/* Price movers (dashboard) — two ranked columns + range chips (spec 2026-08-01). */
.price-movers-chips { display: flex; gap: 6px; margin-bottom: 12px; }
.price-movers-chip {
  display: inline-flex;
  align-items: center;
  height: var(--control-h-sm);
  padding: 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  background: var(--chip-bg);
  color: var(--text);
  font: 500 var(--fs-1) / 1 var(--font-ui);
  cursor: pointer;
}
.price-movers-chip:hover {
  border-color: var(--input-border);
}
.price-movers-chip.is-active {
  background: var(--accent-soft);
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.price-movers-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--s-4);
}
.price-movers-title { margin: 0 0 8px; font-size: var(--fs-2); color: var(--gray-700); }
.price-movers-list { list-style: none; margin: 0; padding: 0; }
.price-movers-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--row-h-sm);
  padding: var(--s-1) 0;
  border-bottom: 1px solid var(--row-border);
}
.price-movers-row:last-child { border-bottom: none; }
.price-movers-main { min-width: 0; }
.price-movers-name { font-size: var(--fs-2); font-weight: 600; }
.price-movers-meta { display: block; font-size: var(--fs-1); color: var(--gray-600); }
.price-movers-foil { font-style: italic; }
.price-movers-nums {
  text-align: right; flex: none; font-variant-numeric: tabular-nums lining-nums;
}
.price-movers-unit { display: block; font-size: var(--fs-1); color: var(--gray-600); }
.price-movers-delta { font-size: var(--fs-2); font-weight: 700; }
.price-movers-delta.is-up {
  color: var(--success);
}
.price-movers-delta.is-down {
  color: var(--danger);
}
.price-movers-none { font-size: var(--fs-2); color: var(--gray-600); margin: 0; }

/* ==========================================================================
   PAGES
   Page-level layout and the classes that replaced one-off inline styles.
   Lengths/colours come from the tokens above; one sub-section per area.
   ========================================================================== */

/* --------------------------------------------------------------------------
   P1. COLLECTION LIST, TABLE, DETAIL, STATS (mtg/collection/*)
   -------------------------------------------------------------------------- */

/* Page head: title + actions row (Add / Mass actions / view / Columns). */
.collection-head {
  margin-bottom: var(--s-4);
}

/* Columns dropdown (Alpine columnToggle). */
.column-toggle {
  position: relative;
}
.column-toggle__menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--s-1));
  z-index: 50;
  min-width: 180px;
  padding: var(--s-1);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.column-toggle__item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--control-h-sm);
  padding: 0 var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-2);
  white-space: nowrap;
  cursor: pointer;
}
.column-toggle__item:hover {
  background: var(--hover);
}

/* The collection table scrolls inside its panel on narrow screens instead
   of squashing its columns (R5). */
#collection-table {
  min-width: 980px;
}
/* Override of the shared .th-sort: centre it in the header cell so labels
   with an (empty) reserved arrow slot sit on the same line as the rest. */
#collection-table .th-sort {
  vertical-align: middle;
}
#collection-table .t-name {
  white-space: nowrap;
}
#collection-table td.col-actions .btn {
  font-size: var(--fs-3);
}
#collection-table .t-name .card-tag-strip {
  margin-left: var(--s-2);
}
#collection-table td.col-condition,
#collection-table td.col-location {
  white-space: nowrap;
}
#collection-table th.col-actions,
#collection-table td.col-actions {
  width: calc(var(--control-h-sm) + var(--s-4) + var(--s-1));
}

/* ✎ "change location" trigger next to the place name. */
.place-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: var(--s-1);
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--muted);
  font-size: var(--fs-1);
  cursor: pointer;
  vertical-align: middle;
}
.place-edit-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.place-error {
  margin: 0 0 var(--s-1);
  font-size: var(--fs-1);
  color: var(--danger);
}

/* Inline (row) pull-confirm: question on its own line, actions below. */
.pull-confirm--inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1);
  max-width: 340px;
  padding: var(--s-1) 0;
  font-size: var(--fs-1);
  white-space: normal;
}
.pull-confirm--inline .pull-confirm__q {
  flex-basis: 100%;
}
.pull-confirm--inline .inline-form {
  display: inline-flex;
  gap: var(--s-1);
}

/* Grid view tiles: qty badge over the art, set + foil in the meta row. */
.gcard-img {
  position: relative;
}
.gcard-qty {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  display: inline-flex;
  align-items: center;
  height: var(--badge-h);
  padding: 0 var(--s-2);
  border-radius: var(--r-badge);
  background: var(--on-art-bg);
  color: var(--on-art-fg);
  font: 700 var(--fs-1) / 1 var(--font-ui);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.gcard-price {
  margin-left: auto;
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
}

/* Shared modal header (mass actions, place picker). */
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.modal-title {
  margin: 0;
  font: var(--fw-display) var(--fs-4) / 1.2 var(--font-display);
}
#collection-modal {
  min-width: min(420px, calc(100vw - 2 * var(--s-4)));
}
#collection-modal .mass-actions-panel {
  max-width: 480px;
}
.mass-actions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.place-modal {
  width: min(420px, calc(100vw - 2 * var(--s-4)));
}

/* Modal place picker (#316) — used on the list, detail and scan pages. */
.place-picker {
  min-width: min(360px, 100%);
}
.place-picker__filter {
  margin-bottom: var(--s-2);
}
.place-picker__list {
  max-height: min(50vh, 360px);
  overflow-y: auto;
}
.place-picker__group {
  margin: var(--s-3) 0 var(--s-1) var(--s-2);
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}
.place-picker__item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--control-h);
  padding: 0 var(--s-2);
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font-size: var(--fs-2);
  text-align: left;
  cursor: pointer;
}
.place-picker__item:hover {
  background: var(--hover);
}
.place-picker__item--current {
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.place-picker__item--create {
  color: var(--success);
}

/* Card detail (collection entry). */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  margin-bottom: var(--s-4);
  font-size: var(--fs-2);
  color: var(--muted);
}
.back-link:hover {
  color: var(--text);
}
.card-detail-image {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-width: 0;
}
.cd-info {
  min-width: 0;
}
.cd-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
}
.cd-mana {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-3);
}
.card-detail .oracle {
  white-space: pre-line;
}
.card-detail .oracle:has(.oracle-pt) {
  padding-bottom: var(--s-6);
}
.oracle-pt {
  position: absolute;
  right: var(--s-3);
  bottom: var(--s-2);
  font-size: var(--fs-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cd-info > .detail-fields {
  margin-bottom: var(--s-4);
}
/* The shared summary is a flex row, which drops the "▸ " glyph's trailing
   space — restore it with a gap on this page's printings toggle. */
.cd-printings > summary {
  gap: var(--s-2);
}
.cd-flavor {
  margin: 0 0 var(--s-4);
}
.cd-stat {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.cd-stat .form-label {
  margin: 0;
}
.cd-capitalize {
  text-transform: capitalize;
}
.cd-collection {
  margin-top: var(--s-5);
}
.cd-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0 var(--s-4);
}
.cd-fields .form-group {
  margin-bottom: var(--s-3);
}

/* − qty + stepper: one 36px control. */
.qty-stepper {
  display: inline-flex;
  align-items: stretch;
  height: var(--control-h);
  border: 1px solid var(--input-border);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
  overflow: hidden;
}
.qty-stepper__btn {
  width: var(--control-h);
  border: 0;
  background: none;
  color: var(--text);
  font-size: var(--fs-3);
  line-height: 1;
  cursor: pointer;
}
.qty-stepper__btn:hover {
  background: var(--hover);
}
.qty-stepper .qty-stepper__input {
  width: 56px;
  height: 100%;
  padding: 0;
  border: 0;
  border-inline: 1px solid var(--border);
  border-radius: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.qty-stepper .qty-stepper__input:focus {
  outline-offset: -2px;
}

/* Current place + Change button. */
.place-field {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.place-field .place-field__value {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: var(--sunken);
  border-color: var(--border);
}

/* Statistics: charts in panels, two up on wide screens. */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.stats-panel-wide {
  margin-bottom: var(--s-4);
}
.stats-chart {
  position: relative;
  min-width: 0;
}
.stats-chart--doughnut {
  height: 260px;
}
.stats-chart--line {
  height: 280px;
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .stats-chart--doughnut {
    height: 300px;
  }
}

/* --------------------------------------------------------------------------
   P1b. COLLECTION ADD / SCAN / IMPORT / MANAGEMENT (mtg scan+add, collection/*)
   -------------------------------------------------------------------------- */
/* Flash-style result messages rendered inside page content (add-card
   success/error swaps) sit in the content column, not under the topbar,
   so they drop the shell's gutter margin. */
.content .django-message {
  margin: 0 0 var(--s-4);
}

/* Secondary line under a table's name cell. */
.cell-sub {
  display: block;
  font-size: var(--fs-1);
  font-weight: 400;
  color: var(--muted);
}

.label-optional {
  color: var(--muted);
  font-weight: 400;
}

/* Settings / create forms: a narrow white panel. */
.settings-form {
  max-width: 480px;
  margin-top: var(--s-4);
}
.tab-bar + .settings-form {
  margin-top: 0;
}
.settings-form .form-group:last-of-type {
  margin-bottom: 0;
}

/* Danger zone (collection settings) */
.danger-zone-title {
  max-width: 480px;
  margin: var(--s-6) 0 var(--s-3);
  font: var(--fw-display) var(--fs-3) / 1.2 var(--font-display);
  color: var(--danger);
}
.danger-zone {
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 45%, transparent);
  padding: 0 var(--s-4);
}
.danger-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-4);
  padding: var(--s-4) 0;
}
.danger-row + .danger-row {
  border-top: 1px solid var(--border);
}
.danger-row > div {
  flex: 1 1 220px;
  min-width: 0;
}
.danger-row__title {
  margin: 0;
  font-weight: 600;
}
.danger-row__desc {
  margin: 2px 0 0;
  font-size: var(--fs-1);
  color: var(--muted);
}
.danger-row__action,
.danger-row > .btn {
  flex: none;
  margin: 0;
}

/* Delete confirmations */
.confirm-panel {
  max-width: 480px;
  margin-top: var(--s-4);
}
.confirm-panel__q {
  margin: 0 0 var(--s-2);
}
.confirm-panel__note {
  margin: 0;
  font-size: var(--fs-2);
  color: var(--muted);
}

/* Import page: form panel + formats aside */
.import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: var(--s-5);
  align-items: start;
}
.import-intro {
  margin: calc(-1 * var(--s-2)) 0 var(--s-4);
  color: var(--muted);
}
.import-mode-toggle {
  margin-bottom: var(--s-4);
}
textarea.import-textarea {
  font-family: var(--mono);
  font-size: var(--fs-2);
}
.import-file-input {
  display: block;
  max-width: 100%;
  font-size: var(--fs-2);
  color: var(--muted);
}
.choice-group {
  border: 0;
  padding: 0;
  min-width: 0;
}
.choice-group > legend {
  padding: 0;
}
.choice-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: var(--s-2) 0;
  cursor: pointer;
}
.choice-row input[type="radio"] {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
}
.choice-row__title {
  display: block;
  font-weight: 500;
}
.choice-row__hint {
  display: block;
  font-size: var(--fs-1);
  color: var(--muted);
}
.import-formats__label {
  margin: 0 0 var(--s-1);
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}
.code-sample {
  margin: 0 0 var(--s-4);
  padding: var(--s-2) var(--s-3);
  background: var(--oracle-bg);
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--border);
  font: var(--fs-1) / 1.5 var(--mono);
  color: var(--text);
  overflow-x: auto;
}
.code-sample:last-child {
  margin-bottom: 0;
}
@media (max-width: 1100px) {
  .import-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Import progress */
.import-progress__label {
  margin: 0 0 var(--s-2);
  font-size: var(--fs-2);
  color: var(--muted);
}
.progress-track {
  width: 100%;
  height: 6px;
  margin-bottom: var(--s-5);
  border-radius: 3px;
  background: var(--sunken);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--bar-fill);
  transition: width 0.4s;
}
.import-result {
  margin-bottom: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  background: var(--raised);
  box-shadow: var(--shadow-1);
}
.import-result--ok { border-left-color: var(--success); }
.import-result--error { border-left-color: var(--danger); }
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
  margin: 0 0 var(--s-5);
}
.stat-tile {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-3);
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  text-align: center;
}
.stat-tile dt {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}
.stat-tile dd {
  margin: 0;
  font: var(--fw-display) var(--fs-4) / 1.1 var(--font-display);
  color: var(--text);
}
.stat-tile__value--accent { color: var(--accent-text) !important; }
.stat-tile__value--warn { color: var(--warning) !important; }
.import-skipped-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

/* Add Cards page */
.add-cards-page {
  max-width: 860px;
  margin: 0 auto;
}
dialog.paste-dialog.paste-dialog--narrow {
  width: min(420px, calc(100vw - 2 * var(--s-4)));
}
/* Compact add strip (market card detail embed) */
.add-card-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-3);
}
.add-field {
  min-width: 0;
}
.add-panel-fields .add-field--place {
  grid-column: 1 / -1;
  order: 1;
}
.add-panel-fields .add-field--place .place-field {
  max-width: 480px;
}
.add-panel-fields {
  margin-bottom: 0;
}
.add-field .form-check {
  min-height: var(--control-h);
}
.add-panel-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--s-3) var(--s-4);
  align-items: end;
}
.place-field {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.form-input.place-display {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.add-card-strip .place-display {
  min-width: 120px;
}
.place-field > .btn {
  flex: none;
}
/* Quantity stepper: one 36px input-group, − / value / + */
.qty-stepper {
  display: inline-flex;
  align-items: stretch;
  height: var(--control-h);
  border: 1px solid var(--input-border);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
  overflow: hidden;
}
.qty-stepper:focus-within {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}
.qty-stepper__btn {
  flex: none;
  width: var(--control-h);
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-3);
  line-height: 1;
  cursor: pointer;
}
.qty-stepper__btn:hover {
  background: var(--hover);
}
.qty-stepper__input {
  width: 48px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 600 var(--fs-2) var(--font-ui);
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.qty-stepper__input::-webkit-inner-spin-button,
.qty-stepper__input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-stepper__input:focus {
  outline: none;
}

/* Scan page */
.scan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  margin-bottom: var(--s-4);
}
.scan-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.scan-total__label {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}
.scan-total__value {
  font: var(--fw-display) var(--fs-4) / 1 var(--font-display);
}
.scan-quick-add {
  position: relative;
  max-width: 420px;
  margin-bottom: var(--s-4);
}
.scan-suggestions {
  position: absolute;
  top: calc(100% + var(--s-1));
  left: 0;
  right: 0;
  z-index: 50;
  padding: var(--s-1);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-2);
}
.scan-suggestions:empty {
  display: none;
}
.scan-carousel-wrap {
  margin-bottom: var(--s-5);
}
#scan-carousel {
  display: flex;
  align-items: flex-end;
  min-height: 120px;
  padding: var(--s-2) var(--s-1) var(--s-2);
  overflow-x: auto;
  scrollbar-width: thin;
}
#scan-carousel .scan-card-thumb {
  flex: none;
  width: 100px;
  margin-left: -20px;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 4.75% / 3.4%;
  transition: transform 0.2s ease;
  cursor: pointer;
}
#scan-carousel .scan-card-thumb:first-child {
  margin-left: 0;
}
#scan-carousel .scan-card-thumb:hover {
  transform: translateY(-4px);
  z-index: 10;
}
#scan-carousel .scan-card-thumb img {
  width: 100%;
  display: block;
  border-radius: 4.75% / 3.4%;
  box-shadow: var(--card-shadow);
}
#scan-carousel .scan-card-thumb.scan-card-selected {
  z-index: 5;
}
#scan-carousel .scan-card-thumb.scan-card-selected img {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@keyframes scan-flash {
  0%, 100% { transform: translateY(0); }
  20% { transform: translateY(-8px); }
  40% { transform: translateY(-2px); }
}
#scan-carousel .scan-card-thumb.scan-card-flash {
  z-index: 20;
  animation: scan-flash 0.4s ease;
}
.scan-disconnected {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-top: var(--s-2);
  font-size: var(--fs-2);
  color: var(--danger);
}
#scan-edit-panel {
  min-height: 200px;
}
.scan-panel-empty {
  padding: var(--s-6) var(--s-4);
  border: 1px dashed var(--input-border);
  border-radius: var(--r-panel);
  color: var(--muted);
  font-style: italic;
  text-align: center;
}
.scan-search-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.scan-search-card {
  position: relative;
  width: 80px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}
.scan-search-card:hover {
  box-shadow: var(--shadow-2), 0 0 0 2px var(--accent);
}
.scan-search-card img {
  width: 100%;
  display: block;
}
.scan-search-set {
  display: block;
  padding: 2px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 768px) {
  #add-card-panel > div:first-child,
  .scan-card-detail > div:first-child {
    justify-self: center;
  }
  .scan-total {
    align-items: flex-start;
  }
  .scan-quick-add {
    max-width: none;
  }
}


/* --------------------------------------------------------------------------
   P2. DECK PAGES (decks/*)
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   P3. MARKET, SEARCH, LANDING, MESSAGING, NOTIFICATIONS, SHARED COMPONENTS
   -------------------------------------------------------------------------- */

/* Shared helpers used by these pages. */
.text-capitalize { text-transform: capitalize; }

/* Inline (in-content) flash: the shell variant carries the topbar gutter. */
.django-message.django-message--inline {
  display: flex;
  margin: 0 0 var(--s-4);
}

.empty-state.empty-state--compact {
  margin-top: 0;
  padding: var(--s-6) var(--s-4);
}

.empty-state-cta {
  margin-top: var(--s-2);
}

dialog.paste-dialog.paste-dialog--sm {
  width: min(380px, calc(100vw - 2 * var(--s-4)));
}

.narrow-panel {
  max-width: 480px;
}

/* Prev/Next-only pagination (deck log, notifications). */
.pagination.pagination--prevnext {
  justify-content: center;
}

/* In-page card search (browse, card detail): the topbar search field,
   anchored to the page instead of the bar. */
.page-search {
  flex: none;
  max-width: 480px;
  margin-bottom: var(--s-5);
}

.page-search--wide {
  max-width: 560px;
  margin-bottom: 0;
}

.topbar-search--lg {
  height: var(--control-h-lg);
  box-shadow: var(--shadow-1);
}

.topbar-search--lg input {
  font-size: var(--fs-3);
}

/* ---- Browse / search -------------------------------------------------- */
.search-head {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}

.search-head .form-help {
  margin-top: 0;
}

#advanced-results > [data-results-count] {
  margin-bottom: var(--s-4);
}

th.col-thumb,
td.col-thumb {
  width: calc(24px + var(--s-4) + var(--s-2));
  padding-right: 0;
}

td.t-type {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-card-noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 63 / 88;
  border-radius: 4.75% / 3.4%;
  background: var(--sunken);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: var(--fs-1);
  color: var(--muted);
}

/* Advanced search: sort + size row under the filter bar. */
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  margin: var(--s-3) 0 var(--s-4);
}

/* ---- Card detail (market) -------------------------------------------- */
.card-detail-image {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-width: 0;
}

.card-detail-face-toggle,
.card-detail-owned {
  margin: 0;
  font-size: var(--fs-2);
  text-align: center;
}

.card-detail-owned {
  text-align: left;
}

/* Info column + price side panel (mockup's third column); they stack under
   1240px, matching the mockup's breakpoint. */
.card-detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: var(--s-5);
  align-items: start;
  min-width: 0;
}

.card-detail-body > .detail-divider {
  grid-column: 1 / -1;
  margin-top: var(--s-2);
}

.card-detail-main {
  min-width: 0;
}

.card-detail-side {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
}

@media (max-width: 1240px) {
  .card-detail-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

.card-detail h2 .card-detail-finish {
  margin-left: var(--s-2);
  vertical-align: middle;
  font-family: var(--font-ui);
  letter-spacing: 0;
}

/* Mana cost: its own line of pips, not an oracle-text box. */
.card-detail-cost {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin: 0 0 var(--s-3);
  font-size: var(--fs-4);
  line-height: 1;
}

.card-detail-finishes .row-flex .filter-btn {
  height: var(--control-h-sm);
  font-size: var(--fs-1);
}

.card-detail-watch {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* Price block + history: white panels (components/card_prices.html and
   the lazy .price-history mount, both shared with the collection detail). */
.price-panel,
.price-history {
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  padding: var(--s-4);
  min-width: 0;
}

.price-panel-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-1) var(--s-2);
  margin: 0 0 var(--s-3);
  font: var(--fw-display) var(--fs-3) / 1.2 var(--font-display);
  color: var(--text);
}

.price-panel-title .price-caption {
  font: 400 var(--fs-1) / 1.3 var(--font-ui);
}

.price-panel .price-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.price-panel .price-row:last-child {
  border-bottom: 0;
}

.price-history > .price-caption {
  margin: 0;
}

.price-history-plot {
  position: relative;
  height: 220px;
}

.price-history-stats {
  margin-top: var(--s-2);
  font-size: var(--fs-1);
  line-height: 1.5;
}

.price-history-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

/* Range picker as a segmented control (sunken track, raised thumb). */
.price-history-ranges {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--r-ctl);
  background: var(--sunken);
}

.price-history-ranges .pagination-link {
  height: calc(var(--control-h-sm) - 2px);
  min-width: 36px;
  border: 0;
  border-radius: calc(var(--r-ctl) - 3px);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.price-history-ranges .pagination-link:hover {
  background: transparent;
  color: var(--text);
}

.price-history-ranges .pagination-link.current {
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.price-history-toggle {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-left: auto;
  cursor: pointer;
}

/* ---- Landing / dashboard ---------------------------------------------- */
.content.content--landing {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.content--landing .landing-hero {
  width: 100%;
}

.collection-card-chips {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex-shrink: 0;
}

.price-movers-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.price-movers-col {
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  padding: var(--s-3) var(--s-4) var(--s-2);
  min-width: 0;
}

.price-movers-title {
  margin: 0 0 var(--s-1);
  font: var(--fw-display) var(--fs-3) / 1.2 var(--font-display);
  color: var(--text);
}

.price-movers-name {
  font-size: var(--fs-2);
  font-weight: 600;
}

.price-movers-meta,
.price-movers-unit {
  font-size: var(--fs-1);
  color: var(--muted);
}

.price-movers-delta {
  font-size: var(--fs-2);
  font-weight: 700;
}

.price-movers-none {
  font-size: var(--fs-2);
  color: var(--muted);
  margin: 0;
}

.price-movers-list > .price-movers-none {
  padding: var(--s-2) 0;
}

/* ---- Watchlist --------------------------------------------------------- */
.watchlist {
  max-width: 760px;
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  overflow: hidden;
}

.watchlist-row:last-child {
  border-bottom: 0;
}

.watchlist-name {
  color: var(--text);
  font-weight: 600;
}

.watchlist-price {
  font-weight: 700;
}

.watchlist-delta {
  font-size: var(--fs-1);
  font-weight: 600;
}

/* ---- Messaging --------------------------------------------------------- */
.inbox-table a {
  color: inherit;
  text-decoration: none;
}

.inbox-table a:hover {
  text-decoration: underline;
}

.inbox-table .is-unread {
  font-weight: 700;
}

.inbox-unread {
  margin-left: var(--s-2);
}

td.inbox-preview {
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

td.inbox-preview.is-unread {
  color: var(--text);
  font-weight: 600;
}

.conversation-subject {
  margin-bottom: var(--s-4);
}

.conversation {
  display: flex;
  flex-direction: column;
  max-width: 820px;
  margin-bottom: var(--s-4);
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  overflow: hidden;
}

.conversation-thread {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--s-4);
}

.conversation-thread > .django-message--inline {
  margin: 0;
}

.conversation-reply {
  padding: var(--s-3);
  border-top: 1px solid var(--border);
  background: var(--th-bg);
}

.conversation-reply-form {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
}

textarea.form-input.conversation-reply-input {
  flex: 1;
  min-height: var(--control-h);
  max-height: 150px;
  padding-top: calc((var(--control-h) - 2px - 1.5em) / 2);
  padding-bottom: calc((var(--control-h) - 2px - 1.5em) / 2);
  resize: none;
  overflow-y: auto;
}

.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.msg--own {
  align-items: flex-end;
}

.msg-bubble {
  max-width: min(75%, 560px);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-sm);
  background: var(--sunken);
  color: var(--text);
}

.msg--own .msg-bubble {
  border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
  background: var(--accent-soft);
}

/* Off-screen sender label: the alignment conveys the sender visually, this
   gives assistive tech the same information. */
.msg-sender-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.msg-body {
  margin: 0;
  font-size: var(--fs-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-time {
  margin: var(--s-1) 0 0;
  font-size: var(--fs-1);
  color: var(--muted);
}

.msg--own .msg-time {
  text-align: right;
}

.msg-load-earlier {
  align-self: center;
}

.compose-form {
  margin-top: var(--s-4);
}

textarea.form-input.compose-body {
  min-height: 140px;
}

/* ---- Notifications ----------------------------------------------------- */
.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 820px;
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  overflow: hidden;
}

.notification-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--row-h);
  padding: var(--s-1) var(--s-4);
  border-bottom: 1px solid var(--row-border);
  color: var(--muted);
}

.notification-row:last-child {
  border-bottom: 0;
}

.notification-row:hover {
  background: var(--hover);
}

/* Unread: text weight + an accent dot in a fixed slot (read rows keep the
   slot empty so messages share one left edge). */
.notification-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.notification-row.is-unread {
  color: var(--text);
}

.notification-row.is-unread .notification-dot {
  background: var(--accent);
}

.notification-message {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-row.is-unread .notification-message {
  font-weight: 600;
}

.notification-message a {
  color: inherit;
  text-decoration: none;
}

.notification-message a:hover {
  text-decoration: underline;
}

.notification-time {
  flex-shrink: 0;
  font-size: var(--fs-1);
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.notification-row .btn {
  flex-shrink: 0;
}

/* ---- Filter-bar popover internals (components/filter_bar/popovers) --- */
.filter-bar__tag-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

.filter-bar__tag-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--control-h-sm);
  padding: 0 var(--s-1);
  border-radius: var(--r-sm);
  cursor: pointer;
}

.filter-bar__tag-row:hover {
  background: var(--hover);
}

.filter-bar__hint {
  font-size: var(--fs-1);
  color: var(--muted);
}

@media (max-width: 768px) {
  .msg-bubble {
    max-width: 88%;
  }

  .notification-row {
    flex-wrap: wrap;
    row-gap: 0;
    padding-block: var(--s-2);
  }

  .notification-message {
    flex: 1 1 calc(100% - 8px - var(--s-3));
    white-space: normal;
  }

  .notification-time {
    margin-left: calc(8px + var(--s-3));
    margin-right: auto;
  }
}

/* --------------------------------------------------------------------------
   P4. ACCOUNT / AUTH (templates/account/*, user/*, 403/404)
   -------------------------------------------------------------------------- */
/* Intro line under an auth heading. */
.auth-lead {
  margin: calc(-1 * var(--s-2)) 0 var(--s-4);
  font-size: var(--fs-2);
  color: var(--muted);
}

.auth-link-muted {
  color: var(--muted);
}

.auth-link-muted:hover {
  color: var(--text);
}

.form-errors-box p + p {
  margin-top: var(--s-1);
}

/* Account settings: stacked panels. */
.settings-page {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.settings-page > h1 {
  margin-bottom: var(--s-1);
}

/* Lone boolean → switch row: label left, switch right (mockup .switch-row).
   Same look as input.switch, scoped so the widget needs no extra class. */
.settings-switch .form-check {
  justify-content: space-between;
  gap: var(--s-3);
}

.settings-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 36px;
  height: 20px;
  margin: 0;
  position: relative;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  background: var(--sunken);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.settings-switch input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 150ms ease, background-color 150ms ease;
}

.settings-switch input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.settings-switch input[type="checkbox"]:checked::before {
  transform: translateX(16px);
  background: var(--accent-ink);
}

.settings-switch input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Label/value row with a trailing link (Email, Password). */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: var(--row-h);
  border-bottom: 1px solid var(--row-border);
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.settings-row-label {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}

.settings-row-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-row-link {
  flex: none;
  font-weight: 600;
}

/* API tokens */
.token-reveal {
  margin-bottom: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-ctl);
  background: var(--success-soft);
  color: var(--success);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 35%, transparent);
}

.token-reveal-title {
  margin-bottom: var(--s-2);
  font-size: var(--fs-2);
  font-weight: 600;
}

.token-reveal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.token-code {
  flex: 1 1 200px;
  min-width: 0;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-1);
  word-break: break-all;
  user-select: all;
}

.token-list {
  list-style: none;
  margin: 0 0 var(--s-3);
  border-radius: var(--r-ctl);
  box-shadow: 0 0 0 1px var(--border);
}

.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: var(--row-h);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--row-border);
}

.token-row:last-child {
  border-bottom: 0;
}

.token-row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.token-row-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-row-meta {
  font-size: var(--fs-1);
  color: var(--muted);
}

.token-empty {
  margin-bottom: var(--s-4);
  color: var(--muted);
}

/* Input + trailing buttons on one row; .copy-field is the read-only
   "copy this link" variant (collection settings' public URL, #233). */
.token-create,
.copy-field {
  display: flex;
  gap: var(--s-2);
}

.token-create .form-input,
.copy-field .form-input {
  flex: 1;
}

.token-create .btn,
.copy-field .btn {
  flex: none;
}

@media (max-width: 480px) {
  .token-create,
  .copy-field {
    flex-direction: column;
  }

  .token-create .form-input,
  .copy-field .form-input {
    flex: none;
  }
}

/* QR overlay (display toggled inline by the page script). */
.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  background: var(--scrim);
}

.qr-modal-card {
  max-width: 340px;
  padding: var(--s-5);
  border-radius: var(--r-modal);
  background: var(--raised);
  box-shadow: var(--shadow-3);
  text-align: center;
}

.qr-modal-title {
  margin-bottom: var(--s-4);
  font-weight: 600;
}

/* White quiet zone is part of the QR code, not decoration. */
.qr-canvas {
  width: 256px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  border: 16px solid #ffffff;
  border-radius: var(--r-sm);
  box-shadow: 0 0 0 1px var(--border);
}

/* Email addresses */
.email-list {
  margin-bottom: var(--s-3);
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--border);
  overflow: hidden;
}

.email-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  min-height: var(--row-h);
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--row-border);
  cursor: pointer;
}

.email-row:last-child {
  border-bottom: 0;
}

.email-row:hover {
  background: var(--hover);
}

.email-row:has(input:checked) {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.email-row input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
}

.email-row-address {
  flex: 1 1 200px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.email-row-badges {
  display: inline-flex;
  gap: var(--s-1);
}

.email-actions {
  margin-top: 0;
}

.email-actions .btn {
  flex: 1 1 auto;
}

/* 403 / 404 */
.error-page {
  max-width: 560px;
  margin: var(--s-6) auto 0;
}
