:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1d222c;
  --line: #2a303c;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --sun-1: #ffb347;
  --sun-2: #ff6a3d;
  --accent: #ff9a3d;
  --ok: #4cc38a;
  --warn: #f2c94c;
  --bad: #ff6b6b;
  --vigilance: #3c8ad8;
  --command: #3fa45b;
  --aggression: #d64545;
  --cunning: #e2b93b;
  --heroism: #e9e4d4;
  --villainy: #3a3a40;
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--sun-1); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: #0a0c10; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 3px; font-weight: 800; letter-spacing: .02em; color: var(--text); }
.brand:hover { text-decoration: none; }
/* Logo: the sun mark plus a wide, heavy "TWIN SUNS" (Unbounded) and a thin, lightly spaced "HUB" (the negative margin drops the trailing letter-space). */
.logo-mark { height: 24px; width: auto; flex: none; display: block; }
.brand-text { display: inline-flex; align-items: baseline; gap: .28em; color: #f2eee3; white-space: nowrap; }
.brand-name { font-family: "Unbounded", var(--font); font-weight: 700; font-size: 1.02rem; text-transform: uppercase; letter-spacing: .01em; }
.brand-hub { font-weight: 400; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; margin-right: -.12em; color: #cfcabd; }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a, .account a, .account button { color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav a:hover, .account a:hover, .nav a.active, .account a.active { color: var(--text); text-decoration: none; }
/* The section you're in: an orange underline (an orange label in the phone menu). */
.nav a.active, .account a.active:not(.btn) { text-decoration: underline 2px var(--accent); text-underline-offset: 8px; }
.account { display: flex; gap: 14px; align-items: center; }
.account form { margin: 0; }
.account button { background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
/* Account menu: your username opens My account, My decks, Collection and Log out (the site's .menu dropdown). */
.account-menu summary {
  display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; white-space: nowrap; cursor: pointer;
}
.account-menu summary:hover, .account-menu[open] summary, .account-menu summary.active { color: var(--text); }
.account-menu summary.active { text-decoration: underline 2px var(--accent); text-underline-offset: 8px; }
.account-menu .caret { width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; margin-top: 4px; transition: transform .15s; }
.account-menu[open] .caret { transform: rotate(180deg) translateY(4px); }
.account-menu .menu-items { min-width: 190px; top: calc(100% + 14px); }
.account .account-menu .menu-items a, .account .account-menu .menu-items button { color: var(--text); font-weight: 500; }
.account .account-menu .menu-items a.active { color: var(--accent); text-decoration: none; }
.container { max-width: 1680px; margin: 0 auto; padding: 28px 40px 60px; }
/* Pages that are mostly card images or tiles (deck, pick list, card, card search, leaders, leader, deck lists, profiles)
   get a wider cap, and their cards and tiles grow on big screens (--card-scale below). Reading pages keep the 1680px
   cap. */
.container.wide { max-width: 2240px; }
/* Past the old cap, fixed-column grids fit tiles of about the size they had at 1680px, grown by --card-scale, so
   tiles get bigger rather than only more numerous. A row of four or more shares the full width, so it doesn't stop
   short of the edge; a shorter one keeps its tile size. */
@media (min-width: 1760px) {
  .container.wide .top-grid { --tile-min: calc(250px * var(--card-scale)); }
  .container.wide .top-grid.top-leaders, .container.wide .leader-grid { --tile-min: calc(300px * var(--card-scale)); }
  .container.wide .top-grid.top-pairs, .container.wide .deck-grid { --tile-min: calc(500px * var(--card-scale)); }
  .container.wide .folder-grid { --tile-min: calc(280px * var(--card-scale)); }
  .container.wide :is(.top-grid, .leader-grid, .deck-grid, .folder-grid) { grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr)); }
  .container.wide .top-grid:has(> :nth-child(4)) { grid-template-columns: repeat(auto-fit, minmax(var(--tile-min), 1fr)); }
}
.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; padding: 18px 24px; text-align: center; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #3d4554; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: default; border-color: var(--line); }
.btn.primary { background: linear-gradient(135deg, var(--sun-1), var(--sun-2)) border-box; border-color: transparent; color: #1a0f05; }
/* Primary buttons have no border to light up, so hover brightens just their edge: a pale-gold line inside it and a faint
   ring outside (no movement). Pressing dims the button a touch. */
.btn.primary { transition: filter .12s, box-shadow .12s; }
.btn.primary:is(:hover, :focus-visible):not(:disabled) { box-shadow: inset 0 0 0 1.5px #ffe2b0, 0 0 0 1px rgba(255, 179, 71, .55); }
.btn.primary:active:not(:disabled) { filter: brightness(.95); box-shadow: 0 0 0 2px rgba(255, 154, 61, .3); }
/* Disabled, a primary button goes plain grey: a faded gradient reads as muddy brown on the dark panels. */
.btn.primary:disabled { background: var(--panel-2); border-color: var(--line); color: var(--muted); opacity: 1; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn-icon { width: 13px; height: 13px; flex: none; fill: currentColor; }
input[type=text], input[type=search], input[type=password], input[type=email], select, textarea {
  background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 8px;
  padding: 8px 10px; font: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255, 154, 61, .45); border-color: transparent; }
/* Keyboard focus: one orange ring everywhere. Chips hide their checkbox/radio, so the label shows the ring. */
:focus-visible, .chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible):not(input, select, textarea) { outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
label { font-size: .85rem; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { background: var(--panel-2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; }

/* ---------- aspects ---------- */
/* Official aspect icons (from starwarsunlimited.com), used wherever a card or deck shows its aspects. */
.pips { display: inline-flex; gap: 2px; vertical-align: middle; }
.pip {
  width: 18px; height: 18px; display: inline-block; flex: none; vertical-align: middle;
  background: center / contain no-repeat;
}
.pip.Vigilance { background-image: url("../img/aspects/vigilance.eb65eb06183a.png"); }
.pip.Command { background-image: url("../img/aspects/command.a79e8f8521b4.png"); }
.pip.Aggression { background-image: url("../img/aspects/aggression.1413d6de45a4.png"); }
.pip.Cunning { background-image: url("../img/aspects/cunning.f18ef1547769.png"); }
.pip.Heroism { background-image: url("../img/aspects/heroism.723304836654.png"); }
.pip.Villainy { background-image: url("../img/aspects/villainy.a32cb1442a4d.png"); }
.chip .pip { width: 20px; height: 20px; }

/* ---------- home page hero (templates/home.html) ---------- */
/* Edge to edge under the top bar: headline, a scope toggle and the big search, with a few leaders from the newest set
   fanned at each side, fading toward the middle so they never compete with the search. */
.hero {
  position: relative; text-align: center; padding: 64px 24px 56px; margin: -28px -40px 0;
  background: radial-gradient(ellipse 60% 70% at 50% 0%, rgba(255, 150, 60, .16), transparent 70%), #0b0d12;
  border-bottom: 1px solid var(--line);
}
.hero-inner { position: relative; z-index: 2; max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: 2.6rem; letter-spacing: -.02em; margin-bottom: 10px; }
.hero h1 em { font-style: normal; background: linear-gradient(135deg, var(--sun-1), var(--sun-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lede { color: var(--muted); font-size: 1.08rem; max-width: 560px; margin: 0 auto 26px; }
.hero-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; margin-bottom: 18px; }
.hero-tag {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 99px;
  border: 1px solid rgba(255, 154, 61, .4); background: rgba(255, 154, 61, .08); color: var(--text); font-size: .88rem;
}
/* Pills, chips and feature squares lift a little on hover, like every other clickable thing on the page. */
.hero-tag, .leader-chip, .home-feature { transition: transform .12s, border-color .12s, box-shadow .12s, background .12s; }
.hero-tag:is(:hover, :focus-visible), .leader-chip:is(:hover, :focus-visible) { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .45); }
.hero-tag:hover { text-decoration: none; border-color: var(--accent); }
.hero-tag b {
  background: linear-gradient(135deg, var(--sun-1), var(--sun-2)); color: #1a0f05; border-radius: 99px; padding: 1px 9px;
  font-size: .8rem; letter-spacing: .05em; text-transform: uppercase;
}
.hero-tag > span:last-child { color: var(--accent); }
.hero-tag .tag-set { white-space: nowrap; }
/* Spoilers: the next set, in a cooler colour so it doesn't read as the same thing as the featured set. */
.hero-tag.spoiled { border-color: rgba(120, 170, 255, .4); background: rgba(120, 170, 255, .08); }
.hero-tag.spoiled:hover { border-color: #78aaff; }
.hero-tag.spoiled b { background: #78aaff; color: #07122a; }
.hero-tag.spoiled > span:last-child { color: #9cc0ff; }
.hero-tag.spoiled .tag-text { display: inline-flex; align-items: baseline; gap: 6px; }
.hero-tag.spoiled .tag-set { white-space: nowrap; }
.hero-tag.spoiled .tag-count { color: var(--muted); white-space: nowrap; }
.hero-tag.spoiled .tag-count::before { content: "·"; margin-right: 6px; }
/* Phones: the set's name over its leader count, so the pill stays a tidy two-line chip instead of wrapping mid-phrase. */
@media (max-width: 700px) {
  .hero-tag.spoiled { padding-right: 16px; text-align: left; }
  .hero-tag.spoiled .tag-text { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.25; }
  .hero-tag.spoiled .tag-count { font-size: .78rem; }
  .hero-tag.spoiled .tag-count::before { content: none; }
}
.tag-faces { display: inline-flex; }
.tag-faces img { width: 26px; height: 26px; object-fit: cover; object-position: 20% 30%; border-radius: 50%; border: 2px solid #0b0d12; display: block; }
.tag-faces img + img { margin-left: -9px; }
/* The fans are clipped by their own layer, not the hero, so the search results can drop below the hero. */
.hero-fans { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.hero-fan { --fan-in: 56px; position: absolute; top: 50%; width: 360px; height: 330px; transform: translateY(-50%); z-index: 1; pointer-events: none; }
/* Each fan fades toward the middle of the page as a whole (fading each card would let the back one show through
   the front one). */
.hero-fan.left { left: max(-40px, calc(50% - 860px)); -webkit-mask-image: linear-gradient(90deg, #000 55%, transparent); mask-image: linear-gradient(90deg, #000 55%, transparent); }
.hero-fan.right { right: max(-40px, calc(50% - 860px)); -webkit-mask-image: linear-gradient(270deg, #000 55%, transparent); mask-image: linear-gradient(270deg, #000 55%, transparent); }
.hero-fan img {
  position: absolute; width: 300px; aspect-ratio: 7 / 5; object-fit: fill; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .08);
  transition: scale .2s, rotate .2s, translate .2s, opacity .2s, box-shadow .2s;
}
.hero-fan.left img:nth-child(1) { left: 0; top: 10px; rotate: -8deg; }
.hero-fan.left img:nth-child(2) { left: 50px; top: 120px; rotate: -2deg; }
.hero-fan.right img:nth-child(1) { right: 0; top: 10px; rotate: 8deg; }
.hero-fan.right img:nth-child(2) { right: 50px; top: 120px; rotate: 2deg; }
/* While a chip is pointed at, its card's fan drops its fade and the other card in it steps back (the rule after
   this one brings the chosen card forward again; same specificity, so the order matters). */
.hero:has(.leader-chip:is([data-fan="1"], [data-fan="2"]):is(:hover, :focus-visible)) .hero-fan.left,
.hero:has(.leader-chip:is([data-fan="3"], [data-fan="4"]):is(:hover, :focus-visible)) .hero-fan.right { -webkit-mask-image: none; mask-image: none; }
.hero:has(.leader-chip:is([data-fan="1"], [data-fan="2"]):is(:hover, :focus-visible)) .hero-fan.left img,
.hero:has(.leader-chip:is([data-fan="3"], [data-fan="4"]):is(:hover, :focus-visible)) .hero-fan.right img { opacity: .25; }
/* Pointing at a leader's chip under the search brings that leader's card out of the fan: whole, upright, unfaded
   and slid in from the edge so none of it is cut off. */
.hero:has(.leader-chip[data-fan="1"]:is(:hover, :focus-visible)) .hero-fan img[data-fan="1"],
.hero:has(.leader-chip[data-fan="2"]:is(:hover, :focus-visible)) .hero-fan img[data-fan="2"],
.hero:has(.leader-chip[data-fan="3"]:is(:hover, :focus-visible)) .hero-fan img[data-fan="3"],
.hero:has(.leader-chip[data-fan="4"]:is(:hover, :focus-visible)) .hero-fan img[data-fan="4"] {
  z-index: 3; scale: 1.08; rotate: 0deg; opacity: 1; box-shadow: 0 0 0 2px var(--accent), 0 20px 50px rgba(0, 0, 0, .7);
}
.hero:has(.leader-chip[data-fan="1"]:is(:hover, :focus-visible)) .hero-fan img[data-fan="1"],
.hero:has(.leader-chip[data-fan="2"]:is(:hover, :focus-visible)) .hero-fan img[data-fan="2"] { translate: var(--fan-in) 0; }
.hero:has(.leader-chip[data-fan="3"]:is(:hover, :focus-visible)) .hero-fan img[data-fan="3"],
.hero:has(.leader-chip[data-fan="4"]:is(:hover, :focus-visible)) .hero-fan img[data-fan="4"] { translate: calc(-1 * var(--fan-in)) 0; }
@media (max-width: 1500px) { .hero-fan { --fan-in: 86px; } .hero-fan img { opacity: .5; width: 250px; } .hero-fan.left { left: -70px; } .hero-fan.right { right: -70px; } }
@media (max-width: 1100px) { .hero-fan { display: none; } }

/* What to search: Everything / Leaders / Cards / Decks / Players. */
.scope { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 4px; margin-bottom: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; }
.scope button { border: 0; background: none; color: var(--muted); font: 600 .88rem var(--font); padding: 6px 14px; border-radius: 99px; cursor: pointer; }
.scope button:hover { color: var(--text); }
.scope button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
/* Segmented toggles (static/js/segmented.js): once the script is running, one sliding thumb marks the chosen option
   instead of each option's own background. Without the script the options above still show it. */
[data-segmented] { position: relative; }
.seg-thumb { position: absolute; z-index: 0; border-radius: 99px; background: var(--seg-bg, var(--panel-2)); box-shadow: inset 0 0 0 1px var(--accent); pointer-events: none; }
[data-segmented].seg-animate .seg-thumb { transition: left .28s cubic-bezier(.3, .8, .3, 1), width .28s cubic-bezier(.3, .8, .3, 1), top .28s; }
[data-segmented] :is(button, label) { position: relative; z-index: 1; transition: color .2s; }
.seg-ready :is(button[aria-pressed="true"], label:has(input:checked)) { background: none; box-shadow: none; }
@media (prefers-reduced-motion: reduce) { [data-segmented].seg-animate .seg-thumb { transition: none; } }
.home-search { position: relative; display: flex; align-items: center; max-width: 720px; margin: 0 auto; }
.home-search .icon { position: absolute; left: 20px; color: var(--muted); pointer-events: none; }
.home-search input[type=search] {
  height: 64px; padding: 0 56px 0 54px; font-size: 1.2rem; border-radius: 16px;
  background: var(--panel); border: 1px solid #353c4a; box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
.home-search input[type=search]:focus { outline: 2px solid rgba(255, 154, 61, .55); border-color: transparent; }
.home-search kbd { position: absolute; right: 16px; font: 600 .8rem var(--font); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; }
.home-search .search-results { left: 0; right: 0; width: 100%; text-align: left; }
.hero-try { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; color: var(--muted); font-size: .88rem; }
/* Four leader names rarely fit the hero's text width, so this row gets a little more room on wide screens. */
@media (min-width: 1101px) { .hero-try { margin-inline: -100px; } }
/* The whole leader card shows, with small rounded corners. The pill's left padding keeps it inside the round end. */
.leader-chip { color: var(--text); padding: 3px 12px 3px 7px; }
.leader-chip img { width: 34px; aspect-ratio: 7 / 5; object-fit: contain; border-radius: 3px; display: block; }
.leader-chip:hover, .leader-chip:focus-visible { border-color: var(--accent); background: var(--panel-2); }
/* The hero's search replaces the top bar's on the home page. */
.home-page .topbar .site-search { display: none; }

.home-features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; max-width: 1320px; margin: 36px auto 44px; }
.home-feature { display: grid; grid-template-columns: auto 1fr; align-content: start; gap: 4px 14px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text); }
.home-feature:is(:hover, :focus-visible) { transform: translateY(-4px); border-color: rgba(255, 255, 255, .4); box-shadow: 0 12px 28px rgba(0, 0, 0, .5); text-decoration: none; }
.home-feature b { font-size: 1.02rem; }
.home-feature > span:not(.feature-icon) { color: var(--muted); font-size: .9rem; }
.feature-icon { grid-row: span 2; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 154, 61, .12); color: var(--sun-1); }
.feature-icon svg { width: 22px; height: 22px; }
@media (max-width: 1100px) { .home-features { grid-template-columns: repeat(2, 1fr); } }

/* Leader and card of the day: two equal panels, art beside its name and who it plays with. Landscape art (the
   leader side) is --daily-h tall; portrait art (the unit side, the card) gets the toggle's old space too, so it's
   readable without making the row taller. */
.home-daily {
  --daily-h: clamp(200px, 12vw, 230px); --daily-tall: calc(var(--daily-h) + 36px); --daily-thumb: clamp(110px, 6.5vw, 125px);
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 40px;
}
/* Tall enough for the unit side and its toggle, so flipping the leader never changes the row's height. */
.daily { display: flex; gap: 20px; padding: 18px; min-height: calc(var(--daily-tall) + 14px + 38px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.daily-art { position: relative; flex: none; align-self: start; }
.daily-art a { display: block; }
.daily-art img { display: block; height: var(--daily-h); width: auto; max-width: 100%; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); transition: translate .15s, box-shadow .15s; }
/* The big leader / card picture opens its page: the same neutral lift and edge as the small leaders beside it. */
.daily-art a:is(:hover, :focus-visible) img { translate: 0 -3px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .85), 0 16px 34px rgba(0, 0, 0, .55); }
.card-daily .daily-art img, .leader-daily .side-unit { height: var(--daily-tall); }
.leader-daily .side-unit, .leader-daily .daily-art:has(input[value="unit"]:checked) .side-leader { display: none; }
.leader-daily .daily-art:has(input[value="unit"]:checked) .side-unit { display: block; }
/* Desktop: the art keeps the leader side's width whichever side shows, the unit side centred in it, so flipping never
   moves the text beside it. */
@media (min-width: 701px) {
  .leader-daily .daily-art { width: calc(var(--daily-h) * 7 / 5); }
  .leader-daily .daily-art a { display: flex; justify-content: center; }
}
/* Leader / Unit: a small version of the search scope toggle, straddling the art's bottom edge (the cards' text
   boxes sit at the bottom, so it mustn't cover more than the border). */
.daily-art:has(.side-toggle) { margin-bottom: 14px; }
.side-toggle {
  --seg-bg: var(--panel); position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 50%); display: inline-flex; gap: 2px; padding: 3px;
  background: rgba(13, 15, 20, .88); border: 1px solid var(--line); border-radius: 99px; box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}
.side-toggle label { position: relative; padding: 2px 12px; border-radius: 99px; font-size: .8rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.side-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.side-toggle label:has(input:checked) { background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.side-toggle label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.daily-info { flex: 1; min-width: 0; }
.daily-label { color: var(--accent); font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.daily h2 { margin: 0 0 4px; font-size: 1.45rem; }
.daily h2 a { color: var(--text); }
.daily-meta { display: flex; align-items: center; gap: 4px; margin: 0 0 2px; color: var(--muted); font-size: .88rem; }
.daily-meta .pip { width: 18px; height: 18px; }
.daily-meta span:not(.pip) { margin-left: 4px; }
.daily-set { margin: 0 0 8px; color: var(--muted); font-size: .8rem; }
.daily-set a { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 3px; }
.daily-set a:hover { color: var(--text); }
.daily-traits { margin: 0 0 2px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.daily .ability { padding: 6px 10px; margin-bottom: 6px; }
.daily .ability p { margin-top: 2px; font-size: .88rem; line-height: 1.45; }
.leader-daily .side-text-unit, .leader-daily:has(input[value="unit"]:checked) .side-text-leader { display: none; }
.leader-daily:has(input[value="unit"]:checked) .side-text-unit { display: block; }
/* Far right: up to four leaders that go with it, a 2x2 grid in order of share, about as tall as the art. */
.daily-side { flex: none; width: calc(2 * var(--daily-thumb) + 10px); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 8px 10px; }
.daily-side .daily-sub { grid-column: 1 / -1; margin: 0; display: flex; justify-content: space-between; gap: 8px; }
.daily-side .daily-sub span { font-size: .8rem; }
.daily-side a { display: grid; gap: 4px; padding: 3px; margin: -3px; border-radius: 8px; color: var(--text); font-size: .8rem; min-width: 0; }
/* Hover: the picture lifts with a soft white outline and the name brightens. Neutral on purpose: orange is kept for
   what's selected, featured or new. */
.daily-side a:is(:hover, :focus-visible) { background: var(--panel-2); text-decoration: none; }
.daily-side a:is(:hover, :focus-visible) img { translate: 0 -2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .85), 0 8px 20px rgba(0, 0, 0, .5); }
.daily-side b { color: #cfd5df; }
.daily-side a:is(:hover, :focus-visible) b { color: #fff; }
.daily-side img { width: 100%; aspect-ratio: 7 / 5; object-fit: fill; border-radius: 6px; display: block; transition: translate .15s, box-shadow .15s; }
.daily-side a > span { display: flex; justify-content: space-between; gap: 6px; min-width: 0; }
.daily-side b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.daily-side .muted { flex: none; }
.daily-sub { margin: 14px 0 6px; font-size: .8rem; color: var(--muted); }
/* Stacked (one panel per row), there's width to spare: the four leaders go in one row instead of 2x2. */
@media (max-width: 1700px) {
  .home-daily { grid-template-columns: 1fr; --daily-h: 215px; --daily-thumb: clamp(120px, 10vw, 156px); }
  .daily-side { width: calc(4 * var(--daily-thumb) + 30px); grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) { .daily-side { width: calc(2 * var(--daily-thumb) + 10px); grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .daily { flex-wrap: wrap; } .daily-side { width: 100%; } }
@media (max-width: 700px) { .daily { flex-direction: column; } .home-daily { --daily-h: 200px; } .daily { min-height: 0; } .daily-art { align-self: center; } .leader-daily .side-leader { width: 100%; height: auto; } }
/* Phones: flipped to Unit, the (portrait) card grows to most of the panel's width so its text is readable. */
@media (max-width: 700px) {
  .leader-daily .daily-art:has(input[value="unit"]:checked) { align-self: stretch; }
  .leader-daily .daily-art:has(input[value="unit"]:checked) .side-unit { width: 82%; height: auto; margin-inline: auto; }
}
/* First printed in the latest release or the upcoming (spoiled) set: an orange pill on trending pairs and cards. */
.new-tag { display: inline-block; vertical-align: 2px; padding: 0 7px; border-radius: 99px; font-size: .8rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: #1a0f05; background: linear-gradient(135deg, var(--sun-1), var(--sun-2)); }
/* Trending cards: always one full row of eight (two rows of four on narrower screens), never a lone card on a row. */
.card-grid.browse.home-cards { grid-template-columns: repeat(8, minmax(0, 1fr)); margin-bottom: 36px; }
@media (max-width: 1100px) { .card-grid.browse.home-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat-line :is(.new-tag, .unreleased-tag) { align-self: center; }

/* ---------- deck tiles ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.deck-tile {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; color: var(--text); transition: transform .12s, border-color .12s, box-shadow .12s;
}
/* Picking a deck (deck tiles, pair tiles, folders, list rows): a clear lift, a light border and a shadow. Neutral, like
   every hover; orange is for what's selected, featured or new. */
.deck-tile:is(:hover, :focus-visible) {
  transform: translateY(-4px); border-color: rgba(255, 255, 255, .4); box-shadow: 0 12px 28px rgba(0, 0, 0, .5); text-decoration: none;
}
/* Deck art (partials/deck_art.html): leaders side by side, then a slim base bar (aspect icon, HP, name) with an
   edge in the base's aspect colour. */
/* The leaders sit on the tile's own colour with a little room around and between them, so each card's rounded corners
   and faint outline show (rather than butting into the tile edge on black). Below the aspect stripe when there is one. */
.deck-art { display: grid; background: var(--panel); }
.deck-art .art-leaders { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; }
.deck-art .art-leaders > * { aspect-ratio: 7 / 5; }
.deck-art .art-leaders img { width: 100%; height: auto; object-fit: cover; display: block; }
.deck-art .art-leaders > div { border: 1px dashed var(--line); border-radius: 5%; }
.deck-art .base-bar {
  display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; overflow: hidden; white-space: nowrap;
  background: #14171d; font-size: .8rem; color: #e7e9ee;
}
.deck-art .base-bar span { overflow: hidden; text-overflow: ellipsis; }
.deck-art .base-bar .pip { width: 15px; height: 15px; }
.deck-art .base-hp { color: var(--text); font-weight: 800; }
.deck-art .base-bar.empty { color: var(--muted); }
.deck-art .base-bar.Vigilance { background: color-mix(in srgb, var(--vigilance) 32%, #14171d); }
.deck-art .base-bar.Command { background: color-mix(in srgb, var(--command) 32%, #14171d); }
.deck-art .base-bar.Aggression { background: color-mix(in srgb, var(--aggression) 32%, #14171d); }
.deck-art .base-bar.Cunning { background: color-mix(in srgb, var(--cunning) 32%, #14171d); }
.deck-tile .body { padding: 12px 14px; }
.deck-tile .name { font-weight: 700; margin-bottom: 2px; }
.tile-head { display: flex; align-items: flex-start; gap: 10px; }
.tile-head .name { flex: 1; min-width: 0; }
.tile-head .pips { flex: none; margin-top: 2px; }
/* Tiles in a row share a height; the date, tags and badges stay on the bottom edge whether or not there's a
   description above them. */
.deck-tile:not(.add-deck-tile) { display: flex; flex-direction: column; }
.deck-tile .body { flex: 1; display: flex; flex-direction: column; }
/* The bottom row never wraps, so nothing ends up floating mid-tile: the date and owner in the bottom-left corner, the
   labels in the bottom-right. When the labels need more room they wrap onto more rows, growing up from the corner. */
.tile-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 8px; }
.tile-labels { display: grid; gap: 4px; justify-items: end; min-width: 0; }
.tile-labels .deck-tags-line { justify-content: flex-end; margin: 0; }
/* static/js/tile-fit.js: the owner's tags drop off a tile whose corner would need more than two rows of labels. */
.tile-foot.tags-hidden .deck-tags-line { display: none; }
/* The date, then "by username" under it. It keeps its width (the labels wrap onto more rows first), up to 60% of the
   row; past that only the username shortens with "…". The date always shows whole. */
.tile-foot .tile-meta { flex: 0 0 auto; max-width: 60%; display: grid; gap: 2px; white-space: nowrap; }
.tile-meta .tile-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tile-badges { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px; }
/* On tiles, "Unreleased cards" is a smaller badge so it fits in the corner (full size on deck pages and list rows). */
.tile-badges .badge.upcoming { font-size: .68rem; padding: 0 6px; }
.badge {
  display: inline-block; font-size: .8rem; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.legal { color: var(--ok); border-color: rgba(76, 195, 138, .4); }
.badge.illegal { color: var(--warn); border-color: rgba(242, 201, 76, .4); }
/* Spoiled cards that aren't out yet: red, on deck badges, card tags and outlines. */
.badge.upcoming { color: var(--bad); border-color: rgba(255, 107, 107, .45); }
.unreleased-tag { flex: none; color: var(--bad); border: 1px solid rgba(255, 107, 107, .45); border-radius: 99px;
  padding: 0 7px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
img.unreleased, .view-tile.unreleased, .result.unreleased { outline: 3px solid var(--bad); outline-offset: -3px; }
.view-tile .tile-new { position: absolute; bottom: 6px; right: 6px; font-size: .8rem; font-weight: 800; padding: 2px 7px;
  border-radius: 99px; background: rgba(0, 0, 0, .85); color: var(--bad); }

.pair-tile { display: flex; gap: 0; align-items: stretch; }
.pair-tile .art { height: 80px; }

/* ---------- grid / list toggle ---------- */
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-toggle[hidden] { display: none; }
.view-toggle a { padding: 6px 12px; color: var(--muted); font-weight: 600; font-size: .85rem; }
.view-toggle a:hover { text-decoration: none; color: var(--text); }
.view-toggle a.on { background: var(--panel-2); color: var(--text); }

.deck-table { width: 100%; border-collapse: collapse; }
.deck-table th, .deck-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.deck-table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.deck-table tbody tr { transition: background .12s, box-shadow .12s; }
.deck-table tbody tr:hover { background: var(--panel-2); box-shadow: inset 3px 0 0 rgba(255, 255, 255, .45); }
.deck-table .art-cell { width: 1%; padding: 10px 18px 10px 10px; }  /* clear of the hover bar on the row's left edge */
.deck-table .deck-art { width: 520px; border-radius: 8px; overflow: hidden; }
.deck-table .deck-name { font-weight: 700; color: var(--text); }
.deck-table .tile-summary { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- leaders ---------- */
/* 5 leaders per row on desktop so the card text stays legible. */
.leader-grid { display: grid; gap: 16px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1300px) { .leader-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .leader-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .leader-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.leader-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); }
.leader-card { transition: transform .12s, border-color .12s, box-shadow .12s; }
.leader-card:is(:hover, :focus-visible) { transform: translateY(-4px); border-color: rgba(255, 255, 255, .4); box-shadow: 0 12px 28px rgba(0, 0, 0, .5); text-decoration: none; }
/* The leader sits inside the tile with 8px of room, like the art on deck and pair tiles. */
.leader-card img { width: calc(100% - 16px); margin: 8px 8px 0; aspect-ratio: 7 / 5; object-fit: fill; display: block; }
.leader-card .body { padding: 8px 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font-size: .85rem; cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 6px; position: relative;
}
.chip.on { background: var(--panel-2); color: var(--text); border-color: var(--accent); }
.chip:hover { text-decoration: none; color: var(--text); }

/* ---------- deck page ---------- */
.deck-head { display: grid; grid-template-columns: auto 1fr; gap: 24px; margin-bottom: 24px; }
.deck-head .commanders { display: flex; gap: 10px; }
.deck-head .commanders img { width: 210px; border-radius: 10px; display: block; }
.deck-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; }
.deck-cols { columns: 3 260px; column-gap: 28px; }
.deck-group { break-inside: avoid; margin-bottom: 20px; }
/* Section headers: a filled bar across all of a section's columns, so where a group starts and ends reads at a glance.
   The builder's .deck-section h3 matches. */
.deck-group h3 { padding: 6px 12px; margin: 0 0 6px; border-radius: 8px; background: var(--panel-2); font-size: 1.02rem; font-weight: 700; color: var(--text); }
.deck-group h3 > .muted { color: var(--sun-1); }
.deck-group h3 .not-in-stats { color: var(--muted); font-size: .82rem; font-weight: 600; }
/* Clicking a section's header collapses it (static/js/deck-sections.js). The builder's headers share these rules. */
:is(.deck-group, .deck-section) > h3 { cursor: pointer; user-select: none; }
:is(.deck-group, .deck-section) > h3:hover { background: #262c38; }
/* A stat or token filter is on and a collapsed section hides some of its cards: an orange outline on that section's
   bar says so (deck page and builder). */
.token-filtered :is(.deck-group, .deck-section).collapsed:has(.token-match) > h3 { box-shadow: inset 0 0 0 2px var(--accent); }
.collapse-btn { display: inline-grid; place-items: center; width: 22px; height: 22px; margin: -2px 4px -2px -6px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; vertical-align: -5px; }
.collapse-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: rotate .15s; }
.collapse-btn:hover { color: var(--text); }
.collapsed > h3 { margin-bottom: 0; }
.collapsed .collapse-btn svg { rotate: -90deg; }
.collapsed > .group-body, .collapsed > .section-body { display: none !important; }
.deck-view.list .deck-group.collapsed { width: var(--list-col, 320px); max-width: 100%; }
.card-line {
  display: flex; gap: 8px; align-items: center; padding: 3px 4px; border-radius: 6px; cursor: default; font-size: .92rem;
}
.card-line:hover { background: var(--panel-2); }
.card-line .qty-n { color: var(--muted); font-size: .8rem; }  /* "×3", only for cards that allow more than one copy */
.card-line .cost {
  width: 20px; height: 20px; border-radius: 50%; background: #2c3340; display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; flex: none;
}
.card-line .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-line .sub { color: var(--muted); }
.penalty { color: var(--warn); font-size: .8rem; font-weight: 700; }
.curve { display: flex; gap: 6px; align-items: flex-end; height: 120px; }
.curve .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
/* The bar's height is a share of the track, which leaves out the labels: as a share of the whole column, tall bars
   plus their labels overflowed and got squashed to the same height (15 and 23 looked alike). The count sits on top
   of the bar, in the track's top padding. */
.curve .bar .track { flex: 1; min-height: 0; width: 100%; display: flex; align-items: flex-end; padding-top: 16px; }
.curve .bar span { position: relative; width: 100%; background: linear-gradient(var(--sun-1), var(--sun-2)); border-radius: 4px 4px 0 0; min-height: 2px; }
.curve .bar small { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.curve .bar b { position: absolute; bottom: 100%; left: 0; right: 0; text-align: center; font-size: .8rem; line-height: 16px; color: var(--muted); }
.issues { list-style: none; padding: 0; margin: 0; }
.issues li { padding: 4px 0 4px 20px; position: relative; font-size: .9rem; }
.issues li::before { position: absolute; left: 0; }
.issues .err::before { content: "✕"; color: var(--bad); }
.issues .warn::before { content: "!"; color: var(--warn); font-weight: 800; left: 4px; }
.issues .ok::before { content: "✓"; color: var(--ok); }
/* Builder: what's left to add, as neutral steps that tick off (not errors: an unfinished deck isn't a wrong one). */
.issues li.steps { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-left: 0; color: var(--muted); }
.issues li.steps::before { content: none; }
.issues .step { display: inline-flex; align-items: center; gap: 6px; }
.issues .step::before { content: ""; width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 50%; flex: none; }
.issues .step b { color: var(--text); font-weight: 600; }
.issues .step.done { color: var(--ok); }
.issues .step.done::before { content: "✓"; border: 0; width: auto; height: auto; font-weight: 800; }
.badge.unfinished { color: var(--muted); border-style: dashed; }
/* A deck's issues, in a popup the legality badge opens (deck-issues.js). */
button.badge { font-family: inherit; line-height: inherit; cursor: pointer; }
button.badge:hover:not(:disabled) { border-color: currentColor; }
button.badge:disabled { cursor: default; }
/* A badge that opens the popup carries a small "?" so it reads as something to click. */
button.badge:not(:disabled) { display: inline-flex; align-items: center; gap: 5px; padding-right: 3px; }
button.badge:not(:disabled)::after {
  content: "?"; display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; flex: none;
  background: color-mix(in srgb, currentColor 22%, transparent); font-size: .68rem; font-weight: 800; line-height: 1;
}
button.badge:not(:disabled):hover::after { background: currentColor; color: var(--panel-2); }
.issues .issue-card {
  padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.issues .issue-card { font-weight: 600; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.issues .issue-card:hover { color: var(--accent); text-decoration-color: currentColor; }
.issues .btn.issue-fix { margin-left: 6px; padding: 0 8px; min-height: 0; font-size: .78rem; line-height: 1.6; vertical-align: 1px; }
.issues-dialog { width: min(600px, calc(100vw - 32px)); max-height: min(80vh, 760px); display: none; flex-direction: column; gap: 10px; }
.issues-dialog[open] { display: flex; }
.issues-dialog .id-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.issues-dialog .id-hint { margin: -4px 0 0; color: var(--muted); font-size: .85rem; }
.issues-dialog .id-hint[hidden] { display: none; }
.issues-dialog .id-list { overflow-y: auto; min-height: 0; flex: 1; margin: 0 -6px; padding: 0 6px; overscroll-behavior: contain; }
.issues-dialog .id-list li { padding-top: 6px; padding-bottom: 6px; border-top: 1px solid var(--line); }
.issues-dialog .id-list li:first-child { border-top: 0; }
.issues-dialog .id-list li.steps { padding-bottom: 10px; }
.issues-dialog :is(.id-fix, .id-action)[hidden] { display: none; }
.issues-dialog .id-action { margin-right: auto; }
/* Phones: a sheet from the bottom, the list scrolling inside it and Close in reach of a thumb. */
@media (max-width: 700px) {
  .issues-dialog { width: 100vw; max-width: 100vw; max-height: 85vh; margin: auto 0 0; border-radius: 14px 14px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .issues-dialog .id-list li { padding-top: 9px; padding-bottom: 9px; }
  .issues-dialog .sd-actions .btn { flex: 1; text-align: center; }
}

/* ---------- hover preview ---------- */
#preview {
  position: fixed; z-index: 100; pointer-events: none; display: none; width: 260px; border-radius: 12px; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .7);
}
#preview img { display: block; width: 100%; }
#preview.wide { width: min(380px, 40vw); }

/* ---------- discovery tables ---------- */
.rate-table { width: 100%; border-collapse: collapse; }
.rate-table td, .rate-table th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: .9rem; }
.rate-table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.meter { height: 6px; background: var(--panel-2); border-radius: 3px; width: 120px; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--sun-1), var(--sun-2)); }
.syn-pos { color: var(--ok); }
.syn-neg { color: var(--muted); }

.auth-box { max-width: 380px; margin: 40px auto; }
.auth-box p { margin: 0 0 12px; }
.auth-box .helptext, .auth-box ul { font-size: .8rem; color: var(--muted); }
.errorlist, .auth-box ul.errorlist { color: var(--bad); font-size: .9rem; }
/* Form-wide errors (a wrong password, too many tries) stand out above the form, so they're seen on a phone. */
.errorlist.nonfield { list-style: none; margin: 0 0 14px; padding: 10px 12px; border: 1px solid rgba(255, 107, 107, .45);
  border-radius: 8px; background: rgba(255, 107, 107, .1); font-weight: 600; }
.errorlist.nonfield li + li { margin-top: 6px; }

@media (max-width: 800px) {
  .topbar { gap: 14px; padding: 0 16px; }
  .brand-text { display: none; }
  .nav { gap: 14px; }
  .nav a, .account a, .account button { white-space: nowrap; font-size: .9rem; }
  .account .btn { display: none; }
  .container { padding: 20px 16px 40px; }
  .grid { grid-template-columns: 1fr; }
  .deck-table .hide-sm { display: none; }
  .hero { margin: -20px -16px 0; padding: 40px 16px; }
  .hero h1 { font-size: 1.9rem; }
  .home-search input[type=search] { height: 54px; font-size: 1.05rem; }
  .home-search kbd { display: none; }
  .scope { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }  /* fits at phone width; scrolls (barless) on the narrowest */
  .scope::-webkit-scrollbar { display: none; }
  .scope button { padding: 6px 9px; font-size: .82rem; }
  .home-features { grid-template-columns: 1fr; margin: 24px 0 32px; }
  .deck-head, .deck-body { grid-template-columns: 1fr; }
  .deck-head .commanders img { width: calc(50% - 5px); }
}

.set-heading { margin: 28px 0 12px; font-size: 1.1rem; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; }

/* ---------- leader page (EDHREC-style) ---------- */
/* The art and the info sit together in the middle of the page, with the info at a readable width. */
/* Leader page filters swap results in place (static/js/leader-filters.js): the parts dim briefly while they load. */
[data-leader-part] { transition: opacity .15s; }
[data-leader-part].is-loading { opacity: .55; }
.leader-hero { display: grid; grid-template-columns: auto minmax(0, 900px); justify-content: center; gap: 32px; margin-bottom: 36px; align-items: start; }
.leader-info h1 { font-size: 2.2rem; margin-bottom: 4px; }
.leader-info h1 .h1-partner { color: var(--muted); font-weight: 600; }
.card-text { white-space: pre-line; max-width: 720px; }
.section { margin-bottom: 40px; }
.section-head { margin-bottom: 4px; }
.section-head h2 { margin: 0; }

/* Leader art in grids: the leader side only (both sides are on the leader's own page). */
.leader-thumb { width: 100%; aspect-ratio: 7 / 5; object-fit: fill; border-radius: 10px; display: block; background: #000; }
/* Leader page: leader side and deployed unit side at the same height. */
/* Same card turned sideways: the unit side is as wide as the leader side is tall, so both print at the
   same size. Top-aligned so they read as a pair. */
.leader-sides { display: flex; gap: 14px; align-items: flex-start; }
.leader-sides figure { margin: 0; display: grid; gap: 6px; justify-items: center; }
.leader-sides img { width: calc(392px * var(--card-scale)); aspect-ratio: 7 / 5; object-fit: fill; border-radius: 12px; display: block; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.leader-sides figure + figure img { width: calc(280px * var(--card-scale)); aspect-ratio: 5 / 7; }
.leader-sides figcaption { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
@media (max-width: 1250px) { .leader-sides img { width: 308px; } .leader-sides figure + figure img { width: 220px; } }
/* Phones: the two sides stacked, full width, like the deck page's leaders. */
@media (max-width: 700px) { .leader-sides { flex-direction: column; align-items: stretch; } .leader-sides figure { width: 100%; } .leader-sides img, .leader-sides figure + figure img { width: 100%; } }
/* Phones: the Leader / Unit toggle shows one side at a time; the unit side a bit narrower so it fits on screen. */
@media (max-width: 700px) {
  .leader-sides:has(.sides-toggle) { align-items: center; }
  .leader-sides .sides-toggle { position: static; transform: none; align-self: center; }
  .leader-sides:has(.sides-toggle) figure.side-unit { display: none; }
  .leader-sides.show-unit figure.side-leader { display: none; }
  .leader-sides.show-unit figure.side-unit { display: grid; width: 82%; }
}

.partner-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(calc(220px * var(--card-scale)), 1fr)); margin-top: 12px; }
/* Five or more partners share the full row, like the card grids below; a short list keeps its tile size. */
.partner-grid:has(> :nth-child(5)) { grid-template-columns: repeat(auto-fit, minmax(calc(220px * var(--card-scale)), 1fr)); }
.partner { color: var(--text); border-radius: 12px; padding: 8px; border: 1px solid transparent; transition: transform .12s, border-color .12s, background .12s, box-shadow .12s; }
/* Hover: the tile lifts onto a panel with a light border, like the printings and deck tiles; the leader picture stays
   put inside it. The picked partner keeps its orange border (it's the active filter) and only lifts. */
.partner:is(:hover, :focus-visible) { text-decoration: none; background: var(--panel); transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, .45); }
.partner:not(.on):is(:hover, :focus-visible) { border-color: rgba(255, 255, 255, .35); }
.partner.on { border-color: var(--accent); background: var(--panel); }
.partner-name { font-weight: 700; margin-top: 8px; }
/* Leader page: share of decks per base aspect, with a bar in the aspect's colour. */
.base-filter { gap: 6px; margin: 4px 0 8px; }
.base-filter [data-card-size-picker] { margin-left: auto; }  /* stays right when the note wraps it */
.base-aspect-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(calc(280px * var(--card-scale)), 1fr));  /* the boxes share the row */ margin-top: 12px; }
.base-aspect { display: grid; gap: 6px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; position: relative; }
/* A base aspect box is the cards filter: its name link covers the box; the top base link sits above it. */
/* Hover: the same tile lift as the partner tiles above; the picked aspect keeps its orange border and only lifts. */
.base-aspect.pickable { transition: transform .12s, border-color .12s, box-shadow .12s; }
.base-aspect.pickable:is(:hover, :focus-within) { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, .45); }
.base-aspect.pickable:not(.on):is(:hover, :focus-within) { border-color: rgba(255, 255, 255, .35); }
.base-aspect.on.pickable:is(:hover, :focus-within) { box-shadow: 0 0 0 1px var(--accent), 0 10px 24px rgba(0, 0, 0, .45); }
.base-aspect.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.base-aspect-link { color: inherit; }
.base-aspect-link:hover { text-decoration: none; }
.base-aspect-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.base-aspect .small a { position: relative; z-index: 1; }
.base-aspect .share-bar { height: 6px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.base-aspect .share-bar span { display: block; height: 100%; background: var(--muted); }
.base-aspect.Vigilance .share-bar span { background: var(--vigilance); }
.base-aspect.Command .share-bar span { background: var(--command); }
.base-aspect.Aggression .share-bar span { background: var(--aggression); }
.base-aspect.Cunning .share-bar span { background: var(--cunning); }

.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(calc(170px * var(--card-scale)), 1fr)); }
.stat-card img { width: 100%; aspect-ratio: 5 / 7; object-fit: fill; border-radius: 9px; display: block; }
/* Name and numbers centred under the art, so they read as that card's and stay clear of the cards beside it. */
.stat-card { text-align: center; }
.stat-name { font-weight: 600; font-size: .88rem; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-line { display: flex; justify-content: center; gap: 4px 6px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
/* A dot between the numbers ("17% of decks · 18 decks"); gone when they stack on phones. */
.stat-line > span:not(.new-tag, .unreleased-tag) + span:not(.new-tag, .unreleased-tag)::before { content: "·"; margin-right: 6px; opacity: .7; }

@media (max-width: 800px) {
  .leader-hero { grid-template-columns: 1fr; }
  .partner-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-line { flex-direction: column; align-items: center; }
  .stat-line > span::before { content: none !important; }
}

/* Per-deck card settings shown on deck pages */
.card-line .cost.custom { background: var(--accent); color: #1a0f05; }
.foil-mark { color: #9fd8ff; }

/* Deck visibility, one-line description, primer */
.badge.vis-unlisted { color: #9fd8ff; border-color: rgba(159, 216, 255, .4); }
.badge.vis-private { color: var(--muted); }
.badge.retired { color: var(--muted); border-style: dashed; }
.badge.unpublished { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.badge.in-paper { color: var(--text); border-color: color-mix(in srgb, var(--text) 35%, transparent); }
.badge.format { color: var(--sun-2); border-color: color-mix(in srgb, var(--sun-2) 40%, transparent); }
.badge.primer { color: var(--sun-1); border-color: color-mix(in srgb, var(--sun-1) 40%, transparent); }
.badge.no-primer { color: var(--muted); border-style: dashed; }
/* Primer text that doesn't count yet (decks/primer.py): the owner's note on why, in the builder and on the deck page. */
.badge.primer-short { color: var(--warn); border-color: rgba(242, 201, 76, .4); border-style: dashed; cursor: pointer; }
.primer-status { margin: 8px 0 0; padding: 8px 12px; border: 1px dashed rgba(242, 201, 76, .4); border-radius: 10px;
  font-size: .85rem; color: var(--text); }
.primer-status b { color: var(--warn); }
a.badge:hover { text-decoration: none; border-color: currentColor; }
.deck-summary-line { font-size: 1.05rem; color: #cfd5df; margin: -4px 0 8px; }
.tile-summary { font-size: .85rem; color: #cfd5df; margin: 2px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Tabs (builder's Deck / Suggestions / Primer, deck page's Deck / Primer). */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab {
  background: none; border: 0; color: var(--muted); padding: 8px 10px; font: inherit; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); text-decoration: none; }
.deck-tabs { margin-top: 18px; }
/* The deck page and the builder: a darker page, with the tabs and the decklist in one panel (.block.deck-block). */
:root { --deck-bg: #0b0d12; }
body:is(.deck-page, .panel-page) { background: var(--deck-bg); }
.deck-page .container { padding: 20px 24px 60px; }
.deck-page .deck-hero { margin-bottom: 20px; }
.block {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; margin-bottom: 16px;
}
.block.deck-block .tabs { margin-top: -4px; }
/* Card and leader pages (.panel-page), three levels: a page section's title sits on the page (a big title, then
   what it shows); its content is in a panel like the deck page's; related parts share one panel,
   split by a thin line (.sub.divided) under smaller titles; groups of cards in a panel are the site's band
   (.band-heading). Inside a panel, what had the page's colour behind it takes the lighter grey to stand off it. */
.page-section { margin-bottom: 28px; }
.page-section-head { margin: 0 0 10px; padding-inline: 2px; }
/* The orange line over a title is the section's count (how many decks, printings, ...), in sun colour like the bands'. */
.kicker { display: block; margin-bottom: 2px; font-size: .76rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--sun-1); }
.page-section-head h2 { margin: 0; font-size: 1.5rem; line-height: 1.2; }
.page-section-head h2 .muted { font-size: 1rem; font-weight: 600; }
.page-section-head p { margin: 4px 0 0; max-width: 900px; }
.page-section > .block { margin-bottom: 0; }
.block > .sub > :first-child, .block > .sub > .section-head h3 { margin-top: 0; }
.block .sub h3 { margin: 0 0 4px; font-size: 1.1rem; }
.block .sub > :last-child { margin-bottom: 0; }
.block .sub.divided { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.block > .base-filter:first-child { margin-top: -4px; }
/* A panel holding only a few printings hugs them instead of running the page's width. */
.block.fit { width: fit-content; max-width: 100%; }
.block.fit .printings { display: flex; flex-wrap: wrap; }
.block.fit .printings > .printing { width: calc(130px * var(--card-scale)); }
.block.fit .leader-printings > .printing { width: calc(180px * var(--card-scale)); }
@media (max-width: 520px) { .block.fit { width: auto; } .block.fit .printings > .printing { width: calc(50% - 4px); } }
@media (max-width: 700px) { .page-section-head h2 { font-size: 1.35rem; } .page-section { margin-bottom: 28px; } }
.block :is(.base-aspect, .deck-tile, .partner.on, .partner:is(:hover, :focus-visible)) { background: var(--panel-2); }
.block .base-aspect .share-bar { background: var(--line); }
.block :is(.printing, .rulings li) { background: #222834; }
.panel-page :is(.card-hero, .leader-hero) { margin-bottom: 20px; }
.panel-page .block { padding: 14px 18px; }
.panel-page .partner-grid, .panel-page .base-aspect-grid, .panel-page .top-grid { margin-top: 8px; }
/* Partners a little smaller, so six fit across a wide screen (one row instead of two). */
.panel-page .partner-grid, .panel-page .partner-grid:has(> :nth-child(5)) { grid-template-columns: repeat(auto-fill, minmax(calc(170px * var(--card-scale)), 1fr)); gap: 12px; }
@media (max-width: 700px) { .panel-page .partner-grid, .panel-page .partner-grid:has(> :nth-child(5)) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.block .band-section { margin-bottom: 14px; }
.block .band-section:last-child { margin-bottom: 0; }
.block .band-heading { margin-bottom: 12px; }  /* card images under it, not list rows */
.block .band-section.collapsed > .band-heading { margin-bottom: 0; }
.band-section[data-section] > .band-heading:hover { background: #262c38; }
/* Deck page Primer tab: a reading column in the middle of the panel, with its contents list (sticky) when it has three or
   more headings. Phones: the column fills the width and the list sits above it. Desktop: 16px text up to about 96
   characters; from 1280px the column is centred in the panel, the list in the middle of the empty left side and an equal column at
   the right balancing it. */
.primer-layout { display: grid; grid-template-columns: minmax(0, 72ch); justify-content: center; padding: 6px 0 18px; }
@media (min-width: 861px) {
  .primer-layout { font-size: 16px; grid-template-columns: minmax(0, 96ch); }
  .primer-layout.has-toc { grid-template-columns: minmax(170px, 230px) minmax(0, 96ch); gap: 40px; }
}
@media (min-width: 1280px) {
  .primer-layout.has-toc { grid-template-columns: minmax(170px, 1fr) minmax(0, 96ch) minmax(170px, 1fr); justify-content: stretch; gap: 32px; }
  .primer-layout.has-toc .primer-toc { grid-column: 1; justify-self: center; width: min(240px, 100%); }  /* mid-way across the empty left side */
  .primer-layout.has-toc .primer { grid-column: 2; }
}
.primer { min-width: 0; }
.primer-body > :first-child { margin-top: 0; }
.primer-toc { position: sticky; top: 16px; align-self: start; font-size: .9rem; }
.primer-toc h3 { margin: 0 0 8px; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.primer-toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.primer-toc a { display: block; padding: 4px 0 4px 12px; margin-left: -2px; border-left: 2px solid transparent; color: var(--muted); line-height: 1.35; }
.primer-toc a:hover { color: var(--text); text-decoration: none; }
.primer-toc a.on { color: var(--text); border-left-color: var(--accent); }
.primer-toc li.sub a { padding: 2px 0 2px 24px; font-size: .85rem; }  /* ### sub-headings, indented under their section */
.primer-body h1, .primer-body h2, .primer-body h3, .primer-body h4 { scroll-margin-top: 16px; }
@media (max-width: 860px) {
  .primer-layout.has-toc { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .primer-toc { position: static; padding: 10px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
  .primer-toc li.sub { display: none; }  /* above the primer here, so sections only: keep it short */
}
/* [[Card]] tags in primers (decks/markdown.py): a dotted underline says "hover me"; the hover preview is preview.js. */
a.card-ref { color: var(--sun-1); text-decoration: underline dotted color-mix(in srgb, var(--sun-1) 60%, transparent); text-underline-offset: 3px; }
a.card-ref:hover { text-decoration-style: solid; }
.card-ref-missing { border-bottom: 1px dashed var(--muted); }
/* ![[Card]]: the card's image; several in a row sit side by side. */
a.card-embed { display: inline-block; vertical-align: top; margin: 4px 8px 4px 0; line-height: 0; }
a.card-embed img { width: 180px; max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, .45); }
a.card-embed.wide img { width: 250px; }
a.card-embed:hover img { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A line of only card images (decks/markdown.py): a centred row, wrapping onto more rows as needed. */
p.card-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 10px; }
p.card-row a.card-embed { margin: 0; }
.primer-body, .primer-preview { line-height: 1.65; }
@media (min-width: 861px) { .primer-preview { font-size: 16px; } }  /* as the deck page's column (.primer-layout), so the preview matches */
.primer-body h1, .primer-body h2, .primer-body h3, .primer-preview h1, .primer-preview h2, .primer-preview h3 { margin: 1.2em 0 .4em; }
/* Nested numbered lists count a, b, c then i, ii, iii, so a sub-step doesn't read as the next step. */
:is(.primer-body, .primer-preview) ol ol { list-style-type: lower-alpha; }
:is(.primer-body, .primer-preview) ol ol ol { list-style-type: lower-roman; }
.primer-body blockquote, .primer-preview blockquote { margin: 0; padding: 4px 14px; border-left: 3px solid var(--accent); color: #cfd5df; }
.primer-body code, .primer-preview code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.primer-body table, .primer-preview table { border-collapse: collapse; }
.primer-body th, .primer-body td, .primer-preview th, .primer-preview td { border: 1px solid var(--line); padding: 4px 8px; }

/* Deck lists: 3 decks per row with big leader art; shared filter bar */
/* One deck-tile size site-wide (deck lists, home, leader and card pages): 3 per row on desktop so
   each leader in the pair is big enough to read. */
.deck-grid { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.deck-grid .deck-tile .body { padding: 14px 16px; }
.deck-grid .deck-tile .name { font-size: 1.05rem; }
/* My decks: an empty tile that starts a new deck in the folder being viewed. Grid rows stretch it to its neighbours. */
.add-deck-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 240px;
  padding: 16px; text-align: center; background: transparent; border: 2px dashed var(--line); color: var(--muted);
}
.add-deck-tile:hover { border-color: var(--accent, #48505f); color: var(--text); }
.add-deck-tile .add-plus { font-size: 2.6rem; line-height: 1; font-weight: 300; }
.add-deck-tile .add-label { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.add-deck-tile .muted { overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.selecting .add-deck-tile { display: none; }
.deck-filters { display: grid; gap: 10px; margin-bottom: 22px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.deck-filters .filter-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.chip.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chip.toggle:has(input:checked) { background: var(--panel-2); color: var(--text); border-color: var(--accent); }
/* List: leaders big enough to recognise, then a smaller base. */
@media (max-width: 1100px) { .deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .deck-table .deck-art { width: 340px; } }
@media (max-width: 700px) { .deck-grid { grid-template-columns: 1fr; } .deck-table .deck-art { width: 150px; } }

/* ---------- deck page (view) ---------- */
html:has(.deck-hero) { scrollbar-gutter: stable; }  /* the deck page's tabs don't shift it sideways either */
.deck-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 32px; margin-bottom: 28px; }
.hero-info { min-width: 0; }
.hero-info .hero-actions { padding-block: 26px; }  /* room around the buttons; the stats sit a little lower */
.hero-art { display: grid; gap: 12px; justify-items: start; align-content: start; }
.hero-leaders { display: flex; gap: 12px; }
.hero-leaders:has(> :only-child) { justify-self: center; }  /* one leader (Premier) sits right over the base */
/* Leader and base art grow with big screens (--card-scale), like the card grids. */
.deck-hero { --hero-leader-w: calc(300px * var(--card-scale)); }
.hero-leaders img { width: var(--hero-leader-w); aspect-ratio: 7 / 5; object-fit: fill; border-radius: 12px; display: block; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); transition: translate .15s, box-shadow .15s; }
/* Each leader opens its page: the same neutral lift and edge as leader pictures elsewhere. */
.hero-leaders a:is(:hover, :focus-visible) img { translate: 0 -3px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .85), 0 16px 34px rgba(0, 0, 0, .55); }
.hero-empty { width: var(--hero-leader-w); aspect-ratio: 7 / 5; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.hero-base { display: grid; gap: 6px; justify-items: center; justify-self: center; }
.hero-base img { width: calc(225px * var(--card-scale)); aspect-ratio: 7 / 5; object-fit: fill; border-radius: 10px; display: block; }
/* Premier: one leader with the base beside it, the same size. */
.hero-art.premier { grid-template-columns: repeat(2, auto); align-items: start; }
.hero-art.premier .hero-leaders { justify-self: start; }
.hero-art.premier .hero-base img { width: var(--hero-leader-w); border-radius: 12px; }
.hero-info h1 { margin-bottom: 4px; }
.hero-sub { display: flex; align-items: flex-start; gap: 24px; }
.hero-sub-main { flex: 1; min-width: 0; }
.hero-sub-main p { margin: 0; }
.hero-by { padding-left: 14px; }
.hero-sub-main .deck-summary-line { margin-top: 6px; }
.hero-sub .deck-tags-line { flex: none; flex-wrap: nowrap; margin: 0; }
@media (max-width: 700px) { .hero-sub { flex-direction: column; gap: 8px; } .hero-sub .deck-tags-line { flex-wrap: wrap; } }
.hero-stats { display: grid; gap: 12px; }
.glance { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.glance-num b { font-size: 1.7rem; font-weight: 800; }
.glance-num b.ok { color: var(--ok); }
.glance-num span { color: var(--muted); margin-left: 4px; font-size: .9rem; }
.glance-legal { display: grid; gap: 6px; padding-top: 8px; }
.glance-badges { gap: 6px; }
.glance-legal .issues li { font-size: .82rem; padding-top: 1px; padding-bottom: 1px; }
.glance-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
/* Deck Makeup: types, aspects, tokens and the owner's highlights, a labeled line each. Every value filters the list. */
.makeup { display: grid; gap: 10px; align-content: start; }
.makeup .stat-title { margin-bottom: 0; }
.makeup-line { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: center; }
.makeup-note { margin: 0; }  /* an aspect-penalty warning under Aspects (builder; the deck page has the same line) */
/* Its Show button highlights the cards that pay the penalty, like the stats above it; pressed, it gets their ring. */
.makeup-note .penalty-show { margin-left: .25rem; padding: 0 .3rem; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
.makeup-note .penalty-show:hover { text-decoration: underline; }
.makeup-line.highlights { padding-top: 10px; border-top: 1px solid var(--line); }
.makeup-vals { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.makeup-vals.tight { gap: 6px; }
.stat-val { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-weight: 700; }
.stat-val:first-child { margin-left: -8px; }
.stat-val:hover:not(:disabled) { background: var(--panel-2); }
.stat-val:disabled { color: var(--muted); }
.stat-val .pip { width: 22px; height: 22px; }
.stat-val .type-icon { margin: 0; }
.stat-chip { padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font: inherit; font-size: .82rem; cursor: pointer; }
.stat-chip b { color: var(--text); font-weight: 800; }
.stat-chip:hover { border-color: var(--muted); }
.stat-chip.add-stat { background: none; border-style: dashed; }
.stat-chip.add-stat:hover { border-color: var(--accent); color: var(--text); }
.glance-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.glance-box .row { margin-bottom: 4px; }
/* Tokens Needed: a chip per token; clicking one filters the decklist to its cards. Unit tokens, token upgrades and
   other tokens tinted apart. */
/* Stats you can click to highlight their cards, like the Tokens Needed chips. */
.stat-click { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: center; cursor: pointer; }
.stat-click:disabled { cursor: default; }
.curve .bar.stat-click:hover:not(:disabled) small { color: var(--text); }
[data-cards], [data-focus] { transition: box-shadow .16s, background-color .16s, border-color .16s; }
.deck-view .view-tile { transition: transform .12s, box-shadow .12s, opacity .15s, filter .15s, outline-color .15s; }
[data-cards][aria-pressed="true"], [data-focus][aria-pressed="true"] { border-radius: 6px; box-shadow: 0 0 0 1.5px var(--sun-1); }
.token-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.token-chip { font-size: .82rem; padding: 3px 10px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--muted); cursor: pointer; color: inherit; font: inherit; font-size: .82rem; }
.token-chip:hover { border-color: var(--muted); }
.token-chip[aria-pressed="true"] { background: var(--panel); border-color: var(--sun-1); box-shadow: 0 0 0 1px var(--sun-1); }
.token-filter-note[hidden] { display: none; }
.token-filter-note { animation: ease-pop .16s ease-out; }
/* Things that appear ease in, and highlights fade, on the deck page and in the builder. */
@keyframes ease-pop { from { opacity: 0; transform: translateY(-4px); } }
.menu[open] > .menu-items, .move-menu, .name-suggest:not([hidden]), .highlight-chooser { animation: ease-pop .14s ease-out; }
.select-bar:not([hidden]) { animation: ease-rise .18s ease-out; }
@keyframes ease-rise { from { opacity: 0; transform: translate(-50%, 10px); } to { transform: translateX(-50%); } }
.card-line, .view-tile, .deck-item { transition: opacity .15s, filter .15s, background-color .15s, box-shadow .15s, outline-color .15s; }
.stat-chip, .token-chip, .chip, .stat-val, .deck-group > h3, .deck-section > h3 { transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; }
[data-section] { transition: outline-color .12s, background-color .12s; }
@media (prefers-reduced-motion: reduce) {
  .token-filter-note, .menu[open] > .menu-items, .move-menu, .name-suggest:not([hidden]), .highlight-chooser, .select-bar:not([hidden]) { animation: none; }
  .card-line, .view-tile, .deck-item, .stat-chip, .token-chip, .chip, .stat-val, .deck-group > h3, .deck-section > h3, [data-section] { transition: none; }
}
/* A token chosen: its cards keep full colour with a highlight; the rest grey out but stay clickable. */
.token-filtered [data-uid]:not(.token-match) { opacity: .35; filter: grayscale(1); }
.token-filtered [data-uid]:not(.token-match):hover { opacity: .7; }
.token-filtered .card-line.token-match { background: color-mix(in srgb, var(--sun-1) 14%, transparent); box-shadow: inset 3px 0 0 var(--sun-1); border-radius: 4px; }
.token-filtered .view-tile.token-match { outline: 3px solid var(--sun-1); outline-offset: 1px; border-radius: 8px; }
.token-filter-note .link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
.token-filter-note .link-btn:hover { text-decoration: underline; }
.token-filter-note { scroll-margin-top: 68px; margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.token-chip.unit { border-left-color: var(--sun-1); }
.token-chip.upgrade { border-left-color: var(--vigilance); }
.stat-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.curve.mini { height: 90px; gap: 4px; }
.icon-counts { display: flex; flex-wrap: wrap; gap: 12px; font-weight: 700; }
.icon-counts > :is(span, button) { display: inline-flex; align-items: center; gap: 4px; }
.icon-counts .pip { width: 22px; height: 22px; }

/* Bigger text wherever a decklist is shown. The builder's block matches. */
.deck-view .card-line { font-size: .98rem; padding-block: 3px; }
.deck-view .card-line .cost { width: 23px; height: 23px; font-size: .8rem; }
.deck-view-bar, .deck-view-bar select { font-size: .95rem; }
.deck-view-bar .view-toggle a { font-size: .92rem; }
.deck-tabs .tab { font-size: 1.04rem; }
.deck-group h3 { font-size: 1.08rem; }
.deck-view-bar { margin-bottom: 14px; gap: 16px; flex-wrap: wrap; }
.deck-view-bar label { flex-wrap: nowrap; }
.deck-view-bar select { width: auto; }
.deck-view .secondary { opacity: .45; }
.deck-group h3 .pips { vertical-align: -3px; }
/* List: laid out like Stacks. Sections sit side by side and wrap to the next row; a long section takes several columns
   under its one heading, so a group reads as one block. */
.deck-view.list { display: flex; flex-wrap: wrap; gap: 20px 24px; align-items: flex-start; margin-inline: auto; }
.deck-view.list .deck-group { margin: 0; max-width: 100%; }
.deck-view.list .group-body { display: flex; flex-wrap: wrap; gap: 0 24px; align-items: flex-start; }
.deck-view.list .list-col { flex: none; width: var(--list-col, 320px); max-width: 100%; }  /* card-size.js sets the width */
.list-break { flex-basis: 100%; height: 0; margin-top: -20px; }  /* the sideboard and maybeboard start a new row */
.deck-view.list .list-col .nm { white-space: normal; overflow: visible; }  /* the whole name, on two lines if it needs them */
@media (max-width: 700px) { .deck-view.list .deck-group, .deck-view.list .list-col { width: 100%; } }
/* Stacks: each section is one or more columns of overlapping cards showing only their top strip (cost, name).
   margin-top percentages are of the column's width; a card is 140% of its width tall, so -116% leaves a strip of
   24% of the width (about 17% of the card). static/js/stacks.js gives the card under a resting pointer .peek,
   which drops the overlap on the next card so the whole card shows, and slides the cards that move. */
.deck-view.stacks { display: flex; flex-wrap: wrap; gap: 18px 22px; align-items: flex-start; }
.deck-view.stacks .deck-group { margin: 0; }
.deck-view.stacks .group-body { display: flex; gap: 10px; align-items: flex-start; }
.deck-view.stacks .stack { width: var(--card-w); display: flex; flex-direction: column; padding-bottom: 4px; }
.deck-view.stacks .view-tile { flex: none; box-shadow: 0 -2px 6px rgba(0, 0, 0, .55); }
.deck-view.stacks .view-tile + .view-tile { margin-top: -116%; }
.deck-view.stacks .view-tile.peek + .view-tile { margin-top: 0; }  /* .peek and the slide: static/js/stacks.js */
.deck-view.stacks a.view-tile:hover { transform: none; box-shadow: 0 -2px 6px rgba(0, 0, 0, .55); }  /* stacks slide instead; the line still shows */
.deck-view.stacks .view-tile .tile-qty { top: 4px; left: auto; right: 6px; }
/* Phones: one wider stack per row (as in the builder), so each card's name strip is big enough to read. */
@media (max-width: 700px) {
  .deck-view.stacks .deck-group { width: 100%; }
  .deck-view.stacks .group-body { flex-direction: column; align-items: center; gap: 14px; }
  .deck-view.stacks .stack { width: min(240px, 68vw); }
}
/* On deck pages the whole row opens the card page: the name link is stretched over the row. */
.deck-view .card-line { position: relative; cursor: pointer; }
.deck-view .card-line .nm a::after { content: ""; position: absolute; inset: 0; }
.deck-view .card-line:hover .nm a { color: var(--sun-1); }
.deck-view .card-line .penalty, .deck-view .card-line .cost.custom { position: relative; z-index: 1; }  /* keep their tooltips */
.deck-view .deck-group { margin-bottom: 20px; }
.deck-view.images .group-body { display: grid; gap: 10px; grid-template-columns: var(--grid-template, repeat(auto-fill, minmax(min(var(--card-w), 100%), 1fr))); }
/* Rounded like the card itself (5%) with no backing of its own, so no black shows at the corners (the image brings a
   loading placeholder). Hover: a small lift and an orange line drawn just inside the card's edge, like the builder's
   card images (::before; ::after is the foil shine). isolation keeps that line inside its own card, so in Stacks the cards
   on top still cover it and it fills in as they slide away. */
.view-tile { position: relative; isolation: isolate; display: block; border-radius: 5%; overflow: hidden; aspect-ratio: 5 / 7;
  color: inherit; transition: transform .12s, box-shadow .12s; }
a.view-tile:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, .5); text-decoration: none; }
.view-tile::before {
  content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .12s;
}
a.view-tile:hover::before { box-shadow: inset 0 0 0 2px var(--accent); }
.view-tile img { width: 100%; height: 100%; object-fit: fill; display: block; }
.view-tile .tile-qty, .view-tile .tile-pen {
  position: absolute; font-size: .8rem; font-weight: 800; padding: 2px 7px; border-radius: 99px; background: rgba(0, 0, 0, .8);
}
.view-tile .tile-qty { top: 6px; left: 6px; }
/* Premier Images: the count under the card (the builder puts − and + beside it), as on the collection's condensed view. */
.count-tile { display: grid; gap: 6px; align-content: start; min-width: 0; }
.tile-count { justify-self: center; min-width: 2.2em; padding: 2px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.view-tile .tile-pen { bottom: 6px; left: 6px; color: var(--warn); }
/* Foil (deck page, builder tiles, the builder's card panel): two soft diagonal rainbows over the printed card. On Standard
   printings it fades out over the black border, so that stays black; two fades, across and down, and the foil shows
   fully only where both are solid. Leaders and bases are landscape, so theirs swap (.wide). Hyperspace, Prestige, most
   promos and the like have no black border, so the foil covers the whole card (.foil-full). */
:is(.view-tile, .deck-tile-img, .info-img, #preview).foil::after {
  --foil-x: transparent 2.5%, #000 8%, #000 92%, transparent 97.5%;
  --foil-y: transparent 1.8%, #000 5.8%, #000 94.2%, transparent 98.2%;
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; mix-blend-mode: hard-light; opacity: .23;
  background: linear-gradient(135deg, #ff5f6d, #ffb347 8%, #fff176 16%, #6fe39a 25%, #5cc8ff 33%, #8f7bff 41%, #ff6fd8 46%, #ff5f6d 50%, #ffb347 58%, #fff176 66%, #6fe39a 75%, #5cc8ff 83%, #8f7bff 91%, #ff6fd8);
  -webkit-mask: linear-gradient(90deg, var(--foil-x)), linear-gradient(180deg, var(--foil-y));
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
.info-img.wide.foil::after {
  --foil-x: transparent 1.8%, #000 5.8%, #000 94.2%, transparent 98.2%;
  --foil-y: transparent 2.5%, #000 8%, #000 92%, transparent 97.5%;
}
:is(.view-tile, .deck-tile-img, .info-img, #preview).foil.foil-full::after { -webkit-mask: none; mask: none; }
@media (max-width: 1250px) {
  .deck-hero { grid-template-columns: 1fr; }
  .glance-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .hero-leaders img, .hero-empty { width: calc(50vw - 24px); }
  .hero-base img { width: 60vw; }
  .glance-grid { grid-template-columns: 1fr; }
  .deck-view.images .group-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Leader rankings */
.leader-art { position: relative; }
.rank {
  position: absolute; top: 8px; left: 8px; padding: 2px 9px; border-radius: 99px; font-weight: 800; font-size: .85rem;
  /* Grey, not near-black, so it stands out from the page as well as from the art (Cards tiles sit on the page itself). */
  background: #2d3441; color: #d5d9e1; border: 1px solid #424a59; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
/* On the leaders page the rank sits centred under the art. */
.rank-line { display: flex; justify-content: center; margin-top: -12px; position: relative; }
.rank-line .rank { position: static; padding: 3px 14px; font-size: .9rem; }
/* Top three: gold, silver and bronze medals. */
.rank.medal-1, .rank.medal-2, .rank.medal-3 { border: 0; color: #1a1206; box-shadow: 0 2px 10px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .5); }
.rank.medal-1 { background: linear-gradient(135deg, #fff1a8, #f5c542 45%, #c8901a); }
.rank.medal-2 { background: linear-gradient(135deg, #ffffff, #cfd6df 45%, #8e98a6); }
.rank.medal-3 { background: linear-gradient(135deg, #ffd2a8, #d4874a 45%, #8f4f22); }

/* ---------- card pages (shared look with the builder's card info panel) ---------- */
/* The card and its info sit together in the middle of the page, like the leader page. */
.card-hero { display: grid; grid-template-columns: minmax(0, clamp(300px, 22vw, 440px)) minmax(0, 760px); justify-content: center;
  gap: 32px; margin-bottom: 30px; align-items: start; }
.card-hero-art img { width: 100%; border-radius: 14px; display: block; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.info-sub { color: var(--muted); margin-top: 2px; }
.info-tags, .info-traits { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.info-tags .pip { width: 22px; height: 22px; }
.tag { font-size: .8rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); }
.trait { font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.trait + .trait::before { content: "·"; margin-right: 6px; }
.stats-row { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
/* Card and leader pages: the sets a card was printed in, newest first. */
.card-sets { margin: 4px 0 14px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.card-sets .filter-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.card-sets ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.card-sets li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.card-sets .set-code { flex: none; min-width: 52px; font-size: .8rem; font-weight: 800; color: var(--accent); }
.card-sets .set-name { font-weight: 600; }
.card-sets a.set-name { color: var(--text); }
.card-sets a.set-name:hover { color: var(--accent); }

/* Sets (/sets/) and a set's page (/sets/<name>/): the set as printed, not ranked. */
.set-list { display: grid; gap: 6px; max-width: 900px; margin-bottom: 32px; }
.set-row { display: grid; grid-template-columns: 60px 1fr auto; align-items: center; gap: 10px; padding: 10px 14px;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .12s, transform .12s; }
.set-row:is(:hover, :focus-visible) { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.set-row .set-code { font-size: .8rem; font-weight: 800; color: var(--accent); }
.set-row-main { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; min-width: 0; }
.set-row-name { font-weight: 700; }
.set-row-name .unreleased-tag { margin-left: 6px; vertical-align: 1px; }
.set-row-go { color: var(--accent); }
@media (max-width: 700px) {
  .set-row { grid-template-columns: 46px 1fr auto; }
  .set-row-main { flex-direction: column; align-items: flex-start; }
}
.set-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.set-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; }
.set-facts:empty { display: none; }
.set-facts > span:not(.unreleased-tag) + span::before { content: "·"; margin-right: 10px; opacity: .7; }
.set-facts + .set-facts::before { content: "·"; opacity: .7; }
.set-links { margin: 8px 0 16px; color: var(--muted); }
/* The cards are one page section (.page-section, as on card and leader pages): a panel of bands, each a type or, under
   the Newest reveals sort, a day of reveals. */
.set-cards { margin-top: 20px; }
.set-empty { margin: 0; }
.set-section .set-grid + .set-grid { margin-top: 16px; }
.set-meta { text-align: center; font-size: .85rem; color: var(--muted); margin-top: 2px; }
.reprint-tag { padding: 0 7px; border: 1px solid var(--line); border-radius: 99px; font-size: .8rem; font-weight: 600; color: var(--muted); }
/* Leaders and bases are landscape: their own grid of wider tiles, so they show full size instead of shrunk into a
   card-shaped tile. Follows the card size picker (wider tiles at L). */
.card-grid.browse.wide-cards { grid-template-columns: repeat(auto-fill, minmax(min(calc(var(--card-w) * 1.6), 100%), 1fr)); }
@media (max-width: 1000px) { .card-grid.browse.wide-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .card-grid.browse.wide-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  html[data-phone-size="L"] .card-grid.browse.wide-cards { grid-template-columns: 1fr; }
  /* Phones: the two summary lines stack instead of running together. */
  .set-summary { flex-direction: column; align-items: flex-start; gap: 6px; font-size: .9rem; }
  .set-facts + .set-facts::before { content: none; }
  .set-links { margin: 8px 0 14px; }
  .cost-chips { gap: 6px; }
  .cost-chips .chip { min-width: 0; padding-inline: 9px; }
}
.stat { display: grid; justify-items: center; min-width: 64px; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.stat b { font-size: 1.25rem; line-height: 1.1; }
.stat span { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ability { background: var(--panel-2); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; border-left: 3px solid var(--line); }
.ability-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.ability p { margin: 4px 0 0; white-space: pre-line; font-size: .93rem; }
.printings { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(calc(140px * var(--card-scale)), 1fr)); }
.printing { display: grid; gap: 2px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; text-align: left; }
.printing img { width: 100%; border-radius: 6px; display: block; margin-bottom: 4px; }
.printing-name { font-weight: 700; font-size: .85rem; }
.printing-meta { font-size: .8rem; color: var(--muted); }
.rulings { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 860px; }
.rulings li { background: var(--panel-2); border-radius: 10px; padding: 10px 14px; }
.rulings p { margin: 2px 0 0; font-size: .92rem; }
.ruling-date { font-size: .8rem; color: var(--muted); font-weight: 600; }
.source-note { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
a.stat-card { color: var(--text); }
/* Card thumbnails (Cards page, leader and card pages, trending cards): the same lift as deck tiles, with an orange
   outline. The one hover that's orange on purpose: picking a card out of a grid of them reads better with it. */
a.stat-card:is(:hover, :focus-visible) { text-decoration: none; }
a.stat-card img { transition: translate .12s, box-shadow .12s; }
a.stat-card:is(:hover, :focus-visible) img { translate: 0 -4px; box-shadow: 0 0 0 2px var(--accent), 0 12px 28px rgba(0, 0, 0, .5); }
.card-grid.browse img.wide { aspect-ratio: 7 / 5; }
/* The Cards page, the leader page's card sections and a card's Often Played With follow the Card size picker (M/L),
   like the deck and builder grids; phones keep three per row. */
.card-grid.browse, .card-grid.sized { grid-template-columns: var(--grid-template, repeat(auto-fill, minmax(min(var(--card-w), 100%), 1fr))); }
@media (max-width: 800px) { .card-grid.browse, .card-grid.sized { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card-line .nm a { color: inherit; }
.card-line .nm a:hover { color: var(--sun-1); text-decoration: none; }
@media (max-width: 800px) { .card-hero { grid-template-columns: 1fr; } .card-hero-art { max-width: 280px; } }

/* Dropdown menu built on <details> (deck page Export) */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-items {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 250px; padding: 6px; display: grid; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
}
.menu-items a { display: grid; padding: 7px 10px; border-radius: 7px; color: var(--text); }
.menu-items a:hover { background: var(--panel); text-decoration: none; }
.menu-items a span, .menu-items button span { font-size: .8rem; color: var(--muted); }
.menu-items button {
  display: grid; gap: 1px; padding: 7px 10px; border-radius: 7px; color: var(--text); background: none; border: 0;
  font: inherit; text-align: left; cursor: pointer; width: 100%;
}
.menu-items button:hover { background: var(--panel); }
.menu-items button.danger b { color: var(--bad); }
.menu-items button[hidden], .edit-actions > [hidden] { display: none; }
/* A main button that can't do its job yet (View deck, Publish, Playtest on a blank deck): greyed out with an orange
   edge. Its title and a click say why. */
.btn.primary.not-ready, .btn.primary.not-ready:is(:hover, :focus-visible, :active) {
  background: var(--panel-2); border-color: var(--accent); color: var(--muted); box-shadow: none; filter: none; cursor: help;
}
.menu-items hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.menu-items.align-right { left: auto; right: 0; }
.menu-items { max-width: calc(100vw - 16px); }  /* and base.html shifts one back on screen if it runs off an edge */

/* Breadcrumbs: top-left trail back to the list a page belongs to */
.breadcrumbs { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); margin: -8px 0 16px; min-width: 0; }
.breadcrumbs a { color: var(--muted); font-weight: 600; }
.breadcrumbs a:hover { color: var(--sun-1); text-decoration: none; }
.breadcrumbs [aria-current] { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Phones: just the way up, "‹ Decks" (the level above this page), since the page title right below already says
   where you are. A touch-sized target. */
@media (max-width: 700px) {
  .breadcrumbs > :not(a:last-of-type) { display: none; }
  .breadcrumbs a:last-of-type { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; color: var(--text); }
  .breadcrumbs a:last-of-type::before { content: "‹"; font-size: 1.4em; line-height: 1; color: var(--sun-1); margin-top: -2px; }
  .breadcrumbs { margin: -16px 0 8px; }
}

/* Large image viewer (card page printings and art) */
.zoomable { padding: 0; border: 0; background: none; cursor: zoom-in; display: block; width: 100%; }
button.printing { cursor: zoom-in; }
/* Printings (card and leader pages) open a larger view, so they hover like other "look closer" items: the tile's
   tile lifts with a lighter border and a shadow; the picture stays put inside it. Neutral, as it isn't an action. */
.printing { transition: border-color .12s, translate .15s, box-shadow .15s; }
button.printing:is(:hover, :focus-visible), .printing:has(.zoomable:is(:hover, :focus-visible)) {
  border-color: rgba(255, 255, 255, .35); translate: 0 -3px; box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
}
/* Leader printings: landscape leader side, so fewer per row; the deployed side opens from a link under it. */
.leader-printings { grid-template-columns: repeat(auto-fill, minmax(calc(200px * var(--card-scale)), 1fr)); }
.leader-printings .printing { align-content: start; }
@media (max-width: 520px) { .leader-printings { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent;
  display: none; align-items: center; justify-content: center; gap: 16px;
}
.lightbox[open] { display: flex; }
.lightbox::backdrop { background: rgba(0, 0, 0, .85); }
.lightbox figure { margin: 0; display: grid; gap: 10px; justify-items: center; pointer-events: none; }
.lightbox img { max-height: 82vh; max-width: min(90vw, 640px); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .7); }
.lightbox figcaption { color: var(--text); font-weight: 600; text-align: center; }
.lightbox button {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font-size: 1.8rem; line-height: 1; cursor: pointer;
}
.lightbox button:hover { border-color: var(--accent); }
.lightbox .lb-close { position: fixed; top: 20px; right: 20px; }
.lightbox.single .lb-prev, .lightbox.single .lb-next { visibility: hidden; }

/* Card page: top 6 leaders / pairings in one row on desktop */
.top-grid { display: grid; gap: 16px; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 12px; }
.pair-art { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border-radius: 10px; overflow: hidden; background: #000; }
.pair-art img { width: 100%; aspect-ratio: 7 / 5; object-fit: fill; display: block; }
@media (max-width: 1300px) { .top-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .top-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Card page: leaders 5 per row like the Leaders page; pairs 3 per row so each leader is about single-tile size. */
.top-grid.top-leaders { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.top-grid.top-pairs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.pair-name span { display: block; }
@media (max-width: 1100px) { .top-grid.top-leaders { grid-template-columns: repeat(3, minmax(0, 1fr)); } .top-grid.top-pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .top-grid.top-leaders { grid-template-columns: repeat(2, minmax(0, 1fr)); } .top-grid.top-pairs { grid-template-columns: 1fr; } }

/* Epic Action / deploy ability: tagged so it stands apart from the card's other text */
.ability.epic { border-left-color: var(--accent); background: rgba(255, 154, 61, .07); }
.epic-tag {
  display: inline-block; font-size: .8rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 99px; background: linear-gradient(135deg, var(--sun-1), var(--sun-2)); color: #1a0f05;
}

/* ---------- error pages ---------- */
.error-page { max-width: 560px; margin: 60px auto; text-align: center; }
.error-page h1 { margin: 6px 0 8px; }
.error-code {
  font-size: 4.5rem; font-weight: 800; line-height: 1; letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--sun-1), var(--sun-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-links { justify-content: center; margin-top: 20px; }

/* ---------- phone menu ---------- */
.topbar-links { display: contents; }
.menu-toggle { display: none; }
@media (max-width: 700px) {
  .brand-text { display: inline-flex; }
  .menu-toggle {
    display: grid; place-items: center; margin-left: auto; width: 40px; height: 40px; padding: 0;
    background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  }
  /* Three-line icon that turns into an × when open. */
  .menu-toggle span, .menu-toggle span::before, .menu-toggle span::after {
    display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; position: relative; transition: transform .15s, background .15s;
  }
  .menu-toggle span::before, .menu-toggle span::after { content: ""; position: absolute; left: 0; }
  .menu-toggle span::before { top: -6px; }
  .menu-toggle span::after { top: 6px; }
  .topbar.open .menu-toggle span { background: transparent; }
  .topbar.open .menu-toggle span::before { transform: translateY(6px) rotate(45deg); }
  .topbar.open .menu-toggle span::after { transform: translateY(-6px) rotate(-45deg); }

  /* The menu glides down from under the header: it stays laid out and is clipped away when closed, so it can
     animate both ways. visibility waits for the slide to finish on close, so hidden links can't be tabbed to. */
  .topbar-links {
    display: flex; position: absolute; top: 56px; left: 0; right: 0; flex-direction: column;
    background: #0a0c10; border-bottom: 1px solid var(--line); padding: 6px 16px 14px; box-shadow: 0 12px 24px rgba(0, 0, 0, .4);
    visibility: hidden; opacity: 0; transform: translateY(-10px); clip-path: inset(0 0 100% 0);
    transition: clip-path .28s cubic-bezier(.2, .8, .2, 1), transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s, visibility 0s linear .28s;
  }
  .topbar.open .topbar-links {
    visibility: visible; opacity: 1; transform: none; clip-path: inset(0 0 -40px 0);
    transition: clip-path .28s cubic-bezier(.2, .8, .2, 1), transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s, visibility 0s;
  }
  .topbar-links .nav, .topbar-links .account { flex-direction: column; align-items: stretch; gap: 0; }
  .topbar-links .account { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
  .topbar-links .nav a, .topbar-links .account a, .topbar-links .account button {
    display: block; padding: 12px 4px; font-size: 1rem; text-align: left; width: 100%;
  }
  .topbar-links .nav a.active, .topbar-links .account a.active { color: var(--accent); text-decoration: none; }
  .topbar-links .account .btn { display: flex; justify-content: center; margin-top: 8px; }
  /* In the phone menu the account menu opens in place, under your username, and starts open. */
  .topbar-links .account-menu summary { padding: 12px 4px; font-size: 1rem; text-decoration: none; justify-content: space-between; }
  .topbar-links .account-menu .menu-items { position: static; min-width: 0; padding: 0 0 0 12px; background: none; border: 0; box-shadow: none; animation: none; }
  .topbar-links .account-menu .menu-items a, .topbar-links .account-menu .menu-items button { padding: 10px 4px; }
  .topbar-links .account-menu .menu-items hr { margin: 4px 0; }
}
@media (max-width: 700px) and (prefers-reduced-motion: reduce) {
  .topbar-links, .topbar.open .topbar-links { transition: none; }
}

/* ---------- site dialogs (static/js/dialog.js) ---------- */
.site-dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px;
  width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.site-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.site-dialog form { display: grid; gap: 12px; margin: 0; }
.site-dialog h2 { margin: 0; font-size: 1.15rem; }
.site-dialog .sd-message { margin: 0; color: #cfd5df; line-height: 1.5; }
.site-dialog .sd-field { display: grid; gap: 6px; }
.site-dialog .sd-field[hidden], .site-dialog .sd-message[hidden], .site-dialog :is(.sd-alt, .sd-alt2)[hidden], .site-dialog .sd-html[hidden] { display: none; }
.site-dialog.wide { width: min(780px, calc(100vw - 32px)); }
.site-dialog .sd-html { max-height: 50vh; overflow: auto; }
/* The Discard window's preview: one history entry, without the page's top margin. */
.draft-preview { margin: 0; max-width: none; }
.draft-preview .history-changes { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.site-dialog .sd-choices { display: grid; gap: 6px; }
.site-dialog .sd-choices[hidden] { display: none; }
.site-dialog .sd-choice {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.site-dialog .sd-choice:has(input:checked) { border-color: var(--accent); background: var(--panel-2); }
.site-dialog .sd-choice input { margin-top: 3px; accent-color: var(--accent); }
.site-dialog .sd-choice span { display: grid; gap: 1px; }
.site-dialog .sd-choice small { color: var(--muted); font-size: .8rem; }
.site-dialog .sd-error { margin: -4px 0 0; color: var(--bad); font-size: .85rem; min-height: 0; }
.site-dialog .sd-error:empty { display: none; }
.site-dialog .sd-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
/* A third choice (alt2), in a dialog wide enough for four buttons: Cancel stands apart at the far left, then the
   destructive choice, the second one, and the main one. On phones they stack full width: the main choice first,
   Cancel last. */
.site-dialog.has-alt2:not(.wide) { width: min(540px, calc(100vw - 32px)); }
.site-dialog.has-alt2 .sd-cancel { order: -1; margin-right: auto; }
@media (max-width: 560px) {
  .site-dialog.has-alt2 .sd-actions { flex-direction: column; }
  .site-dialog.has-alt2 .sd-actions .btn { margin: 0; justify-content: center; text-align: center; }
  .site-dialog.has-alt2 .sd-alt { order: 1; }
  .site-dialog.has-alt2 .sd-alt2 { order: 2; }
  .site-dialog.has-alt2 .sd-cancel { order: 3; }
}
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #1a0606; }

/* ---------- filter panels: always open on desktop, collapsed behind "Filters (n)" on phones ---------- */
.filter-panel > summary { display: none; list-style: none; }
/* Live filters (filters.js): the old results dim while the new ones load. */
/* No fade: results swap straight in. Only a slow answer dims them, so you can tell it's working. */
[data-live-results].is-loading { opacity: .45; transition: opacity 0s .3s; }
.filter-panel > summary::-webkit-details-marker { display: none; }
@media (max-width: 700px) {
  .filter-panel > summary { display: inline-flex; margin-bottom: 12px; }
  .filter-panel[open] > summary { margin-bottom: 10px; }
  .filter-panel > summary.has-active { border-color: var(--accent); color: var(--text); }
  /* Open, the button reads "Hide filters" with its caret flipped and looks pressed, so tapping it again clearly closes. */
  .filter-panel[open] > summary { background: var(--panel); border-color: #3d4554; }
  .filter-panel > form { overflow: hidden; }  /* for the open/close slide (filters.js) */
}
/* "Show N cards" at the foot of an open panel: phones only. The one orange button while the filters are open. */
.filter-show { display: none; }
@media (max-width: 700px) {
  .filter-show { display: flex; justify-content: center; width: 100%; margin-top: 4px; }
}
.filter-panel > summary .caret { width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; margin-top: 4px; transition: transform .15s; }
.filter-panel[open] > summary .caret { transform: rotate(180deg) translateY(4px); }

/* ---------- phones: touch-sized controls ---------- */
/* Chips, small buttons and toggles at least 44px tall (Apple's guideline), with a little more room between chips. */
@media (max-width: 700px) {
  .chip { min-height: 44px; padding-block: 8px; padding-inline: 14px; }
  .leader-chip { padding-block: 4px; padding-left: 8px; }
  .leader-chip img { width: 48px; }
  .tag-menu .chip { display: inline-flex; align-items: center; }
  .chips { gap: 8px; }
  .btn.sm { min-height: 44px; padding-inline: 16px; }
  .view-toggle a { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding-inline: 18px; }
}

/* Phones: moving between pages (or applying a filter) cross-fades instead of flashing; the top bar and an open filter
   panel stay put while the rest changes. Browsers without view transitions just load the page as before. */
@media (max-width: 700px) and (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .topbar { view-transition-name: topbar; }
  .filter-panel[open] { view-transition-name: filter-panel; }
}
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }

/* ---------- toasts (static/js/toast.js) ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px 11px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-size: .9rem; line-height: 1.4; animation: toast-in .18s ease-out;
  transition: opacity .2s, transform .2s;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--bad); }
.toast span { flex: 1; white-space: pre-line; }  /* a message of several lines (\n) keeps them */
.toast button { background: none; border: 0; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast button:hover { color: var(--text); }
.toast .toast-action { font-size: .85rem; font-weight: 600; color: var(--accent); padding: 2px 6px; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 700px) { .toasts { right: 16px; left: 16px; bottom: 16px; width: auto; } }

/* Deck lists: count and "Load more" under the tiles/rows */
.load-more { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 24px; }

/* ---------- image placeholders ----------
   Card art comes from swu-db and can take a moment: show a soft card-coloured panel in its place (the images are
   opaque, so they cover it once loaded). Every one of these reserves its size, so nothing jumps when art arrives. */
.deck-art img, .stat-card img, .leader-card img, .leader-sides img, .hero-leaders img, .hero-base img,
.card-hero-art img, .printing img, .pair-art img, .leader-art img, .result img, .deck-tile-img img, .sug-tile img,
.slot img, .info-img img {
  background: linear-gradient(135deg, #1d222b, #14171d 60%, #1a1e26);
}
/* Whole cards use object-fit: fill, not cover, here and in builder.css and playtest.css. The card images are never
   exactly 5:7 (716×1000, 886×1268, 1117×1560…), so cover scales each one to a fraction of a pixel and crops a sliver,
   and Chrome's GPU drawing (graphics acceleration) then shows the card text blurry and broken up. fill stretches the
   image by at most about 2%, which doesn't show. Only crops on purpose (a leader's face, a folder thumbnail) keep cover. */
.card-hero-art img { aspect-ratio: 5 / 7; object-fit: fill; }
/* Card page printings only (the builder's info panel has its own sizes). */
section.section .printing img { aspect-ratio: 5 / 7; object-fit: fill; }
.card-hero-art img.wide, section.section .printing img.wide { aspect-ratio: 7 / 5; }

/* Show/Hide toggle inside password fields (static/js/password.js) */
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 64px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 3px 8px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer;
}
.password-toggle:hover { color: var(--text); }

/* ---------- deck history ---------- */
.history { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 12px; max-width: 900px; }
.history-entry { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.history-head { display: flex; align-items: center; gap: 10px; }
.history-head form { margin: 0; }
.history-when { font-weight: 700; }
.history-note { margin: 8px 0 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: rgba(255, 154, 61, .06); border-radius: 4px; }
.history-changes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 18px; margin-top: 10px; }
.change { font-size: .9rem; padding: 2px 0; }
.change a { color: var(--text); }
.change b { display: inline-block; min-width: 26px; }
.change.in b { color: var(--ok); }
.change.out b { color: var(--bad); }
.change.move b { color: var(--sun-1); }
.history-filter { margin: 14px 0 0; gap: 8px; align-items: center; }
.history-section { margin-top: 12px; }
.history-section h3 { margin: 0 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.history-section .history-changes { margin-top: 0; }
/* Blocks: In (green), Out (red), Moved to not counted (amber), with a coloured edge so they read apart. */
.history-section { border-left: 3px solid var(--line); padding-left: 10px; }
.history-section[data-kind="in"] { border-color: var(--ok); }
.history-section[data-kind="in"] h3 { color: var(--ok); }
.history-section[data-kind="out"] { border-color: var(--bad); }
.history-section[data-kind="out"] h3 { color: var(--bad); }
.history-section[data-kind="aside"] { border-color: var(--sun-1); }
.history-section[data-kind="aside"] h3 { color: var(--sun-1); }
.change { display: block; color: var(--text); }
.change:hover { text-decoration: none; }
.change:hover .change-name { color: var(--sun-1); }
.change.aside b { color: var(--sun-1); }
.change-where { color: var(--muted); font-size: .8rem; }
.change-art { display: none; }
/* Images view: card tiles with the change on a badge and where it went underneath. */
.history.images .history-changes { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.history.images .change { position: relative; padding: 0; font-size: .8rem; }
.history.images .change-art { display: block; width: 100%; aspect-ratio: 5 / 7; object-fit: fill; border-radius: 7px; background: #000; }
.history.images .change-art.wide { aspect-ratio: 7 / 5; }
.history.images .change b { position: absolute; top: 5px; left: 5px; min-width: 0; padding: 1px 7px; border-radius: 99px;
  background: rgba(0, 0, 0, .85); font-size: .8rem; }
.history.images .change-name { display: none; }
.history.images .change-where { display: block; margin-top: 3px; line-height: 1.25; }
.history.images .change.out .change-art { opacity: .55; filter: grayscale(.6); }
.detail-change { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; font-size: .9rem; padding: 3px 0; }
.detail-label { min-width: 90px; font-weight: 700; }
.detail-change .was { color: var(--muted); text-decoration: line-through; }
.detail-change details { flex: 1; min-width: 240px; }
.detail-change summary { cursor: pointer; color: var(--sun-1); }
.text-diff { margin-top: 6px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  font-size: .84rem; white-space: pre-wrap; max-height: 320px; overflow: auto; }
.text-diff .in b { color: var(--ok); }
.text-diff .out { color: var(--muted); }
.text-diff .out b { color: var(--bad); }
.change-chip { font-size: .8rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); }
.change-chip.in { color: var(--ok); }
.change-chip.out { color: var(--bad); }

/* ---------- top-bar search (static/js/site-search.js) ---------- */
.site-search { position: relative; width: min(340px, 28vw); margin-right: 8px; }
.site-search input { padding: 6px 30px 6px 10px; font-size: .88rem; background: var(--panel); }
/* The "/" shortcut as a key badge (like the home search), not text in the placeholder; it steps aside once you type. */
.site-search kbd { position: absolute; right: 8px; top: 50%; translate: 0 -50%; font: 600 .8rem var(--font); color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; pointer-events: none; }
.site-search input:is(:focus, :not(:placeholder-shown)) ~ kbd, .touch-ui .site-search kbd { display: none; }
.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: max(100%, 420px); max-height: 70vh; overflow-y: auto; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, .6);
}
.search-results[hidden] { display: none; }
.search-hit { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; color: var(--text); }
.search-hit:hover, .search-hit.on { background: var(--panel); text-decoration: none; }
.search-hit.on { outline: 1px solid var(--accent); }
.hit-art { width: 40px; aspect-ratio: 5 / 7; border-radius: 4px; overflow: hidden; background: #14171d; justify-self: center; }
.hit-art.wide { width: 56px; aspect-ratio: 7 / 5; }
.hit-art img { width: 100%; height: 100%; object-fit: fill; display: block; }
/* People have no picture: a round initial instead. */
.hit-art:has(.hit-initial) { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; }
.hit-initial { font-weight: 700; color: var(--muted); }
.hit-text { display: grid; min-width: 0; }
.hit-text b, .hit-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit-text span { font-size: .8rem; color: var(--muted); }
.hit-kind { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.search-empty { padding: 10px; color: var(--muted); font-size: .88rem; }
@media (max-width: 1000px) { .site-search { width: 200px; } }
/* Phones: the search box is the first thing in the menu panel. */
@media (max-width: 700px) {
  .topbar-links .site-search { order: -1; width: auto; margin: 8px 0 6px; }
  .search-results { width: 100%; left: 0; }
}

/* Type-to-search leader picker (static/js/leader-picker.js); its list reuses the top-bar search styles. */
.leader-picker { position: relative; flex: 1 1 220px; }
/* Search suggestions in the Leaders, Cards and deck list filter bars (filter-suggest.js). */
.filter-suggest { position: relative; flex: 1 1 220px; }
.filter-suggest input { width: 100%; }
.filter-suggest .search-results { left: 0; right: auto; width: max(100%, 360px); max-height: 420px; }
.filter-suggest .search-hit { grid-template-columns: 56px minmax(0, 1fr); }
.leader-picker .search-results { left: 0; right: auto; width: max(100%, 360px); max-height: 420px; }
.leader-picker .search-hit { grid-template-columns: 56px minmax(0, 1fr); }
.leader-picker .search-hit.clear { display: block; color: var(--muted); }

/* ---------- card-type icons on decklist sections (deck page and builder) ---------- */
/* How many of each card type a Cost group holds (builder and deck page). */
.type-counts { display: inline-flex; gap: 10px; margin-left: 12px; font-size: .8rem; font-weight: 600; color: var(--muted);
  text-transform: none; letter-spacing: 0; vertical-align: 1px; }
.type-counts > span { display: inline-flex; align-items: center; }
.type-counts .type-icon { width: 12px; height: 12px; margin-right: 3px; vertical-align: 0; }
.type-icon { display: inline-block; width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; flex: none;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; background: var(--muted); }
.type-icon.t-ground { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M2%2021%209%208l4%206%203-4%206%2011z%27/%3E%3C/svg%3E"); background: #c49a6c; }
.type-icon.t-space { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M12%202l5%2013-5-2-5%202zM10%2016h4l-2%206z%27/%3E%3C/svg%3E"); background: #5aa9e6; }
.type-icon.t-event { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M13%202%204%2014h7l-1%208%2010-13h-7z%27/%3E%3C/svg%3E"); background: #e2b93b; }
.type-icon.t-upgrade { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M12%203l8%208h-5v10H9V11H4z%27/%3E%3C/svg%3E"); background: #9b8cff; }

/* Aspect accent: a thin stripe in the deck's aspect colours across the top of its art, so lists scan by colour.
   Segments sit 2px apart on a dark ground, so white (Heroism) and black (Villainy) stay distinct.
   Villainy is black with a light inner outline so it still shows on dark art and the dark page. */
.deck-art { position: relative; }

/* Deck tags (Aggro, Budget, ...): small neutral chips on tiles, list rows and the deck page. */
.deck-tags-line { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.deck-tag { font-size: .8rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.hero-info .deck-tags-line { margin: 8px 0; }
.hero-info .deck-tag { font-size: .8rem; padding: 2px 10px; }

/* ---------- accounts: settings, profile, sign-in buttons ---------- */
/* One column of grouped rows. A row's button sits top right; opening it drops the form in below the row's text. */
.settings-page { max-width: 760px; margin: 0 auto; }
.settings-group { margin-top: 26px; padding: 20px; }
.settings-group h2 { margin: 0 0 14px; font-size: 1.05rem; }
.danger-zone { border-color: rgba(255, 107, 107, .35); }
.danger-zone h2 { color: var(--bad); }
.set-row { position: relative; padding: 16px 18px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.set-row + .set-row { margin-top: 10px; }
.danger-zone .set-row { border-color: rgba(255, 107, 107, .25); }
.set-info h3, .set-info h3 + p { padding-right: 104px; }  /* clear of the button; lines below it can run full width */
.set-info h3 { margin: 0 0 6px; font-size: .95rem; }
.set-info p { margin: 0 0 10px; line-height: 1.5; overflow-wrap: anywhere; }
.set-info p:last-child { margin-bottom: 0; }
.set-info form { margin: 0 0 12px; }
.set-row > details > summary, .set-row > .set-action { position: absolute; top: 14px; right: 14px; }
@media (max-width: 700px) { .settings-group { padding: 16px 14px; } .set-row { padding: 14px; } }
.set-row > details > summary { list-style: none; }
.set-row > details > summary::-webkit-details-marker { display: none; }
.set-row > details .if-open, .set-row > details[open] .if-closed { display: none; }
.set-row > details[open] .if-open { display: inline; }
.set-row > details > form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.set-row > details > form > * { max-width: 420px; }
.set-row > details > form p { margin: 0 0 14px; line-height: 1.5; }
.set-row > details > form input:not([type="checkbox"]) { width: 100%; }
.set-row .helptext, .set-row form ul { font-size: .8rem; color: var(--muted); }
.social-mark { font-weight: 700; }
.social-mark.discord { color: #8b95ff; }
.social-mark.google { color: #8ab4f8; }
.social-buttons { display: grid; gap: 8px; margin-bottom: 4px; }
.social-btn { justify-content: center; font-weight: 600; }
.social-btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.social-btn.google { background: #fff; border-color: #dadce0; color: #1f1f1f; }
.or-line { display: flex; align-items: center; gap: 10px; margin: 10px 0 12px; }
.or-line::before, .or-line::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.profile-head { gap: 14px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; font-weight: 800;
  color: #1a0f05; background: linear-gradient(135deg, var(--sun-1), var(--sun-2)); flex: none; }

/* ---------- My decks folders (static/js/folders.js) ---------- */
.folder-icon {
  display: inline-block; width: 16px; height: 16px; vertical-align: -2px; margin-right: 6px; background: var(--sun-1);
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
  --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M2%206a2%202%200%200%201%202-2h5l2%202h9a2%202%200%200%201%202%202v10a2%202%200%200%201-2%202H4a2%202%200%200%201-2-2z%27/%3E%3C/svg%3E");
}
.folder-icon.lg { width: 26px; height: 26px; vertical-align: -4px; margin-right: 10px; }
.folder-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-bottom: 22px; }
.folder-tile {
  display: flex; align-items: center; gap: 4px; padding: 10px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); transition: transform .12s, border-color .12s, background .12s, box-shadow .12s;
}
.folder-tile:hover { transform: translateY(-4px); border-color: rgba(255, 255, 255, .4); box-shadow: 0 12px 28px rgba(0, 0, 0, .5); }
.folder-tile:has(.folder-more[open]) { transform: none; z-index: 5; }
.folder-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: inherit; }
.folder-link:hover { text-decoration: none; }
.folder-more-btn {
  list-style: none; padding: 2px 8px; border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1;
  border: 1px solid transparent;
}
.folder-more-btn::-webkit-details-marker { display: none; }
.folder-more-btn:hover, .folder-more[open] .folder-more-btn { color: var(--text); border-color: var(--line); }
.folder-tile.off-profile .folder-thumb { opacity: .55; }
.folder-up { border-style: dashed; background: none; }
.folder-up .up-arrow { font-size: 1.6rem; line-height: 1; color: var(--sun-1); }
.off-profile-badge { justify-self: start; border-style: dashed; }
.menu-items button:disabled { cursor: default; opacity: .6; }
.menu-items button:disabled:hover { background: none; }
.profile-folder { display: flex; align-items: center; margin: 0 0 14px; }
.folder-thumb {
  flex: none; display: grid; grid-auto-flow: column; gap: 2px; place-items: center; width: 92px; height: 52px;
  border-radius: 7px; overflow: hidden; background: var(--panel-2);
}
.folder-thumb img { width: 45px; height: 52px; object-fit: cover; display: block; }
.folder-thumb img:only-child { width: 92px; }
.folder-thumb .folder-icon { margin: 0; }
.folder-text { display: grid; gap: 2px; min-width: 0; }
.folder-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-scope { margin: -10px 0 16px; }
.deck-folder { margin: 2px 0; }
.deck-folder .folder-icon { width: 13px; height: 13px; margin-right: 4px; }
/* Drag and drop: drop targets light up while something is being dragged. */
.drag-active .folder-tile, .drag-active .breadcrumbs [data-drop-folder] { outline: 1px dashed #48505f; outline-offset: 2px; }
.drop-over, .drag-active .drop-over { background: var(--panel-2); border-color: var(--accent); outline: 2px solid var(--accent) !important; }
.dragging { opacity: .45; }
/* Select mode: clicks pick decks; the bar at the bottom moves them. */
.btn.on { border-color: var(--accent); }
.selecting [data-deck] { position: relative; cursor: pointer; user-select: none; }
.selecting .deck-tile[data-deck]::after {
  content: ""; position: absolute; top: 10px; left: 10px; width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid #fff; background: rgba(0, 0, 0, .55); box-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}
.selecting .deck-tile[data-deck] { transform: none; }
.selecting [data-deck].selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.selecting .deck-tile.selected::after {
  background: var(--accent) url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M5%2012l5%205L19%207%27%20fill%3D%27none%27%20stroke%3D%27%231a0f05%27%20stroke-width%3D%273%27/%3E%3C/svg%3E") center / 16px no-repeat;
  border-color: var(--accent);
}
.selecting .deck-table tr.selected { background: var(--panel-2); }
.select-bar {
  position: sticky; bottom: 16px; z-index: 30; display: flex; align-items: center; gap: 10px; margin-top: 20px;
  padding: 10px 14px; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
}
.select-bar[hidden] { display: none; }
/* Select all is a light text action beside the count, not a third button competing with Move to… and Done. */
.select-bar [data-select-all] { background: none; border-color: transparent; color: var(--accent); padding-inline: 6px; }
.select-bar [data-select-all]:hover { border-color: transparent; text-decoration: underline; }
/* Phones: the count and Select all on one line, then Move to… and Done as two wide buttons, so nothing runs off. */
@media (max-width: 700px) {
  .select-bar { flex-wrap: wrap; row-gap: 0; bottom: 10px; }
  .select-bar > .spacer { flex-basis: 100%; height: 0; }
  .select-bar > [data-move-selected], .select-bar > [data-select-cancel] { flex: 1; margin-top: 8px; }
  .select-bar > [data-select-all] { margin-left: auto; }
}
/* The folder menu sits mid-row on phones: open it leftward so it stays on screen. */
@media (max-width: 700px) { .folder-menu .menu-items { left: auto; right: 0; } }
.folder-picker .folder-options { display: grid; gap: 2px; max-height: min(60vh, 420px); overflow-y: auto; margin: 0 -8px; }
.folder-option {
  display: flex; align-items: center; padding: 8px 12px; border: 0; border-radius: 7px; background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.folder-option:hover:not(:disabled), .folder-option:focus-visible { background: var(--panel-2); }
.folder-option:disabled { color: var(--muted); cursor: default; }

/* Card image size picker (static/js/card-size.js): one tile width per size for every card grid. */
/* A card grid's column count (card-size.js fitCardGrids), set on the grid itself; nested grids don't inherit it. */
@property --grid-template { syntax: "*"; inherits: false; }
:root { --card-base: 160px; --card-scale: 1; --card-w: calc(var(--card-base) * var(--card-scale)); }
/* On <html> (site-wide) or on one grid with its own size (data-card-size-scope, e.g. the builder's card search). */
[data-card-size] { --card-w: calc(var(--card-base) * var(--card-scale)); }
[data-card-size="M"] { --card-base: 160px; }
[data-card-size="L"] { --card-base: 195px; }
/* Big screens show bigger cards, not only more of them. */
@media (min-width: 1900px) { :root { --card-scale: 1.15; } }
@media (min-width: 2400px) { :root { --card-scale: 1.3; } }
.card-size[hidden] { display: none; }
.card-size { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.card-size .view-toggle a { min-width: 30px; display: inline-flex; align-items: center; justify-content: center; }
.card-size .view-toggle svg { display: block; }
/* Phones: the site-wide picker hides; the Cards and Leaders pages show a phone picker of their own (its own setting, on
   <html data-phone-size>), choosing 3 or 2 cards a row on Cards and a leader page, 2 or 1 leaders a row on Leaders. */
@media (max-width: 700px) {
  .card-size { display: none; }
  .card-size.phone-size:not([hidden]) { display: inline-flex; }
  html[data-phone-size="L"] .card-grid.browse:not(.home-cards) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html[data-phone-size="L"] .leader-grid { grid-template-columns: 1fr; }
  html[data-phone-size="L"] [data-leader-part="cards"] .card-grid.sized { grid-template-columns: repeat(2, minmax(0, 1fr)); }  /* leader page */
  /* Decks: leaders stacked, only on pages with a Leaders picker. Elsewhere (a leader page's Decks) they stay side by side. */
  html[data-phone-size="L"]:has([data-card-size-picker="phone"][data-label="Leaders"]) .deck-tile .art-leaders { grid-template-columns: 1fr; }
}
@media (min-width: 701px) { .card-size.phone-size { display: none; } }
/* A control on the right end of the Filters button's line on phones, such as the phone size picker. Place it just
   before the filter panel: a zero-height strip that overlays the button's line, so filters.js can relabel the button
   and swap the form without touching it. */
.filter-line-end { display: flex; justify-content: flex-end; align-items: flex-start; height: 0; position: relative; z-index: 1; }
/* Phones: the filter panel's search box sits outside it, above the Filters button (partials/filter_search.html), with
   room for a button beside it (My decks' New deck). The panel's own box then hides, so there's only one. */
.filter-find { display: none; }
@media (max-width: 700px) {
  .filter-find { display: flex; gap: 10px; margin-bottom: 12px; }
  .filter-find > .btn { flex: none; }
  .filter-find-box .search-results { width: calc(100vw - 32px); }
  .filter-find ~ .filter-panel .filter-suggest { display: none; }
}

/* My decks (decks/mine.html). Desktop: Select, New folder, Folder ▾ and New deck beside the title. Phones: the title
   on a line of its own; then the search box with New deck; then Filters, the ··· menu holding the rest, and the
   Leaders picker at the right. */
.mine-head { margin-bottom: 16px; }
.mine-head h1 { margin: 0; }
.mine-more { display: none; }
@media (max-width: 700px) {
  .mine-head { margin-bottom: 12px; }
  /* A long folder name wraps to a second line, then ends in "…". */
  .mine-head h1 { min-width: 0; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.15; }
  .mine-head h1 .folder-icon.lg { width: 22px; height: 22px; margin-right: 8px; }
  .mine-head h1:has(.folder-icon) { font-size: 1.6rem; }
  .mine-head > .spacer { display: none; }
  /* ··· sits just after the Filters button, whatever its label ("Filters (2)", "Hide filters"): folders.js sets
     --filters-w to the button's width. Its menu opens to the right, from under it. */
  .mine-more { display: block; flex: none; margin-left: calc(var(--filters-w, 84px) + 10px); }
  .mine-more > summary { min-width: 44px; min-height: 44px; justify-content: center; font-size: 1.2rem; }
  .mine-more .menu-items { left: 0; right: auto; }
  .mine-size > .phone-size { margin-left: auto; }
  /* Folders: two to a row, short, with a small folder icon instead of art, so the decks start higher up. Names wrap
     to three lines before "…". The breadcrumb already goes back up a level, and there's no dragging on a phone, so
     the "Back to …" tile hides. */
  .folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .folder-tile { padding: 6px 0 6px 10px; gap: 0; }
  .folder-tile.folder-up { display: none; }
  .folder-link { gap: 8px; align-items: flex-start; }
  .folder-thumb { width: auto; height: auto; background: none; }
  .folder-thumb img { display: none; }
  .folder-thumb { margin-top: 1px; }
  .folder-thumb::before { content: ""; width: 16px; height: 16px; background: var(--sun-1); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
    --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M2%206a2%202%200%200%201%202-2h5l2%202h9a2%202%200%200%201%202%202v10a2%202%200%200%201-2%202H4a2%202%200%200%201-2-2z%27/%3E%3C/svg%3E"); }
  .folder-thumb .folder-icon { display: none; }
  .folder-text { gap: 0; }
  .folder-text b { font-size: .9rem; white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-height: 1.25; }
  .folder-text .small { font-size: .75rem; }
  .folder-text .off-profile-badge { font-size: .7rem; }
  .folder-tile > .folder-more { align-self: stretch; display: flex; }
  .folder-more-btn { display: flex; align-items: center; padding: 0 10px; min-width: 36px; justify-content: center; }
  /* Add deck: New deck is right above, so a slim row rather than a whole tile. */
  .add-deck-tile { min-height: 0; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 12px 16px; }
  .add-deck-tile .add-label { white-space: nowrap; }
  .add-deck-tile .muted { min-width: 0; }
  .add-deck-tile .add-plus { font-size: 1.5rem; }
  .add-deck-tile .add-label { font-size: 1rem; }
}
/* Press and hold a deck to start selecting: no iOS link preview or text selection getting in the way. */
[data-deck] { -webkit-touch-callout: none; }
.page-head { align-items: baseline; margin-bottom: .5em; }
.page-head h1 { margin: 0; }

/* Pick list (decks/pick.html): tick cards off while pulling them from a collection. */
.pick-head { gap: 14px; margin-bottom: 6px; }
.pick-progress { color: var(--muted); }
.pick-progress b { color: var(--text); font-size: 1.2rem; }
.pick-bar { margin: 12px 0 18px; }
/* Sections use the deck page's headers (.deck-group: a filled bar, collapsible); the count turns green when done. */
.pick-group.done h3 > .muted { color: var(--ok); }
.pick-group.done h3 > .muted::after { content: " ✓"; }
.pick-list.hide-picked .pick-group.done { display: none; }  /* nothing left to pick there */
.pick-group h3 { display: flex; align-items: center; gap: 6px; }
.pick-group h3 .pick-all { margin-left: auto; font-weight: 600; }
/* List: each section spans the page (as on the deck page) with its cards in columns inside it. */
.pick-list.list .pick-lines { columns: 2 380px; column-gap: 32px; }
.pick-line { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 6px; cursor: pointer; break-inside: avoid; }
.pick-line:hover { background: var(--panel-2); }
.pick-line input { width: 18px; height: 18px; flex: none; accent-color: var(--ok); cursor: pointer; }
.pick-qty { color: var(--muted); min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.pick-name { flex: 1; min-width: 0; }
.pick-printing { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.pick-line.picked .pick-name, .pick-line.picked .pick-qty { text-decoration: line-through; color: var(--muted); }
.pick-list.hide-picked .pick-line.picked { display: none; }  /* beats the Images view's display: grid */
/* Images: just the cards, like the deck page's tiles (rounded and clipped, so no white corners); the checkbox sits on the
   card. Picked cards dim, with a green line just inside the edge. */
.pick-list.images .pick-lines { display: grid; gap: 10px; align-items: start;
  grid-template-columns: var(--grid-template, repeat(auto-fill, minmax(min(var(--card-w), 100%), 1fr))); }
.pick-tile { position: relative; isolation: isolate; display: block; padding: 0; aspect-ratio: 5 / 7; border-radius: 5% / 3.6%;
  overflow: hidden; transition: transform .12s, box-shadow .12s; }
.pick-tile.wide { aspect-ratio: 7 / 5; border-radius: 3.6% / 5%; }
.pick-tile:hover { background: none; transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, .5); }
.pick-tile::before { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .12s; }
.pick-tile:hover::before { box-shadow: inset 0 0 0 2px var(--accent); }
.pick-tile.picked::before { box-shadow: inset 0 0 0 3px var(--ok); }
.pick-tile img { width: 100%; height: 100%; object-fit: fill; display: block; transition: opacity .15s; }
.pick-tile.picked img { opacity: .35; }
.pick-tile input { position: absolute; z-index: 3; top: 8px; left: 8px; width: 22px; height: 22px; }
.pick-tile .tile-qty { position: absolute; z-index: 3; top: 8px; right: 8px; font-size: .8rem; font-weight: 800; padding: 2px 7px;
  border-radius: 99px; background: rgba(0, 0, 0, .8); }
@media print {
  .topbar, .pick-bar, .pick-head .btn, .breadcrumbs, footer { display: none !important; }
}

/* ---------- card image corners ----------
   Most swu-db card scans have square white corners baked in (the printed card's are round, about 2.8% of its long
   side). A fixed radius like 10px hides them on small images but not on big ones, so every card image is rounded in
   proportion instead: 5% of each side, always a little rounder than the card itself. Comes last so it wins over the
   per-component radii; round face crops (the hero's spoiler faces, its leader chips) keep theirs.
   Card images come from swu-db (/images/cards/) or from our own copies (cards/images.py): images.twinsunshub.com
   live, /card-images/ on a laptop. A new image host needs adding to both rules here. */
img:is([src*="/images/cards/"], [src^="https://images.twinsunshub.com/"], [src*="/card-images/"]):not(.tag-faces img, .leader-chip img) { border-radius: 5%; }
/* A hairline just inside each card's edge (deck and pair tile art included), so its black border doesn't vanish into
   the dark page. Zero specificity (:where), so any component's own outline (unreleased red, hover orange) still wins. */
:where(img:is([src*="/images/cards/"], [src^="https://images.twinsunshub.com/"], [src*="/card-images/"]):not(.tag-faces img, .leader-chip img)) { outline: 1px solid rgba(255, 255, 255, .16); outline-offset: -1px; }
/* The Cost Curve fills its box, however tall Deck Makeup makes the row. */
.glance-grid .glance-box:has(> .curve) { display: flex; flex-direction: column; }
.glance-grid .curve.mini { flex: 1; height: auto; min-height: 130px; align-items: stretch; }
.glance-grid .curve.mini .bar { height: auto; }

/* Collection (collection/page.html) */
.owned-add { display: grid; gap: 8px; margin-bottom: 18px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.owned-add .filter-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.owned-add input[type=search] { max-width: 420px; }
/* Add cards: matches drop down under the box and float over the page, like the site search. */
.owned-find-box { position: relative; flex: 1 1 260px; max-width: 420px; }
.owned-add .owned-find-box input[type=search] { width: 100%; max-width: none; }
.owned-found { position: absolute; top: calc(100% + 4px); left: 0; z-index: 25; display: grid; gap: 2px; width: max(100%, 360px);
  max-height: min(60vh, 460px); overflow-y: auto; padding: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .55); }
.owned-found[hidden] { display: none; }
.owned-found-none { margin: 6px 8px; }
@media (max-width: 700px) { .owned-find-box { flex-basis: 100%; max-width: none; } .owned-found { width: 100%; } }
.owned-result { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 6px 8px; color: var(--text);
  background: none; border: 0; border-radius: 8px; text-align: left; font: inherit; cursor: pointer; }
.owned-result:hover, .owned-result:focus-visible { background: var(--panel-2); }
.owned-result img { width: 34px; aspect-ratio: 5 / 7; object-fit: fill; border-radius: 4px; display: block; }
.owned-result > span:nth-child(2) { display: grid; min-width: 0; }
.owned-picked { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.owned-printings { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.owned-printing { display: grid; gap: 4px; align-content: start; }
.owned-printing-name { font-weight: 600; font-size: .88rem; margin-top: 4px; }
.owned-printing-info { display: grid; gap: 4px; align-content: start; min-width: 0; }
/* Phones: printings stack one under another, each a large image, then its name and set, then its three counts side
   by side. */
@media (max-width: 700px) {
  .owned-printings { grid-template-columns: 1fr; gap: 0; }
  .owned-printing { justify-items: center; text-align: center; gap: 6px; padding: 16px 0; }
  .owned-printing + .owned-printing { border-top: 1px solid var(--line); }
  .owned-printing > .view-tile { width: min(100%, 260px); }
  .owned-printing > .view-tile.wide { width: 100%; max-width: 360px; }
  .owned-printing .owned-printing-info { justify-items: center; }
  .owned-printing .owned-counts { gap: 6px 16px; margin-top: 4px; }
  .owned-printing .owned-count.main { flex-basis: auto; }
}
.owned-finish { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
:is(.owned-tile, .owned-printing, .owned-table) .view-tile.wide { aspect-ratio: 7 / 5; }
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.qty-stepper button { width: 30px; height: 30px; padding: 0; color: var(--text); background: none; border: 0; font: inherit; font-weight: 700; cursor: pointer; }
.qty-stepper button:hover { background: var(--panel-2); }
.qty-stepper input { width: 44px; height: 30px; padding: 0; color: var(--text); background: none; border: 0; border-inline: 1px solid var(--line); border-radius: 0; font: inherit; font-weight: 700; 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; }
.owned-section { margin-bottom: 22px; }
.owned-heading { font-size: 1rem; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.owned-heading .small { font-weight: 500; margin-left: 6px; }
.owned-table .deck-name, .owned-sub { display: block; }
.owned-phone-meta { display: none; }
.owned-table .owned-qty-col { width: 1%; white-space: nowrap; text-align: right; }
/* In decks / Available: what the In Paper decks hold of a printing, and what's left. */
.owned-table .owned-paper-col { white-space: nowrap; text-align: right; }
.owned-table td.owned-paper-col.small { text-align: left; max-width: 170px; }
.in-deck { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owned-available { font-variant-numeric: tabular-nums; }
.owned-short { color: var(--warn); font-weight: 600; }
.owned-paper-line { display: block; margin-top: 4px; }
/* Name, numbers and counts centred under the art, as on the Cards page, so they read as that card's. */
.owned-tile { display: grid; gap: 4px; align-content: start; min-width: 0; text-align: center; }
.owned-tile .qty-stepper { justify-self: center; margin-top: 2px; }
.owned-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.owned-empty { padding: 24px 0; }
@media (max-width: 800px) {
  /* Review pages keep only the change badge: "2 → 3" moves under the card's name (diff-phone), so nothing runs off. */
  .owned-table :is(th, td):not(.art-cell):not(.owned-card):not(.owned-qty-col):not(.change-col) { display: none; }
  .owned-phone-meta { display: block; }
  .owned-table .change-col { width: 1%; padding-inline: 4px 8px; }
}
.diff-phone b { font-size: .95rem; }

/* Import and export dialogs (builder, collection) */
.io-dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.io-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.info-close {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.info-close:hover { border-color: var(--accent); }
.io { display: grid; gap: 10px; }
/* Import and export windows: what you read here (previews, help, descriptions) stays a step above the 12px floor. */
.io textarea { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; line-height: 1.45; }
.io > p.small { font-size: .9rem; }
.io-dialog { width: min(820px, calc(100vw - 32px)); }
.io-head { display: flex; justify-content: space-between; align-items: center; }
.io-head h2 { margin: 0; }
.io-examples { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.io-example { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.io-example-title { font-weight: 700; margin-bottom: 6px; }
.io-example pre { margin: 0 0 8px; font-size: .87rem; color: #cfd5df; white-space: pre-wrap; }
.io-example p { margin: 0; font-size: .87rem; line-height: 1.45; color: var(--muted); }
.io-example code { font-size: .87rem; color: var(--text); }
@media (max-width: 700px) { .io-examples { grid-template-columns: 1fr; } }

/* Collection import */
.owned-add .row input[type=search] { flex: 1 1 260px; max-width: 420px; }
.owned-modes { display: flex; flex-wrap: wrap; gap: 6px; }
/* Replacing a collection deletes what's there: said in red wherever Replace is picked (import window, Review Import). */
.replace-warning { margin: 0; padding: 10px 12px; border: 1px solid rgba(255, 107, 107, .45); border-radius: 8px;
  background: rgba(255, 107, 107, .08); font-size: .9rem; line-height: 1.45; }
.replace-warning b { color: var(--bad); }
.replace-warning[hidden] { display: none; }
.owned-review { margin: 8px 0; padding-left: 18px; }
.owned-problems-title { font-size: .9rem; margin: 14px 0 6px; color: var(--warn); }
.owned-problems { display: grid; gap: 6px; max-height: 240px; overflow: auto; padding: 8px 10px; background: var(--panel-2); border-radius: 8px; }
.owned-problems > div { display: grid; gap: 1px; min-width: 0; }
.owned-problems code { overflow-wrap: anywhere; }
.io-dialog [hidden] { display: none; }
/* The collection's card popup (Condensed) and Share window on phones: like the builder's card details, the × is a
   round button pinned to the bottom of the screen, in reach wherever you've scrolled. The card popup's Done goes, as
   the × does the same. */
@media (max-width: 800px) {
  :is(#owned-card-dialog, #share-dialog) .io-head .info-close {
    position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); translate: -50% 0; z-index: 5;
    width: 52px; height: 52px; font-size: 1.7rem; background: var(--panel-2); border-color: #48505f;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  }
  #owned-card-dialog .io > .row:last-child { display: none; }
  :is(#owned-card-dialog, #share-dialog) .io { padding-bottom: 72px; }
}

/* Collection: counts that aren't saved yet */
.qty-stepper.unsaved { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.qty-stepper.unsaved input { color: var(--accent); }
.owned-finish:has(.qty-stepper.unsaved) > span { color: var(--accent); }
.owned-table tbody tr.unsaved, .owned-table tbody tr.unsaved:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); box-shadow: inset 4px 0 0 var(--accent); }
.owned-table tbody tr.unsaved .deck-name { color: var(--accent); }
.owned-tile.unsaved .view-tile { outline: 2px solid var(--accent); outline-offset: 2px; }
.owned-tile.unsaved .stat-name { color: var(--accent); }
.owned-savebar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 14px 16px 14px 22px; background: var(--panel-2); border: 1px solid var(--accent); border-radius: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .6); font-weight: 600; font-size: 1.02rem; white-space: nowrap; }
.owned-savebar:not(.docked) .btn.sm { padding: 8px 16px; font-size: .95rem; }
.owned-savebar[hidden] { display: none; }
body.owned-has-drafts .container { padding-bottom: 100px; }
/* Review Import / Changes / Last Import: the bar's buttons sit beside the title while it's in view (collection-import.js). */
.review-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.review-head h1 { margin-right: auto; }
.owned-savebar.docked { position: static; transform: none; box-shadow: none; border: 0; background: none; padding: 0; max-width: none; }
.owned-savebar.docked > span:first-child { display: none; }  /* the count: the line under the title already says it */
/* My collection: the line under the title is the collection's totals, so the docked bar keeps its count. */
.owned-savebar.docked[data-keep-count] > span:first-child { display: inline; color: var(--accent); font-size: .92rem; margin-right: 2px; }
/* Phones: the bar spans the screen, the count gets its own line and the buttons share the next, Save at the right,
   so Save is never pushed off the edge. */
@media (max-width: 600px) {
  .owned-savebar { left: 12px; right: 12px; bottom: 12px; transform: none; max-width: none; flex-wrap: wrap; gap: 8px; padding: 10px 12px; white-space: normal; }
  .owned-savebar [data-save-text] { flex-basis: 100%; }
  .owned-savebar [data-save] { margin-left: auto; }
  .savebar-long { display: none; }
  body.owned-has-drafts .container { padding-bottom: 124px; }
  /* The review pages' bar: one row of buttons sharing the width. Its count is said under the page title already. */
  .owned-savebar[role=region] { flex-wrap: nowrap; padding: 8px; }
  .owned-savebar[role=region] > span:first-child { display: none; }
  .owned-savebar[role=region] .btn { flex: 1 1 0; min-width: 0; justify-content: center; padding-inline: 8px; }
  body.owned-has-drafts .container:has(.owned-savebar[role=region]) { padding-bottom: 84px; }
}
/* Phones: the results bar's search gets its own line, and the view toggles sit together on the next with the count. */
@media (max-width: 700px) {
  .owned-results-bar > form { flex-basis: 100%; }
  .owned-results-bar > form input[type=search] { width: 100% !important; }
  .owned-results-bar .view-toggle a { padding-inline: 10px; }
  .owned-results-bar > .spacer { display: none; }
  /* The two view toggles first, together on one line; Share this view and Reset follow under them. */
  .owned-results-bar > form { order: -2; }
  .owned-results-bar > .view-toggle { order: -1; }
  /* Even 10px between the Filters button, each line of the bar and the count under it. */
  /* Rows are spaced by each item's bottom margin rather than row-gap, so the empty line break adds nothing. The class
     is doubled to outrank the base rule further down. */
  .owned-results-bar.owned-results-bar { margin: 10px 0 0; gap: 0 10px; }
  .filter-panel + .owned-results-bar.owned-results-bar { margin-top: -2px; }  /* the panel leaves 12px under Filters */
  .owned-results-bar > * { margin-bottom: 10px; }
  .owned-results-bar + .owned-count-line { margin: 0 0 10px; }
  .owned-results-bar::after { content: ""; order: -1; flex-basis: 100%; height: 0; margin: 0; }  /* ends the toggles' line */
  .owned-results-bar:not(:has(> :not(form, .view-toggle, .spacer, .card-size, [data-card-size-picker])))::after { display: none; }
}

/* Collection list: each row's card, like the art column on the Decks list */
.owned-table .art-cell { padding: 10px 14px 10px 10px; }
.owned-art { width: 120px; }
@media (max-width: 800px) {
  .owned-art { width: 64px; }
  .owned-table .art-cell { padding: 8px 8px 8px 4px; }
  .owned-table .owned-card { padding-inline: 4px; }
}

/* Collection, Show: All cards: what you don't own is dimmed until it has a count */
.not-owned:not(.unsaved) :is(.view-tile, .deck-name, .owned-sub, .stat-name, .owned-meta, .owned-phone-meta) { opacity: .5; }

/* Page numbers, between Previous and Next */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 20px; }
.pager-num { min-width: 36px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .85rem; text-align: center; }
a.pager-num:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.pager-num.on { color: var(--text); background: var(--panel-2); border-color: var(--accent); }
.pager-gap { color: var(--muted); padding: 0 2px; }

/* Collection, Condensed view: one tile per card, opening its printings */
.owned-card-tile { padding: 0; color: var(--text); background: none; border: 0; font: inherit; text-align: center; cursor: pointer; }
.owned-card-tile .view-tile { transition: transform .12s, box-shadow .12s; }
.owned-card-tile:is(:hover, :focus-visible) .view-tile { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, .5), 0 0 0 2px var(--accent); }
.owned-tile-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 14px; }
.owned-total { display: inline-block; min-width: 30px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.unsaved .owned-total { color: var(--accent); border-color: var(--accent); }

/* Collection, For trade: green, apart from the orange of unsaved counts, as it saves straight away */
.trade-mark { color: var(--ok); font-weight: 600; }
.trade-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); vertical-align: middle; }
.trade-stepper button { width: 24px; height: 24px; padding: 0; color: var(--muted); background: none; border: 0; font: inherit; font-weight: 700; cursor: pointer; }
.trade-stepper button:hover { color: var(--text); background: var(--panel-2); }
.trade-stepper output { min-width: 26px; color: var(--muted); font-weight: 700; text-align: center; }
.trade-stepper.on { border-color: var(--ok); }
.trade-stepper.on output { color: var(--ok); }
/* A view-toggle choice that doesn't apply here (Condensed under Show: In my paper decks): greyed out, with a tooltip. */
.view-toggle .is-disabled { padding: 6px 12px; color: var(--muted); font-weight: 600; font-size: .85rem; opacity: .45; cursor: help; }
/* Wanted (the wishlist): blue, so it never reads as For trade at a glance */
.want-mark { color: #7cb8ff; font-weight: 600; }
.trade-stepper.want.on { border-color: #7cb8ff; }
.trade-stepper.want.on output { color: #7cb8ff; }
/* Grid view, your own collection: For trade and Wanted as tabs on the card's sides, a little above the middle, beside
   the art and clear of the cost, name, stats and rules text. For trade on the left (copies going out, like −), Wanted
   on the right (coming in, like +). The card is drawn 10px narrower each side so the tabs stay inside its tile and never
   meet the next card's. At 0 a tab is a quiet dashed outline with just its icon; clicking it opens a small −/+. */
.trade-tabs-art { position: relative; margin: 0 10px; }
.trade-tab { position: absolute; top: 36%; z-index: 3; }
.trade-tab.trade { left: -10px; }
.trade-tab.want { right: -10px; }
.trade-tab.open { z-index: 30; }
.trade-tab-btn { display: inline-flex; align-items: center; gap: 3px; height: 26px; padding: 0 7px; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--line); font: inherit; font-size: .78rem; font-weight: 700;
  font-variant-numeric: tabular-nums; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.trade-tab.trade .trade-tab-btn { border-radius: 99px 6px 6px 99px; }
.trade-tab.want .trade-tab-btn { border-radius: 6px 99px 99px 6px; }
.trade-tab-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.trade-tab-btn:not(.on) .trade-tab-count { display: none; }
.trade-tab-btn:hover, .trade-tab.open .trade-tab-btn { color: var(--text); border-color: var(--muted); }
.trade-tab-btn.on { border-style: solid; }
.trade-tab.trade .trade-tab-btn.on { color: var(--ok); border-color: var(--ok); }
.trade-tab.want .trade-tab-btn.on { color: #7cb8ff; border-color: #7cb8ff; }
.trade-tab-pop { position: absolute; top: calc(100% + 4px); display: grid; justify-items: center; gap: 4px; padding: 6px 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 20px rgba(0, 0, 0, .55); white-space: nowrap; }
.trade-tab-pop[hidden] { display: none; }
.trade-tab.trade .trade-tab-pop { left: 0; }
.trade-tab.want .trade-tab-pop { right: 0; }
.trade-tab-label { font-size: .72rem; color: var(--muted); }
.trade-tab-pop .trade-stepper button { width: 30px; height: 30px; }
.trade-tab-pop .trade-stepper output { min-width: 32px; }
/* Phones: two cards a row, not three, so the tabs have room beside each card. */
@media (max-width: 800px) { .card-grid.browse:has(.trade-tabs-art) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.owned-table .owned-trade-col { width: 1%; white-space: nowrap; text-align: right; }
.owned-trade-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; margin-top: 4px; }
/* A printing's counts (the Condensed card popup): Owned on its own line, For trade and Wanted side by side under
   it, each named above its counter. */
.owned-counts { display: flex; flex-wrap: wrap; justify-content: center; align-items: end; gap: 6px 12px; margin-top: 4px; }
.owned-count { display: grid; justify-items: center; gap: 2px; }
.owned-count.main { flex-basis: 100%; }
.owned-count-label { font-size: .72rem; color: var(--muted); }
.owned-count.main:has(.qty-stepper.unsaved) .owned-count-label { color: var(--accent); }
.owned-finish-block { margin-top: 8px; text-align: center; }
.owned-finish-block + .owned-finish-block { padding-top: 8px; border-top: 1px solid var(--line); }
.owned-finish-name { font-weight: 600; }
.owned-finish-block:has(.qty-stepper.unsaved) .owned-finish-name { color: var(--accent); }
.owned-share-note { padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
/* The collection in numbers under the title: short items spaced apart (no separators, so a wrapped line on a phone
   never starts with one). */
.owned-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin: 4px 0 16px; color: var(--muted); }
.owned-stat { white-space: nowrap; }
.owned-stat b { color: var(--text); font-weight: 700; }
.stat-link { color: var(--muted); }
.stat-link:hover { color: var(--text); }
.share-state.on, .share-state.on .link-btn { color: var(--accent); }
.share-state .link-btn { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.share-state .link-btn:hover { text-decoration: underline; }
/* Share dialog: points to skim, then each link with its Copy, then the actions, each with room around it. */
.share-dialog { width: min(640px, calc(100vw - 32px)); }
.share-points { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: .88rem; }
.share-links { display: grid; gap: 16px; margin-top: 18px; }
.share-link { display: grid; gap: 6px; }
.share-link[hidden] { display: none; }
.share-hint { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.share-copy { display: flex; gap: 8px; align-items: center; }
.share-copy input[readonly] { flex: 1; min-width: 0; }
.share-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 600px) { .share-actions .spacer { display: none; } .share-actions .btn { flex: 1 1 auto; justify-content: center; } }
.owned-card-row { cursor: pointer; }
.owned-card-row button.deck-name { padding: 0; background: none; border: 0; font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.owned-card-row button.deck-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.owned-card-tile .view-tile.wide { aspect-ratio: 7 / 5; }

/* Collection: row count, Clear filters and the view toggles, between the filters and the cards */
.owned-results-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: -8px 0 14px; }

/* Review Import: each printing's count now and after */
.diff { font-weight: 700; white-space: nowrap; }
.diff.new, .diff.up { color: var(--ok); }
.diff.down { color: var(--warn); }
.diff.removed { color: var(--bad); }
.diff.same { color: var(--muted); font-weight: 500; }
.diff-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--muted); vertical-align: 1px; }
.diff-dot.new, .diff-dot.up { background: var(--ok); }
.diff-dot.down { background: var(--warn); }
.diff-dot.removed { background: var(--bad); }
.owned-kinds { margin: 4px 0 18px; }
.owned-problems-box { margin: 0 0 18px; }
.owned-problems-box > summary { cursor: pointer; font-weight: 700; color: var(--warn); margin-bottom: 8px; }
.diff.changed { color: var(--accent); }
.diff-dot.changed { background: var(--accent); }
/* Review Import: the change sits under the card, bottom right; the counts are labelled beside the name */
.diff-badge { display: block; width: max-content; margin: 6px 0 0 auto; padding: 2px 9px; border-radius: 99px; font-weight: 800; font-size: .85rem;
  border: 1px solid currentColor; color: var(--muted); }
.diff-badge.new, .diff-badge.up { color: var(--ok); }
.diff-badge.down { color: var(--warn); }
.diff-badge.removed { color: var(--bad); }
.diff-badge.changed { color: var(--accent); }
.owned-tile .diff-badge { margin-top: -2px; }
.owned-table .art-cell .diff-badge { margin-top: 6px; }
.diff-counts { display: flex; align-items: baseline; gap: 6px; font-size: .85rem; color: var(--muted); }
.diff-counts b { color: var(--text); font-size: 1rem; }
.owned-tile .diff-counts { justify-content: center; flex-wrap: wrap; }
/* Phones: tiles are narrow, so just "1 → 2" (the badge above says what changed). */
@media (max-width: 700px) { .owned-tile .diff-word { display: none; } }
.owned-count-line { margin: -6px 0 10px; }
.owned-table .diff-col { width: 1%; white-space: nowrap; text-align: center; font-size: 1rem; }
.owned-table th.diff-col { font-size: .8rem; }

/* Review Import: lines that won't be imported, each with Fix when it can be */
.owned-problem { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.owned-problem > div { display: grid; gap: 1px; min-width: 0; }
.owned-problem .btn { flex: none; }
#fix-dialog .owned-printing .row { gap: 6px; margin-top: 4px; }

/* Review Import: every line that won't be imported, then Fix Imports, one line at a time */
.owned-problems-box .owned-problems { max-height: none; overflow: visible; }
.owned-problem[hidden] { display: none; }
.owned-problems-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.owned-problems [data-problems-more] { justify-self: start; }
.fix-dialog { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.fix-typed { display: grid; gap: 2px; padding: 10px 12px; background: var(--panel-2); border-radius: 10px; }
.fix-typed code { font-size: .95rem; }
.fix-printings { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 8px; }
.fix-printing { position: relative; display: grid; gap: 3px; align-content: start; padding: 6px; color: var(--text); text-align: left;
  background: none; border: 2px solid transparent; border-radius: 12px; font: inherit; cursor: pointer; }
.fix-printing:is(:hover, :focus-visible) { border-color: rgba(255, 255, 255, .35); }
.fix-printing.suggested { border-color: var(--accent); }
.fix-printing .view-tile.wide { aspect-ratio: 7 / 5; }
.fix-suggested { position: absolute; top: 12px; left: 12px; z-index: 3; padding: 2px 8px; border-radius: 99px; background: var(--accent); color: #1a0f05; font-size: .8rem; font-weight: 800; }
/* The heading line: count on the left, Fix imports on the right, above the grey box */
.owned-problems-title { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.owned-problems-title h3 { margin: 0 auto 0 0; font-size: .95rem; color: var(--warn); }
.owned-problems > .owned-problem { display: flex; }

/* Fix All Imports: one row per failed line, the suggested printing picked, others to pick instead */
.fix-table-wrap { overflow-x: auto; }
.fix-table { width: 100%; border-collapse: collapse; }
.fix-table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; text-align: left; padding: 6px 8px; }
.fix-table td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.fix-typed-cell { width: 26%; }
.fix-typed-cell code { display: block; overflow-wrap: anywhere; }
.fix-suggested-cell { width: 120px; }
.fix-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.fix-pick { flex: none; width: 104px; display: grid; gap: 2px; padding: 4px; color: var(--text); text-align: left; background: none;
  border: 2px solid transparent; border-radius: 10px; font: inherit; font-size: .8rem; cursor: pointer; }
.fix-pick:is(:hover, :focus-visible) { border-color: rgba(255, 255, 255, .35); }
.fix-pick.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fix-pick .view-tile.wide { aspect-ratio: 7 / 5; }
.fix-pick-label { font-weight: 700; }
.fix-pick-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fix-table tr:not(.picked) .fix-typed-cell code { color: var(--muted); }
/* Fix All Imports, roomier: a wide window, bigger pictures that wrap onto more rows */
#fix-all-dialog { width: min(1600px, calc(100vw - 32px)); }
.fix-table { table-layout: fixed; }
.fix-table th:nth-child(1), .fix-typed-cell { width: 300px; }
.fix-table th:nth-child(2), .fix-suggested-cell { width: 176px; }
.fix-typed-cell { display: table-cell; }
.fix-typed-cell > * { display: block; }
.fix-typed-cell code { font-size: .95rem; margin-bottom: 4px; }
.fix-typed-cell .fix-finish { display: inline-flex; margin-top: 10px; }
.fix-strip { flex-wrap: wrap; overflow: visible; gap: 10px; }
.fix-pick { width: 156px; font-size: .85rem; }
@media (max-width: 900px) {
  .fix-table, .fix-table tbody, .fix-table tr, .fix-table td { display: block; width: auto; }
  .fix-table thead { display: none; }
}
.owned-revise-note { padding: 10px 12px; border: 1px solid var(--accent); border-radius: 10px; color: var(--text); }
/* In List, the change has its own column, last (Grid keeps it under the picture) */
.owned-table .change-col { width: 90px; text-align: center; }
.owned-table .change-col .diff-badge { margin: 0 auto; }
/* Section headings over groups of cards, as the deckbuilder's: a filled band, a little bigger, the count in sun colour.
   .band-heading is the general name (set pages); .owned-heading the Collection and review pages', whose band's left
   edge also takes the change's colour. */
.owned-heading, .band-heading { display: flex; align-items: center; gap: 8px; padding: 8px 14px; margin: 0 0 10px; border: 0; border-radius: 8px;
  background: var(--panel-2); font-size: 1.12rem; font-weight: 700; color: var(--text); }
.owned-heading .small, .band-heading .small { margin-left: 0; font-size: .95rem; font-weight: 700; color: var(--sun-1); }
.owned-heading .diff-dot { margin-right: 0; }
.owned-heading:has(.diff-dot.new, .diff-dot.up) { box-shadow: inset 4px 0 0 var(--ok); }
.owned-heading:has(.diff-dot.down) { box-shadow: inset 4px 0 0 var(--warn); }
.owned-heading:has(.diff-dot.removed) { box-shadow: inset 4px 0 0 var(--bad); }
.owned-heading:has(.diff-dot.changed) { box-shadow: inset 4px 0 0 var(--accent); }
.owned-section { margin-bottom: 26px; }
/* Collection and review sections collapse from their heading, like the deck page's (static/js/deck-sections.js) */
.owned-section[data-section] > .owned-heading { cursor: pointer; user-select: none; }
.owned-heading .collapse-btn, .band-heading .collapse-btn { margin: 0 -2px 0 -6px; }
.band-section[data-section] > .band-heading { cursor: pointer; user-select: none; }
.band-section.collapsed > .band-heading { margin-bottom: 0; }
.collapsed > .band-body { display: none !important; }
.owned-section.collapsed > .owned-heading { margin-bottom: 0; }
.collapsed > .owned-body { display: none !important; }
/* Section headings: exactly the deckbuilder's size and spacing (builder.css .deck-section h3) */
.owned-heading, .band-heading { padding: 6px 12px; margin: 0 0 6px; font-size: 1.02rem; }
.owned-heading .small, .band-heading .small { font-size: 1.02rem; }
.owned-results-bar .card-size { margin-right: 4px; }

/* Phone-only and desktop-only pieces (the builder's More menu takes Playtest and Copy deck on phones). */
@media (min-width: 701px) { .phone-only { display: none !important; } }
@media (max-width: 700px) { .phone-hide { display: none !important; } }

/* ---------- deck page on phones: laid out like the builder's ----------
   Name and details, the leaders and base stacked big, then Edit deck (or Copy deck) / Export / More, the numbers, the
   stats. The view controls sit in a tidy grid. */
@media (max-width: 700px) {
  .deck-hero { display: flex; flex-direction: column; gap: 14px; }
  .hero-info { display: contents; }
  .hero-info > h1, .hero-info > .hero-sub { order: 1; }
  .hero-info h1 { margin-bottom: -6px; }
  .hero-by { padding-left: 0; }
  .hero-art { order: 2; justify-items: stretch; gap: 10px; }
  .hero-leaders { flex-direction: column; gap: 10px; }
  .hero-leaders img, .hero-empty { width: 100%; }
  /* Leader / Unit toggle: under the leaders; on Unit each leader shows its portrait unit side, a bit narrower than
     the screen so the pair doesn't run several screens tall, but large enough to read. */
  .hero-side-toggle { position: static; transform: none; justify-self: center; order: -1; }  /* above the leaders, reachable either way */
  .side-toggle label { padding: 8px 18px; }  /* touch-sized */
  .hero-art.show-unit .hero-leaders { align-items: center; }
  .hero-art.show-unit .hero-leaders a { width: 82%; }
  .hero-art.show-unit .hero-leaders img { aspect-ratio: 5 / 7; }
  .hero-base { justify-self: stretch; }
  .hero-base img, .hero-art.premier .hero-base img { width: 100%; }
  .hero-art.premier { grid-template-columns: minmax(0, 1fr); }  /* stacked big, as for Twin Suns */
  .hero-info .hero-actions { order: 3; padding-block: 0; flex-wrap: nowrap; gap: 6px; }
  .hero-actions > .btn, .hero-actions > .menu, .hero-actions > form { flex: 1 1 0; min-width: 0; }
  .hero-actions > .btn, .hero-actions > .menu > summary, .hero-actions > form > .btn { width: 100%; justify-content: center; }
  .hero-info > .hero-stats { order: 4; }
  .deck-tabs .tab { font-size: .95rem; }
  .deck-page .container { padding: 14px 16px 60px; }
  .block { padding: 12px 14px; border-radius: 12px; }
  /* Tabs share the width while they fit; a row too wide for the screen (the builder's five) scrolls sideways, fading
     at the edge where there's more (deck-sections.js sets .more-left / .more-right and keeps the open tab in view). */
  .deck-block .tabs { gap: 0; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .deck-block .tabs::-webkit-scrollbar { display: none; }
  .deck-block .tabs .tab { flex: 1 0 auto; padding: 8px 8px; font-size: .9rem; white-space: nowrap; }
  .deck-block .tabs.more-right { mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
  .deck-block .tabs.more-left { mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); }
  .deck-block .tabs.more-left.more-right { mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); }
  .deck-view-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .deck-view-bar .view-toggle { grid-column: 1 / -1; display: flex; }
  .deck-view-bar .view-toggle a { flex: 1; text-align: center; padding-block: 8px; }
  .deck-view-bar label { display: grid; gap: 4px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .deck-view-bar select { width: 100%; padding: 8px; font-size: .95rem; letter-spacing: 0; text-transform: none; color: var(--text); }
}
/* Touch: no hover lift or line left behind on the deck page's cards after a tap. */
.touch-ui .deck-view:not(.stacks) a.view-tile:hover, .touch-ui .hero-leaders a:hover img { transform: none; translate: none; box-shadow: none; }
.touch-ui a.view-tile:hover::before { box-shadow: inset 0 0 0 2px transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }



/* Home page on phones: Trending pairs and Recent decks show 3 each (one per row, so 6 ran several screens);
   "Browse all" leads to the rest. */
@media (max-width: 700px) {
  .home-trim > :nth-child(n+4) { display: none; }
  /* Trending cards: 2 across and 3 rows, so each card is big enough to read next to the leader tiles above. */
  .card-grid.browse.home-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-cards > :nth-child(n+7) { display: none; }
}

/* Home section headers: the title, then a line with what the list is on the left and its link on the right, right
   above the tiles (the link in the same place for every section). */
.home-title { margin-bottom: 2px; }
.home-sub { margin-bottom: 12px; flex-wrap: nowrap; }
.home-sub > a { white-space: nowrap; }

/* Text pages such as Privacy: a readable line length and spacing between sections. */
.legal-page { max-width: 70ch; margin: 0 auto; padding-bottom: 24px; line-height: 1.6; }
.legal-page h2 { margin-top: 28px; }
.legal-page ul { padding-left: 20px; }
.legal-page li + li { margin-top: 6px; }

/* Contact page: a roomy message box, and the bot trap kept off screen (it's there for bots, not people). */
.contact-box { max-width: 560px; }
.contact-box textarea, .contact-box select { width: 100%; }
.contact-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* A deck's Collection tab (builder and deck page): its cards against the viewer's collection, in three groups. */
.coll-summary { margin: 0 0 12px; }
/* List view: laid out like the decklist (groups side by side in 20-line columns, card-size.js). Each line is the
   card's cost, its name on one line (a long one ends in "…": the full name is its hover text, and the card shows on
   hover) and its counts at the right. A group of one column stays that wide, so a long heading hint wraps. */
.coll-line { display: flex; align-items: center; gap: 10px; }
:is(#coll-list, #tab-collection) .list-col .coll-line .nm { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coll-line .coll-name { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coll-line .coll-status { flex: none; margin-left: auto; }
#tab-collection .deck-view.list .deck-group:not(:has(.list-col + .list-col)) { width: var(--list-col, 320px); max-width: 100%; }
/* Left-aligned under the note and tally above it (the decklist centres its block of columns). */
#coll-list.list, #tab-collection .deck-view.list { margin-inline: 0; }
:is(#coll-list, #tab-collection) .list-col { container: coll-col / inline-size; }
@container coll-col (max-width: 420px) {
  .coll-line .coll-counts { gap: 7px; }
  .coll-line .coll-counts .long { display: none; }
  .coll-line .coll-counts .short { display: inline; }
}
.coll-warn { color: var(--warn); font-weight: 600; }
.coll-tile { display: grid; gap: 4px; align-content: start; min-width: 0; }
.coll-cap { display: grid; gap: 3px; overflow-wrap: anywhere; }
@media (max-width: 480px) {  /* phones: Own / Avail / Need, so a line still fits */
  .coll-line .coll-counts { gap: 7px; }
  .coll-line .coll-counts .long { display: none; }
  .coll-line .coll-counts .short { display: inline; }
}
#tab-collection .coll-line .cost { flex: none; }
.coll-page-head { gap: 12px; margin-bottom: 10px; align-items: center; }

/* Compare (a shared collection against yours): exact matches in green, the same card in another printing in amber */
.compare-cta { margin: -6px 0 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.compare-lede { max-width: 760px; margin: -4px 0 8px; color: var(--muted); }
.compare-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -8px 0 6px; }
.compare-heading { margin-top: 26px; }
.compare-table .compare-match-col { width: 1%; min-width: 120px; max-width: 280px; text-align: left; }
.compare-badge { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); white-space: nowrap; }
.compare-note { color: var(--warn); }
.compare-phone { display: none; }
.compare-table tbody tr.compare-hit { box-shadow: inset 3px 0 0 var(--ok); }
.compare-table tbody tr.compare-close { box-shadow: inset 3px 0 0 var(--warn); }
@media (max-width: 800px) {
  .compare-phone { display: block; margin-top: 2px; }
}
.compare-tile.compare-hit .view-tile { box-shadow: 0 0 0 2px var(--ok); }
.compare-tile.compare-close .view-tile { box-shadow: 0 0 0 2px var(--warn); }
.compare-tile .compare-note { text-align: center; }

/* Share dialog: Share… (the phone's share sheet, shown where there is one) and a QR code to scan in person. The code
   always sits on white, as cameras read dark-on-light best, whatever the theme. */
.share-copy [data-share-native][hidden] { display: none; }
.share-qr { display: grid; justify-items: start; gap: 10px; }
.share-qr-panel { display: grid; justify-items: center; gap: 10px; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.share-qr-panel[hidden] { display: none; }
.share-qr-opens { display: grid; justify-items: center; gap: 6px; }
.share-qr-scope { margin: 0; }
.share-qr-scope button[hidden] { display: none; }
.share-qr-img { width: min(232px, 70vw); height: auto; aspect-ratio: 1; background: #fff; border-radius: 8px; }
.share-qr-note { margin: 0; text-align: center; }

/* Collection list with Trading on: Owned, For trade and Wanted stacked in one cell, labels left of their steppers.
   The trade steppers take the Owned stepper's size there, so the three line up and are easy to tap on a phone. */
.owned-table .owned-stack-col { width: 1%; }
.owned-stack { display: grid; grid-template-columns: max-content max-content; align-items: center; justify-content: end; justify-items: end; gap: 4px 8px; }
.owned-stack-label { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.owned-stack .trade-stepper button { width: 30px; height: 30px; }
.owned-stack .trade-stepper output { min-width: 44px; }
.owned-stack-none { display: inline-block; width: 104px; text-align: center; }
.owned-stack:has(.qty-stepper.unsaved) .owned-stack-label:first-child { color: var(--accent); }
/* Between phone and wide screens the stacked counts need the room: Type and Cost step aside while Trading is on. */
@media (max-width: 1100px) {
  .owned-table.trading .owned-minor { display: none; }
}
@media (max-width: 800px) {
  .owned-stack { gap: 6px 6px; }
  .owned-stack-label { font-size: .7rem; }
}

/* Tip bars: "Tip: …" with a "Got it" button. .touch-tip shows on touch screens only, .view-tip on every screen.
   Tips on every screen say "click" or "tap" to match (.tip-mouse, .tip-touch). Shown and hidden by tips.js or builder.js. */
.touch-tip { display: none; }
.touch-ui .touch-tip:not([hidden]), .view-tip:not([hidden]) { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
  background: rgba(255, 154, 61, .1); border: 1px solid rgba(255, 154, 61, .35); font-size: .88rem; line-height: 1.35; }
.touch-tip b { color: var(--sun-1); }
.touch-tip .btn { flex: none; margin-left: auto; }
.touch-ui .tip-mouse, html:not(.touch-ui) .tip-touch { display: none; }

/* Collection tabs (builder and deck page). The note: a line or two and the Owned / Available / Needed key. */
.coll-note { margin: 0 0 10px; }
.coll-note p { margin: 0; }
.coll-note p + p, .coll-note ul + p { margin-top: 6px; }
.coll-note ul { margin: 2px 0 0; padding-left: 18px; display: grid; gap: 2px; line-height: 1.4; }
.coll-note b { color: var(--text); font-weight: 600; }
.coll-note .btn { margin-left: 6px; }
/* Owned · Available · Needed per card, on one line, coloured red (none owned), yellow (owned, not enough available)
   or green (enough available). On a narrow tile the labels shorten to Own / Avail / Need. */
.coll-cap { container: coll-cap / inline-size; justify-items: center; text-align: center; }
.coll-counts { display: inline-flex; gap: 10px; white-space: nowrap; color: var(--tone); }
.coll-counts b { font-weight: 700; }
.coll-counts .short { display: none; }
@container coll-cap (max-width: 210px) {
  .coll-counts { gap: 7px; }
  .coll-counts .long { display: none; }
  .coll-counts .short { display: inline; }
}
/* "In use: Deck A, Deck B" under a yellow card whose copies other In Paper decks hold: one line, under the name in a
   list and centred under a tile, ending in "…" when long (the full list is its hover text). */
.coll-inuse { display: block; max-width: 100%; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coll-line:has(.coll-inuse) { flex-wrap: wrap; row-gap: 0; }
.coll-line .coll-inuse { flex-basis: 100%; padding-left: 32px; margin-top: -3px; line-height: 1.3; }
.coll-red { --tone: var(--bad); }
.coll-yellow { --tone: var(--warn); }
.coll-green { --tone: var(--ok); }
.coll-summary { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.coll-tally::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: var(--tone); }

/* Deck drafts: the owner's banner on a deck page with unpublished changes, and the dates window by the byline */
.draft-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}
.draft-banner b { color: var(--accent); }
.draft-banner.note { border-color: var(--line); background: var(--panel); }
.draft-banner form { margin: 0; }
.deck-dates { display: inline-block; }
.deck-dates summary { display: inline; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.deck-dates .menu-items { min-width: 260px; max-width: min(340px, calc(100vw - 16px)); }
.date-row { display: grid; padding: 6px 10px; color: var(--text); font-size: .88rem; }
.date-row .date-when { color: var(--text); font-size: .85rem; }
.date-row span:last-child { font-size: .78rem; color: var(--muted); }
@media (max-width: 600px) { .draft-banner .spacer { display: none; } }
