/* Arkham Drafter. One stylesheet, CSS custom properties for the palette.
   Dark eldritch-lounge: near-black green/indigo ground, parchment-cream ink,
   class-color accents, serif reserved for h1/h2. No external fonts. */

:root {
  --bg: #0a0d0b;
  --bg-vignette: #050706;
  --panel: #12171a;
  --panel-2: #171d21;
  --panel-3: #1e252a;
  --line: #2b343a;
  --line-soft: #222a2f;
  --ink: #ece5d2;
  --ink-dim: #a7a290;
  --ink-faint: #726f63;
  --accent: #8fb7c9;
  --accent-ink: #0a0d0b;
  --good: #5aa06a;
  --warn: #d8a24a;
  --bad: #cc5b52;

  --guardian: #2185d0;
  --seeker: #d7a13c;
  --rogue: #479944;
  --mystic: #7b5bab;
  --survivor: #cc3d3d;
  --neutral: #8a8794;

  --serif: Georgia, "Times New Roman", "Iowan Old Style", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Consolas", "Liberation Mono", monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --gap: 18px;
  --maxw: 2400px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #101a18 0%, transparent 60%),
    radial-gradient(900px 900px at 100% 0%, #0f1220 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
}

/* Vignette overlay, non-interactive. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, var(--bg-vignette) 100%);
  z-index: 1;
}

#app { position: relative; z-index: 2; }

h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.2px; }
h1 { font-size: 2rem; margin: 0 0 0.3em; }
h2 { font-size: 1.35rem; margin: 0 0 0.5em; }
h3 { font-size: 1.05rem; margin: 0 0 0.4em; font-weight: 600; }
p { margin: 0 0 0.8em; }
a { color: var(--accent); }

.noscript {
  max-width: 640px;
  margin: 15vh auto;
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}

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

/* Use most of the viewport (grids exploit the width), capped at --maxw so ultra-wide
   monitors do not spread a single row edge to edge. Prose blocks cap their own line
   length below (see .lede); the grids take the full width. */
.shell { width: 96vw; max-width: var(--maxw); margin: 0 auto; padding: 0 20px 80px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 20px;
  background: rgba(10, 13, 11, 0.82);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar .brand {
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.3px;
  color: var(--ink);
  white-space: nowrap;
}
.topbar .brand .sub { color: var(--ink-faint); font-family: var(--sans); font-size: 0.75rem; display: block; letter-spacing: 0.4px; text-transform: uppercase; }
.topbar .spacer { flex: 1 1 auto; }
.topbar .status-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 0.85rem; color: var(--ink-dim); }

.phase-strip { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.78rem; }
.phase-strip .step {
  padding: 3px 9px; border-radius: 999px; color: var(--ink-faint);
  border: 1px solid transparent; white-space: nowrap;
}
.phase-strip .step.done { color: var(--ink-dim); }
.phase-strip .step.current { color: var(--ink); border-color: var(--line); background: var(--panel-2); }

.screen { padding-top: 26px; }
.screen-head { margin-bottom: 22px; }
.screen-head .lede { color: var(--ink-dim); max-width: 62ch; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
}
.panel + .panel { margin-top: 18px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title h2, .panel-title h3 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--gap); align-items: start; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }
/* Deckbuild gives the pool the larger share so it hits many columns on a wide screen; the
   deck side (meter, deck list, submit) does not need to grow with the viewport. */
.grid-2.deck-grid { grid-template-columns: 2fr 1fr; }
@media (max-width: 820px) { .grid-2.deck-grid { grid-template-columns: 1fr; } }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.small { font-size: 0.85rem; }
.tabular { font-variant-numeric: tabular-nums; }
.center-narrow { max-width: 560px; margin: 6vh auto 0; }

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

button, .btn {
  font-family: var(--sans);
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.02s;
}
button:hover, .btn:hover { background: var(--panel-3); border-color: #3a444b; }
button:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600;
}
button.primary:hover { background: #a6c9d8; }
button.ghost { background: transparent; }
button.danger { border-color: #4a2b2b; color: #e79b93; }
button.danger:hover { background: #2a1a1a; }
button.small { padding: 5px 10px; font-size: 0.82rem; }
button.icon { padding: 6px 9px; line-height: 1; }

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

/* ---------- Forms ---------- */

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; color: var(--ink-dim); }
input[type="text"], input[type="number"], select {
  font-family: var(--sans);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
input.invalid { border-color: var(--bad); }
.hint { font-size: 0.78rem; color: var(--ink-faint); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.field-inline { display: flex; align-items: center; gap: 8px; }

.errline { color: var(--bad); font-size: 0.85rem; margin-top: 6px; }
.warnline { color: var(--warn); font-size: 0.85rem; margin-top: 6px; }

/* ---------- Banners / toasts ---------- */

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid; font-size: 0.9rem; margin-bottom: 16px;
}
.banner.warn { background: #241d10; border-color: #4a3c1c; color: #e6c079; }
.banner.bad { background: #241312; border-color: #4a2624; color: #e79b93; }
.banner.info { background: #101d22; border-color: #22414c; color: #9fc8d6; }

.toasts {
  position: fixed; z-index: 50; right: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px; max-width: 340px;
}
.toast {
  background: var(--panel-3); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; box-shadow: var(--shadow); font-size: 0.9rem;
  animation: toast-in 0.16s ease-out;
}
.toast.good { border-left: 3px solid var(--good); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.bad { border-left: 3px solid var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Roster ---------- */

.roster { display: flex; flex-direction: column; gap: 8px; }
.roster-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--line-soft);
}
.roster-row .name { font-weight: 600; }
.roster-row .tag { font-size: 0.75rem; color: var(--ink-faint); }
.roster-row .spacer { flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 6px rgba(90,160,106,0.7); }
.dot.off { background: var(--ink-faint); }
.pill {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-dim); white-space: nowrap;
}
.pill.you { border-color: var(--accent); color: var(--accent); }
.pill.host { border-color: #4a3c1c; color: var(--warn); }
.pill.ready { border-color: #24402a; color: var(--good); }
.pill.waiting { color: var(--ink-faint); }

/* ---------- Card tiles + grid ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min, 336px), 1fr));
  gap: 20px 16px; /* generous row-gap so tall tiles never read as touching */
  align-items: start; /* tiles carry full rules text now, so cells vary in height */
  /* Size each row to its tallest tile. Critical for the pool viewer: that grid is its own
     overflow:auto scroll container inside a max-height flex column, so it has a DEFINITE
     height, and with `auto` rows CSS splits that height into equal fractions (far shorter
     than the tiles) - tiles then overflow into the row below and physically overlap, which
     ping-pongs :hover between them (the "expanded still flickers" bug). max-content pins
     rows to content; auto-height grids (pack, deckbuild pool) are unaffected. */
  grid-auto-rows: max-content;
}
/* Cards are deliberately large for readability: roughly double the old width, so fewer
   columns per row (expected, and chosen). ~3 columns at 1920, 4 at 2560, 2 at 1366. */
.card-grid.wide { --card-min: 380px; }
/* The deckbuild pool doubles too but stays "compact" via its clamped rules. */
.card-grid.pool { --card-min: 288px; }
/* Acquired upgrades folded into the campaign-edit pool get a small accent marker. */
.pool-cell.acquired .card-tile { border-color: var(--accent); }
.acq-label { font-size: 0.68rem; color: var(--accent); text-align: center; margin-top: 3px; letter-spacing: 0.4px; text-transform: uppercase; }

/* A drafted pick outside the chosen investigator's deckbuilding options: still counted
   and submittable (options are advisory), just flagged with a subtle warning accent. */
/* Off-options cards are allowed up to the allowance: a subtle neutral marker (it helps you
   choose which cards spend the allowance), no alarm color. */
.pool-cell.deckbuild-outside .card-tile { border-color: var(--line); }
.outside-label { font-size: 0.66rem; color: var(--ink-dim); text-align: center; margin-top: 3px; letter-spacing: 0.3px; }
.roster-row.deckbuild-outside { border-color: var(--line); }
.pill.warn { border-color: #4a3c1c; color: var(--warn); }
.pill.info { border-color: var(--line); color: var(--ink-dim); }
/* Past the allowance the whole off-options set turns warning-colored. */
.card-grid.pool.over-allowance .pool-cell.deckbuild-outside .card-tile { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.card-grid.pool.over-allowance .outside-label { color: var(--warn); }
/* The off-options allowance meter under the deck-size meter: neutral until over. */
.off-meter { font-size: 0.82rem; color: var(--ink-dim); }
.off-meter.over { color: var(--warn); font-weight: 600; }
.deck-warnings { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }

/* Collapsed investigator-options strip at the top of the draft screen. */
.options-strip { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--panel); padding: 10px 14px; }
.options-strip > summary { cursor: pointer; color: var(--ink-dim); list-style: revert; }
.options-strip > summary:hover { color: var(--ink); }

/* Pick-and-pass draft: the burn log line under the status row. */
.draft-burn-log { font-size: 0.8rem; color: var(--warn); min-height: 1.1em; margin-bottom: 10px; }

.tier-group { margin-bottom: 22px; }
.tier-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--line-soft); padding-bottom: 6px;
}
.tier-head .lvl { font-size: 0.78rem; color: var(--ink-faint); }

/* The universal card box: image face(s) on top, an always-visible text block below.
   The box is a column so tiles in a grid row share a height and stay aligned. */
.card-tile {
  position: relative;
  display: flex; flex-direction: column;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  overflow: hidden;
  transition: border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.card-tile[data-select] { cursor: pointer; }
.card-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.card-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.card-tile.disabled { opacity: 0.45; pointer-events: none; }

.card-faces { display: grid; grid-template-columns: 1fr; }
.card-tile.two-sided .card-faces { grid-template-columns: 1fr 1fr; }
.card-face { position: relative; display: block; text-decoration: none; min-width: 0; }
.card-face + .card-face { border-left: 1px solid var(--line-soft); }
/* The image box carries the card's aspect ratio (portrait 5:7 for player cards, landscape
   7:5 for investigators). A load handler in components.js then sets the box to the image's
   true natural ratio, so real art is neither cropped nor letterboxed. object-fit:contain is
   the safety net for any residual mismatch (letterbox, never crop); the opaque backing keeps
   a transient letterbox showing a clean panel, not the text underlay bleeding around it. */
.card-face .face-img { position: relative; width: 100%; aspect-ratio: 5 / 7; overflow: hidden; background: var(--panel-3); }
.card-tile.inv .card-face .face-img { aspect-ratio: 7 / 5; }
.card-face img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: contain; background: var(--panel-3); display: block; }
@media (max-width: 560px) {
  .card-tile.two-sided .card-faces { grid-template-columns: 1fr; }
  .card-face + .card-face { border-left: none; border-top: 1px solid var(--line-soft); }
}

.card-tile .qty {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  font-size: 0.72rem; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: rgba(6,9,8,0.85); color: var(--ink); border: 1px solid var(--line);
}
.card-tile .check {
  position: absolute; top: 6px; left: 6px; z-index: 3;
  width: 22px; height: 22px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink);
  font-size: 0.8rem; font-weight: 800; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.card-tile.selected .check { display: flex; }
/* The qty badge sits top-right over the image; the centered fallback name clears it. */

/* Face base layer: a class band plus the centered name, shown while the image loads
   or if it fails, so an art-less tile reads as an intentional placeholder. */
.card-fallback {
  position: absolute; inset: 0; z-index: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 16px 10px; gap: 4px; background: var(--panel-2);
}
.card-fallback .band { position: absolute; top: 0; left: 0; right: 0; height: 6px; }
.card-fallback .nm { font-size: 0.9rem; font-weight: 600; line-height: 1.25; }
.card-fallback .sub { font-size: 0.72rem; color: var(--ink-dim); line-height: 1.2; }
.card-fallback .tl { font-size: 0.68rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.4px; }

/* Always-visible full text block (arkhamdb-style, includes rules text). */
.card-text { display: flex; flex-direction: column; gap: 4px; padding: 9px 10px; flex: 1; }
.card-text .nm { font-weight: 600; font-size: 0.9rem; line-height: 1.2; }
.card-text .sub { font-size: 0.75rem; color: var(--ink-dim); line-height: 1.2; }
.card-text .tl { font-size: 0.7rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.4px; }
.card-text .traits { font-size: 0.75rem; font-style: italic; color: var(--ink-dim); }
.card-text .meta { display: flex; align-items: center; gap: 5px 8px; flex-wrap: wrap; font-size: 0.76rem; color: var(--ink-dim); }
.card-text .meta .s { display: inline-flex; gap: 3px; align-items: center; }
.card-text .meta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.card-text .cost { font-weight: 700; color: var(--ink); }
.card-text .rules { font-size: 0.75rem; line-height: 1.35; color: var(--ink); white-space: pre-line; margin-top: 2px; }
.card-tile.inv .card-text .nm { font-size: 1.05rem; }

/* Fits-row: which of the viewer's offered investigators can legally use this card. */
.card-tile .fits-row { display: flex; align-items: center; gap: 4px; padding: 5px 10px 0; }
.fits-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cls, var(--neutral)); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); }
.fits-none { font-size: 0.64rem; color: var(--ink-faint); font-style: italic; }

/* Compact tile (deckbuild pool only): a smaller fixed-height image and a rules block
   clamped to three lines with a More/Less toggle, so many cards fit a multi-column grid.
   The full text stays on the title attribute and one click away; every other context keeps
   full, untruncated text. */
/* The compact cell keeps the card's true (uncropped) portrait image like every other
   surface; "compact" now means only the clamped rules block below, not a cropped thumbnail. */
.card-tile.compact .card-text { padding: 7px 9px; gap: 3px; }
.card-tile.compact .card-text .rules.clamped {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
.rules-toggle {
  align-self: flex-start; background: none; border: none; padding: 1px 0;
  color: var(--accent); font-size: 0.72rem; cursor: pointer;
}
.rules-toggle:hover { text-decoration: underline; }

.card-source-toggle { gap: 8px; }
.card-source-toggle select { width: auto; }

.pips { display: inline-flex; gap: 2px; }
.pips .pip { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
.pips .pip.on { background: var(--warn); }

/* Class color helpers (set via .cls-<faction>) */
.cls-guardian { --cls: var(--guardian); }
.cls-seeker { --cls: var(--seeker); }
.cls-rogue { --cls: var(--rogue); }
.cls-mystic { --cls: var(--mystic); }
.cls-survivor { --cls: var(--survivor); }
.cls-neutral { --cls: var(--neutral); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--cls, var(--line)); color: var(--cls, var(--ink-dim));
}
.chip {
  font-size: 0.8rem; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-dim);
  cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: #3a444b; color: var(--ink); }
.chip.active { border-color: var(--cls, var(--accent)); color: var(--ink); background: var(--panel-3); }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------- Investigator offer grid ---------- */
/* Investigator boxes are large so the front and back art read clearly; the offer
   row wraps (2x2 for the default four offers) rather than shrinking the cards. */
/* auto-fit so a handful of investigator boxes stretch to fill the width instead of leaving
   empty tracks; doubled min for readability, so 2-3 large boxes per row. */
.inv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(600px, 1fr)); gap: 20px; }

/* ---------- Meter ---------- */

.meter { display: flex; flex-direction: column; gap: 5px; }
.meter .track { height: 8px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.meter .fill { height: 100%; background: var(--accent); transition: width 0.18s; }
.meter.over .fill { background: var(--bad); }
.meter.exact .fill { background: var(--good); }
.meter .label { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--ink-dim); }
.meter .label b { color: var(--ink); }

/* ---------- Sticky action bar ---------- */

.actionbar {
  position: sticky; bottom: 12px; z-index: 4;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 24px; padding: 14px 16px;
  background: rgba(9,12,10,0.98); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.actionbar .spacer { flex: 1; }

/* ---------- Home ---------- */

.home-hero { text-align: center; padding: 6vh 0 2vh; }
.home-hero h1 { font-size: 2.6rem; }
.home-hero .tagline { color: var(--ink-dim); max-width: 54ch; margin: 0 auto; font-size: 1.05rem; }
.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
@media (max-width: 620px) { .home-actions { grid-template-columns: 1fr; } }
.home-actions .card-action { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.home-actions .card-action h3 { margin: 0; }

.resume-list { display: flex; flex-direction: column; gap: 8px; }
.resume-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.resume-row .spacer { flex: 1; }
.resume-row code { font-family: var(--mono); color: var(--accent); }

/* ---------- Locked deck entries (signatures + random basic weakness) ---------- */
/* These sit at the top of the deck list: always included, non-removable, not counted
   toward deck size, and marked with a dashed border and a tag pill. */
.deck-locked { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.deck-locked-head { font-size: 0.7rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.4px; }
.deck-locked-row { border-style: dashed; }
.pill.locked { border-color: var(--line); color: var(--ink-dim); }
.wk-text { display: flex; flex-direction: column; line-height: 1.25; }

/* ---------- Upgrade log ---------- */

.log-list { display: flex; flex-direction: column; gap: 6px; }
.log-row { display: flex; gap: 8px; align-items: baseline; font-size: 0.85rem; padding: 6px 10px; background: var(--panel-2); border-radius: var(--radius-sm); border: 1px solid var(--line-soft); }
.log-row .who { font-weight: 600; }
.log-row .took { color: var(--good); }
.log-row .declined { color: var(--ink-faint); }

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

.empty-state { text-align: center; color: var(--ink-faint); padding: 30px 10px; font-size: 0.9rem; }
.divider { height: 1px; background: var(--line-soft); margin: 16px 0; }
.kbd { font-family: var(--mono); font-size: 0.8rem; background: var(--panel-3); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); }
.count-badge { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.xp-counter { display: inline-flex; align-items: center; gap: 8px; }
.xp-counter .val { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: center; }

.notes-list { font-size: 0.8rem; color: var(--warn); list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 3px; }

.link-btn { background: none; border: none; color: var(--accent); padding: 0; font-size: 0.85rem; cursor: pointer; }
.link-btn:hover { text-decoration: underline; background: none; }

/* We are not targeting tiny screens; keep narrow functional (headings, padding) but do
   not shrink the card grids to fight density. */
@media (max-width: 480px) {
  h1 { font-size: 1.7rem; }
  .home-hero h1 { font-size: 2.1rem; }
  .shell { padding: 0 12px 60px; }
  .topbar { padding: 10px 12px; }
}

/* ---------- Phase strip (clickable revisit step) ---------- */

.phase-strip .step.link { cursor: pointer; color: var(--ink-dim); }
.phase-strip .step.link:hover { color: var(--ink); border-color: var(--line); background: var(--panel-2); }

/* ---------- Body row + pools sidebar ---------- */

.app-body { display: flex; align-items: flex-start; gap: 18px; }
.screen-host { flex: 1 1 auto; min-width: 0; }
.sidebar-host { flex: 0 0 auto; }

.sidebar { position: sticky; top: 66px; }

.sidebar.is-open {
  width: 300px; max-height: calc(100vh - 84px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); overflow: hidden;
}
.sidebar-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
}
.sidebar-head h3 { margin: 0; font-size: 0.95rem; }
.sidebar-head .spacer { flex: 1; }
.sidebar-body { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 14px; }

.sidebar.is-collapsed .tab-toggle {
  writing-mode: vertical-rl; text-orientation: mixed;
  width: 38px; padding: 14px 0; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line-soft); color: var(--ink-dim);
  letter-spacing: 0.5px; font-size: 0.8rem;
}
.sidebar.is-collapsed .tab-toggle:hover { color: var(--ink); border-color: var(--accent); }

.sb-section { display: flex; flex-direction: column; gap: 7px; }
.sb-section .sb-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.82rem; font-weight: 600; color: var(--ink);
}
.sb-section .sb-title .count { color: var(--ink-faint); font-weight: 400; font-variant-numeric: tabular-nums; }
.sb-section .sb-sub { font-size: 0.74rem; color: var(--ink-dim); }
.sb-divider { height: 1px; background: var(--line-soft); }
.sb-inv-row { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--ink-dim); flex-wrap: wrap; }
.sb-inv-row .label { color: var(--ink-faint); }
.sb-offers { display: flex; flex-wrap: wrap; gap: 4px; }
.sb-pool { display: flex; flex-direction: column; gap: 3px; }
.sb-empty { font-size: 0.74rem; color: var(--ink-faint); font-style: italic; }

.mini-card { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; line-height: 1.25; }
.mini-card .mini-chip { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.mini-card .mini-name { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-card .mini-name:hover { text-decoration: underline; color: var(--accent); }
.mini-card .mini-lvl { margin-left: auto; color: var(--warn); font-variant-numeric: tabular-nums; flex: none; }
.mini-card .mini-thumb { width: 30px; height: 42px; flex: none; border-radius: 3px; overflow: hidden; background: var(--panel-3); position: relative; }
.mini-card .mini-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mini-chipname {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--cls, var(--line)); color: var(--ink-dim);
}
.mini-chipname .dotc { width: 7px; height: 7px; border-radius: 2px; background: var(--cls, var(--neutral)); }

.thumbs-toggle { font-size: 0.74rem; }

/* Per-section Expand control opens the full pool viewer. */
.sb-expand { margin-left: auto; font-size: 0.72rem; flex: none; }

/* Thumbnails-on pool: a two-up grid of readable card art (the default during the draft). */
.sb-thumb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sb-thumb { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sb-thumb-img {
  position: relative; display: block; width: 100%; aspect-ratio: 5 / 7;
  border-radius: 6px; overflow: hidden; background: var(--panel-3); border: 1px solid var(--line-soft);
}
.sb-thumb-img .band { position: absolute; top: 0; left: 0; right: 0; height: 5px; z-index: 0; }
.sb-thumb-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--panel-3); z-index: 1; }
.sb-thumb-foot { display: flex; align-items: baseline; gap: 5px; font-size: 0.72rem; min-width: 0; }
.sb-thumb-name { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.sb-thumb-name:hover { text-decoration: underline; color: var(--accent); }
.sb-thumb-lvl { color: var(--warn); flex: none; }
.sb-thumb-qty { color: var(--ink-dim); flex: none; }

/* Full-width pool viewer overlay: standard, fully readable tiles over the whole app,
   opened from a sidebar section's Expand control. The draft screen stays mounted beneath,
   so opening it never disturbs pick state. */
.pool-viewer-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center;
  padding: 24px; background: rgba(4, 7, 6, 0.72); overflow-y: auto;
}
.pool-viewer {
  width: 100%; max-width: 1800px; align-self: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100vh - 48px);
}
.pool-viewer-head {
  display: flex; align-items: baseline; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.pool-viewer-head h3 { margin: 0; font-size: 1rem; }
.pool-viewer-head .spacer { flex: 1; }
/* The viewer is a wide modal, so its tiles can be larger than the sidebar-constrained pack. */
.pool-viewer-grid { overflow-y: auto; padding: 16px; --card-min: 440px; }
@media (max-width: 560px) {
  .pool-viewer-overlay { padding: 0; }
  .pool-viewer { max-height: 100vh; border-radius: 0; }
}

/* On wide screens the sidebar docks and pushes content; on narrow screens it detaches
   to an overlay so it never forces horizontal scroll or shrinks the cards. Collapsed,
   it is just a small tab near the top-right; open, it is a full-height panel. */
@media (max-width: 1000px) {
  .sidebar-host { position: fixed; top: 0; right: 0; z-index: 20; }
  .sidebar { position: static; }
  .sidebar.is-open { height: 100vh; max-height: 100vh; border-radius: 0; box-shadow: var(--shadow); }
  .sidebar.is-collapsed { margin-top: 68px; margin-right: 8px; }
}
