/* Dungeon Master v0.4 — unified dark theme.
 *
 * Single source of truth for the application chrome. Mirrors the
 * harness palette in `static/harness/dashboard.css` so every page
 * (catalog, play, spectator, auth, landing) reads as the same app.
 *
 * Conventions:
 *   --bg     : page background (deepest)
 *   --panel  : card/topbar background
 *   --border : low-contrast separator
 *   --text   : primary copy
 *   --muted  : labels, hints, secondary copy
 *   --accent : interactive accent (links, primary buttons, active outlines)
 *   --good   : success / positive numbers
 *   --warn   : warnings / amber metrics
 *   --bad    : destructive / negative numbers
 *
 * Type stack:
 *   --font-sans    : Geist Sans  — body, UI chrome, headings
 *   --font-mono    : JetBrains Mono — IDs, dice, JSON, KPI numerals
 *   --font-display : Cormorant Garamond — entity-name <h1> only,
 *                    for sourcebook flavor on friendly catalog views.
 *
 * Responsive breakpoints (standardized):
 *   mobile  : max-width: 640px
 *   tablet  : 641px to 1023px
 *   desktop : min-width: 1024px
 */

:root {
  /* Candlelit Grimoire — warm ink-black base, ember + gold accents.
     The cold GitHub-dark slate/blue was retired for an atmospheric
     dark-fantasy key. Component classes are unchanged; only the tokens
     (and the atmosphere layer at the foot of this file) carry the theme. */
  --bg: #0c0a07;          /* deepest page — warm ink black */
  --bg-2: #120d09;        /* subtly raised */
  --panel: #17120c;       /* cards / topbar — aged vellum-dark */
  --panel-2: #1e1710;     /* nested raised panel */
  --border: #3a2e1d;      /* brass-shadow separator */
  --border-soft: #2a2115; /* faint inner separators */
  --text: #ece1cb;        /* parchment */
  --muted: #9a8a6e;       /* aged paper / secondary */
  --accent: #e0792c;      /* EMBER — primary interactive */
  --accent-rgb: 224, 121, 44;
  --gold: #c9a227;        /* BRASS/GOLD — display headings, active, highlights */
  --gold-rgb: 201, 162, 39;
  --good: #3fb950;        /* success (kept; reads fine on warm black) */
  --warn: #d29922;        /* amber */
  --bad: #f85149;         /* danger */

  --glow-ember: 0 0 18px -4px rgba(var(--accent-rgb), 0.55);
  --glow-gold: 0 0 16px -5px rgba(var(--gold-rgb), 0.5);

  --font-sans: "Geist Sans", "Geist", ui-sans-serif, system-ui, -apple-system,
               BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono",
               Menlo, Consolas, monospace;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;

  --ease-soft: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

code, .mono, .font-mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-ligatures: none;
}

h1, h2, h3, h4 {
  color: var(--text);
  margin: 0 0 8px 0;
  font-weight: 600;
  font-family: var(--font-sans);
}
h1 { font-size: 24px; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
h3 { font-size: 14px; }

p { margin: 0 0 8px 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

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

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar-brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.topbar-brand:hover { text-decoration: none; color: var(--accent); }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
}

.topbar-nav a {
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color 160ms var(--ease-soft), border-color 160ms var(--ease-soft);
}

.topbar-nav a:hover {
  color: var(--accent);
  border-color: var(--border);
  text-decoration: none;
}

.topbar-form {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}

/* Mobile drawer toggle (hamburger). Hidden on >=tablet, revealed on
   mobile via the @media block below. The drawer state is held by a
   visually-hidden checkbox so the layout works without JS; a tiny
   inline <script> in base.html mirrors :checked into aria-expanded
   and closes the drawer when a nav link is tapped. */
.topbar-toggle {
  display: none;
  margin-left: auto;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.topbar-toggle:hover { border-color: var(--accent); color: var(--accent); }
.topbar-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

.campaign-strip {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.campaign-strip-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  flex-wrap: wrap;
}

.campaign-strip code {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: 4px;
}

main.app-main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

footer.app-footer {
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

footer.app-footer .footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.footer-tag { color: var(--muted); font-size: 12px; white-space: nowrap; }
.fleet-panel .fleet-host { margin-right: 12px; }

/* ---------- Panel primitive -------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
}

.panel + .panel { margin-top: 14px; }

.panel h2,
.panel-title {
  margin: 0 0 10px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.panel-meta {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}

.panel-link {
  font-size: 12px;
  color: var(--muted);
}

.panel-link:hover { color: var(--accent); }

/* ---------- KPI cards -------------------------------------------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.kpi {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}

.kpi label, .kpi .kpi-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
  font-family: var(--font-sans);
}

.kpi span, .kpi .kpi-value {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kpi .kpi-value.good { color: var(--good); }
.kpi .kpi-value.warn { color: var(--warn); }
.kpi .kpi-value.bad  { color: var(--bad); }

/* ---------- Status pills ----------------------------------------- */

.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--border);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.6;
  transition: filter 160ms var(--ease-soft);
}

.status-pill:hover { filter: brightness(1.05); }

/* Sub-location placement overlay (Atlas studio) */
.plate-frame { position: relative; }
.claimed-layer { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.claimed-layer .claimed {
  fill: rgba(231,200,121,.16); stroke: rgba(231,200,121,.9); stroke-width: .5;
  pointer-events: none;          /* display-only; navigate via the cards below */
}
.claimed-layer .draw-poly { fill: rgba(216,178,90,.18); stroke: #d8b25a; stroke-width: .6; }
.claimed-layer .place-marker { fill: rgba(216,178,90,.5); stroke: #d8b25a; stroke-width: .4; }
.place-mode { font-size: 12px; color: var(--muted); display: inline-flex; gap: 10px; align-items: center; }
.place-mode label { display: inline-flex; gap: 3px; align-items: center; cursor: pointer; }
.btn-mini { font-size: 11px; padding: 1px 8px; }
.type-tip { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.add-error { color: var(--bad); font-size: 13px; margin: 6px 0; }
.add-hint { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* Switchboard fleet panel (global footer) */
.fleet-panel { font-size: 11px; color: var(--muted); cursor: pointer; text-align: right; }
.fleet-panel .fleet-host { display: inline-block; }
.fleet-panel .status-pill { font-size: 10px; padding: 1px 6px; text-transform: none; }

.status-pill.live,
.status-pill.running { background: var(--accent); color: var(--bg); }
.status-pill.done,
.status-pill.good    { background: var(--good); color: var(--bg); }
.status-pill.warn    { background: var(--warn); color: var(--bg); }
.status-pill.error,
.status-pill.bad     { background: var(--bad); color: var(--bg); }

.status-pill.canonical { background: var(--border); color: var(--muted); }
.status-pill.override  { background: var(--accent); color: var(--bg); }
.status-pill.hide      { background: var(--bad); color: var(--bg); }
.status-pill.new       { background: var(--good); color: var(--bg); }
.status-pill.variant   {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Pills that hold human-readable book titles (after the source-id →
   title rewrite) need to behave on long strings without breaking the
   header / list / search rows they sit in. Cap width with an ellipsis
   and drop the all-caps treatment that worked for short tokens like
   ``PHB`` but reads poorly for "Tasha's Cauldron of Everything".
   The id stays available on hover via the ``title`` attribute, so
   readability is preserved at no cost. */
.status-pill.variant,
.status-pill.source,
.variant-pill,
a.variant-pill,
.variant-chip,
a.variant-chip {
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  vertical-align: middle;
}

/* Compact source modifier — used in dense table cells (search
   results, list rows) where vertical room is at a premium. */
.status-pill.source {
  max-width: 24ch;
}

/* Tagged-id pills carry a small inline source chip showing where
   the referenced entity came from (PHB / TCoE / MPMM / …). The
   chip inherits the pill's background but adds a colored stripe
   on the right edge so multi-source lists scan visually at a
   glance. */
.tagged-pill { display: inline-flex; align-items: center; gap: 6px; }
.tagged-pill .source-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  line-height: 1.4;
}
/* Source-specific tints — accent for the most common patches, muted
   for base sources. Match on the ``data-token`` attribute the
   templates stamp on the chip; the chip's ``title`` attribute now
   carries a free-text "From <book title>" string, so it can't be
   used as a selector key. Unknown tokens fall back to the default
   chip colour. */
.tagged-pill .source-chip[data-token="PHB"],
.tagged-pill .source-chip[data-token="MM"],
.tagged-pill .source-chip[data-token="DMG"] {
  color: var(--muted);
  border-color: var(--border);
}
.tagged-pill .source-chip[data-token="XGTE"],
.tagged-pill .source-chip[data-token="TCOE"],
.tagged-pill .source-chip[data-token="MPMM"],
.tagged-pill .source-chip[data-token="MTOF"],
.tagged-pill .source-chip[data-token="VRGTR"],
.tagged-pill .source-chip[data-token="SCAG"],
.tagged-pill .source-chip[data-token="JTRC"] {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.08);
}

/* ---------- Variants strip (header) + chip strip (list) --------- */

.variants-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: -6px 0 14px 0;
  font-size: 12px;
}

.variants-strip .variants-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-right: 4px;
}

.variant-pill,
a.variant-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: border-color 160ms var(--ease-soft),
              color 160ms var(--ease-soft);
}

a.variant-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.variant-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

/* List-view inline chips — slightly smaller, sit next to the name. */
.variant-chips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  vertical-align: middle;
}

.variant-chip,
a.variant-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: border-color 160ms var(--ease-soft),
              color 160ms var(--ease-soft);
}

a.variant-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.variant-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.variant-compare {
  position: relative;
  margin-left: 4px;
}
.variant-compare > summary { list-style: none; cursor: pointer; }
.variant-compare > summary::-webkit-details-marker { display: none; }
.variant-compare-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 4;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  box-shadow: 0 8px 18px -10px rgba(0, 0, 0, 0.6);
}
.variant-compare-menu a {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
}
.variant-compare-menu a:hover {
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Chain strip (composition layers) -------------------- */

.chain-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: -6px 0 14px 0;
  font-size: 12px;
}

.chain-strip .chain-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-right: 4px;
}

.chain-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 4px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Numbered prefix on each chain chip — the "1", "2", "3" badges
   that make ordering scannable. */
.chain-chip-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

/* Tiny role caption inside the chip — "base" / "mid" / "top" — so
   the chain orientation isn't carried only by border colour. */
.chain-chip-role {
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0.7;
  margin-left: 2px;
  text-transform: lowercase;
}

/* Arrow rendered between chips. Pure visual cue for direction. */
.chain-arrow {
  color: var(--muted);
  opacity: 0.55;
  font-size: 14px;
  font-weight: 500;
  user-select: none;
  margin: 0 -2px;
}

.chain-chip.is-base {
  border-style: dashed;
  border-color: var(--border);
}

.chain-chip.is-mid {
  /* Mid layers in a 3+ chain — neutral but still clearly between
     base and top. */
  border-color: var(--border);
}

.chain-chip.is-top {
  border-color: var(--accent);
  color: var(--accent);
}

.chain-chip.is-top .chain-chip-index {
  background: var(--accent);
  color: var(--bg);
}

.chain-chip-remove,
a.chain-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  text-decoration: none;
  background: transparent;
  border: 0;
  margin-left: 2px;
  transition: color 160ms var(--ease-soft),
              background 160ms var(--ease-soft);
}

a.chain-chip-remove:hover {
  color: var(--bad);
  background: rgba(248, 81, 73, 0.12);
  text-decoration: none;
}

.chain-add {
  position: relative;
}
.chain-add > summary { list-style: none; cursor: pointer; }
.chain-add > summary::-webkit-details-marker { display: none; }

.chain-add-toggle {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.chain-add-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chain-add-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 4;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-width: 140px;
  box-shadow: 0 8px 18px -10px rgba(0, 0, 0, 0.6);
}
.chain-add-menu a {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
}
.chain-add-menu a:hover {
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
}

a.chain-reset {
  font-size: 11px;
  color: var(--muted);
  text-decoration: underline dotted;
  margin-left: 4px;
}
a.chain-reset:hover { color: var(--accent); }

/* ---------- Per-field source badge ------------------------------- */

.field-source {
  display: inline-block;
  padding: 0 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--border);
  color: var(--muted);
  border: 1px solid transparent;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.6;
}

.field-source.is-modified {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

.field-source.is-small {
  font-size: 8px;
  padding: 0 4px;
  margin-left: 4px;
}

/* ---------- Per-list-element layer stripe ----------------------- */

.layer-stripe {
  position: relative;
  padding-left: 10px;
  border-left: 3px solid var(--muted);
  /* Subtle inset so the stripe sits inside the panel padding without
     overlapping the panel border. */
  margin-left: 0;
}

.layer-stripe--from-base { border-left-color: var(--border); }
.layer-stripe--from-patch { border-left-color: var(--accent); }

/* When the stripe wraps a <tr>, the border-left only applies to the
   leading <td>; ::before takes over to draw a continuous bar across
   the row's vertical extent. */
tr.layer-stripe { border-left: 0; padding-left: 0; }
tr.layer-stripe > td:first-child {
  border-left: 3px solid var(--muted);
  padding-left: 10px;
}
tr.layer-stripe--from-base > td:first-child { border-left-color: var(--border); }
tr.layer-stripe--from-patch > td:first-child { border-left-color: var(--accent); }

/* ---------- Diff highlight wrappers (variant compare) ----------- */

.diff-add {
  display: inline-block;
  border-left: 3px solid var(--good);
  background: rgba(63, 185, 80, 0.08);
  padding-left: 6px;
}

.diff-rm {
  text-decoration: line-through;
  color: var(--bad);
  background: rgba(248, 81, 73, 0.08);
}

.diff-change {
  background: rgba(210, 153, 34, 0.18);
  border-radius: 3px;
  padding: 0 3px;
}

.compare-summary { margin-bottom: 14px; }

/* ---------- Compare card grid ----------------------------------- */

.compare-summary .compare-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.compare-summary .diff-group { margin-top: 16px; }
.compare-summary .diff-group:first-of-type { margin-top: 8px; }

.compare-summary .diff-group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px 0;
}

.compare-summary .diff-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 800px) {
  .compare-summary .diff-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.compare-summary .diff-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  border-left-width: 3px;
}

.compare-summary .diff-card-change { border-left-color: var(--warn); }
.compare-summary .diff-card-add    { border-left-color: var(--good); }
.compare-summary .diff-card-rm     { border-left-color: var(--bad); }

.compare-summary .diff-card-path {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.compare-summary .path-token {
  color: var(--text);
}
.compare-summary .path-sep {
  color: var(--border);
  font-weight: 700;
  opacity: 0.6;
}
.compare-summary .path-index {
  color: var(--muted);
  font-size: 10px;
  background: var(--panel);
  padding: 0 4px;
  border-radius: 3px;
}

.compare-summary .diff-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  line-height: 1;
}
.compare-summary .diff-card-add  .diff-glyph { background: rgba(63, 185, 80, 0.18); color: var(--good); }
.compare-summary .diff-card-rm   .diff-glyph { background: rgba(248, 81, 73, 0.18); color: var(--bad); }

.compare-summary .diff-card-bodies {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: start;
}

.compare-summary .diff-card-bodies-single {
  grid-template-columns: 1fr;
}

.compare-summary .diff-card-side {
  background: var(--panel);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12.5px;
  word-break: break-word;
  min-width: 0;
}

.compare-summary .diff-card-label {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 4px;
}

.compare-summary .diff-card-arrow {
  color: var(--warn);
  font-weight: 700;
  align-self: center;
  font-family: var(--font-mono, monospace);
}

.compare-summary .diff-card-before .diff-value {
  text-decoration: line-through;
  color: var(--muted);
}

.compare-summary .diff-card-after .diff-value,
.compare-summary .diff-card-add .diff-value {
  color: var(--text);
}

.compare-summary .diff-card-rm .diff-value {
  color: var(--bad);
  text-decoration: line-through;
}

.compare-summary .diff-value-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 8px;
  border-left: 1px dotted var(--border);
}
.compare-summary .diff-value-list li {
  margin: 2px 0;
}

@media (max-width: 640px) {
  .compare-summary .diff-card-bodies {
    grid-template-columns: 1fr;
  }
  .compare-summary .diff-card-arrow {
    transform: rotate(90deg);
    align-self: flex-start;
    margin: 2px 0;
  }
}

/* ---------- Helpers ---------------------------------------------- */

.muted { color: var(--muted); }
.muted-i { color: var(--muted); font-style: italic; }
.right { text-align: right; }
.center { text-align: center; }

.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-baseline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.crumbs {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 13px;
}

.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); text-decoration: none; }
.crumbs .sep { color: var(--border); }
.crumbs h1 { font-size: 22px; margin: 0; }

/* Display-font entity name on friendly entity-detail views. The
   _header.html partial wraps the entity <h1> in .entity-name so
   only the catalog "what is this thing?" headers get the serif
   treatment; admin/raw/edit views keep the standard sans h1. */
.entity-name {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  font-size: 30px;
  line-height: 1.1;
  color: var(--text);
}

/* ---------- Buttons + inputs ------------------------------------- */

.btn,
button.btn,
a.btn {
  display: inline-block;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  font-family: var(--font-sans);
  transition: border-color 160ms var(--ease-soft),
              color 160ms var(--ease-soft),
              transform 80ms var(--ease-soft);
}

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

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-good {
  background: var(--good);
  color: var(--bg);
  border-color: var(--good);
  font-weight: 600;
}
.btn-good:hover { opacity: 0.85; color: var(--bg); }

.btn-bad {
  background: var(--bad);
  color: var(--bg);
  border-color: var(--bad);
  font-weight: 600;
}
.btn-bad:hover { opacity: 0.85; color: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--border); }

.field,
input[type="text"].field,
input[type="search"].field,
input[type="number"].field,
input[type="password"].field,
select.field,
textarea.field {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  width: 100%;
  outline: none;
  transition: border-color 160ms var(--ease-soft);
}

.field:focus { border-color: var(--accent); }

textarea.field { font-family: var(--font-mono); font-size: 12px; line-height: 1.5; }

/* ── Instrument control bars ─────────────────────────────────────────────────
   Toolbars for the document reader + extraction pages. Controls are grouped
   into flush "capsules" (.seg) divided by hairline brass rules, like the bezel
   controls on an antique instrument. One fixed height (--ctl-h) governs EVERY
   element so buttons, inputs, and readouts align to a single baseline; each
   capsule is a non-wrapping unit, so a bar wraps only between groups, never
   mid-control. */
:root { --ctl-h: 34px; }

.ctlbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
/* Any .btn dropped into a control bar matches the capsule height exactly. */
.ctlbar .btn {
  height: var(--ctl-h); display: inline-flex; align-items: center;
  box-sizing: border-box; line-height: 1; white-space: nowrap;
}

.seg {
  display: inline-flex; align-items: stretch; height: var(--ctl-h);
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); overflow: hidden; flex-wrap: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03), 0 1px 2px rgba(0, 0, 0, .35);
}
.seg > * {
  display: inline-flex; align-items: center; justify-content: center;
  height: 100%; box-sizing: border-box; margin: 0; border: 0; border-radius: 0;
  background: transparent; font: 500 13px/1 var(--font-sans); white-space: nowrap;
}
.seg > * + * { border-left: 1px solid var(--border-soft); }   /* single hairline divider */

.seg-btn { padding: 0 14px; color: var(--text); cursor: pointer;
  transition: color .15s var(--ease-soft), background .15s var(--ease-soft); }
.seg-btn:hover:not([disabled]) { color: var(--accent); background: rgba(var(--accent-rgb), .10); }
.seg-btn:active:not([disabled]) { background: rgba(var(--accent-rgb), .18); }
.seg-btn[disabled] { opacity: .3; cursor: default; }
.seg-btn.active { background: var(--gold); color: #0c0a07; font-weight: 600;
  box-shadow: inset 0 0 14px -6px rgba(0, 0, 0, .5); }

.seg-field {
  width: 3.6rem; padding: 0 6px; text-align: center; color: var(--text);
  font: 600 13px/1 var(--font-mono); background: rgba(0, 0, 0, .25);
  -moz-appearance: textfield; appearance: textfield;
}
.seg-field:focus { outline: none; background: rgba(var(--accent-rgb), .12); color: var(--text); }
.seg-field::-webkit-outer-spin-button,
.seg-field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.seg-label { padding: 0 11px; color: var(--muted); font: 500 12px/1 var(--font-mono); }
.seg-ico { font-size: 16px; }   /* chevrons/glyphs read a touch larger, still centered */

.field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Tables ----------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--panel);
}

.table th, .table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
}

.table tbody tr:hover td { background: var(--bg); }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* Default table behaviour on narrow viewports: wrap in horizontal
   scroll. Pages that would rather re-stack into label/value pairs
   should add the .table--stack class instead. */
.table--scroll { overflow-x: auto; }

.table .mono, .table code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  background: transparent;
}

/* ---------- Card grid (landing) --------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.card-grid.cols-4 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 200ms var(--ease-soft),
              transform 200ms var(--ease-soft),
              box-shadow 200ms var(--ease-soft);
}

.card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.18),
              0 8px 18px -10px rgba(var(--accent-rgb), 0.35);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.card-icon { font-size: 22px; }

.card-body {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

.card-foot {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.card-count {
  margin-left: auto;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Flash + alerts --------------------------------------- */

#flash:empty { display: none; }

.alert {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--panel);
}
.alert.success { border-color: var(--good); color: var(--good); }
.alert.error   { border-color: var(--bad);  color: var(--bad); }
.alert.info    { border-color: var(--accent); color: var(--accent); }

/* ---------- Definition lists ------------------------------------- */

dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 0;
  font-size: 13px;
}
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; color: var(--text); }
dl.kv dd code, dl.kv dd .mono {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ---------- Pre / code blocks ------------------------------------ */

pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* ---------- HP bar (spectator roster) --------------------------- */

.hpbar {
  width: 96px;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.hpbar > span {
  display: block;
  height: 100%;
  background: var(--good);
}
.hpbar.warn > span { background: var(--warn); }
.hpbar.bad  > span { background: var(--bad); }

/* ---------- Action panel (play) ---------------------------------- */

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

.action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 4px;
  font-family: inherit;
}

.action-btn:hover { border-color: var(--accent); }
.action-btn .kind {
  width: 84px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.action-btn.kind-action       { border-left: 3px solid var(--warn); }
.action-btn.kind-bonus_action { border-left: 3px solid var(--good); }
.action-btn.kind-reaction     { border-left: 3px solid var(--bad); }
.action-btn.kind-movement     { border-left: 3px solid var(--accent); }
.action-btn.kind-free_interaction { border-left: 3px solid var(--border); }

.budget-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.budget-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--muted);
}
.budget-pill .mono { color: var(--accent); }

/* ---------- Battlemap helpers ------------------------------------ */

.battlemap-frame {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  display: block;
  width: 100%;
}

.battlemap-svg {
  display: block;
  /* Fill the wrapper in BOTH dimensions; preserveAspectRatio="xMidYMid
     meet" on the <svg> handles fitting the actual graphics so wide-
     aspect maps don't crop and tall-aspect maps don't either. */
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* Pan/zoom viewport. Clips the SVG when zoomed past 100% so it
   doesn't blow out the page. Inner stage holds the transform state +
   lives OUTSIDE the HTMX swap target (#battlemap-region), which
   means user zoom + pan survive the periodic /battlemap refresh. */
.battlemap-viewport {
  position: relative;
  overflow: hidden;
  height: 78vh;
  max-height: 78vh;
  border-radius: 6px;
  background: var(--bg);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

/* Pan/zoom stage + nested HTMX-swapped containers all need to fill
   the viewport so the SVG inside has a finite height to size against.
   Without this, SVG height auto-collapses to its viewBox-derived
   intrinsic height and overflows the viewport at non-4:3 aspects. */
.battlemap-pan-zoom {
  width: 100%;
  height: 100%;
  will-change: transform;
}
.battlemap-viewport #battlemap-region,
.battlemap-viewport .battlemap-frame {
  width: 100%;
  height: 100%;
}
.battlemap-viewport .battlemap-frame {
  /* Drop the inner padding so we don't shave 16 px off both axes —
     viewport already has the rounded background. */
  padding: 0;
  border: 0;
}

.battlemap-toolbar {
  align-items: center;
  flex-wrap: wrap;
}
.battlemap-toolbar .btn-ghost {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.4;
}

.battlemap-cell { cursor: pointer; }
.battlemap-cell:hover { stroke: var(--accent); stroke-width: 2; }

.battlemap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

.battlemap-legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-right: 4px;
}

/* ---------- Narration log ---------------------------------------- */

.narration-log {
  max-height: 18rem;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
}

.narration-log li {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin-bottom: 8px;
  list-style: none;
}

.narration-log ol { margin: 0; padding: 0; }

/* ---------- Audit timeline -------------------------------------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--border);
}

.timeline > li {
  position: relative;
  padding: 6px 0 14px 12px;
  font-size: 13px;
}

.timeline > li::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline > li.create::before { background: var(--good); }
.timeline > li.delete::before { background: var(--bad); }

.timeline pre {
  margin-top: 6px;
  font-size: 11px;
  max-height: 200px;
}

/* ---------- Layout grids reused by many pages -------------------- */

.split-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 900px) {
  .split-2 { grid-template-columns: 1fr 1fr; }
}

.split-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 1100px) {
  .split-3 { grid-template-columns: 2fr 1fr; }
}

/* ---------- Misc utility classes used in templates -------------- */

.tabs {
  display: flex;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 12px;
}

.tabs .status-pill { cursor: default; }

/* Prevent forms inside flex layouts from collapsing inputs */
form.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-head h1 { margin: 0; }
.section-head .sub { color: var(--muted); font-size: 13px; }

/* ---------- Play screen — tactical-tool overlay layout ----------
   The /play/{cid} screen now puts the battlemap in a full-viewport
   stage; UI elements (party roster, action tray, narration drawer,
   view controls, generate-map controls) sit on TOP of the map as
   semi-transparent overlay panels at the corners + edges. Pure CSS
   positioning — only the narration drawer + generate-map popover
   ship a tiny bit of inline JS for toggling.
*/

:root {
  --topbar-h: 56px;
  --crumbs-h: 36px;
}

.play-stage {
  position: relative;
  height: calc(100dvh - var(--topbar-h, 56px) - var(--crumbs-h, 36px));
  /* Fallback for browsers without dynamic-viewport units. */
  min-height: calc(100vh - var(--topbar-h, 56px) - var(--crumbs-h, 36px));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%,
      rgba(var(--accent-rgb), 0.04) 0%,
      transparent 65%),
    #0b0805;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Override main padding so the stage fills edge-to-edge. The play
   screen breaks out of the standard 1200px content column. */
body:has(.play-stage) main.app-main {
  max-width: none;
  padding: 12px 12px 12px;
}

.play-stage .battlemap-viewport {
  position: absolute;
  inset: 0;
  height: auto;
  max-height: none;
  border-radius: 0;
  border: 0;
}

/* ---------- Overlay panel primitive ------------------------------ */
.overlay-panel {
  position: absolute;
  z-index: 5;
  background: rgba(22, 27, 34, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  color: var(--text);
  font-size: 12px;
}

.overlay-panel .panel-title {
  margin: 0 0 6px 0;
  font-size: 11px;
}

.overlay-top-left    { top: 12px;    left: 12px;   max-width: 280px; }
.overlay-top-right   { top: 12px;    right: 12px;  max-width: 360px; }
.overlay-bottom {
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  max-width: calc(100% - 360px);
  min-width: min(420px, 80%);
}
.overlay-bottom-left { bottom: 12px; left: 12px;   }

.overlay-right-drawer {
  top: 12px;
  bottom: 12px;
  right: 12px;
  width: 320px;
  max-width: 38vw;
  display: flex;
  flex-direction: column;
}

/* ---------- Party roster overlay -------------------------------- */
.party-overlay {
  padding: 10px 12px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
}

.party-overlay h2 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px 0;
  font-weight: 600;
}

.party-overlay-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.party-overlay-row:first-of-type { border-top: none; }

.party-overlay-row.is-active {
  background: linear-gradient(90deg,
    rgba(var(--accent-rgb), 0.10) 0%,
    transparent 100%);
  margin: 0 -4px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 4px;
}

.party-overlay-row .swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
}
.party-overlay-row.is-active .swatch { border-color: var(--accent); }

.party-overlay-row .name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.party-overlay-row .hpbar {
  width: 56px;
  height: 5px;
  flex-shrink: 0;
}

.party-overlay-row .hp-text {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.party-overlay-row .ac-badge {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  flex-shrink: 0;
}

.party-overlay-row .active-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}

/* ---------- Generate-map overlay (popover) ---------------------- */
.gen-map-overlay {
  padding: 6px;
}

.gen-map-overlay-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  border-radius: 6px;
}
.gen-map-overlay-toggle:hover { color: var(--accent); background: rgba(var(--accent-rgb),0.08); }

.gen-map-overlay-body {
  display: none;
  padding: 10px 12px 12px;
  width: 320px;
  max-width: 90vw;
}
.gen-map-overlay.is-open .gen-map-overlay-toggle { display: none; }
.gen-map-overlay.is-open .gen-map-overlay-body   { display: block; }
.gen-map-overlay.is-open                         { padding: 4px 6px 6px; }

.gen-map-overlay-body .field-label {
  margin-top: 6px;
}

.gen-map-overlay-body form { display: flex; flex-direction: column; gap: 6px; }
.gen-map-overlay-body .row { gap: 6px; }
.gen-map-overlay-body .field { font-size: 12px; padding: 4px 8px; }

/* ---------- Narration drawer ------------------------------------ */
.narration-drawer {
  padding: 0;
  transition: transform 220ms var(--ease-soft);
}
.narration-drawer .drawer-body {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.narration-drawer h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px 0;
  font-weight: 600;
}
.narration-drawer .narration-log {
  max-height: none;
  border: 0;
  padding: 0;
  background: transparent;
}

/* The drawer slides off-screen to the right when closed. The toggle
   tab stays anchored to the screen edge. */
.narration-drawer.is-closed {
  transform: translateX(calc(100% + 12px));
}

.narration-drawer-toggle {
  position: absolute;
  top: 50%;
  left: -28px;
  transform: translateY(-50%);
  width: 28px;
  height: 64px;
  background: rgba(22, 27, 34, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  pointer-events: auto;
}
.narration-drawer-toggle:hover { color: var(--accent); }

/* When the drawer is closed the toggle becomes a stand-alone tab
   pinned to the right edge of the play stage. */
.narration-drawer.is-closed .narration-drawer-toggle {
  left: auto;
  right: 0;
  border-right: 1px solid var(--border);
  border-radius: 8px 0 0 8px;
}

/* ---------- Action tray (bottom overlay) ------------------------ */
.actions-overlay {
  padding: 8px 10px;
  max-height: 36vh;
}

.actions-overlay .budget-row {
  margin-bottom: 6px;
  padding-bottom: 6px;
  gap: 4px;
}

.actions-overlay .budget-pill {
  font-size: 11px;
  padding: 1px 6px;
}

/* Force the action panel into a horizontal scrollable tray inside
   the bottom overlay. The partial keeps emitting <ul.action-list><li>
   <button.action-btn>; we just relayout via CSS. */
.actions-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.actions-overlay .action-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 4px;
  margin: 0;
  scrollbar-width: thin;
}
.actions-overlay .action-list > li { flex: 0 0 auto; }
.actions-overlay .action-btn {
  width: auto;
  margin: 0;
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
  flex-direction: row;
  gap: 6px;
}
.actions-overlay .action-btn .kind {
  width: auto;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.04);
}

/* ---------- View controls overlay ------------------------------- */
.viewctl-overlay {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
}
.viewctl-overlay .viewctl-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.viewctl-overlay .viewctl-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.viewctl-overlay .btn-ghost {
  padding: 2px 6px;
  font-size: 11px;
  min-height: 0;
  line-height: 1.2;
}

/* ---------- Phase 4: mode badge --------------------------------- */
.mode-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.mode-badge.mode-explore { color: var(--accent); border-color: rgba(var(--accent-rgb),0.5); }
.mode-badge.mode-social  { color: #3fb950; border-color: rgba(63,185,80,0.5); }
.mode-badge.mode-combat  { color: var(--bad); border-color: var(--bad); }

/* ---------- Phase 4: scene strip / arc timeline ----------------- */
.scene-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 8px 0;
  padding: 6px 8px;
  background: rgba(22, 27, 34, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.scene-strip-rail {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.scene-chip-form { display: contents; }
.scene-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
}
.scene-chip:hover { border-color: var(--accent); }
.scene-chip.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.scene-chip .scene-chip-kind {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.scene-chip.kind-explore .scene-chip-kind { color: var(--accent); }
.scene-chip.kind-social  .scene-chip-kind { color: #3fb950; }
.scene-chip.kind-combat  .scene-chip-kind { color: var(--bad); }
.scene-chip .scene-chip-title { font-weight: 600; }
.scene-arrow { color: var(--muted); font-size: 12px; }
.scene-empty { font-size: 12px; }
.scene-new { margin-left: auto; }
.scene-new > summary { list-style: none; cursor: pointer; }
.scene-new > summary::-webkit-details-marker { display: none; }

/* ---------- Phase 4: narrative stage (explore / social) --------- */
.play-stage.narrative-mode {
  display: block;
  overflow: visible;
  height: auto;
  min-height: 0;
  padding: 0;
  background:
    radial-gradient(circle at 50% 0%,
      rgba(var(--accent-rgb), 0.04) 0%, transparent 60%),
    #0b0805;
}
.play-stage.narrative-mode.mode-social {
  background:
    radial-gradient(circle at 50% 0%,
      rgba(63, 185, 80, 0.05) 0%, transparent 60%),
    #0b0805;
}
.narrative-region {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  padding: 12px;
}
.play-stage.narrative-mode .party-overlay {
  position: static;
  max-width: none;
  grid-column: 2;
  grid-row: 1;
  align-self: start;
}
.narrative-stage {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.narrative-scroll {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  min-height: 40vh;
  max-height: 60vh;
  overflow-y: auto;
}
.narrative-scroll .narration-log {
  max-height: none;
  border: 0;
  padding: 0;
  background: transparent;
}
.narration-entry { margin-bottom: 14px; }
.narration-intent {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px 0;
}
.narration-intent .narration-actor {
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}
.narration-prose { margin: 0; line-height: 1.6; }
.narration-check {
  margin: 4px 0 0 0;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* Suggested actions (envelope ACTIONS as clickable intents). */
.suggested-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.suggested-actions .suggested-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.suggested-action-form { display: contents; }
.suggested-action {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(22, 27, 34, 0.7);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.suggested-action:hover { border-color: var(--accent); color: var(--accent); }

/* Free-text intent box. */
.intent-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.intent-input { width: 100%; resize: vertical; font-family: inherit; }
.intent-controls { justify-content: flex-end; }

/* ---------- Phase 4: combat HUD --------------------------------- */
.combat-hud {
  top: 12px;
  bottom: 12px;
  right: 12px;
  width: 260px;
  max-width: 34vw;
  display: flex;
  flex-direction: column;
  padding: 0;
}
/* Sit the combat HUD to the LEFT of the narration drawer when both
   are open (the narration drawer is 320px wide on the right edge). */
.combat-mode .narration-drawer { right: 12px; }
.combat-mode .combat-hud { right: 344px; }
.combat-hud-body {
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hud-panel { font-size: 12px; }
.hud-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 6px 0;
  font-weight: 600;
}
.initiative-list, .enemy-list, .combat-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.initiative-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 4px;
}
.initiative-row.is-active {
  background: linear-gradient(90deg, rgba(var(--accent-rgb),0.12), transparent);
}
.initiative-row .init-marker { width: 10px; color: var(--accent); }
.initiative-row .init-name { flex: 1; font-weight: 600; }
.initiative-row.kind-monster .init-name { color: var(--bad); }
.initiative-row .init-hp { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
.initiative-row .init-hp.is-down { color: var(--bad); }
.enemy-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  flex-wrap: wrap;
}
.enemy-row.is-dead { opacity: 0.45; text-decoration: line-through; }
.enemy-row .enemy-name { flex: 1; font-weight: 600; }
.enemy-conditions { display: flex; gap: 3px; flex-wrap: wrap; flex-basis: 100%; }
.cond-pill {
  font-size: 9px;
  text-transform: uppercase;
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid var(--bad);
  color: var(--bad);
}
.combat-log-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.combat-log-row .cl-target { font-weight: 600; }
.combat-log-row .cl-kind { color: var(--muted); }
.combat-log-row .cl-amount { font-family: ui-monospace, monospace; color: var(--bad); }
.combat-log-row .cl-detail { color: var(--muted); font-style: italic; }

@media (max-width: 900px) {
  .narrative-region { grid-template-columns: 1fr; }
  .play-stage.narrative-mode .party-overlay { grid-column: 1; grid-row: 2; }
  .narrative-stage { grid-column: 1; }
}

/* ---------- Mobile collapse ------------------------------------- */
@media (max-width: 640px) {
  :root {
    --topbar-h: 52px;
    --crumbs-h: 30px;
  }

  body:has(.play-stage) main.app-main { padding: 6px; }

  /* Party roster collapses to a 40px icon button. Tap to expand. */
  .party-overlay {
    max-width: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
  }
  .party-overlay::before {
    content: "P";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent);
    font-size: 14px;
  }
  .party-overlay > * { display: none; }
  .party-overlay.is-open {
    width: auto;
    height: auto;
    max-width: 280px;
    max-height: 60dvh;
    padding: 10px 12px;
    overflow-y: auto;
  }
  .party-overlay.is-open::before { display: none; }
  .party-overlay.is-open > * { display: block; }
  .party-overlay.is-open .party-overlay-row { display: flex; }

  /* Narration drawer takes the full-edge tab pattern; default
     closed on phones since the map is the focus. */
  .overlay-right-drawer { width: 84vw; max-width: 84vw; }

  /* Bottom action tray spans full width edge-to-edge. */
  .overlay-bottom {
    left: 6px;
    right: 6px;
    transform: none;
    max-width: none;
    min-width: 0;
  }

  .overlay-bottom-left { bottom: 60px; }
}

/* ---------- Page-load motion ------------------------------------- */

@keyframes panelRise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  .rise {
    animation: panelRise 240ms var(--ease-soft) both;
    animation-delay: calc(var(--i, 0) * 30ms);
  }
}

/* ===================================================================
   RESPONSIVE LAYER
   =================================================================== */

/* ---------- Mobile: <= 640px ------------------------------------- */
@media (max-width: 640px) {
  body { font-size: 15px; line-height: 1.5; }

  main.app-main { padding: 14px 12px; }

  h1 { font-size: 22px; }
  h2 { font-size: 17px; }

  .entity-name { font-size: 26px; }

  /* Topbar collapses into brand + hamburger; the nav + form become a
     vertical drawer revealed when the toggle checkbox is :checked. */
  .topbar-inner { padding: 8px 12px; gap: 8px; }

  .topbar-toggle { display: inline-flex; }

  .topbar-nav,
  .topbar-form {
    display: none;
    width: 100%;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  /* Drawer open: toggled by JS via the body[data-nav-open] attribute.
     A peer-checkbox-only fallback is also accepted via .nav-open. */
  body[data-nav-open="true"] .topbar-nav,
  body[data-nav-open="true"] .topbar-form,
  .topbar.nav-open .topbar-nav,
  .topbar.nav-open .topbar-form {
    display: flex;
  }

  .topbar-nav a {
    padding: 12px 14px;
    border-radius: 6px;
    border-color: var(--border);
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .topbar-form .field,
  .topbar-form select.field,
  .topbar-form input.field {
    width: 100% !important;
    min-height: 44px;
  }

  .topbar-form .btn { width: 100%; min-height: 44px; }

  .campaign-strip-inner { padding: 6px 12px; font-size: 12px; }

  .panel { padding: 12px; border-radius: 8px; }

  .crumbs { font-size: 13px; gap: 6px; }
  .crumbs h1 { font-size: 20px; flex-basis: 100%; }
  .crumbs .btn { margin-left: 0 !important; }

  .section-head { flex-direction: column; align-items: stretch; }

  /* KPI row: 2 columns on mobile. */
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .kpi { padding: 8px 6px; }
  .kpi span, .kpi .kpi-value { font-size: 18px; }

  /* Card grid: 1 column. */
  .card-grid,
  .card-grid.cols-4 { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 14px 14px; }

  /* Buttons + fields touch-friendly. */
  .btn, button.btn, a.btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .field, input.field, select.field, textarea.field {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 10px 12px;
  }
  textarea.field { min-height: 12rem; }

  /* Inline forms collapse to vertical on mobile. */
  form.inline { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }

  /* Field-row stacks. */
  .field-row { grid-template-columns: 1fr; gap: 10px; }

  /* Tables — default scroll wrap. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 6px 8px; white-space: nowrap; }

  /* The .table--stack opt-in re-flows table rows as label/value
     pairs on mobile; entity_list uses this since its narrow many-
     column layout is unreadable when scrolled. */
  .table--stack thead { display: none; }
  .table--stack,
  .table--stack tbody,
  .table--stack tr,
  .table--stack td { display: block; width: 100%; }
  .table--stack tr {
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }
  .table--stack tr:last-child { border-bottom: none; }
  .table--stack td {
    padding: 4px 0;
    border: none;
    white-space: normal;
  }
  .table--stack td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 7rem;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 8px;
    font-weight: 600;
  }

  /* Crumb action buttons full-width. */
  .crumbs .btn,
  .section-head .btn { width: 100%; }

  /* Definition lists: stack so the column doesn't squish. */
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dt { margin-top: 6px; }

  /* Battlemap: legacy non-stage embed (e.g. spectator view) keeps a
     shorter viewport on phones. The new .play-stage wrapper inside
     /play/{cid} overrides this rule with absolute positioning. */
  .battlemap-viewport { height: 60vh; max-height: 60vh; }

  /* Chain strip wraps; per-field source badges hide so they don't
     crowd the labels in narrow KPI grids. */
  .chain-strip { gap: 4px; }
  .field-source { display: none; }
}

/* ---------- Tablet: 641px to 1023px ------------------------------ */
@media (min-width: 641px) and (max-width: 1023px) {
  main.app-main { padding: 18px 16px; }

  /* Topbar: brand + nav row 1, jump form row 2. */
  .topbar-inner { gap: 10px 14px; }
  .topbar-nav { order: 2; }
  .topbar-form {
    order: 3;
    margin-left: 0;
    width: 100%;
    border-top: 1px dashed var(--border);
    padding-top: 8px;
  }

  /* KPI row: 4 across. */
  .kpi-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* Card grid: 2 across. */
  .card-grid,
  .card-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .field-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- Desktop: >= 1024px ----------------------------------- */
@media (min-width: 1024px) {
  /* Restore single-row topbar — topbar-form auto-pushes to right. */
  .topbar-form { margin-left: auto; }
}

/* ================================================================ */
/* Dice widget — global floating roll tray.                         */
/* Markup: templates/partials/dice_widget.html (included from        */
/* base.html). Behaviour: /static/dice_widget.js. Server roll:       */
/* POST /play/dice/roll. Anchored bottom-left, lifted clear of the   */
/* play screen's view-control overlay.                               */
/* ================================================================ */

.dice-widget { font-family: var(--font-sans); }

.dice-launcher {
  position: fixed;
  left: 14px;
  bottom: 84px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px 8px 11px;
  background: rgba(22, 27, 34, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  transition: border-color 160ms var(--ease-soft),
              color 160ms var(--ease-soft);
}
.dice-launcher svg { width: 16px; height: 16px; fill: currentColor; }
.dice-launcher:hover { border-color: var(--accent); color: var(--accent); }
.dice-widget.is-open .dice-launcher { display: none; }

.dice-popover {
  position: fixed;
  left: 14px;
  bottom: 84px;
  z-index: 60;
  width: 320px;
  max-width: calc(100vw - 28px);
  max-height: min(72vh, 580px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(22, 27, 34, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 40px -12px rgba(0, 0, 0, 0.7);
  color: var(--text);
}
.dice-popover[hidden] { display: none; }

.dice-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.dice-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  margin-right: auto;
}
.dice-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.dice-iconbtn svg { width: 15px; height: 15px; fill: currentColor; }
.dice-iconbtn:hover { color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }

.dice-body {
  padding: 12px;
  overflow-y: auto;
}

.dice-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.dice-die {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms var(--ease-soft),
              color 140ms var(--ease-soft);
}
.dice-die:hover { border-color: var(--accent); color: var(--accent); }
.dice-die.is-active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.dice-die-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--bg);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.dice-die-count[hidden] { display: none; }

.dice-modrow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.dice-modlabel { font-size: 12px; color: var(--muted); margin-right: auto; }
.dice-stepbtn {
  width: 26px;
  height: 26px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.dice-stepbtn:hover { border-color: var(--accent); color: var(--accent); }
.dice-modval {
  width: 48px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 4px 0;
}

.dice-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.dice-actions .dice-roll { flex: 1; }
.dice-actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.dice-actions .btn:disabled:hover {
  border-color: var(--border); color: var(--text);
}

.dice-rollto {
  margin-top: 12px;
  text-align: center;
}
.dice-rollto-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.dice-segbtn {
  padding: 5px 12px;
  background: var(--bg);
  border: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.dice-segbtn + .dice-segbtn { border-left: 1px solid var(--border); }
.dice-segbtn-on { background: var(--accent); color: var(--bg); }
.dice-rollto-label {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.dice-rollto-label.is-muted { color: var(--warn); }

.dice-result-region { margin-top: 12px; }
.dice-result-hint, .dice-result-empty {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}
.dice-result-empty { color: var(--bad); font-style: normal; }
.dice-result {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
}
.dice-result-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.dice-result-total-num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.dice-result-shared {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--good);
}
.dice-result-spec {
  margin: 4px 0 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.dice-result-groups {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.dice-result-groups li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.dice-result-die {
  font-family: var(--font-mono);
  color: var(--muted);
  min-width: 38px;
}
.dice-result-rolls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}
.dice-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.dice-pip.is-max { border-color: var(--good); color: var(--good); }
.dice-pip.is-min { border-color: var(--bad); color: var(--bad); }
.dice-result-subtotal { font-family: var(--font-mono); color: var(--muted); }
.dice-result-mod .dice-result-rolls { font-family: var(--font-mono); }

@keyframes dice-pop {
  0%   { transform: scale(0.94); opacity: 0.4; }
  60%  { transform: scale(1.02); }
  100% { transform: scale(1);    opacity: 1; }
}
.dice-result.dice-pop { animation: dice-pop 0.34s var(--ease-soft); }

.dice-settings {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(420px, 92vw);
}
.dice-settings::backdrop { background: rgba(0, 0, 0, 0.55); }
.dice-settings form { padding: 16px 18px 18px; }
.dice-settings-head {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}
.dice-settings-head h2 {
  margin: 0 auto 0 0;
  font-family: var(--font-display);
  font-size: 20px;
}
.dice-set-field {
  display: block;
  border: 0;
  padding: 0;
  margin: 0 0 14px;
}
.dice-set-field > span,
.dice-set-field legend {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  padding: 0;
}
.dice-set-field small { display: block; color: var(--muted); margin-top: 4px; }
.dice-set-field .field { width: 100%; }
.dice-radio {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  margin: 6px 0;
  cursor: pointer;
}
.dice-radio small { color: var(--muted); }
.dice-settings-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
}

.dice-toasts {
  position: fixed;
  left: 14px;
  bottom: 132px;
  z-index: 61;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.dice-toast {
  max-width: 320px;
  padding: 8px 12px;
  background: rgba(22, 27, 34, 0.95);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms var(--ease-soft),
              transform 220ms var(--ease-soft);
}
.dice-toast.is-in { opacity: 1; transform: translateY(0); }

/* Shared rolls rendered into the spectator narration log. */
.dice-roll-line {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
}

@media (max-width: 640px) {
  .dice-launcher { bottom: 70px; }
  .dice-popover {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-width: none;
    max-height: 80vh;
  }
}

/* Dice physics overlay — full viewport, never blocks input. Behaviour
 * in /static/dice_widget.js. Honors prefers-reduced-motion (the JS
 * skips the sim entirely in that case, so this is just the surface). */
.dice-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 62;
  pointer-events: none;
  background: transparent;
}
.dice-canvas[hidden] { display: none; }

/* ===================================================================
   CANDLELIT GRIMOIRE — atmosphere + display typography (Phase A)
   Appended last so it layers over the component base above. Only
   tokens + this block carry the dark-fantasy theme; component classes
   are untouched.
   =================================================================== */

/* Warm candlelight wash + vignette behind all content. Fixed, inert,
   sits beneath everything (negative z). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(125% 90% at 50% -8%,
      rgba(var(--accent-rgb), 0.07) 0%, transparent 52%),
    radial-gradient(110% 80% at 50% 116%,
      rgba(var(--gold-rgb), 0.045) 0%, transparent 55%),
    radial-gradient(140% 120% at 50% 50%,
      transparent 60%, rgba(0, 0, 0, 0.45) 100%),
    var(--bg);
}

/* Fine paper grain for texture — static SVG fractal noise, very low
   opacity. Above the wash, below content. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* ---- Display typography — illuminated serif headings -------------- */
h1,
.page-title,
.section-head h1,
.crumbs h1,
.card-title,
.hero-title {
  font-family: var(--font-display);
}
h1,
.page-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.12;
}
.card-title { font-size: 19px; font-weight: 600; }

/* Small uppercase "label" titles stay sans-shaped but go brass. */
.panel-title,
.panel h2 { color: var(--gold); }

/* Hero — large illuminated, glowing display title (home/landing). */
.hero-title {
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: 0.005em;
  color: var(--text);
  text-shadow: 0 0 30px rgba(var(--accent-rgb), 0.22);
}
.hero-title .ember { color: var(--accent); }
.hero-title .gilt { color: var(--gold); text-shadow: var(--glow-gold); }

/* Illuminated drop-cap helper for hero/lead paragraphs. */
.dropcap::first-letter {
  font-family: var(--font-display);
  float: left;
  font-size: 3.1em;
  line-height: 0.82;
  padding: 4px 10px 0 0;
  color: var(--gold);
  text-shadow: var(--glow-gold);
}

/* ---- Accent glow + interaction polish ---------------------------- */
a { transition: color 140ms var(--ease-soft); }
a:hover { color: var(--gold); }

::selection { background: rgba(var(--accent-rgb), 0.32); color: var(--text); }

.brand-mark { color: var(--gold); }

.topbar-brand {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.03em;
  color: var(--gold);
}
.topbar-brand:hover { color: var(--accent); text-decoration: none; }

/* Primary buttons ignite — ember fill with a soft glow, gilding on hover. */
.btn-primary { box-shadow: var(--glow-ember); }
.btn-primary:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1206;
  box-shadow: var(--glow-gold);
}

/* Reusable glow / accent-color utilities. */
.glow { box-shadow: var(--glow-ember); }
.text-gold { color: var(--gold); }
.text-ember { color: var(--accent); }

/* Active turn / live indicators pulse with ember warmth. */
.party-overlay-row.is-active .active-dot,
.status-pill.live { box-shadow: var(--glow-ember); }

/* ---- Decorative divider — ✦ flourish ----------------------------- */
hr {
  border: 0;
  height: 1px;
  position: relative;
  overflow: visible;
  margin: 24px 0;
  background: linear-gradient(90deg,
    transparent, var(--border) 18%, var(--border) 82%, transparent);
}
hr::after {
  content: "\2726";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -55%);
  color: var(--gold);
  background: var(--bg);
  padding: 0 12px;
  font-size: 12px;
}

/* ---- Themed scrollbars ------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---- Accessibility — visible focus + skip link ------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--panel);
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 8px 14px;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ===================================================================
   SHARED UI PRIMITIVES (Phase B) — toasts, modals, command palette,
   smart-table controls, empty states, page headers, kbd.
   Behaviour lives in /static/ui.js.
   =================================================================== */

/* ---- Toasts ------------------------------------------------------ */
#toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms var(--ease-soft), transform 200ms var(--ease-soft);
}
.toast.is-in { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--good); }
.toast-error   { border-left-color: var(--bad); }
.toast-warn    { border-left-color: var(--warn); }
.toast-icon { color: var(--accent); font-size: 13px; line-height: 1.5; }
.toast-success .toast-icon { color: var(--good); }
.toast-error .toast-icon   { color: var(--bad); }
.toast-warn .toast-icon    { color: var(--warn); }
.toast-msg { flex: 1; min-width: 0; }
.toast-close {
  background: none; border: 0; color: var(--muted);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
}
.toast-close:hover { color: var(--text); }

/* ---- Modal / confirm + cheatsheet -------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 3, 1, 0.66);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.modal-backdrop.is-in { display: flex; }
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8), var(--glow-gold);
}
.modal-title { font-family: var(--font-display); font-size: 22px; color: var(--gold); margin: 0 0 8px; }
.modal-body { color: var(--muted); margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.cheatsheet { max-width: 460px; }
.cheat-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; font-size: 13px; }
.cheat-grid dt { text-align: right; }
.cheat-grid dd { margin: 0; color: var(--muted); }

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text);
}

/* ---- Command palette --------------------------------------------- */
.cmdk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
  background: rgba(4, 3, 1, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.cmdk-backdrop.is-in { display: flex; }
.cmdk {
  width: min(560px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 28px 70px -24px rgba(0, 0, 0, 0.85), var(--glow-ember);
  overflow: hidden;
}
.cmdk-input {
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0;
  font-size: 16px;
  padding: 14px 16px;
}
.cmdk-input:focus { border-bottom-color: var(--accent) !important; }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.cmdk-item.is-active { background: rgba(var(--accent-rgb), 0.14); }
.cmdk-ic { width: 18px; text-align: center; color: var(--gold); }
.cmdk-label { flex: 1; }
.cmdk-hint { color: var(--muted); font-size: 12px; }
.cmdk-foot {
  padding: 8px 14px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 11px; display: flex; gap: 12px;
}

/* ---- Smart-table controls ---------------------------------------- */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.table-search { max-width: 240px; }
.table-count { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.table-density { margin-left: auto; padding: 4px 10px; }
.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sortable:hover { color: var(--gold); }
.th-sortable::after { content: "↕"; opacity: 0.35; margin-left: 6px; font-size: 10px; }
.th-sortable[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--accent); }
.th-sortable[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--accent); }
.table.is-compact th, .table.is-compact td { padding: 3px 8px; font-size: 12px; }

/* ---- Empty states ------------------------------------------------ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background:
    radial-gradient(60% 80% at 50% 0%, rgba(var(--accent-rgb), 0.05), transparent 70%),
    var(--panel);
}
.empty-state .empty-icon { font-size: 40px; color: var(--gold); opacity: 0.8; }
.empty-state .empty-title { font-family: var(--font-display); font-size: 24px; margin: 10px 0 4px; }
.empty-state .empty-text { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }

/* ---- Page header + breadcrumb ------------------------------------ */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.page-header .ph-title { margin: 0; }
.page-header .ph-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-header .ph-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- HTMX loading indicator -------------------------------------- */
.htmx-indicator { opacity: 0; transition: opacity 160ms var(--ease-soft); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 999px; animation: spin 0.7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Codex (corpus) thumbnails ----------------------------------- */
.codex-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: block;
  background: var(--bg);
}

/* ---- Home hero --------------------------------------------------- */
.home-hero {
  position: relative;
  text-align: center;
  padding: 58px 16px 40px;
  margin-bottom: 10px;
}
.home-hero::before {
  content: "";
  position: absolute;
  inset: -12% 0 0 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(58% 70% at 50% 0%,
    rgba(var(--accent-rgb), 0.12), transparent 70%);
}
.hero-kicker {
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 11px;
  color: var(--gold);
  margin: 0 0 12px;
}
.home-hero .hero-title { margin: 0 auto; }
.hero-lede {
  color: var(--muted);
  font-size: 16px;
  max-width: 52ch;
  margin: 14px auto 24px;
  line-height: 1.6;
}
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero-actions .btn { padding: 8px 18px; font-size: 14px; }

/* ---- Narrative reading — storybook prose ------------------------- */
.narrative-stage .narration-log {
  max-height: none;
  border: 0;
  background: transparent;
  padding: 0;
}
.narrative-stage .narration-entry {
  border-left: 2px solid var(--border);
  padding-left: 14px;
  margin-bottom: 20px;
  list-style: none;
}
.narrative-stage .narration-prose {
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.7;
  color: var(--text);
  margin: 0;
}
.narrative-stage .narration-intent { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.narrative-stage .narration-actor {
  color: var(--gold);
  font-family: var(--font-mono);
  margin-right: 6px;
}
.narrative-stage .narration-check {
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  margin: 6px 0 0;
}
.narrative-stage .muted-i { font-size: 16px; line-height: 1.6; }
.narrative-stage .intent-input { font-family: var(--font-sans); font-size: 14px; }
.narrative-stage .suggested-action {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.narrative-stage .suggested-action:hover { border-color: var(--accent); color: var(--gold); }
.narrative-stage .suggested-action-form { display: inline; }
.narrative-stage .suggested-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0; }
.narrative-stage .suggested-label { color: var(--muted); font-size: 12px; margin-right: 4px; }

/* ---- Codex item gallery ------------------------------------------ */
.codex-gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.codex-gallery a {
  display: inline-block;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
}
.codex-gallery a:hover { border-color: var(--accent); }
.codex-gallery img { max-height: 180px; max-width: 240px; display: block; object-fit: contain; }

/* ---- Topbar account menu ----------------------------------------- */
.topbar-account { display: flex; align-items: center; }
.account-menu { position: relative; }
.account-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-mono);
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary:hover { border-color: var(--accent); color: var(--gold); }
.account-ava { color: var(--gold); }
.account-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 168px;
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account-pop a,
.account-pop button {
  text-align: left;
  background: none;
  border: 0;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-sans);
  width: 100%;
}
.account-pop a:hover,
.account-pop button:hover { background: var(--bg); color: var(--gold); text-decoration: none; }
.account-pop form { margin: 0; }

/* ---- #3 click-to-roll tokens in prose ---------------------------- */
.rollable {
  background: rgba(var(--accent-rgb), 0.1);
  border: 0;
  border-bottom: 1px dashed var(--accent);
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0 2px;
  border-radius: 3px;
}
.rollable:hover { background: rgba(var(--accent-rgb), 0.22); color: var(--gold); }

/* #4 roll skill/save from sheet */
.rollable-check {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  cursor: pointer;
  padding: 1px 8px;
}
.rollable-check:hover {
  border-color: var(--accent);
  color: var(--gold);
  background: rgba(var(--accent-rgb), 0.2);
}

/* #11 HP quick-track controls */
.hp-controls { display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: middle; }
.hp-btn { padding: 0 9px; line-height: 1.7; font-size: 14px; }

/* #2 dice macros */
.macro-list { display: flex; flex-direction: column; gap: 6px; }
.macro-item { display: flex; gap: 6px; align-items: center; }
.macro-roll { flex: 1; text-align: left; }

/* ---- #7 your-turn cue -------------------------------------------- */
.your-turn-banner {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--gold);
  font-weight: 600;
  box-shadow: var(--glow-ember);
  animation: yourTurnPulse 1.8s var(--ease-soft) infinite;
}
body[data-your-turn="1"] .your-turn-banner { display: flex; }
@keyframes yourTurnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.0); }
  50% { box-shadow: 0 0 18px -2px rgba(var(--accent-rgb), 0.55); }
}

/* ---- #6 Intent slash-menu ---------------------------------------- */
.intent-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow: auto;
  box-shadow: 0 -10px 28px -14px rgba(0, 0, 0, 0.75);
}
.intent-menu[hidden] { display: none; }
.intent-opt {
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.intent-opt:hover { background: var(--bg); color: var(--gold); }

/* ---- #17 roll feed + #8 recap ------------------------------------ */
.roll-feed-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.roll-feed-list li { padding: 3px 0; border-bottom: 1px solid var(--border-soft); color: var(--muted); }
.roll-feed-list li:last-child { border-bottom: 0; }
.recap { margin-bottom: 10px; }
.recap .recap-prose {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  margin: 0;
}
