/* ══════════════════════════════════════════════════════════════════════════
   SWU Tracker — "Hyperspace" design system.

   Deep navy ground, glassy raised surfaces, holo-blue accent with soft glow.
   Tokens first (dark by default, light under [data-theme="light"]), then the
   component classes the templates use. Plain CSS on plain HTML; the JS only
   adds progressive enhancements (menus, sheets, counters, theme toggle).

   Motion: every hover/press transition is 120–200 ms; page changes use the
   cross-document View Transitions API. All of it is switched off under
   prefers-reduced-motion.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Type: Inter, self-hosted variable face (no runtime CDN requests) ──── */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter/Inter-Variable.260c81a4759b.woff2") format("woff2");
}

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Ground + surfaces */
  --color-bg:        #060912;
  --color-surface:   #0d1424;
  --color-surface-2: #131c31;
  --color-surface-3: #1a2540;
  --color-glass:     rgb(12 18 34 / .78);
  --color-menu:      rgb(14 21 39 / .97);   /* panels nested in the blurred bar can't blur themselves */
  --color-text:      #e9eefb;
  --color-border:    rgb(148 170 220 / .12);
  --color-border-strong: rgb(148 170 220 / .22);
  --color-divider:   var(--color-border);
  --page-glow:
    radial-gradient(1100px 520px at 50% -260px, rgb(46 110 255 / .26), transparent 70%),
    radial-gradient(700px 420px at 100% -80px, rgb(0 190 255 / .10), transparent 70%);
  --hover:  rgb(255 255 255 / .05);
  --press:  rgb(255 255 255 / .09);

  /* Neutral ramp (light → dark), blue-tinted */
  --color-neutral-100: #f0f4fd;
  --color-neutral-200: #dbe2f2;
  --color-neutral-300: #bcc6dd;
  --color-neutral-400: #98a3be;
  --color-neutral-500: #77839f;
  --color-neutral-600: #586480;
  --color-neutral-700: #3d4762;
  --color-neutral-800: #273049;
  --color-neutral-900: #171e33;

  /* Accent — holo blue */
  --color-accent:     #3d9dff;
  --color-accent-100: #eaf4ff;
  --color-accent-200: #cfe6ff;
  --color-accent-300: #9fcdff;
  --color-accent-400: #6ab4ff;
  --color-accent-500: #3d9dff;
  --color-accent-600: #1f7ff0;
  --color-accent-700: #1a5fc0;
  --color-accent-800: #163f80;
  --color-accent-900: #10264d;
  --accent-soft:  rgb(61 157 255 / .13);
  --accent-soft-2: rgb(61 157 255 / .22);
  --grad-accent:  linear-gradient(135deg, #52b8ff 0%, #2a73ff 100%);
  --glow-accent:  0 0 0 1px rgb(61 157 255 / .45), 0 8px 28px -8px rgb(61 157 255 / .65);

  /* Semantic — Rebel green (good) / Sith red (bad) */
  --color-good:        #7fe0a6;
  --color-good-fill:   #12402a;
  --color-good-strong: #2fb06a;
  --color-bad:         #ff9aa4;
  --color-bad-fill:    #4d1520;
  --color-bad-strong:  #e5485b;
  --color-badge:       #ff4d6a;

  /* Elevation */
  --shadow-sm: 0 0 0 1px var(--color-border);
  --shadow-md: 0 0 0 1px var(--color-border-strong), 0 10px 30px -8px rgb(0 0 0 / .7);
  --shadow-lg: 0 0 0 1px var(--color-border-strong), 0 24px 60px -12px rgb(0 0 0 / .8);
  --highlight: inset 0 1px 0 rgb(255 255 255 / .05);

  /* Type + rhythm */
  --font-heading: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-heading-weight: 650;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Menlo", monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --topbar-h: 64px;
  --content-w: 1320px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-bg:        #eef2fa;
  --color-surface:   #ffffff;
  --color-surface-2: #f6f8fd;
  --color-surface-3: #e9eef8;
  --color-glass:     rgb(255 255 255 / .8);
  --color-menu:      rgb(255 255 255 / .98);
  --color-text:      #111a2e;
  --color-border:    rgb(30 50 100 / .10);
  --color-border-strong: rgb(30 50 100 / .18);
  --page-glow:
    radial-gradient(1100px 520px at 50% -260px, rgb(46 110 255 / .16), transparent 70%),
    radial-gradient(700px 420px at 100% -80px, rgb(0 190 255 / .08), transparent 70%);
  --hover: rgb(20 40 90 / .05);
  --press: rgb(20 40 90 / .09);

  --color-neutral-100: #172036;
  --color-neutral-200: #27314b;
  --color-neutral-300: #3c4762;
  --color-neutral-400: #56617c;
  --color-neutral-500: #6d7893;
  --color-neutral-600: #9aa4bc;
  --color-neutral-700: #c3cbdc;
  --color-neutral-800: #dde3ef;
  --color-neutral-900: #edf1f8;

  --color-accent:     #1a6fe0;
  --color-accent-100: #0b2550;
  --color-accent-200: #12397a;
  --color-accent-300: #1a56b0;
  --color-accent-400: #1a6fe0;
  --color-accent-500: #1a6fe0;
  --color-accent-600: #5aa2ff;
  --color-accent-700: #9cc8ff;
  --color-accent-800: #d6e8ff;
  --color-accent-900: #edf5ff;
  --accent-soft:  rgb(26 111 224 / .09);
  --accent-soft-2: rgb(26 111 224 / .16);
  --grad-accent:  linear-gradient(135deg, #3a9bff 0%, #1a5fe0 100%);
  --glow-accent:  0 0 0 1px rgb(26 111 224 / .35), 0 8px 24px -10px rgb(26 111 224 / .5);

  --color-good:        #157a43;
  --color-good-fill:   #d5f3e1;
  --color-good-strong: #23a35d;
  --color-bad:         #b3203a;
  --color-bad-fill:    #fde0e4;
  --color-bad-strong:  #d93b55;

  --shadow-sm: 0 0 0 1px var(--color-border);
  --shadow-md: 0 0 0 1px var(--color-border), 0 10px 30px -12px rgb(20 40 90 / .25);
  --shadow-lg: 0 0 0 1px var(--color-border), 0 24px 60px -16px rgb(20 40 90 / .3);
  --highlight: inset 0 1px 0 rgb(255 255 255 / .7);
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--color-neutral-700) transparent; }
body {
  min-height: 100vh; min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  font-feature-settings: "cv11", "ss01";
  color: var(--color-text);
  background: var(--page-glow) no-repeat, var(--color-bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 var(--space-2);
}
h1 { font-size: 34px; font-weight: 750; letter-spacing: -0.03em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-decoration: none; text-underline-offset: 3px; transition: color .15s; }
a:hover { color: var(--color-accent-400); }
img { display: block; max-width: 100%; }
strong, b { font-weight: 600; }
code { font-family: var(--font-mono); font-size: .88em; background: var(--hover); padding: .1em .35em; border-radius: var(--radius-sm); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft-2); }
input[type=checkbox], input[type=radio] { accent-color: var(--color-accent); }
[hidden] { display: none !important; }

/* Inline SVG icons (Phosphor) */
.ph { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ph-sm { width: 14px; height: 14px; vertical-align: -2px; }
.ph-lg { width: 32px; height: 32px; }

/* Text utilities */
.text-muted, .dim { color: var(--color-neutral-500); }
.text-sub { font-size: 12.5px; color: var(--color-neutral-500); }
.text-good { color: var(--color-good); }
.text-bad  { color: var(--color-bad); }
.text-accent { color: var(--color-accent-300); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hint {
  width: 14px; height: 14px; vertical-align: -2px; margin-left: 2px;
  color: var(--color-neutral-500); cursor: help;
}
.hint:hover { color: var(--color-accent-300); }

.hr {
  height: 1px; border: 0; margin: var(--space-4) 0;
  background: linear-gradient(to right, transparent, var(--color-border) 48px,
    var(--color-border) calc(100% - 48px), transparent);
}
.hr-inline { display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--color-neutral-600); }
.hr-inline .hr { flex: 1; margin: 0; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  font-family: var(--font-heading); font-weight: 600;
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  min-height: 38px; padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: background .15s, border-color .15s, color .15s, box-shadow .2s, transform .12s var(--ease);
}
.btn:hover { color: var(--color-text); }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary, .btn-accent {
  color: #fff; background: var(--grad-accent); border-color: transparent;
  box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, 0 6px 18px -8px rgb(42 115 255 / .8);
}
.btn-primary:hover, .btn-accent:hover { color: #fff; box-shadow: var(--glow-accent); filter: brightness(1.08); }
.btn-secondary {
  background: var(--color-surface-2); border-color: var(--color-border-strong);
  box-shadow: var(--highlight);
}
.btn-secondary:hover { background: var(--color-surface-3); border-color: var(--color-neutral-700); }
.btn-ghost { color: var(--color-accent); padding-inline: 10px; }
.btn-ghost:hover { color: var(--color-accent-400); background: var(--accent-soft); }
.btn-danger { color: var(--color-bad); background: color-mix(in srgb, var(--color-bad-strong) 10%, transparent); border-color: color-mix(in srgb, var(--color-bad-strong) 45%, transparent); }
.btn-danger:hover { color: #fff; background: var(--color-bad-strong); border-color: var(--color-bad-strong); }
.btn-icon { width: 38px; height: 38px; min-height: 0; padding: 0; }
.btn-block { width: 100%; margin-top: var(--space-2); min-height: 44px; }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 13px; border-radius: 10px; }
.btn-xs { min-height: 0; padding: 2px 8px; font-size: 11.5px; line-height: 1.4; border-radius: 8px; }
.btn-back { margin-left: -6px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; }
.field > label, .field > .field-label, .field-label {
  display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px;
  color: var(--color-neutral-300);
}
.input {
  width: 100%; min-height: 40px; padding: 8px 12px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-surface) 70%, transparent);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:hover { border-color: var(--color-neutral-600); }
.input:focus-visible, .input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
.input:disabled { opacity: .6; }
.input::placeholder { color: var(--color-neutral-600); }
select.input { appearance: auto; cursor: pointer; }
textarea.input { min-height: 90px; resize: vertical; }
.input-auto { width: auto; }
.input-compact { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.input-num { width: 76px; text-align: right; }
.input-date { width: 140px; }
input[type=file].input { padding: 6px 10px; }
input[type=file].input::file-selector-button {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; margin-right: 10px;
  color: var(--color-text); background: var(--color-surface-3);
  border: 1px solid var(--color-border-strong); border-radius: 8px; padding: 4px 12px;
}
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.form-hint { font-size: 12.5px; color: var(--color-neutral-500); margin: 0; line-height: 1.5; }
.form-error {
  font-size: 13px; color: var(--color-bad);
  background: color-mix(in srgb, var(--color-bad-strong) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-bad-strong) 40%, transparent);
  padding: 10px 12px; border-radius: var(--radius-md);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--color-neutral-300); cursor: pointer; }

/* Search input with a leading icon */
.search { position: relative; flex: 1; min-width: 220px; }
.search .ph { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-neutral-500); width: 17px; height: 17px; pointer-events: none; }
.search .input { padding-left: 38px; min-height: 42px; }

/* Radio (custom dot) */
.radio { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; }
.radio input, .seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.radio .dot { width: 18px; height: 18px; flex: none; border-radius: 50%; margin-top: 2px; border: 1.5px solid var(--color-neutral-600); transition: border-color .15s, background .15s; }
.radio:hover .dot { border-color: var(--color-accent); }
.radio input:checked + .dot { border-color: var(--color-accent); background: var(--color-accent); box-shadow: inset 0 0 0 4px var(--color-surface); }
.radio input:focus-visible + .dot { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.radio-stack { display: flex; flex-direction: column; gap: 12px; }
.radio strong { font-weight: 600; }
.radio .text-sub { display: block; }

/* Segmented control — works for radios and for plain links */
.seg {
  display: inline-flex; gap: 2px; padding: 3px; overflow: hidden;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: calc(var(--radius-md) + 2px);
}
.seg-opt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 500; cursor: pointer; color: var(--color-neutral-400);
  position: relative; white-space: nowrap; border-radius: 9px;
  transition: background .15s, color .15s;
}
.seg-opt:has(input:checked), .seg-opt[aria-current] {
  color: var(--color-text); background: var(--color-surface-3);
  box-shadow: var(--highlight), 0 0 0 1px var(--color-border-strong);
}
.seg-opt:not(:has(input:checked)):not([aria-current]):hover { background: var(--hover); color: var(--color-text); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.seg-opt .text-sub { font-size: 11px; }

/* Chip (filter pill) */
.chip {
  cursor: pointer; padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--color-border-strong); background: var(--color-surface);
  color: var(--color-neutral-300); font: inherit; font-size: 13px; font-weight: 500; line-height: 1.4;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.chip:hover { background: var(--color-surface-2); color: var(--color-text); border-color: var(--color-neutral-600); }
.chip[aria-pressed='true'], .chip.is-on {
  color: var(--color-accent-200); border-color: color-mix(in srgb, var(--color-accent) 60%, transparent);
  background: var(--accent-soft);
}
select.chip, .chip-caret { padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='%2377839f'><path d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 11px;
}
select.chip { appearance: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* Multi-select chip: <details> whose summary looks like a select.chip */
.chip-multi { position: relative; }
.chip-multi > summary { list-style: none; }
.chip-multi > summary::-webkit-details-marker { display: none; }
.chip-multi[open] > summary { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip-multi-panel {
  position: absolute; z-index: 30; top: calc(100% + 8px); left: 0;
  width: min(340px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px;
  padding: 8px; border-radius: var(--radius-lg); border: 1px solid var(--color-border-strong);
  background: var(--color-menu);
  box-shadow: var(--shadow-lg);
  animation: pop-in .16s var(--ease);
}
.chip-multi-search { width: 100%; }
.chip-multi-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.chip-multi-list label {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  cursor: pointer; font-size: 13.5px; transition: background .12s;
}
.chip-multi-list label:hover { background: var(--hover); }
.chip-multi-list label:has(input:checked) { background: var(--accent-soft); }
.chip-multi-list input { accent-color: var(--color-accent); width: 16px; height: 16px; margin: 0; }
.chip-multi-list .set-code { min-width: 4.5em; font-weight: 650; }
.chip-multi-list .text-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-multi-foot { display: flex; justify-content: space-between; gap: 8px; padding-top: 4px; border-top: 1px solid var(--color-border); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4); border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--color-surface-2), var(--color-surface));
  border: 1px solid var(--color-border);
  box-shadow: var(--highlight);
}
a.card { color: inherit; transition: transform .18s var(--ease), border-color .18s, box-shadow .2s; }
a.card:hover { color: inherit; transform: translateY(-2px); border-color: color-mix(in srgb, var(--color-accent) 45%, transparent); box-shadow: var(--highlight), 0 14px 34px -14px rgb(61 157 255 / .45); }
a.card:active { transform: translateY(0) scale(.99); }
.card-row { flex-direction: row; align-items: center; gap: var(--space-4); }
.card-pad { padding: var(--space-6); gap: var(--space-4); }
.card-kicker, .kicker { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--color-accent-400); }
.card-title { font-family: var(--font-heading); font-weight: 650; font-size: 17px; line-height: 1.25; }
.card-body { margin: 0; font-size: 13.5px; color: var(--color-neutral-400); flex: 1; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-neutral-500); }
.card .btn-ghost { align-self: flex-start; }
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* Card art — <img> from cdn.swu-db.com, or a neutral placeholder <span> */
.thumb {
  flex: none; display: block; border-radius: 6px; object-fit: cover; object-position: top;
  background: linear-gradient(160deg, var(--color-neutral-800), var(--color-neutral-900));
  box-shadow: 0 0 0 1px var(--color-border), 0 4px 12px -4px rgb(0 0 0 / .6);
}
.thumb-sm { width: 26px; height: 36px; border-radius: 4px; }
.thumb-md { width: 42px; height: 59px; }
.thumb-lg { width: 56px; height: 78px; border-radius: 7px; }
.thumb-xl { width: 220px; height: 308px; border-radius: 14px; max-width: 100%; }
.thumb-wide.thumb-sm { width: 36px; height: 26px; }
.thumb-wide.thumb-md { width: 59px; height: 42px; }
.thumb-wide.thumb-lg { width: 78px; height: 56px; }
.thumb-wide.thumb-xl { width: 308px; height: 220px; }

/* Hover / tap preview of card art */
.art-pop {
  position: fixed; z-index: 60; pointer-events: none;
  padding: 5px; border-radius: 16px; background: var(--color-glass);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-lg);
  animation: pop-in .14s var(--ease);
}
.art-pop img { display: block; width: 300px; max-width: calc(100vw - 48px); height: auto; border-radius: 12px; }
.art-pop img.is-wide { width: 420px; }
/* Touch: tap a thumbnail → centred overlay, tap anywhere to close */
.art-pop.is-modal {
  pointer-events: auto; cursor: zoom-out;
  left: 50% !important; top: 50% !important; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / .6), var(--shadow-lg);
  animation: none;
}
.art-pop.is-modal img { width: min(360px, calc(100vw - 48px)); max-height: calc(100dvh - 48px); object-fit: contain; }
.art-pop.is-modal img.is-wide { width: min(520px, calc(100vw - 48px)); }
img.thumb { cursor: zoom-in; }
.coll-row[data-art] .coll-print, .coll-name, .cell-card .cell-title, [data-art]:not(.coll-row) { cursor: zoom-in; }
/* Hover targets hug their text, so empty space beside a name doesn't trigger */
.coll-row .coll-print { justify-self: start; }
.coll-name, .cell-card .cell-title { width: fit-content; max-width: 100%; }

@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ── Collection: catalog grouped by card, one −/+ counter per printing ──── */
.coll-toolbar {
  position: relative; z-index: 20;   /* its dropdowns must stay above the list, even mid-animation */
  padding: var(--space-3); border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--color-surface-2), var(--color-surface));
  border: 1px solid var(--color-border); box-shadow: var(--highlight);
}
.coll-toolbar select.chip { max-width: 190px; text-overflow: ellipsis; }
.coll-group { transition: border-color .15s, box-shadow .2s; border: 1px solid transparent; }
.coll-group:hover { border-color: var(--color-border-strong); }
.coll-group[open] { border-color: color-mix(in srgb, var(--color-accent) 35%, transparent); box-shadow: var(--shadow-sm), 0 16px 40px -20px rgb(61 157 255 / .35); }
.coll-toolbar .chip-num { width: 36px; background: transparent; border: 0; color: inherit; font: inherit; -moz-appearance: textfield; appearance: textfield; }
.coll-toolbar .chip-num::-webkit-outer-spin-button, .coll-toolbar .chip-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.coll-toolbar .chip-num:first-of-type { text-align: right; }
.coll { display: flex; flex-direction: column; gap: var(--space-2); }
.coll-group {
  background: var(--color-surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); scroll-margin-top: 12px;   /* no overflow clip: request menus pop out */
}
.coll-head {
  display: grid; align-items: center; column-gap: var(--space-4); row-gap: var(--space-2);
  grid-template-columns: auto minmax(0, 1fr) auto minmax(64px, auto) auto;
  grid-template-areas: "art title stats total caret";
  padding: var(--space-3) var(--space-4);
  cursor: pointer; list-style: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.coll-head::-webkit-details-marker { display: none; }
.coll-head:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.coll-head:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.coll-head { border-radius: var(--radius-md); }
.coll-group[open] > .coll-head { border-bottom: 1px solid var(--color-divider); border-radius: var(--radius-md) var(--radius-md) 0 0; }
.coll-row:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.coll-caret { display: inline-flex; color: var(--color-neutral-500); transition: transform .15s; }
.coll-group[open] .coll-caret { transform: rotate(180deg); color: var(--color-accent); }
.coll-focus strong { color: var(--color-accent-300); }
.coll-foldall { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: calc(-1 * var(--space-4)); }
.coll-toolbar .seg { flex-wrap: wrap; }
.coll-head > .thumb { grid-area: art; }
.coll-title { grid-area: title; min-width: 0; }
.coll-total { grid-area: total; }
.coll-caret { grid-area: caret; }

/* Card stats: aspects, cost, power, HP. Big and colour-coded like the card frame. */
.coll-stats { grid-area: stats; display: flex; align-items: center; gap: 2px; }
.coll-aspects { display: inline-flex; justify-content: flex-end; gap: 3px; margin-right: 4px; min-width: 88px; }
.stat-empty { visibility: hidden; }
.coll-aspects .aspect-icon { width: 26px; height: 29px; }
.coll-aspects .aspect-pip { width: 24px; height: 24px; font-size: 12px; }
/* Quiet stats: a small outlined cost circle, then power / HP as coloured numbers. */
.stat {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; font-size: 14px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--color-neutral-300);
}
.stat b { font-weight: inherit; }
.stat small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stat-cost { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--color-neutral-600); font-size: 13px; margin-right: 4px; }
.stat-power { color: #e98a84; justify-content: flex-end; }
.stat-hp { color: #8db4ec; justify-content: flex-start; min-width: 26px; }
.stat-power + .stat-hp::before { content: "/"; color: var(--color-neutral-600); font-weight: 400; margin: 0 3px; }
:root[data-theme="light"] .stat-power { color: #a3211a; }
:root[data-theme="light"] .stat-hp    { color: #1b4f9c; }
.coll-name { font-weight: 500; font-size: 15px; line-height: 1.25; }
.coll-sub { font-size: 12px; color: var(--color-neutral-400); }
.coll-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; color: var(--color-neutral-500); margin-top: 2px; }
.coll-total { text-align: right; white-space: nowrap; font-size: 13px; color: var(--color-neutral-300); }
.coll-total strong { font-size: 18px; font-weight: 600; color: var(--color-text); }
.coll-total.is-zero, .coll-total.is-zero strong { color: var(--color-neutral-600); }
.coll-pool { font-size: 11px; color: var(--color-neutral-500); }

.coll-rows { list-style: none; margin: 0; padding: 0; }
.coll-row {
  display: grid; align-items: center; column-gap: var(--space-3); row-gap: 2px;
  grid-template-columns: 18px minmax(150px, 240px) minmax(0, 1fr) auto auto;
  grid-template-areas: "check print info others counter";
  padding: 6px var(--space-4);
  border-bottom: 1px solid color-mix(in srgb, var(--color-divider) 60%, transparent);
}
.coll-row:last-child { border-bottom: 0; }
.coll-row:hover { background: color-mix(in srgb, var(--color-text) 3%, transparent); }
.coll-check { grid-area: check; display: flex; }
.coll-check input { margin: 0; }
.coll-print { grid-area: print; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.coll-print .set-code { color: var(--color-accent-300); font-weight: 500; }
.coll-num { color: var(--color-neutral-400); font-variant-numeric: tabular-nums; }
.coll-info { grid-area: info; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--color-neutral-400); }
.coll-info > span { display: inline-flex; align-items: center; gap: 3px; }
.coll-info .info-deck { color: var(--color-accent-300); }
.coll-info .info-inactive { color: var(--color-neutral-500); font-style: italic; }
.coll-others { grid-area: others; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.coll-others:empty { display: none; }
.owner-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-neutral-300);
  padding: 1px 2px 1px 8px; border-radius: 999px; border: 1px solid var(--color-divider);
}
.owner-chip strong { color: var(--color-text); font-weight: 600; }
.owner-chip:not(:has(.btn)) { padding-right: 8px; }
.owner-chip .row-check { margin: 0 2px 0 -2px; }
/* Request menu on a partner's copies: trade for it, or ask to borrow it. */
.req-menu { position: relative; display: inline-block; }
.req-menu > summary { list-style: none; }
.req-menu > summary::-webkit-details-marker { display: none; }
.req-menu[open] > summary { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.req-menu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 15; min-width: 170px;
  display: flex; flex-direction: column; padding: 4px;
  background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.req-menu-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--color-text); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.req-menu-opt:hover, .req-menu-opt:focus-visible { background: color-mix(in srgb, var(--color-accent) 12%, transparent); color: var(--color-accent-200); }
.selection-hint { flex-basis: 100%; }

/* Printing chip: standard / hyperspace / foil / other special treatments. */
.vchip {
  display: inline-flex; align-items: center; font-size: 11px; line-height: 1.5;
  padding: 0 7px; border-radius: 999px; white-space: nowrap;
  background: var(--color-neutral-800); color: var(--color-neutral-300);
}
.vchip-normal { background: transparent; color: var(--color-neutral-500); padding-inline: 0; }
.vchip-hyperspace { background: var(--color-accent-800); color: var(--color-accent-100); }
.vchip-foil { background: color-mix(in srgb, #d8b64a 22%, transparent); color: #e8cf7a; }
.vchip-special { background: color-mix(in srgb, #b07be0 22%, transparent); color: #d2b4f0; }
.vchip-stamp { background: transparent; border: 1px dashed var(--color-divider); color: var(--color-neutral-400); }
:root[data-theme="light"] .vchip-foil { color: #7a5d00; }
:root[data-theme="light"] .vchip-special { color: #5b2d8a; }

/* Zero rows stay visible but recede, so owned printings stand out. */
.coll-row.is-zero .coll-print, .coll-row.is-zero .counter-val { opacity: .45; }
.coll-row.is-zero:hover .coll-print { opacity: .75; }

.counter { grid-area: counter; display: inline-flex; align-items: center; margin: 0; }
.counter-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-divider); background: transparent; color: var(--color-accent);
  cursor: pointer; padding: 0; touch-action: manipulation;
  transition: background .12s, border-color .12s;
}
.counter-btn:first-of-type { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.counter-btn:last-of-type { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.counter-btn:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); border-color: var(--color-accent); }
.counter-btn:active { background: color-mix(in srgb, var(--color-accent) 24%, transparent); }
.counter-btn:disabled { color: var(--color-neutral-600); cursor: default; background: transparent; border-color: var(--color-divider); }
.counter-btn { font-size: 20px; font-weight: 500; line-height: 1; font-family: var(--font-body); }
.counter-val {
  width: 46px; height: 34px; text-align: center; font: inherit; font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--color-text); background: var(--color-bg);
  border: 1px solid var(--color-divider); border-left: 0; border-right: 0; border-radius: 0;
  -moz-appearance: textfield; appearance: textfield;
}
.counter-val::-webkit-outer-spin-button, .counter-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.counter-val:focus { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.counter.is-busy .counter-val { color: var(--color-accent-300); }
.counter.is-error .counter-val { outline: 2px solid var(--color-bad-strong); outline-offset: -2px; }
.counter-static { grid-area: counter; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.coll-pager { padding: var(--space-2) 0; }

/* Phone: counter on the right of the printing line, details wrap below. */
@media (max-width: 720px) {
  .coll-head {
    padding: var(--space-3); column-gap: var(--space-3);
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "art title total caret"
      "art stats stats stats";
  }
  .stat-empty { display: none; }
  .coll-aspects { min-width: 0; justify-content: flex-start; }
  .coll-aspects:empty { display: none; }
  /* Scope buttons: one swipeable row, like the filter chips. */
  .coll-toolbar .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .coll-toolbar .seg::-webkit-scrollbar { display: none; }
  .coll-toolbar .seg-opt { flex: none; }
  .coll-aspects .aspect-icon { width: 22px; height: 25px; }
  .coll-row {
    grid-template-columns: 18px minmax(0, 1fr) auto;
    grid-template-areas:
      "check print  counter"
      ".     info   counter"
      ".     others others";
    padding: 8px var(--space-3);
  }
  .coll-others { justify-content: flex-start; }
  .counter-btn { width: 42px; height: 42px; }
  .counter-val { width: 48px; height: 42px; font-size: 16px; }  /* 16px stops iOS zooming on focus */
  .coll-toolbar .search { min-width: 100%; }
  /* Filters become one swipeable row instead of five wrapped ones. */
  .coll-toolbar .chips {   /* swipe edge-to-edge inside the toolbar panel */
    width: calc(100% + 2 * var(--space-3)); margin-inline: calc(-1 * var(--space-3));
    padding: 0 var(--space-3) 2px; flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .coll-toolbar .chips::-webkit-scrollbar { display: none; }
  .coll-toolbar .chips > * { flex: none; }
  .coll-toolbar .chips select.chip { max-width: 60vw; }
  /* The swipeable row clips overflow, so the panel docks to the viewport. */
  .chip-multi-panel { position: fixed; top: auto; left: 16px; right: 16px; bottom: 16px; width: auto; }
  .chip-multi-list { max-height: 50vh; }
}

/* Metric tiles */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-3); }
.metric { gap: 4px; padding: var(--space-4) 18px; position: relative; overflow: hidden; }
.metric-label { font-size: 12.5px; font-weight: 550; color: var(--color-neutral-400); display: flex; gap: 8px; align-items: center; }
.metric-label .ph { width: 20px; height: 20px; color: var(--color-accent); }
.metric-value { font-size: 32px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: 4px; }
.metric-value-sm { font-size: 22px; }
.metric-delta { font-size: 12.5px; color: var(--color-neutral-500); }
.metric-hot { border-color: color-mix(in srgb, var(--color-accent) 50%, transparent); }
.metric-hot::after { content: ""; position: absolute; inset: auto -30% -60% auto; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, rgb(61 157 255 / .25), transparent 70%); pointer-events: none; }
.metric-hot .metric-value { color: var(--color-accent-300); }

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; letter-spacing: .02em; padding: 3px 10px; white-space: nowrap;
  border-radius: calc(var(--radius-md) * .75); line-height: 1.4;
}
.tag-accent  { background: var(--color-accent-800); color: var(--color-accent-100); }
.tag-neutral { background: var(--color-neutral-800); color: var(--color-neutral-100); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }
.tag-good    { background: var(--color-good-fill); color: var(--color-good); }
.tag-bad     { background: var(--color-bad-fill); color: var(--color-bad); }
.tag-muted   { border: 1px solid var(--color-divider); color: var(--color-neutral-500); }
.tag-tier    { width: 28px; padding-inline: 0; font-weight: 500; }
.tag-mini    { font-size: 10px; padding: 2px 7px; }

/* Status colours (string-keyed from model status fields) */
.status-pending, .status-running, .status-request { color: var(--color-accent-300); }
.status-succeeded, .status-confirmed, .status-active, .status-returned { color: var(--color-good); }
.status-failed, .status-rejected, .status-cancelled, .status-declined { color: var(--color-bad); }
.status-gift, .status-trade, .status-lend, .status-lend_return { color: var(--color-neutral-400); }
.tag.status-pending, .tag.status-running { background: var(--color-accent-800); color: var(--color-accent-100); }
.tag.status-succeeded, .tag.status-confirmed, .tag.status-active { background: var(--color-good-fill); color: var(--color-good); }
.tag.status-failed, .tag.status-rejected, .tag.status-cancelled, .tag.status-declined { background: var(--color-bad-fill); color: var(--color-bad); }
.tag.status-returned { background: var(--color-neutral-800); color: var(--color-neutral-100); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { min-width: 0; overflow-x: auto; }
.table, .data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .data-table th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 500;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: var(--space-2); border-bottom: 1px solid transparent; white-space: nowrap;
}
.table td, .data-table td { padding: var(--space-2); border-bottom: 1px solid transparent; vertical-align: middle; }
.table thead tr, .data-table thead tr {
  background: linear-gradient(to right,
    transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table tbody tr, .data-table tbody tr {
  background: linear-gradient(to right,
    transparent, color-mix(in srgb, var(--color-text) 8%, transparent) 48px,
    color-mix(in srgb, var(--color-text) 8%, transparent) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table tbody tr:hover, .data-table tbody tr:hover {
  background:
    linear-gradient(color-mix(in srgb, var(--color-text) 4%, transparent),
                    color-mix(in srgb, var(--color-text) 4%, transparent)) no-repeat 0 0 / 100% 100%,
    linear-gradient(to right,
      transparent, color-mix(in srgb, var(--color-text) 8%, transparent) 48px,
      color-mix(in srgb, var(--color-text) 8%, transparent) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table-tight { font-size: 13px; }
.table .col-check { width: 32px; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { text-align: right; white-space: nowrap; }
.table .cell-title { font-weight: 500; }
.table .cell-sub { font-size: 12px; color: var(--color-neutral-500); }
.table .cell-set { font-size: 12px; color: var(--color-neutral-400); white-space: nowrap; }
.table .cell-set .set-code { color: var(--color-accent-300); }
.table .cell-dim { font-size: 13px; color: var(--color-neutral-400); }
.table .cell-idx { color: var(--color-neutral-600); font-size: 12px; }
.table .cell-card { display: flex; align-items: center; gap: 10px; min-width: 0; }
.table .cell-card > div { min-width: 0; }
tr.row-link { cursor: pointer; }
tr.row-in-aspect  td:first-child { box-shadow: inset 3px 0 0 var(--color-good-strong); }
tr.row-off-aspect td:first-child { box-shadow: inset 3px 0 0 var(--color-bad-strong); }
tr.row-off-aspect { opacity: .8; }
.sort-link { color: inherit; display: inline-flex; align-items: center; gap: 3px; }
.sort-link:hover, .sort-link.is-sorted { color: var(--color-text); }
.sort-arrow { font-size: 10px; }
.foil-mark { color: var(--color-accent-300); }
.variant-tag { display: inline-flex; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--color-divider); color: var(--color-neutral-400); }
.stamp { font-size: 12px; color: var(--color-neutral-500); }
.reserved-hint { font-size: 11px; color: var(--color-neutral-500); margin-left: 4px; }

/* Inline meter (share / similarity / coverage) */
.bar { display: flex; align-items: center; gap: 8px; }
.bar-track { width: 80px; height: 4px; border-radius: 2px; background: var(--color-neutral-800); overflow: hidden; flex: none; }
.bar-fill { height: 100%; background: var(--color-accent); }
.bar-label { font-size: 12px; color: var(--color-neutral-400); font-variant-numeric: tabular-nums; }

/* Row lists — request rows with a fading rule under each row */
.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4);
  padding: 9px 0;
  background: linear-gradient(to right, transparent, var(--color-divider) 24px,
    var(--color-divider) calc(100% - 24px), transparent) no-repeat bottom / 100% 1px;
}
.row-item:last-child { background: none; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .sub { font-size: 12px; color: var(--color-neutral-500); }
.row-item .val { font-size: 15px; color: var(--color-neutral-400); white-space: nowrap; }
.row-item .actions { display: flex; gap: 6px; flex: none; }
.row-rank { display: grid; grid-template-columns: 24px minmax(0,1fr) auto; gap: 10px; align-items: center; }
.row-rank .tag { padding: 2px 0; }
a.row-item, a.row-rank { color: inherit; }
a.row-item:hover, a.row-rank:hover { color: inherit; }
a.row-rank:hover .title { color: var(--color-accent-300); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: var(--space-4); }
.timeline .rail { display: flex; flex-direction: column; align-items: center; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--color-neutral-700); }
.timeline .dot-accent { background: var(--color-accent); }
.timeline .dot-good { background: var(--color-good-strong); }
.timeline .dot-bad { background: var(--color-bad-strong); }
.timeline .line { flex: 1; width: 1px; background: linear-gradient(var(--color-divider), transparent); }
.timeline li:last-child .line { display: none; }
.timeline .title { font-size: 14px; }
.timeline .meta { font-size: 12px; color: var(--color-neutral-500); }

/* Drop zone (import) */
.dropzone {
  border: 1px dashed var(--color-neutral-700); border-radius: var(--radius-lg);
  padding: 32px var(--space-8); display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
}
.dropzone .ph-lg { color: var(--color-accent); }
.dropzone-title { font-size: 15px; }
.dropzone .input { max-width: 320px; margin-top: 6px; }

/* Empty states */
.empty-state {
  text-align: center; padding: 48px var(--space-6);
  border: 1px dashed var(--color-neutral-700); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
}
.empty-state h2 { font-size: 18px; margin: 0; }
.empty-state p { color: var(--color-neutral-500); font-size: 14px; margin: 0; max-width: 46ch; }
.empty-state .btn { margin-top: var(--space-2); }

/* Log output */
.log-pre {
  background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-4);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; color: var(--color-neutral-300);
  white-space: pre-wrap; max-height: 60vh; overflow: auto; margin: 0;
}
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--color-neutral-500); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; word-break: break-all; }

/* Aspect pips — single-letter swatches in the SWU palette. */
.aspect-icon {
  display: inline-block; width: 16px; height: 18px; object-fit: contain;
  margin-right: 2px; vertical-align: middle;
}
.aspect-icon-lg { width: 22px; height: 24px; }
.aspect-pip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: 9px; font-weight: 700; margin-right: 2px;
  border: 1px solid rgba(0,0,0,.35); vertical-align: middle;
}
.aspect-vigilance  { background: #2c79c8; color: #fff; }
.aspect-command    { background: #2da551; color: #fff; }
.aspect-aggression { background: #c8302c; color: #fff; }
.aspect-cunning    { background: #e0c324; color: #1a1a1a; }
.aspect-heroism    { background: #ececec; color: #1a1a1a; }
.aspect-villainy   { background: #1a1a1a; color: #ececec; border-color: var(--color-neutral-600); }

/* ── Dialog-ish surfaces: toasts, selection bar ──────────────────────────── */
.toast-stack { position: fixed; top: calc(var(--topbar-h) + 14px); right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 50; max-width: min(400px, calc(100vw - 28px)); }
.toast {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--color-glass); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--shadow-lg); border: 1px solid var(--color-border-strong);
  padding: 12px 16px 12px 14px; border-radius: var(--radius-md); font-size: 14px;
  animation: toast-in .32s var(--ease) both;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--color-accent); box-shadow: 0 0 10px var(--color-accent); }
.toast-success::before { background: var(--color-good-strong); box-shadow: 0 0 10px var(--color-good-strong); }
.toast-warning::before { background: #f0b542; box-shadow: 0 0 10px #f0b542; }
.toast-error::before, .toast-danger::before { background: var(--color-bad-strong); box-shadow: 0 0 10px var(--color-bad-strong); }
.toast.is-leaving { animation: toast-out .25s ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
@keyframes bar-in { from { opacity: 0; transform: translate(-50%, 12px); } }

.selection-bar {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  width: min(920px, calc(100vw - 32px)); z-index: 35;
  background: var(--color-glass); backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--color-border-strong); box-shadow: var(--shadow-lg), 0 0 40px -10px rgb(61 157 255 / .35);
  border-radius: var(--radius-lg); animation: bar-in .25s var(--ease);
}
.selection-bar-inner { padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.selection-count { font-size: 14px; }
.selection-count strong { color: var(--color-accent-300); margin-right: 4px; }
.selection-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Shell: top bar, dropdown menus, phone tab bar + sheets ──────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  background: var(--color-glass);
  backdrop-filter: blur(20px) saturate(170%); -webkit-backdrop-filter: blur(20px) saturate(170%);
  border-bottom: 1px solid var(--color-border);
  view-transition-name: topbar;
}
.topbar::after {   /* faint holo line under the bar */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgb(61 157 255 / .45), transparent);
  opacity: .6;
}
.topbar-inner {
  max-width: var(--content-w); height: 100%; margin: 0 auto; padding: 0 var(--space-8);
  display: flex; align-items: center; gap: var(--space-6);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--color-text); font-size: 16px; font-weight: 600; letter-spacing: -.01em; flex: none; }
.brand:hover { color: var(--color-text); }
.brand b { font-weight: 750; background: var(--grad-accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: var(--color-accent); filter: drop-shadow(0 0 10px rgb(61 157 255 / .55)); transition: transform .3s var(--ease); }
.brand-mark svg { width: 100%; height: 100%; }
.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.06); }

.topnav { display: flex; align-items: center; gap: 2px; height: 100%; }
.topnav-item { position: relative; height: 100%; display: flex; align-items: center; }
.topnav-link {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
  border-radius: 10px; color: var(--color-neutral-300); font-size: 14.5px; font-weight: 550; white-space: nowrap;
  transition: background .15s, color .15s;
}
.topnav-link .ph { width: 19px; height: 19px; }
.topnav-link:hover, .has-menu:hover > .topnav-link, .has-menu.is-open > .topnav-link { color: var(--color-text); background: var(--hover); }
.topnav-link[aria-current="page"] { color: var(--color-text); }
.topnav-link[aria-current="page"] > .ph:first-child { color: var(--color-accent); }
.topnav-link[aria-current="page"]::after {   /* glowing underline on the bar's edge */
  content: ""; position: absolute; left: 14px; right: 14px; bottom: calc((40px - var(--topbar-h)) / 2);
  height: 2px; border-radius: 2px; background: var(--grad-accent); box-shadow: 0 0 12px rgb(61 157 255 / .9);
}
.topnav-caret { width: 12px !important; height: 12px !important; opacity: .6; transition: transform .2s var(--ease); }
.has-menu:hover .topnav-caret, .has-menu.is-open .topnav-caret, .has-menu:focus-within .topnav-caret { transform: rotate(180deg); }

/* Dropdown panel: opens on hover, keyboard focus, or a tap (JS adds .is-open). */
.menu-panel {
  position: absolute; top: calc(100% - 6px); left: -8px; z-index: 45; min-width: 340px;
  padding: 8px; border-radius: var(--radius-lg);
  background: var(--color-menu); border: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgb(0 0 0 / .2);
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-6px) scale(.985); transform-origin: top left;
  transition: opacity .16s var(--ease), transform .18s var(--ease), visibility 0s linear .18s;
}
.menu-panel::before { content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 14px; }  /* hover bridge */
.menu-panel-right { left: auto; right: -8px; transform-origin: top right; min-width: 300px; }
.has-menu:hover > .menu-panel, .has-menu:focus-within > .menu-panel, .has-menu.is-open > .menu-panel {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition-delay: 0s;
}
.has-menu.is-closed > .menu-panel { opacity: 0; visibility: hidden; pointer-events: none; }  /* Esc / click-away */
.menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-item {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  width: 100%; padding: 8px 10px; border: 0; border-radius: 12px; background: transparent;
  color: var(--color-text); font: inherit; text-align: left; cursor: pointer;
  transition: background .14s, transform .12s var(--ease);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-soft); color: var(--color-text); }
.menu-item:active { transform: scale(.985); }
.menu-icon {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--color-accent);
  box-shadow: inset 0 0 0 1px rgb(61 157 255 / .18);
  transition: background .15s, color .15s, box-shadow .2s;
}
.menu-icon .ph { width: 22px; height: 22px; }
.menu-item:hover .menu-icon, .menu-item[aria-current="page"] .menu-icon { background: var(--grad-accent); color: #fff; box-shadow: 0 6px 16px -6px rgb(42 115 255 / .9); }
.menu-item[aria-current="page"] { background: var(--accent-soft); }
.menu-item[aria-current="page"] .menu-label { color: var(--color-accent-200); }
.menu-text { display: flex; flex-direction: column; min-width: 0; }
.menu-label { font-size: 14px; font-weight: 600; line-height: 1.3; display: flex; align-items: center; gap: 6px; }
.menu-desc { font-size: 12.5px; color: var(--color-neutral-500); line-height: 1.35; }
.menu-chevron { color: var(--color-neutral-600); }
.menu-item-danger:hover { background: color-mix(in srgb, var(--color-bad-strong) 14%, transparent); }
.menu-item-danger:hover .menu-icon { background: var(--color-bad-strong); box-shadow: none; }
.menu-item-danger .menu-icon { color: var(--color-bad); background: color-mix(in srgb, var(--color-bad-strong) 12%, transparent); box-shadow: none; }
.menu-sep { height: 1px; background: var(--color-border); margin: 6px 10px; }
.menu-who { display: flex; align-items: center; gap: 12px; padding: 8px 10px 14px; margin-bottom: 4px; border-bottom: 1px solid var(--color-border); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; height: 100%; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--color-neutral-300); background: transparent; border: 0; cursor: pointer;
  transition: background .15s, color .15s, transform .12s var(--ease);
}
.icon-btn .ph { width: 21px; height: 21px; }
.icon-btn:hover { color: var(--color-text); background: var(--hover); }
.icon-btn:active { transform: scale(.94); }
.icon-btn[aria-current="page"] { color: var(--color-accent); }
.dot-badge {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--color-badge); color: #fff;
  font-size: 10.5px; font-weight: 750; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 12px rgb(255 77 106 / .6);
}
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--color-badge); color: #fff; font-size: 11px; font-weight: 750; line-height: 1;
}
.account-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 4px;
  border-radius: 999px; border: 1px solid var(--color-border-strong); background: var(--color-surface);
  color: var(--color-text); font-size: 14px; font-weight: 550;
  transition: background .15s, border-color .15s;
}
.account-btn:hover, .account-menu.is-open > .account-btn, .account-menu:hover > .account-btn { color: var(--color-text); background: var(--color-surface-2); border-color: var(--color-neutral-600); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--grad-accent); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 750;
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 3px rgb(61 157 255 / .5);
}
.avatar-lg { width: 40px; height: 40px; font-size: 16px; }
.logout-form { margin: 0; }

/* Phone tab bar (hidden on desktop) */
.tabbar { display: none; }

/* Bottom sheet (phone sub-menus, account) — a native <dialog>. */
.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 100%; max-height: 86dvh; overflow-y: auto;
  padding: 6px 12px calc(16px + env(safe-area-inset-bottom));
  border: 0; border-top: 1px solid var(--color-border-strong); border-radius: 24px 24px 0 0;
  background: var(--color-surface); color: var(--color-text);
  box-shadow: 0 -24px 60px rgb(0 0 0 / .55);
  transform: translateY(100%);
  transition: transform .3s var(--ease), overlay .3s allow-discrete, display .3s allow-discrete;
}
.sheet[open] { transform: none; }
@starting-style { .sheet[open] { transform: translateY(100%); } }
.sheet::backdrop {
  background: rgb(2 5 12 / 0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0);
  transition: background .3s, backdrop-filter .3s, overlay .3s allow-discrete, display .3s allow-discrete;
}
.sheet[open]::backdrop { background: rgb(2 5 12 / .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@starting-style { .sheet[open]::backdrop { background: rgb(2 5 12 / 0); backdrop-filter: blur(0); } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--color-neutral-700); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 10px; }
.sheet-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.sheet-title .ph { width: 24px; height: 24px; color: var(--color-accent); }
.sheet .menu-item { padding: 10px; }

/* Main column */
.main-col { min-height: calc(100dvh - var(--topbar-h)); display: flex; flex-direction: column; }
.main {
  flex: 1; width: 100%; max-width: var(--content-w); margin: 0 auto;
  padding: var(--space-8) var(--space-8) 72px;
  display: flex; flex-direction: column; gap: var(--space-8);
}
.main-wide { max-width: 1440px; }
.site-footer {
  width: 100%; max-width: var(--content-w); margin: 0 auto; padding: var(--space-6) var(--space-8) var(--space-8);
  font-size: 11.5px; line-height: 1.6; color: var(--color-neutral-600);
  border-top: 1px solid var(--color-border);
}
.site-footer a { color: inherit; text-decoration: underline; }

/* Page header block */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6); flex-wrap: wrap; }
.page-head h1, .page-title { font-size: 34px; margin: 6px 0 0; }
.page-head .kicker + h1 { margin-top: 8px; }
.page-sub, .lead { font-size: 15px; color: var(--color-neutral-400); margin: 8px 0 0; max-width: 72ch; }
.lead-sm { font-size: 13.5px; color: var(--color-neutral-500); margin: 0; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.page-head-media { display: flex; gap: var(--space-4); align-items: center; }
.page-head-media .thumbs { display: flex; gap: 6px; }
.page-head-media .thumb { width: 64px; height: 46px; border-radius: 8px; }

/* Hero banner (dashboard): card art fades into the page */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 240px; padding: var(--space-8); border-radius: 24px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: var(--space-3);
  background: linear-gradient(120deg, #0c1a3a 0%, #0b1328 55%, #0a0f1f 100%);
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--highlight), 0 30px 60px -30px rgb(0 0 0 / .8);
}
.hero-art {
  position: absolute; inset: 0 0 0 auto; width: 62%; z-index: -2;
  /* Leader cards are landscape with the art on the left and rules text on
     the right: zoom in on the art half. */
  background-size: 215% auto; background-position: 4% 22%; background-repeat: no-repeat;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 45%); mask-image: linear-gradient(90deg, transparent 0%, #000 45%);
  opacity: .85; transform: scale(1.03); transition: transform 6s ease-out;
}
.hero:hover .hero-art { transform: scale(1.08); }
.hero::before {   /* glow + bottom fade for legibility */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(600px 300px at 0% 100%, rgb(42 115 255 / .35), transparent 70%),
    linear-gradient(0deg, rgb(6 9 18 / .85), transparent 65%);
}
.hero h1 { font-size: 40px; margin: 0; color: #fff; text-shadow: 0 2px 24px rgb(0 0 0 / .6); }
.hero .kicker, .hero .text-accent { color: #9fcdff; }   /* the hero is dark in both themes */
.hero .text-sub { color: #a9b6d3; }
.hero-sub { color: #c8d3ea; font-size: 15px; margin: 0; max-width: 56ch; }
.hero-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }
.hero .btn-secondary { background: rgb(255 255 255 / .08); border-color: rgb(255 255 255 / .18); color: #fff; backdrop-filter: blur(8px); }
.hero .btn-secondary:hover { background: rgb(255 255 255 / .16); }
:root[data-theme="light"] .hero { background: linear-gradient(120deg, #0f2a66 0%, #0d1b40 60%, #0b1430 100%); }

/* Toolbar */
.toolbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.toolbar .push { margin-left: auto; }
.toolbar-form { display: contents; }

/* Sections + layouts */
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-lg { gap: var(--space-6); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); }
.section-head h2, .section-title { font-size: 18px; margin: 0; }
.section-head a { font-size: 13.5px; font-weight: 500; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.two-col-even { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: var(--space-8); }
.with-aside { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-8); align-items: start; }
.with-aside > .form, .with-aside > .stack { max-width: 580px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-4); align-items: stretch; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); }
.tool-card { color: inherit; gap: var(--space-2); padding: var(--space-6); }
.tool-card.is-disabled { opacity: .5; }
.tool-card .ph-lg { color: var(--color-accent); width: 28px; height: 28px; }
.pager-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--color-neutral-500); gap: var(--space-3); flex-wrap: wrap; }
.pager { display: flex; gap: 6px; }
.sub-nav { display: flex; gap: var(--space-4); flex-wrap: wrap; }

/* Combobox (leader / base pickers on Similar cards) */
.combobox { position: relative; min-width: 260px; flex: 1; }
.combobox-input { padding-right: 30px; }
.combobox-chevron {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--color-neutral-500); cursor: pointer; padding: 6px; line-height: 1;
}
.combobox-chevron:hover { color: var(--color-text); }
.combobox-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  max-height: 320px; overflow: hidden;
}
.combobox-list { list-style: none; margin: 0; padding: 4px 0; max-height: 320px; overflow-y: auto; }
.combobox-group {
  padding: 6px 12px 2px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 500;
  color: var(--color-neutral-500); background: var(--color-surface); position: sticky; top: 0;
}
.combobox-option { padding: 6px 12px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.combobox-option:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.combobox-clear { color: var(--color-neutral-500); font-style: italic; }
.combobox-option .opt-sub { color: var(--color-neutral-500); }

/* Deck context strip (Similar cards) */
.deck-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.deck-card-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--color-divider); border-radius: 99px; padding: 3px 10px; }
.deck-card-sub { color: var(--color-neutral-500); }
.deck-coverage { color: var(--color-neutral-500); margin-left: auto; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.owner-pill { display: inline-flex; gap: 4px; border: 1px solid var(--color-divider); border-radius: 99px; padding: 1px 8px; font-size: 12px; margin-right: 4px; }
.owner-pill strong { color: var(--color-accent-300); }

/* ── Auth ────────────────────────────────────────────────────────────────── */
.auth {
  flex: 1; min-height: 100dvh; display: grid; place-items: center; padding: var(--space-8) var(--space-4);
  background: radial-gradient(520px 380px at 50% 42%, rgb(42 115 255 / .22), transparent 70%);
}
.auth-box {
  width: min(420px, 100%); display: flex; flex-direction: column; gap: var(--space-6);
  padding: var(--space-8); border-radius: 24px;
  background: linear-gradient(180deg, var(--color-surface-2), var(--color-surface));
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--highlight), 0 30px 80px -30px rgb(0 0 0 / .9), 0 0 80px -30px rgb(61 157 255 / .5);
  animation: rise .45s var(--ease) both;
}
.auth-box h1 { font-size: 30px; margin: 8px 0 4px; }
.auth-box .brand { font-size: 17px; }
.auth-foot { font-size: 12px; color: var(--color-neutral-600); margin: 0; line-height: 1.5; }
.auth .btn-ghost { align-self: flex-start; margin-left: -6px; }
body:not(.has-shell) .site-footer { border-top: 0; text-align: center; max-width: 640px; }
@media (max-width: 480px) { .auth-box { padding: var(--space-6) var(--space-4); border-radius: 20px; } }
.mfa-qr { background: #fff; padding: 12px; border-radius: var(--radius-md); align-self: flex-start; }
.mfa-qr svg { display: block; width: 200px; height: 200px; }
.recovery-codes { list-style: none; margin: 0; padding: var(--space-4); display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 24px;
  border: 1px solid var(--color-divider); border-radius: var(--radius-md); font-size: 14px; }

/* ── Decks ───────────────────────────────────────────────────────────────── */
.bar-track.bar-stacked { display: flex; width: 100%; height: 6px; border-radius: 3px; }
.bar-fill-good { background: var(--color-good-strong); }
.bar-fill-accent { background: var(--color-accent); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 2px; }
.legend-good { background: var(--color-good-strong); }
.legend-accent { background: var(--color-accent); }
.legend-bad { background: var(--color-bad-strong); }
.deck-coverage-card .metrics { gap: var(--space-2); }
.deck-coverage-card .metric { padding: var(--space-2) 0; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); }
.deck-tile { padding: 0; gap: 0; overflow: hidden; }
.deck-art {
  position: relative; height: 150px; background: linear-gradient(135deg, var(--color-accent-900), var(--color-surface));
  background-size: 210% auto; background-position: 4% 20%; background-repeat: no-repeat;
  transition: background-size .5s var(--ease);
}
.deck-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, var(--color-surface-2) 0%, transparent 60%); }
.deck-tile:hover .deck-art { background-size: 222% auto; }
.deck-base {
  position: absolute; z-index: 1; right: 14px; bottom: -18px; width: 86px; height: 62px; object-fit: cover;
  border-radius: 8px; box-shadow: 0 0 0 2px var(--color-surface-2), 0 10px 24px -6px rgb(0 0 0 / .8);
}
.deck-flag {
  position: absolute; z-index: 1; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  color: #fff; background: rgb(47 176 106 / .85); backdrop-filter: blur(6px); box-shadow: 0 0 16px rgb(47 176 106 / .5);
}
.deck-body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4) var(--space-4); }
.deck-body .card-title { padding-right: 96px; }
.deck-body .card-meta { flex-wrap: wrap; }
.deck-source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-tile .bar-track { width: 100%; }
.deck-tile-active { border-color: color-mix(in srgb, var(--color-good-strong) 55%, transparent); }
.deck-tile-new {
  align-items: center; justify-content: center; text-align: center; gap: var(--space-2); padding: var(--space-6);
  min-height: 240px; background: transparent; border: 1.5px dashed var(--color-border-strong); box-shadow: none;
}
.deck-tile-new .menu-icon { width: 52px; height: 52px; border-radius: 16px; }
.deck-tile-new .menu-icon .ph { width: 26px; height: 26px; }
.deck-tile-new:hover .menu-icon { background: var(--grad-accent); color: #fff; }
.qty-ctl { display: inline-flex; align-items: center; gap: 2px; }
.qty-ctl form { display: contents; }
.qty-ctl .btn-icon { width: 26px; height: 26px; }
.deck-table .row-missing td:first-child { box-shadow: inset 3px 0 0 var(--color-bad-strong); }
.deck-table .row-partner td:first-child { box-shadow: inset 3px 0 0 var(--color-accent); }
.deck-table .row-clash td:first-child { box-shadow: inset 3px 0 0 var(--color-bad-strong); }
.cell-decks { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }
.cell-decks .tag { text-decoration: none; }

/* Deck activation */
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.45; margin-bottom: var(--space-4); border: 1px solid var(--color-divider); }
.notice svg { flex: none; margin-top: 2px; }
.notice-muted { color: var(--color-neutral-300); }
.notice-bad { color: var(--color-bad); background: var(--color-bad-fill); border-color: transparent; }
.conflict-deck { border: 1px solid var(--color-divider); border-radius: 8px; padding: var(--space-3); margin-bottom: var(--space-3); }
.conflict-deck-head { display: flex; align-items: center; gap: 8px; margin-bottom: var(--space-2); cursor: pointer; }
.conflict-deck-head input { width: 16px; height: 16px; }


/* Deck analysis: legality + stats */
.deck-analysis { align-items: start; }
.issue-list { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.4; }
.issue-error { color: var(--color-bad); }
.issue-warning { color: var(--color-neutral-300); }
.issue-warning svg { color: var(--color-accent-300); }
.curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; height: 132px; align-items: end; }
.curve-col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.curve-val { font-size: 11px; color: var(--color-neutral-500); min-height: 14px; }
.curve-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.curve-bar { width: 100%; background: var(--color-accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.curve-lbl { font-size: 11px; color: var(--color-neutral-500); }
.breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-4); margin-top: var(--space-4); }
.breakdown-title { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-neutral-500); margin-bottom: 6px; }
.breakdown-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr auto; align-items: center; gap: 8px; font-size: 12px; padding: 2px 0; }
.breakdown-row > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breakdown-bar { display: block; height: 4px; border-radius: 2px; background: var(--color-neutral-800); overflow: hidden; }
.breakdown-bar > span { display: block; height: 100%; background: var(--color-accent); border-radius: 2px; }
.export-box { width: 100%; min-height: 320px; resize: vertical; font-size: 12px; white-space: pre; }

.bulk-request { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.bulk-request form { margin: 0; }

/* ── Trade prices ────────────────────────────────────────────────────────── */
.price-field { display: inline-flex; align-items: center; gap: 4px; color: var(--color-neutral-400); }
.input-price { width: 76px; text-align: right; font-variant-numeric: tabular-nums; }
.price-hint { font-size: 11px; color: var(--color-neutral-500); margin-top: 2px; }
.price-total-row td { border-top: 1px solid var(--color-divider); }
.price-total-row strong { font-variant-numeric: tabular-nums; }
.trade-price { font-size: 13px; color: var(--color-accent-300); margin-top: 2px; }
.trade-side-total { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--color-divider); font-size: 13px; color: var(--color-neutral-400); display: flex; justify-content: space-between; }
.trade-side-total strong { color: var(--color-text); }
.input.is-invalid { border-color: var(--color-bad-strong); }


/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .two-col, .with-aside { grid-template-columns: minmax(0, 1fr); }
  .with-aside > aside { max-width: 580px; }
  .topnav-link { padding: 0 10px; }
  .account-name { display: none; }
}
/* Phone / small tablet: top bar keeps brand + bell + avatar, the menu moves
   to a bottom tab bar, and sub-menus open as sheets. */
@media (max-width: 900px) {
  :root { --topbar-h: 56px; }
  .topbar-inner { padding: 0 var(--space-4); gap: var(--space-3); }
  .topnav { display: none; }
  .account-menu > .menu-panel { display: none; }
  .account-btn { padding: 0; border: 0; background: transparent; height: auto; }
  .account-btn .topnav-caret { display: none; }
  body.has-shell { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--color-glass);
    backdrop-filter: blur(20px) saturate(170%); -webkit-backdrop-filter: blur(20px) saturate(170%);
    border-top: 1px solid var(--color-border);
    view-transition-name: tabbar;
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0;
    color: var(--color-neutral-400); font-size: 11px; font-weight: 600; border-radius: 14px;
    transition: color .15s;
  }
  .tab:hover { color: var(--color-text); }
  .tab-icon {
    position: relative; width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center;
    transition: background .2s var(--ease), transform .12s var(--ease);
  }
  .tab-icon .ph { width: 23px; height: 23px; }
  .tab:active .tab-icon { transform: scale(.9); }
  .tab[aria-current="page"] { color: var(--color-text); }
  .tab[aria-current="page"] .tab-icon { background: var(--accent-soft-2); color: var(--color-accent); }
  .tab .dot-badge { top: -2px; right: 8px; }
  .main { padding: var(--space-6) var(--space-4) 48px; gap: var(--space-6); }
  .site-footer { padding: var(--space-4) var(--space-4) var(--space-6); }
  .page-head h1, .page-title { font-size: 28px; }
  .hero { min-height: 200px; padding: var(--space-6); border-radius: 20px; }
  .hero h1 { font-size: 30px; }
  .hero-art { width: 100%; -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 95%); mask-image: linear-gradient(180deg, #000 0%, transparent 95%); opacity: .55; }
  .form-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .metrics > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .metric { padding: var(--space-3) 14px; }
  .metric-value { font-size: 26px; }
  .metric-delta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-row { flex-wrap: wrap; }
  .thumb-xl { width: 160px; height: 224px; }
  .card-row > .btn { margin-left: auto; }
  .toast-stack { top: auto; bottom: calc(84px + env(safe-area-inset-bottom)); left: 16px; right: 16px; max-width: none; }
  .selection-bar { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .brand-name { display: none; }
}

/* ── Motion ──────────────────────────────────────────────────────────────── */
/* Cross-document view transitions: the bars stay put, the page fades/slides. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .12s ease-in both; }
::view-transition-new(root) { animation: vt-in .24s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* First paint: content rises in, staggered a little. Fill mode is
   "backwards", not "both": a finished animation that stays applied keeps each
   block in its own stacking context, and later blocks (the card list) would
   then paint over earlier blocks' dropdowns (the filter panels). */
.main > * { animation: rise .4s var(--ease) backwards; }
.main > :nth-child(2) { animation-delay: .04s; }
.main > :nth-child(3) { animation-delay: .08s; }
.main > :nth-child(n+4) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* Trade builder: trade / loan per line */
.kind-side { align-self: center; }
.kind-side .seg-opt { border: 0; font: inherit; font-size: 12.5px; padding: 5px 10px; }
.kind-side .seg-opt:not([aria-current]) { background: transparent; }
.kind-select { width: auto; min-width: 84px; }

/* Deck stand-ins */
.standin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.standin {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--color-border);
}
.standin.is-ready { border-color: color-mix(in srgb, var(--color-good) 45%, transparent); }
.standin-cards { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); min-width: 0; }
.standin-cards .cell-card { display: flex; align-items: center; gap: 10px; }
.standin-cards .cell-card > span { display: flex; flex-direction: column; min-width: 0; }
.standin .cell-title, .suggest .cell-title { font-weight: 500; }
.standin .cell-sub, .suggest .cell-sub { font-size: 12px; color: var(--color-neutral-500); }
.cell-card .tag-mini { margin-top: 3px; display: inline-flex; align-items: center; gap: 3px; }
.suggest-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.suggest { display: flex; gap: var(--space-3); align-items: flex-start; }
.suggest-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.suggest-body form { display: flex; gap: var(--space-2); align-items: center; margin-top: 4px; }

/* Deck lab */
.lab-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.lab-style { display: flex; align-items: center; gap: var(--space-2); }
.lab-style input[type=range] { flex: 1; accent-color: var(--color-accent); min-width: 0; }
.seg.seg-wrap { flex-wrap: wrap; }
.lab-leaders { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.lab-leader {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); color: inherit; text-decoration: none;
  border: 1px solid var(--color-border); border-radius: var(--radius-md); transition: background .15s, border-color .15s;
}
.lab-leader:hover { background: var(--hover); border-color: var(--color-border-strong); }
.lab-leader > span { display: flex; flex-direction: column; min-width: 0; }
.lab-leader .cell-title { font-weight: 500; }
.lab-leader .cell-sub { font-size: 12px; color: var(--color-neutral-500); }
.lab-result { display: grid; gap: var(--space-4); }
.lab-result-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.lab-save { display: flex; gap: var(--space-2); align-items: center; }
.lab-save .input { width: 200px; }
.lab-body { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr) 260px; align-items: start; }
.lab-why { font-size: 12px; color: var(--color-neutral-400); }
.lab-why span { display: block; }
.row-locked td { background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.lab-track { position: relative; }
.lab-target { position: absolute; left: -2px; right: -2px; height: 0; border-top: 2px dashed var(--color-neutral-500); opacity: .7; }
.lab-signals { font-size: 12px; }
@media (max-width: 900px) {
  .lab-body { grid-template-columns: minmax(0, 1fr); }
  .lab-save { flex-wrap: wrap; }
  .lab-save .input { width: 100%; }
}
/* ── Requests overview (trades + loans + returns) ────────────────────────── */
.req-table td { vertical-align: top; }
.req-table .req-row.is-incoming td:first-child { box-shadow: inset 3px 0 0 var(--color-accent); }
.req-cards ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13px; }
.req-cards li { line-height: 1.4; }
.req-side + .req-side { margin-top: 6px; }
.req-side-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-neutral-500); margin-bottom: 2px; }
.req-ref { font-size: 12px; color: var(--color-neutral-400); white-space: nowrap; }
.req-ref .set-code { color: var(--color-accent-300); }
.req-note { margin-top: 6px; font-size: 12.5px; color: var(--color-neutral-400); font-style: italic; }
.req-warn { margin-top: 6px; font-size: 12.5px; color: var(--color-bad); display: flex; gap: 6px; align-items: flex-start; }
.req-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.req-form { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.req-form .input-date { width: 104px; }
.seg-opt .nav-badge { margin-left: 4px; }
.nav-badge-muted { color: var(--color-neutral-400); }
.tag.status-countered { background: var(--color-accent-800); color: var(--color-accent-100); }
.status-countered { color: var(--color-accent-300); }
a.req-menu-opt { text-decoration: none; }

/* ── Deck page: filter bar, category groups, shareable missing list ──────── */
.deck-toolbar { margin-bottom: var(--space-2); }
.deck-toolbar .search { max-width: 280px; }
.deck-table { table-layout: fixed; min-width: 960px; }
.deck-table .dc-set { width: 72px; } .deck-table .dc-aspects { width: 72px; } .deck-table .dc-cost { width: 52px; }
.deck-table .dc-qty { width: 92px; } .deck-table .dc-owned { width: 84px; } .deck-table .dc-status { width: 170px; }
.deck-table .dc-also { width: 100px; } .deck-table .dc-actions { width: 170px; }
.deck-table .col-actions .qty-ctl { justify-content: flex-end; flex-wrap: nowrap; }
.deck-table .cell-title, .deck-table .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-table td:nth-child(7) .tag { white-space: normal; }
.deck-table .deck-cat-row th {
  text-align: left; font-size: 20px; font-weight: 650; text-transform: none; letter-spacing: -.01em;
  color: var(--color-text); padding: 26px var(--space-2) 10px; border-bottom: 1px solid var(--color-divider);
}
.deck-table tbody.deck-cat:first-of-type .deck-cat-row th { padding-top: 14px; }
.deck-table .deck-cat-row:hover { background: transparent; }
.deck-table .deck-cat-row th .text-sub { font-size: 15px; font-weight: 500; margin-left: 8px; }
.missing-share { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-2); }
.missing-share-details { flex-basis: 100%; }
.missing-share-details summary { cursor: pointer; }
.export-box-sm { min-height: 0; margin-top: 6px; }

/* ── Import plan / basket / lend override ─────────────────────────────────── */
.import-mode { display: grid; gap: var(--space-3); }
.table .row-remove td:first-child { box-shadow: inset 3px 0 0 var(--color-bad-strong); }
.table .row-create td:first-child { box-shadow: inset 3px 0 0 var(--color-good-strong); }
.basket-group + .basket-group { margin-top: var(--space-4); }
.override-list { margin: 6px 0 0; padding-left: 18px; }

@media (max-width: 720px) {
  .req-actions, .req-form { justify-content: flex-start; }
  .deck-toolbar .search { max-width: none; flex: 1 1 100%; }
  /* Requests stack into cards: type + partner, cards, date, then the answer. */
  .req-table { min-width: 0; }
  .req-table thead { display: none; }
  .req-table, .req-table tbody, .req-table tr, .req-table td { display: block; width: 100%; }
  .req-table tr { padding: 10px 0; border-bottom: 1px solid var(--color-divider); }
  .req-table td { padding: 3px 10px; border: 0; }
  .req-table td.col-actions { text-align: left; white-space: normal; padding-top: 8px; }
  .req-table .req-row.is-incoming td:first-child { box-shadow: none; }
  .req-table .req-row.is-incoming { box-shadow: inset 3px 0 0 var(--color-accent); }
}

/* ── Borrowed copies (on loan to the deck's owner) ───────────────────────── */
.bar-fill-borrowed { background: color-mix(in srgb, var(--color-good-strong) 45%, transparent); }
.legend-borrowed { background: color-mix(in srgb, var(--color-good-strong) 45%, transparent); }
.tag-borrowed { border: 1px solid var(--color-good-strong); color: var(--color-good); }
.text-borrowed { color: var(--color-good); opacity: .8; }
.deck-table .row-borrowed td:first-child { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--color-good-strong) 55%, transparent); }
.assign-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Sortable deck columns (click: ascending → descending → default) ─────── */
.deck-table th .sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.deck-table th .sort-link:hover, .deck-table th .sort-link.is-sorted { color: var(--color-accent-300); }
.deck-table th .sort-arrow { font-size: 10px; opacity: .45; }
.deck-table th .sort-link.is-sorted .sort-arrow { opacity: 1; }

/* ── Popup: a <details> whose panel is a dialog (bottom sheet on phones) ──── */
.popup { display: inline-block; }
.popup > summary { list-style: none; }
.popup > summary::-webkit-details-marker { display: none; }
/* The backdrop belongs to the summary, so clicking it closes the popup — no JS needed. */
.popup[open] > summary::before {
  content: ""; position: fixed; inset: 0; z-index: 90; cursor: default;
  background: rgb(2 5 12 / .62); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.popup-panel {
  position: fixed; z-index: 91; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto;
  background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 20px; text-align: left; white-space: normal;
  display: grid; gap: 12px; font-size: 15px; cursor: auto;
  animation: popup-in .18s var(--ease, ease-out);
}
@keyframes popup-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); } }
.popup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.popup-title { font-size: 18px; font-weight: 650; line-height: 1.25; }
.popup-text { margin: 0; color: var(--color-neutral-300); }
.popup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.popup-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--color-text) 5%, transparent); }
.popup-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.popup-actions form { margin: 0; }
@media (max-width: 720px) {
  .popup-panel {
    left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; max-height: 85vh;
    border-radius: 18px 18px 0 0; border-bottom: 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
    animation-name: sheet-in;
  }
  .popup-actions .btn { flex: 1 1 auto; justify-content: center; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
}

/* ── Request page ─────────────────────────────────────────────────────────── */
.request-group + .request-group { margin-top: var(--space-2); }
.request-table .cell-card .tag { margin-top: 4px; }
.owner-chip-pick { cursor: pointer; }
.owner-chip-pick:has(input:checked) { box-shadow: inset 0 0 0 1px var(--color-accent); color: var(--color-accent-200); }

/* ── Desktop: a bit bigger and easier to read ────────────────────────────── */
@media (min-width: 1100px) {
  .table { font-size: 15px; }
  .table-tight { font-size: 14.5px; }
  .table th { font-size: 12px; }
  .table .cell-sub, .table .cell-set, .table .cell-dim { font-size: 13.5px; }
  .deck-table { font-size: 15px; }
  .deck-table td { padding-top: 11px; padding-bottom: 11px; }
  .deck-table .tag { font-size: 12.5px; }
  .deck-toolbar .seg-opt, .deck-toolbar .input { font-size: 15px; }
}
html.has-popup { overflow: hidden; }
/* The press effect (.btn:active scale) would make the summary the containing
   block of its fixed backdrop mid-click, so the click never lands: off while open. */
.popup[open] > summary, .popup[open] > summary:active { transform: none; transition: none; }

/* Per-card trade / borrow / lend tag on requests */
.verb-tag { min-width: 52px; justify-content: center; }
.verb-trade { background: var(--color-accent-800); color: var(--color-accent-100); }
.verb-borrow, .verb-lend { border: 1px solid var(--color-good-strong); color: var(--color-good); }
