/*
 * Realms Unbound — the table.
 *
 * Direction taken from the owner's existing dndcode UI: a low-light table rather than a
 * reference manual. Near-black with a green cast, amber for labels and structure, rust
 * for the one action that matters on a screen. Narrative is set in a book serif because
 * a scene should read like a scene; interface furniture is a workmanlike sans in small
 * caps so it stays out of the way.
 *
 * Accessibility is a requirement here, not polish (Mandate §39):
 *  - colour never carries meaning alone — every verdict and badge also has text;
 *  - focus is always visible and drawn outside the element so it is never clipped;
 *  - contrast holds against the dark ground, which is where dark themes usually fail;
 *  - motion is removed entirely under prefers-reduced-motion.
 *
 * This design commits to one visual world — a lit table in a dark room. There is no
 * light theme, deliberately, and every colour is painted explicitly so the page holds
 * whatever ground the browser puts behind it.
 */

:root {
  color-scheme: dark;

  /* Ground: near-black, faintly green, like a table lit by one lamp. */
  --ground: #16110e;
  --surface: #1d1714;
  --raised: #251d19;
  --sunken: #0c0908;

  --line: #35291f;
  --line-soft: #241c17;

  --ink: #ece3d4;
  --ink-dim: #a8998a;
  --ink-faint: #90857c;

  /* Amber carries structure — labels, eyebrows, section rules. */
  --amber: #c9a227;
  --amber-dim: #9d8742;
  /* Rust is the single primary action on any screen. Used sparingly on purpose. */
  --rust: #d86543;
  --rust-lit: #e8703f;
  /* words ON the rust: white on #d86543 is 3.58:1, under AA (device gate round three) */
  --on-rust: #170d08;

  --pass: #7fa650;
  --pass-bg: #1a2113;
  --fail: #e87f6e;
  --fail-bg: #2a1512;
  --unknown: #a5988b;
  --unknown-bg: #211a15;

  --focus: #86b8ff;

  --radius: 4px;
  --wrap: 78rem;
  --measure: 62ch;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background:
    /* two faint pools of light, so the ground is not a flat slab */
    radial-gradient(1100px 620px at 18% -10%, rgba(217,164,65,0.055), transparent 60%),
    radial-gradient(900px 520px at 88% 8%, rgba(194,72,31,0.045), transparent 62%),
    var(--ground);
  background-attachment: fixed;
  color: var(--ink);
  font-family: 'Spectral', Georgia, 'Times New Roman', serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* headings — Bitter */
h1, h2, h3, h4 {
  font-family: 'Bitter', Georgia, serif;
  font-weight: 700;
  letter-spacing: -.01em;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }

/* Interface furniture: small, uppercase, tracked. Never used for prose. */
.ui, nav, button, label, legend, .eyebrow, .badge, .chip, th,
input, select, textarea, .meta, .stats dt, .rail h2, .rail li span.count {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

a { color: var(--amber); text-decoration-color: var(--amber-dim); text-underline-offset: 2px; }
a:hover { color: var(--rust-lit); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--rust); color: var(--on-rust); padding: .6rem 1rem;
}
.skip-link:focus { left: 0; }

.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;
}

.eyebrow {
  font-size: .68rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--amber); margin: 0 0 .5rem;
}

/* ── masthead ──────────────────────────────────────────────────────────── */
.masthead { border-bottom: 1px solid var(--line-soft); }

.topbar {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 0; font-size: .74rem;
  letter-spacing: .16em; text-transform: uppercase;
}
.brand { font-weight: 700; color: var(--ink); letter-spacing: .2em; text-decoration: none; }
.brand em { font-style: normal; color: var(--rust-lit); margin-left: .35rem; }
.spacer { flex: 1; }
.session-tag { color: var(--ink-faint); letter-spacing: .14em; }

button.ghost {
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .45rem .9rem; font-size: .7rem; letter-spacing: .14em;
  text-transform: uppercase; cursor: pointer;
}
button.ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--amber-dim); }
button.ghost:disabled { opacity: .45; cursor: not-allowed; }

.hero { padding: 3rem 0 2.25rem; max-width: 44rem; }
.hero h1 {
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 1.06; letter-spacing: -0.015em; margin: 0 0 .9rem;
  text-wrap: balance; font-weight: 600;
}
.hero .lede { font-size: 1.12rem; color: var(--ink-dim); margin: 0 0 .85rem; max-width: var(--measure); }
.hero .lede strong { color: var(--ink); font-weight: 600; }
.note { color: var(--ink-faint); font-size: .875rem; margin: 0; }

/* ── the count strip ───────────────────────────────────────────────────── */
.stats {
  display: flex; flex-wrap: wrap; margin: 2rem 0 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.stats > div { flex: 1 1 7.5rem; padding: .75rem 1rem; border-right: 1px solid var(--line-soft); }
.stats > div:last-child { border-right: 0; }
.stats dt {
  font-size: .62rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 .2rem;
}
.stats dd {
  margin: 0; font-size: 1.3rem; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--amber);
}

/* ── main menu cards ───────────────────────────────────────────────────── */
.menu-section { padding: 2.5rem 0 1rem; }
.section-head {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem;
}
.section-head h2 {
  font-size: .72rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--amber); margin: 0; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-weight: 600;
}
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.cards { display: grid; gap: .85rem; grid-template-columns: 1fr; }
@media (min-width: 44rem) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 68rem) { .cards { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative;
  display: block; width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  /* The amber rail is the card's spine — it is what makes a grid read as a menu. */
  border-left: 2px solid var(--amber-dim);
  border-radius: var(--radius);
  padding: 1.1rem 3rem 1.15rem 1.15rem;
  color: inherit; font: inherit; text-decoration: none; cursor: pointer;
}
.card:hover { background: var(--raised); border-left-color: var(--amber); }
.card.is-live { border-left-color: var(--rust); }
.card[aria-disabled="true"] { cursor: not-allowed; opacity: .62; }
.card[aria-disabled="true"]:hover { background: var(--surface); border-left-color: var(--amber-dim); }

.card h3 {
  margin: 0 0 .35rem; font-size: 1.22rem; font-weight: 600;
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
}
.card p { margin: 0; color: var(--ink-faint); font-size: .93rem; line-height: 1.5; }
.card .key {
  position: absolute; right: .9rem; top: 1.15rem;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .66rem; letter-spacing: .1em; color: var(--ink-faint);
  border: 1px solid var(--line); border-radius: 3px; padding: .05rem .35rem;
}

/* State is always spelled out, never only coloured. */
.tag {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .58rem; letter-spacing: .14em; text-transform: uppercase;
  padding: .12rem .4rem; border-radius: 2px; border: 1px solid currentColor;
  white-space: nowrap;
}
.tag-live { color: var(--pass); background: var(--pass-bg); }
.tag-partial { color: var(--unknown); background: var(--unknown-bg); }
.tag-soon { color: var(--ink-faint); background: var(--sunken); }

/* ── tabs ──────────────────────────────────────────────────────────────── */
.tabs { margin-top: 2.25rem; }
[role="tablist"] { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); }
[role="tab"] {
  appearance: none; background: none; border: 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: .65rem 1rem; font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint); cursor: pointer;
}
[role="tab"][aria-selected="true"] { color: var(--amber); border-bottom-color: var(--rust); }
[role="tab"]:hover { color: var(--ink); }
[role="tabpanel"] { padding: 1.75rem 0 2.5rem; }
[role="tabpanel"]:focus { outline: none; }

/* ── forms ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
label, legend {
  display: block; font-size: .68rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--amber); margin-bottom: .35rem; font-weight: 600;
}
.help { color: var(--ink-faint); font-size: .85rem; margin: .35rem 0 0; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; }
.help-inline { text-transform: none; letter-spacing: 0; color: var(--ink-faint); font-weight: 400; }

input[type="search"], input[type="text"], input[type="number"], select, textarea {
  width: 100%; padding: .6rem .75rem;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .95rem;
  color: var(--ink); background: var(--sunken);
  border: 1px solid var(--line); border-radius: var(--radius);
}
input::placeholder { color: var(--ink-faint); }
textarea { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85rem; line-height: 1.5; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0 0 1rem; }
legend { padding: 0 .4rem; }

.check { display: inline-flex; align-items: center; gap: .45rem; margin-right: 1.25rem;
  font-size: .82rem; letter-spacing: .02em; text-transform: none; color: var(--ink-dim); font-weight: 400; }
.check input { width: auto; }
.inline-field { display: inline-flex; align-items: center; gap: .5rem;
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--amber); }
.inline-field select { width: auto; text-transform: none; letter-spacing: 0; color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 0; }

button.primary {
  background: var(--rust); color: #fff; border: 1px solid transparent;
  border-radius: var(--radius); padding: .6rem 1.4rem;
  font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  font-weight: 600; cursor: pointer;
}
button.primary:hover { background: var(--rust-lit); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: 0 1rem; }

/* ── results ───────────────────────────────────────────────────────────── */
.status { margin: 1rem 0 .75rem; color: var(--ink-faint); font-size: .9rem;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; }

.results-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
@media (min-width: 62rem) { .results-layout { grid-template-columns: minmax(0, 1fr) 23rem; } }

.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }

.result-btn {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--line);
  border-radius: var(--radius); padding: .7rem .9rem;
  color: inherit; font: inherit; cursor: pointer;
}
.result-btn:hover { background: var(--raised); border-left-color: var(--amber-dim); }
.result-btn[aria-current="true"] { border-left-color: var(--rust); background: var(--raised); }
.result-name { font-weight: 600; font-size: 1.05rem; }
.result-meta { display: block; margin-top: .2rem; color: var(--ink-faint); font-size: .78rem;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; letter-spacing: .02em; }

.badge {
  display: inline-block; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .58rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  padding: .1rem .38rem; border-radius: 2px; border: 1px solid currentColor;
  margin-left: .4rem; vertical-align: .12em;
}
.badge-full { color: var(--pass); background: var(--pass-bg); }
.badge-cat { color: var(--ink-faint); background: var(--sunken); }
.badge-verified { color: var(--amber); background: var(--unknown-bg); }
.badge-warn { color: var(--fail); background: var(--fail-bg); }

/* ── detail rail ───────────────────────────────────────────────────────── */
.detail {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; align-self: start;
}
.detail h2 { margin: 0 0 .75rem; font-size: .7rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--amber); font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; }
.detail h3 { margin: 0 0 .6rem; font-size: 1.3rem; font-weight: 600; }
.detail h4 { margin: 1rem 0 .5rem; font-size: .66rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--amber); font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  padding-top: .7rem; border-top: 1px solid var(--line-soft); }
.detail dl { display: grid; grid-template-columns: minmax(5.5rem, auto) 1fr;
  gap: .3rem .8rem; margin: 0; font-size: .88rem; }
.detail dt { color: var(--ink-faint); font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.statblock dt { text-transform: none; letter-spacing: 0; font-size: .8rem; color: var(--amber-dim); }

/* ── verdicts ──────────────────────────────────────────────────────────── */
.check-result { margin-top: 1.75rem; }
.verdict {
  display: inline-block; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-weight: 700; font-size: .8rem; letter-spacing: .16em;
  padding: .4rem 1rem; border-radius: var(--radius); border: 1px solid currentColor;
}
.verdict-legal { color: var(--pass); background: var(--pass-bg); }
.verdict-blocked { color: var(--fail); background: var(--fail-bg); }
.verdict-unproven { color: var(--unknown); background: var(--unknown-bg); }

.unknowns {
  margin: 1rem 0; padding: .8rem 1rem;
  background: var(--unknown-bg); border-left: 2px solid var(--unknown);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.unknowns h3 { margin: 0 0 .4rem; font-size: .68rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--unknown); font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; }
.unknowns ul { margin: 0; padding-left: 1.1rem; font-size: .9rem; }

pre.trace {
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem; overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .8rem; line-height: 1.55; color: var(--ink-dim);
}

.error {
  padding: .75rem 1rem; border-left: 2px solid var(--fail);
  background: var(--fail-bg); color: var(--fail);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .9rem;
}

/* ── footer ────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line-soft); padding: 1.5rem 0 3rem;
  color: var(--ink-faint); font-size: .85rem;
}
.site-footer strong { color: var(--ink-dim); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   The vault and the table
   ══════════════════════════════════════════════════════════════════════════
   Same world as the landing page — one lamp over a dark table — but the job is
   different. The landing page is read; these are operated. So: the situation comes
   first and largest, state is encoded in shape as well as colour (a clock is drawn
   as discrete segments because "5 of 6" is a different fact from "83%"), and the
   interface furniture recedes until it is needed.
   ────────────────────────────────────────────────────────────────────────── */

.hero-tight { padding: 2.25rem 0 1.75rem; }

.crumb {
  color: var(--ink-faint); text-decoration: none;
  letter-spacing: .16em; text-transform: uppercase; font-size: .72rem;
  padding-left: .9rem; margin-left: .3rem; border-left: 1px solid var(--line);
}
.crumb:hover { color: var(--amber); }

.vault-main { padding-block: 1.5rem 3rem; } /* block only: the shorthand zeroed .wrap's side gutter (phone walk, 2026-09-27) */

/* ── empty and signed-out states ───────────────────────────────────────── */
/* An empty vault is a normal state, not an error, so it gets a real panel that
   explains what a campaign is and offers the one action that resolves it. */
.empty-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--amber-dim); border-radius: var(--radius);
  padding: 1.6rem 1.75rem; margin: 1.5rem 0; max-width: 42rem;
}
.empty-panel h2 { margin: 0 0 .6rem; font-size: 1.5rem; font-weight: 600; }
.empty-panel p { margin: 0 0 1rem; color: var(--ink-dim); max-width: var(--measure); }
.empty-panel p:last-child { margin-bottom: 0; }

/* ── the campaign list ─────────────────────────────────────────────────── */
.campaign-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .85rem; grid-template-columns: 1fr;
}
@media (min-width: 56rem) { .campaign-list { grid-template-columns: repeat(2, 1fr); } }

.campaign-card {
  display: flex; flex-direction: column; gap: .45rem; height: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--rust); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; text-decoration: none; color: inherit;
}
.campaign-card:hover { background: var(--raised); border-left-color: var(--rust-lit); }
.campaign-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.campaign-head h3 { margin: 0; font-size: 1.35rem; font-weight: 600; color: var(--ink); }

.chip {
  font-size: .58rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--amber); border: 1px solid var(--amber-dim); background: var(--unknown-bg);
  border-radius: 2px; padding: .12rem .4rem; white-space: nowrap;
}

.campaign-where {
  margin: 0; color: var(--amber-dim); font-size: .78rem;
  letter-spacing: .1em; text-transform: uppercase;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
/* The scene is prose and set as prose, clamped so one long paragraph cannot make a
   card three times the height of its neighbour. */
.campaign-scene {
  margin: 0; color: var(--ink-dim); font-size: .98rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.campaign-meta {
  margin: auto 0 0; padding-top: .55rem; border-top: 1px solid var(--line-soft);
  display: flex; gap: 1rem; flex-wrap: wrap;
  color: var(--ink-faint); font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

/* ── create form ───────────────────────────────────────────────────────── */
.create-panel {
  margin: 1.75rem 0 0; padding: 1.5rem 1.75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--rust); border-radius: var(--radius);
  max-width: 52rem;
}
.create-panel h2 { margin: 0 0 1rem; font-size: 1.4rem; font-weight: 600; }
.form-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .5rem; }
.prose-input {
  font-family: "EB Garamond", Georgia, serif; font-size: 1.02rem; line-height: 1.55;
}

/* ── the table ─────────────────────────────────────────────────────────── */

/* The scene band is the page's thesis: where the party is standing, before anything
   else. It gets its own ground so it reads as the lit part of the table. */
.scene-band {
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(217,164,65,0.05), transparent 70%),
    var(--surface);
  padding: 2rem 0 2.25rem;
}
.scene-band h1 {
  margin: 0 0 .6rem; font-size: clamp(1.9rem, 4vw, 2.9rem);
  line-height: 1.08; font-weight: 600; letter-spacing: -0.012em; text-wrap: balance;
}
.scene-where {
  margin: 0 0 .9rem; color: var(--amber); font-size: .74rem;
  letter-spacing: .16em; text-transform: uppercase;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
.scene-text {
  margin: 0; max-width: var(--measure); font-size: 1.18rem; line-height: 1.6;
  color: var(--ink);
}

.table-layout { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); padding: 2rem 1.5rem 3rem; }
@media (min-width: 64rem) { .table-layout { grid-template-columns: minmax(0, 1fr) 20rem; } }

.table-main { display: flex; flex-direction: column; gap: 2.25rem; min-width: 0; }

/* ── the log ───────────────────────────────────────────────────────────── */
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }

.entry {
  border-left: 2px solid var(--line); padding: .2rem 0 .2rem 1rem;
}
/* Who is speaking is carried by the rail colour AND by the label, never colour alone. */
.entry-gm { border-left-color: var(--amber); }
.entry-action { border-left-color: var(--rust); }
.entry-beat { border-left-color: var(--line); }

.entry-head {
  margin: 0 0 .2rem; display: flex; gap: .7rem; align-items: baseline; flex-wrap: wrap;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .64rem; letter-spacing: .14em; text-transform: uppercase;
}
.entry-kind { color: var(--amber); font-weight: 600; }
.entry-gm .entry-kind { color: var(--amber); }
.entry-action .entry-kind { color: var(--rust-lit); }
.entry-author { color: var(--ink-dim); }
.entry-when { color: var(--ink-faint); }
.entry-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }

/* ── the hand-off ──────────────────────────────────────────────────────── */
.handoff textarea { margin-bottom: .25rem; }

/* ── dice ──────────────────────────────────────────────────────────────── */
.quick-rolls { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.1rem; }
button.quick {
  background: var(--sunken); color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .4rem .8rem; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
}
button.quick:hover:not(:disabled) { color: var(--ink); border-color: var(--amber-dim); background: var(--raised); }
button.quick:disabled { opacity: .5; cursor: progress; }

.roll-form { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 40rem) { .roll-form { grid-template-columns: 12rem minmax(0, 1fr); } }
.roll-form .form-actions { grid-column: 1 / -1; }
.roll-form .error { grid-column: 1 / -1; }

.rolls { list-style: none; margin: 1.25rem 0 .75rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.roll {
  display: flex; align-items: center; gap: .9rem;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--amber-dim); border-radius: var(--radius);
  padding: .5rem .8rem;
}
.roll-hidden { border-left-color: var(--fail); background: var(--sunken); }
.roll-total {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-weight: 600;
  font-size: 1.45rem; font-variant-numeric: tabular-nums;
  color: var(--amber); min-width: 2.6rem; text-align: right;
}
.roll-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.roll-head { display: flex; gap: .55rem; align-items: baseline; flex-wrap: wrap; }
.roll-expr {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .82rem; color: var(--ink);
}
.roll-purpose { font-size: .92rem; color: var(--ink-dim); }
.roll-detail, .roll-when {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .68rem;
  letter-spacing: .06em; color: var(--ink-faint);
}

/* ── the rail ──────────────────────────────────────────────────────────── */
.table-rail { display: flex; flex-direction: column; gap: 1.5rem; align-self: start; min-width: 0; }
@media (min-width: 64rem) { .table-rail { position: sticky; top: 1.5rem; } }

.rail-block {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.rail-block h2 {
  margin: 0 0 .8rem; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .66rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--amber); font-weight: 600;
}
.rail-block .note { font-size: .82rem; }

/* ── party ─────────────────────────────────────────────────────────────── */
.party { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.party-member { display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; align-items: baseline; }
.party-name { font-size: 1.02rem; font-weight: 600; }
.party-class {
  grid-column: 1; color: var(--ink-faint); font-size: .72rem;
  letter-spacing: .06em; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
.party-hp {
  grid-column: 2; grid-row: 1; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .72rem; font-variant-numeric: tabular-nums; letter-spacing: .04em;
}
/* Health is stated in numbers first; the bar only repeats what the text already says. */
.hp-well { color: var(--pass); }
.hp-hurt { color: var(--amber); }
.hp-bloodied { color: var(--fail); }
.hp-down { color: var(--fail); }
.hp-bar {
  grid-column: 1 / -1; height: 3px; background: var(--sunken);
  border-radius: 2px; overflow: hidden; margin-top: .2rem;
}
.hp-fill { display: block; height: 100%; background: currentColor; }

/* ── clocks ────────────────────────────────────────────────────────────── */
.clocks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.clock-head { margin: 0 0 .35rem; display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.clock-name { font-size: .96rem; font-weight: 600; }
.clock-count {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .72rem;
  font-variant-numeric: tabular-nums; color: var(--ink-faint); letter-spacing: .08em;
}
/* Discrete segments, because a clock is counted, not measured. */
.clock-track { display: flex; gap: 2px; }
.clock-seg { flex: 1; height: 6px; background: var(--sunken); border: 1px solid var(--line); border-radius: 1px; }
.clock-seg.is-filled { background: var(--amber); border-color: var(--amber); }
.clock-full .clock-seg.is-filled { background: var(--rust); border-color: var(--rust); }
.clock-full .clock-name { color: var(--rust-lit); }
.clock-consequence { margin: .4rem 0 0; font-size: .84rem; color: var(--ink-faint); line-height: 1.45; }
.clock-controls { margin: .4rem 0 0; display: flex; gap: .3rem; }
button.ghost.tiny {
  padding: .1rem .5rem; font-size: .8rem; line-height: 1.3; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

/* ── threads ───────────────────────────────────────────────────────────── */
.threads { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.thread-head { margin: 0; display: flex; gap: .45rem; align-items: baseline; flex-wrap: wrap; }
.thread-code {
  font-family: ui-monospace, Consolas, monospace; font-size: .68rem;
  color: var(--amber-dim); border: 1px solid var(--line); border-radius: 2px; padding: 0 .3rem;
}
.thread-title { font-size: .96rem; font-weight: 600; }
.thread-detail { margin: .2rem 0 0; font-size: .86rem; color: var(--ink-faint); line-height: 1.45; }

/* ── shared ────────────────────────────────────────────────────────────── */
.table-shell code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .85em; color: var(--amber); background: var(--sunken);
  border: 1px solid var(--line-soft); border-radius: 2px; padding: 0 .25rem;
}

/* The topbar is a single row until it cannot be. At 375px the brand, the crumb, the
   session tag and the sign-in button together overrun the viewport by a few pixels and
   push the whole page sideways — the classic dark-theme mobile bug, invisible on a
   desktop check. Wrapping costs a line of height and removes the sideways scroll. */
.topbar { flex-wrap: wrap; row-gap: .5rem; }
.session-tag { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 30rem) {
  .crumb { padding-left: 0; margin-left: 0; border-left: 0; }
  .topbar .spacer { flex-basis: 100%; height: 0; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Session zero — the setup flow
   ══════════════════════════════════════════════════════════════════════════
   A wizard, but not a form-filling one. Each step asks one question, states why it
   matters, and shows what the answer costs. The step rail is numbered because these
   really are a sequence — each step is a precondition for the next — which is the
   only case where numbered markers carry information rather than decoration.
   ────────────────────────────────────────────────────────────────────────── */

.setup { padding: 2rem 1.5rem 4rem; max-width: 58rem; }

.steps {
  display: flex; flex-wrap: wrap; gap: .35rem 1.4rem;
  list-style: none; margin: 0 0 2.5rem; padding: 0 0 1rem;
  border-bottom: 1px solid var(--line);
}
.steps li {
  display: flex; align-items: center; gap: .5rem;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
}
.step-n {
  display: grid; place-items: center;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  border: 1px solid var(--line); font-size: .7rem;
  font-variant-numeric: tabular-nums;
}
.steps .is-current { color: var(--amber); }
.steps .is-current .step-n { border-color: var(--amber); color: var(--amber); }
.steps .is-done { color: var(--ink-dim); }
.steps .is-done .step-n { border-color: var(--rust); color: var(--rust-lit); }

.step-panel h1 {
  margin: 0 0 .6rem; font-size: clamp(1.7rem, 3.6vw, 2.4rem);
  font-weight: 600; line-height: 1.12; text-wrap: balance;
}
.step-panel h1:focus { outline: none; }
.step-lede {
  margin: 0 0 1.8rem; color: var(--ink-dim);
  font-size: 1.05rem; max-width: var(--measure);
}
.step-panel fieldset { margin-bottom: 1.5rem; }

/* ── choice cards ──────────────────────────────────────────────────────── */
/* Real radios underneath: arrow-key navigation and the control role come free. */
.choice-grid { display: grid; gap: .6rem; grid-template-columns: 1fr; margin-bottom: 1.5rem; }
@media (min-width: 46rem) { .choice-grid { grid-template-columns: repeat(2, 1fr); } }
.choice-grid.tight { gap: .4rem; }
@media (min-width: 46rem) { .choice-grid.tight { grid-template-columns: repeat(3, 1fr); } }

.choice {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem; cursor: pointer;
  font-family: "EB Garamond", Georgia, serif;
  text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 400;
  margin: 0;
}
.choice:hover { background: var(--raised); border-left-color: var(--amber-dim); }
.choice.is-chosen { border-left-color: var(--rust); background: var(--raised); }
.choice input { margin: .35rem 0 0; accent-color: var(--rust); width: auto; flex: none; }
.choice-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.choice-title {
  font-size: 1.02rem; font-weight: 600; display: flex;
  align-items: baseline; gap: .5rem; flex-wrap: wrap;
}
.choice-count {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .6rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--amber);
  border: 1px solid var(--amber-dim); border-radius: 2px; padding: .05rem .35rem;
  font-variant-numeric: tabular-nums;
}
.choice-note { color: var(--ink-faint); font-size: .9rem; line-height: 1.45; }

/* ── the book picker ───────────────────────────────────────────────────── */
.book-list {
  list-style: none; margin: 0; padding: 0; max-height: 26rem; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken);
}
.book-row {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: .6rem;
  align-items: center; padding: .4rem .8rem;
  border-bottom: 1px solid var(--line-soft); cursor: pointer;
  font-family: "EB Garamond", Georgia, serif; text-transform: none;
  letter-spacing: 0; color: var(--ink); font-weight: 400; margin: 0; font-size: .95rem;
}
.book-row:last-child { border-bottom: 0; }
.book-row:hover { background: var(--raised); }
.book-row input { width: auto; accent-color: var(--rust); }
.book-title { overflow-wrap: anywhere; }
/* The grade is a letter, so it needs a tooltip and a shape, not just a colour. */
.book-auth {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .6rem; font-weight: 600;
  letter-spacing: .1em; border: 1px solid currentColor; border-radius: 2px;
  padding: 0 .3rem; cursor: help;
}
.auth-A, .auth-B { color: var(--pass); }
.auth-C, .auth-D, .auth-E { color: var(--amber); }
.auth-F, .auth-G { color: var(--ink-faint); }
.auth-H, .auth-X { color: var(--fail); }
.book-records {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .7rem;
  color: var(--ink-faint); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right;
}

/* ── review ────────────────────────────────────────────────────────────── */
.review {
  display: grid; grid-template-columns: minmax(8rem, auto) 1fr; gap: .5rem 1.2rem;
  margin: 0 0 2rem; padding: 1.1rem 1.25rem;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--amber-dim); border-radius: var(--radius);
}
.review dt {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .66rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint);
}
.review dd { margin: 0; overflow-wrap: anywhere; }

/* ── step navigation ───────────────────────────────────────────────────── */
.step-nav {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line);
}
.step-nav .spacer { flex: 1; }
.step-hint {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .8rem; color: var(--unknown);
}

/* ── session zero at the table ─────────────────────────────────────────── */
.session-zero {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--rust); border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
}
.sz-lede { margin: 0 0 1.25rem; color: var(--ink-dim); max-width: var(--measure); }
.session-zero .choice { font-size: .95rem; padding: .7rem .85rem; }
.session-zero .choice-note { font-size: .84rem; }

/* Where a character came from, on the party rail. Never colour alone — the word is the
   signal and the tint only reinforces it. */
.party-origin {
  grid-column: 1 / -1; justify-self: start;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .58rem;
  letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: 2px; padding: 0 .3rem;
}
.origin-imported { color: var(--unknown); }
.origin-pregen   { color: var(--ink-faint); }
.origin-sketch   { color: var(--ink-faint); }

/* ── the frame, in the rail ────────────────────────────────────────────── */
.frame-facts {
  display: grid; grid-template-columns: minmax(4.5rem, auto) 1fr;
  gap: .3rem .7rem; margin: 0; font-size: .86rem;
}
.frame-facts dt {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: .62rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint);
}
.frame-facts dd { margin: 0; color: var(--ink-dim); overflow-wrap: anywhere; }

/* A campaign still in setup, on its vault card. */
.chip-setup { color: var(--unknown); border-color: var(--unknown); background: var(--unknown-bg); }

/* Anchors styled as buttons need the button's own reset, since `a` sets colour. */
a.ghost, a.primary { display: inline-block; text-decoration: none; }
a.ghost { color: var(--ink-dim); }
a.ghost:hover { color: var(--ink); border-color: var(--amber-dim); }
a.primary { color: #fff; }
a.primary:hover { color: #fff; }

/* ── the world behind a campaign card ──
   Chosen by the campaign's own scene keywords — the same judgement the play
   screen makes, from the same module. Decoration, marked aria-hidden, behind
   a scrim so the card's text never fights the paint. */
.campaign-card { position: relative; overflow: hidden; isolation: isolate; }
.campaign-art { position: absolute; inset: 0; z-index: -2; }
.campaign-art img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 30%;
  filter: saturate(.7) brightness(.8);
}
.campaign-card::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(to right, rgba(12,9,8,.92) 0%, rgba(12,9,8,.82) 55%, rgba(12,9,8,.55) 100%);
}

/* ── the vault's quick start ── */
.qs-card { width: 100%; text-align: left; cursor: pointer; border-color: var(--gold-dim); }
.qs-card:hover:not(:disabled) { border-color: var(--gold); }
.qs-card:disabled { opacity: .7; cursor: progress; }
.qs-tag {
  font-family: var(--data); font-size: .6rem; letter-spacing: .14em;
  color: var(--ember); border: 1px solid var(--ember); padding: .2rem .5rem; border-radius: 3px;
}

/* PLAYABILITY QA 2026-09-25: the ready-made card sits below the player's own campaigns, under its own heading. */
.campaign-list .list-break { list-style: none; margin: 1.4rem 0 .2rem; }
.campaign-list .list-break h3 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; opacity: .75; margin: 0; }

/* The player's chosen look (public/prefs.js, 2026-09-25): the same light palette realms.css
   carries, in this sheet's own token names. */
:root[data-theme="light"] {
  color-scheme: light;
  --ground: #f5efe4; --surface: #fbf7f0; --raised: #ffffff; --sunken: #ebe3d5;
  --line: #d2c4ae; --line-soft: #e3d9c8;
  --ink: #231a12; --ink-dim: #5e4f40; --ink-faint: #665849;
  --amber: #795c0b; --amber-dim: #725e28; --rust: #a63d1c; --rust-lit: #9a3a18; --on-rust: #ffffff;
  --pass: #436a23; --pass-bg: #e3ecd6; --fail: #a3322a; --fail-bg: #f4dcd6;
  --unknown: #61574c; --unknown-bg: #ece4d8; --focus: #2f6fb0;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="device"] {
    color-scheme: light;
    --ground: #f5efe4; --surface: #fbf7f0; --raised: #ffffff; --sunken: #ebe3d5;
    --line: #d2c4ae; --line-soft: #e3d9c8;
    --ink: #231a12; --ink-dim: #5e4f40; --ink-faint: #665849;
    --amber: #795c0b; --amber-dim: #725e28; --rust: #a63d1c; --rust-lit: #9a3a18; --on-rust: #ffffff;
    --pass: #436a23; --pass-bg: #e3ecd6; --fail: #a3322a; --fail-bg: #f4dcd6;
    --unknown: #61574c; --unknown-bg: #ece4d8; --focus: #2f6fb0;
  }
}
:root[data-text-size="small"] body { zoom: 0.9; }
:root[data-text-size="large"] body { zoom: 1.15; }

/* On a touch screen every control is a finger's target, 44 CSS pixels at least (phone and
   tablet walks, 2026-09-27). The same rule realms.css carries for the pages that load it. */
@media (pointer: coarse) {
  .brand, #signin, #new-campaign, footer a, .btn {
    min-height: 44px; display: inline-flex; align-items: center;
  }
}
@media (pointer: coarse) { footer a { min-width: 44px; justify-content: center; } }

/* The account link in the campaign list's header: 21px tall under a finger (device gate round
   two, 2026-09-29). */
@media (pointer: coarse) {
  .session-tag-link { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ── label floor (generated by tools/label-floor.mjs; do not edit by hand) ── */
@media (pointer: coarse) {
  .note,
  .card p,
  .help,
  input[type="search"], input[type="text"], input[type="number"], select, textarea,
  textarea,
  .check,
  .status,
  .result-meta,
  .detail dl,
  .statblock dt,
  .unknowns ul,
  pre.trace,
  .error,
  .site-footer,
  .campaign-scene,
  .roll-expr,
  .roll-purpose,
  .rail-block .note,
  .party-hp,
  .clock-name,
  .clock-consequence,
  button.ghost.tiny,
  .thread-code,
  .thread-title,
  .thread-detail,
  .step-n,
  .choice-note,
  .book-row,
  .book-records,
  .step-hint,
  .session-zero .choice,
  .session-zero .choice-note,
  .frame-facts { font-size: 1rem; }
  .table-shell code { font-size: max(1rem, .85em); }
}
@media (pointer: coarse) {
  .eyebrow,
  .topbar,
  button.ghost,
  .stats dt,
  .section-head h2,
  .card .key,
  [role="tab"],
  label, legend,
  .inline-field,
  button.primary,
  .badge,
  .detail h2,
  .detail h4,
  .detail dt,
  .verdict,
  .unknowns h3,
  .crumb,
  .campaign-where,
  .campaign-meta,
  .scene-where,
  .entry-head,
  button.quick,
  .roll-detail, .roll-when,
  .rail-block h2,
  .party-class,
  .clock-count,
  .steps li,
  .choice-count,
  .book-auth,
  .review dt,
  .party-origin,
  .frame-facts dt,
  .qs-tag,
  .campaign-list .list-break h3 { font-size: 1rem; letter-spacing: .05em; }
  .tag,
  .chip { font-size: 1rem; letter-spacing: .05em; white-space: normal; overflow-wrap: break-word; }
}
@media (pointer: fine) {
  .help,
  textarea,
  .check,
  .result-meta,
  .statblock dt,
  pre.trace,
  .site-footer,
  .roll-expr,
  .rail-block .note,
  .party-hp,
  .clock-consequence,
  button.ghost.tiny,
  .thread-code,
  .thread-detail,
  .step-n,
  .book-records,
  .step-hint,
  .session-zero .choice-note,
  .frame-facts { font-size: .875rem; }
  .table-shell code { font-size: max(.875rem, .85em); }
}
@media (pointer: fine) {
  .eyebrow,
  .topbar,
  button.ghost,
  .stats dt,
  .section-head h2,
  .card .key,
  [role="tab"],
  label, legend,
  .inline-field,
  button.primary,
  .badge,
  .detail h2,
  .detail h4,
  .detail dt,
  .verdict,
  .unknowns h3,
  .crumb,
  .campaign-where,
  .campaign-meta,
  .scene-where,
  .entry-head,
  button.quick,
  .roll-detail, .roll-when,
  .rail-block h2,
  .party-class,
  .clock-count,
  .steps li,
  .choice-count,
  .book-auth,
  .review dt,
  .party-origin,
  .frame-facts dt,
  .qs-tag,
  .campaign-list .list-break h3 { font-size: .875rem; letter-spacing: .05em; }
  .tag,
  .chip { font-size: .875rem; letter-spacing: .05em; white-space: normal; overflow-wrap: break-word; }
}
/* ── end label floor ── */
