/* ==========================================================================
   app.css — Mythforge in the Dark
   --------------------------------------------------------------------------
   Mobile-first: base rules target phones (~375px); each section keeps its own
   @media blocks for tablets/desktops next to the rules they adjust. Colours
   and radii live in CSS variables (section 1) so a theme (static/css/themes/)
   re-skins by swapping them rather than restyling classes one by one.
   ========================================================================== */

/* ---------- 1. Theme tokens --------------------------------------------- */
:root {
  --bg: #14110f;          /* soot-black background            */
  --surface: #1f1a17;     /* cards and bars                   */
  --surface-2: #2a231f;   /* hover / raised surfaces          */
  --ink: #e9e1d4;         /* main text: aged paper            */
  --ink-muted: #a89c8b;   /* secondary text                   */
  --accent: #c8923a;      /* brass / lamplight                */
  --accent-ink: #1a1208;  /* text on accent backgrounds       */
  --danger: #b5412f;      /* blood / stress                   */
  --line: #3a312b;        /* borders                          */
  --on-danger: #fff;      /* (MF-041) text on a danger fill   */
  --assist: #6fa8c0;      /* (MF-050) ghost-light blue: an assist's die */

  --radius: 10px;
  --radius-sm: 8px;       /* (MF-041) small boxes: claims, chips' cards, dice, messages */
  --radius-xs: 3px;       /* (MF-041) tick boxes                                      */
  --radius-pill: 999px;   /* (MF-041) badges, chips, status chips                     */
  --gap: 16px;
  --tap: 44px;            /* minimum tap target (Apple/Google guidance) */
  --tabbar-h: 64px;
  --topbar-h: 64px;       /* (MF-047) the sticky top bar's height on phones; desktop below */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: Georgia, "Times New Roman", serif;
}

/* ---------- 2. Reset & base -------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute always wins (form steps, sheet tabs, panel tools): card/flex rules must not
   override it. (MF-041: was written per page.) */
[hidden] { display: none !important; }
/* Every <details> title is a full-size tap target (MF-041: was written per page, five times).
   Panels, openers and other classed summaries refine it below. */
details > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);   /* 16px prevents iOS zoom on inputs */
  /* Leave room so the fixed bottom bar never covers content */
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; }
a { color: var(--accent); }
.sr-only {               /* visible to screen readers only */
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- 3. Top bar & full menu ------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap);
  padding: 8px var(--gap);
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--font-head); font-size: 1.1rem;
  color: var(--ink); text-decoration: none;
}
.menu-toggle {
  min-width: var(--tap); min-height: var(--tap);
  background: none; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); font-size: 1.3rem;
}
/* Phone: menu is a hidden drop-down panel; app.js toggles .open */
.full-menu {
  display: none;
  position: absolute; left: 0; right: 0; top: 100%;
  flex-direction: column;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.full-menu.open { display: flex; }
.full-menu a, .full-menu .disabled {
  min-height: var(--tap); display: flex; align-items: center;
  padding: 0 var(--gap); border-top: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.full-menu .active { color: var(--accent); }
.disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 4. Page & cards --------------------------------------------- */
.page { padding: var(--gap); max-width: 960px; margin: 0 auto; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--gap); margin-bottom: var(--gap);
}
.hero h1 { font-size: 1.8rem; }
.lede { color: var(--ink-muted); }

/* ---------- 5. Buttons -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink);
  font: inherit; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.hero .btn { width: 100%; }   /* full-width on phones = easy thumb target */

/* ---------- 6. Module list (landing page) ------------------------------ */
.module-list { list-style: none; margin: 0; padding: 0; }
.module-list li {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap); border-top: 1px solid var(--line);
}
.module-list li:first-child { border-top: 0; }
.module-icon { width: 1.5em; text-align: center; color: var(--accent); }
.badge {
  margin-left: auto; font-size: .75rem; color: var(--ink-muted);
  border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 2px 10px;
}

/* ---------- 7. Error page ----------------------------------------------- */
.error-card { text-align: center; }
.error-code { font-family: var(--font-head); font-size: 3rem; color: var(--danger); margin: 0; }

/* ---------- 8. Phone bottom tab bar ------------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--ink-muted); text-decoration: none; font-size: .7rem;
}
.tab-icon { font-size: 1.3rem; line-height: 1; }
.tab.active { color: var(--accent); }

/* ---------- 8b. Sign-in (MF-003) --------------------------------------- */
.auth-card { max-width: 420px; margin: 0 auto; }
.auth-form { margin-top: var(--gap); display: grid; gap: 10px; }
.auth-form .btn { width: 100%; }
.field { display: grid; gap: 4px; }
/* (MF-041) Every text box, select and textarea shares one look; rules below only add sizes. */
.field input, .field select, .field textarea, .stack-form select, .sheet textarea {
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit;                      /* 16px: no iOS zoom on focus */
}
.field input { min-height: var(--tap); padding: 0 12px; }
/* (MF-051 review) a file picker shrinks to its panel instead of widening the page at 375px */
.field input[type="file"] { min-width: 0; max-width: 100%; box-sizing: border-box; padding: 8px; }
.notice { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); }
.notice-error { border-color: var(--danger); }

/* ---------- 8c. Campaigns (MF-005) ------------------------------------ */
.campaign-list { list-style: none; margin: 0; padding: 0; }
.campaign-pick {
  width: 100%; min-height: var(--tap); display: flex; align-items: center; gap: 10px;
  padding: 10px 0; background: none; border: 0; border-top: 1px solid var(--line);
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.campaign-list li:first-child .campaign-pick { border-top: 0; }
.campaign-name { flex: 1; }
.stack-form { display: grid; gap: 12px; }
.stack-form select { min-height: var(--tap); padding: 0 10px; }
.eyebrow { margin: 0; color: var(--ink-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.notice-ok { border-color: var(--accent); }
.hint { color: var(--ink-muted); font-size: .9rem; margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0 16px; }
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.check input { width: 22px; height: 22px; }
.field textarea {
  padding: 10px 12px; resize: vertical;
}
.house-rules { white-space: pre-wrap; margin: 0; }
.card h1, .campaign-name, .facts dd, .house-rules { overflow-wrap: anywhere; }  /* long unbroken names */

/* ---------- 9. Wider screens (tablet / desktop) ------------------------ */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .tabbar, .menu-toggle { display: none; }      /* no bottom bar on desktop */
  .full-menu {                                  /* menu becomes an inline row */
    display: flex; position: static; flex-direction: row; gap: 4px;
    background: none; border: 0;
  }
  .full-menu a, .full-menu .disabled { border-top: 0; padding: 0 10px; }
  .hero .btn { width: auto; }
}

/* ---------- 10. Creation forms & crews (MF-010) ------------------------ */
/* Reusable pieces for the crew (MF-010) and character (MF-011) creation pages. */
.plain { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }  /* fieldset without the box */
.plain legend { padding: 0; margin-bottom: 6px; color: var(--ink-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }  /* covers the chip: the whole chip is the tap target */
.chip span {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--bg);
}
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.option input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.upgrade-boxes .box {                       /* each upgrade box: a 44px tap target around a 22px checkbox */
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); cursor: pointer;
}
.upgrade-boxes .box input { width: 22px; height: 22px; margin: 0; }
.upgrade-list { list-style: none; margin: 0; padding: 0; }
.upgrade-list li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.upgrade-boxes { display: flex; gap: 0; min-width: var(--tap); flex: none; }
.cohort-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.counter { color: var(--accent); font-weight: 600; }
.error-items { margin: 6px 0 0; padding-left: 20px; }
.save-bar { position: sticky; bottom: calc(var(--tabbar-h) + 8px); display: flex; gap: 12px;
  align-items: center; justify-content: space-between; }
.type-grid { display: grid; gap: var(--gap); }
.type-card { display: block; color: inherit; text-decoration: none; }
.type-card:hover { border-color: var(--accent); }
.plain-list { margin: 0; padding-left: 20px; }
.btn-danger { border-color: var(--danger); color: var(--ink); background: none; }
.form-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }   /* minmax: never wider than the screen */
.creation-form .field input[type="text"], .creation-form .field select { min-height: var(--tap); }

@media (min-width: 768px) {
  .save-bar { bottom: 8px; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Character creation (MF-011): one row per action, rating chips beside the name. */
.action-row { grid-template-columns: 1fr auto; align-items: center; }
.action-row legend { float: left; margin: 0; color: var(--ink); }
.chip input:disabled + span { opacity: .35; }
.dots { letter-spacing: 2px; color: var(--accent); }
.action-facts { grid-template-columns: 7.5em 1fr; }       /* dots line up across attributes */

/* Desktop (Don, 2026-09-29): wide pages use the width, cards in two columns. */
@media (min-width: 1024px) {
  .page:has(> .wide) { max-width: 1280px; }
  .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .type-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Stepped creation forms on phones (CR-007, FormStepper in app.js). The save bar
   becomes a compact step bar: "2 / 6 · Actions" and the running count on one
   line, Back / Next (or Create) below. */
.creation-form.stepping .save-bar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
.step-progress { margin: 0; font-weight: 600; color: var(--accent); }
.step-head { flex-basis: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.step-head .hint { margin: 0; font-size: .85rem; text-align: right; }
.creation-form.stepping .save-bar .btn { flex: 1; }
.creation-form.stepping .step-back { order: 2; flex: 0 0 30%; }
.creation-form.stepping .step-next,
.creation-form.stepping .save-bar button[type="submit"] { order: 3; }
.creation-form:not(.stepping) .step-head { display: contents; }   /* hint stays in the bar */
.creation-form:not(.stepping) .step-progress,
.creation-form:not(.stepping) .step-back,
.creation-form:not(.stepping) .step-next { display: none; }
.creation-form.stepping .step-no { display: none; }

/* Cards never grow wider than the screen (a long cohort field pushed the
   upgrades card off the right edge at 375px). */
.form-grid > *, .creation-form fieldset { min-width: 0; }   /* fieldsets default to min-content */
.creation-form input, .creation-form select { max-width: 100%; box-sizing: border-box; }
/* Grid fieldsets/labels size their column to content by default; a select with
   long option text then overflows. Let them shrink (action rows keep their own
   two-column layout). */
.creation-form :where(.plain:not(.action-row), .field) { grid-template-columns: minmax(0, 1fr); }
.creation-form .check > span { min-width: 0; }

/* ---- Character sheet (MF-012) ------------------------------------------------
   Phone: a pinned condition strip (stress, trauma, harm) and tabs; each change is
   a tiny form, so buttons sit side by side. Desktop: panels in columns. */
.sheet-head { margin-bottom: 0; }
.sheet-strip { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 4px 14px;
  padding: 8px 12px; margin: 8px 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); font-size: .9rem; }
.sheet-tabs { display: flex; gap: 4px; margin: 0 0 12px; overflow-x: auto; }
.sheet-tabs button { flex: 1; min-height: var(--tap); padding: 0 6px; border: 1px solid var(--line);
  border-radius: var(--radius); background: none; color: var(--ink-muted); font: inherit; white-space: nowrap; }
.sheet-tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }
.sheet-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.sheet-panel { display: grid; gap: 12px; align-content: start; min-width: 0; }
.move-form { display: inline; margin: 0; }
.inline-form { display: grid; gap: 8px; margin-top: 10px; }
.inline-form .btn { justify-self: start; }
.track-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; }
.steppers { display: flex; gap: 6px; }
.steppers .btn { min-width: var(--tap); padding: 0 10px; }
.boxes { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.box { width: 18px; height: 18px; border: 2px solid var(--accent); border-radius: var(--radius-xs); }
.box.on { background: var(--accent); }
.btn-small { min-width: var(--tap); padding: 0 8px; }
.tag-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.tag-list li, .harm-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.harm-level { margin: 6px 0 10px; }
.harm-name { margin: 0 0 4px; }
.harm-row { min-height: var(--tap); padding: 0 0 0 10px; border-left: 3px solid var(--danger); }
.harm-row.empty { border-left-color: var(--line); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.item-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.item-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-btn { min-height: var(--tap); padding: 0 8px; border: 0; background: none; color: var(--ink-muted);
  font: inherit; text-align: left; }
.item-btn.on { color: var(--ink); font-weight: 600; }
.attr-block + .attr-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sheet textarea, .sheet .field select, .sheet .field input { width: 100%; max-width: 100%; box-sizing: border-box; }
.sheet .field select, .sheet .field input { min-height: var(--tap); }
.sheet .field select, .sheet textarea { padding: 0 10px; }
.sheet textarea { padding: 10px; }
.sheet :where(.field, .inline-form) { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) {
  .sheet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #tab-gear { grid-row: span 2; }
  #tab-bio { grid-column: 1 / -1; }
}
.sheet-head h1 { margin-bottom: 0; }

/* ---- MF-013 crew sheet ------------------------------------------------------------
   Edge/flaw/feature checkbox groups, upgrade rows, cohorts, and the claim map.
   The claim map is a list on phones and a 5 x 3 grid (positions as r-N / c-N
   classes; the CSP forbids inline styles) from tablet width up. */
.check-grid { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 12px; margin: 0 0 12px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0 12px; }
.check-grid legend { padding: 0 4px; font-weight: 600; }
.upgrade-row { justify-content: space-between; align-items: flex-start; }
.upgrade-name { min-width: 0; }
.upgrade-actions { display: flex; gap: 6px; flex: none; }
.cohort { border-top: 1px solid var(--line); padding-top: 8px; }
.cohort:first-of-type { border-top: 0; padding-top: 0; }
.claim-map { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.claim { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; display: grid; gap: 4px;
  min-width: 0; overflow-wrap: anywhere; }
.claim.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.claim.lair { border-style: dashed; }
@media (min-width: 768px) {
  .claim-map { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .claim.r-0 { grid-row: 1; } .claim.r-1 { grid-row: 2; } .claim.r-2 { grid-row: 3; }
  .claim.r-3 { grid-row: 4; } .claim.r-4 { grid-row: 5; }
  .claim.c-0 { grid-column: 1; } .claim.c-1 { grid-column: 2; } .claim.c-2 { grid-column: 3; }
  .claim.c-3 { grid-column: 4; } .claim.c-4 { grid-column: 5; }
}
/* (MF-047, docs/FORMATTING.md §3) The crew sheet in columns. Phones: one column, in the template's
   order (left, middle, right, then the wide row). Desktop (>= 1024px): left | middle | right side by
   side, each stacking its own panels, and the wide row (claims, details, GM fixes) across all three. */
.crew-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.crew-col { display: grid; gap: 12px; align-content: start; min-width: 0; }
@media (min-width: 1024px) {
  .crew-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crew-grid > .crew-wide { grid-column: 1 / -1; }
}

/* ---- MF-014 dice page ----------------------------------------------------------
   Action tiles (big radio buttons with rating dots), segmented position/effect
   choices, the result card and the shared log. Desktop: forms left, log right. */
.action-tiles, .seg { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.action-tiles legend, .seg legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.tile { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: var(--tap);
  padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; min-width: 0; }
.tile input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tile:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg .tile { justify-content: center; text-align: center; }
.num-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.btn-roll { width: 100%; min-height: 52px; font-size: 1.1rem; }
.roll-outcome { font-size: 1.8rem; font-weight: 700; margin: 0; }
.roll-result.outcome-critical, .roll-result.outcome-success { border-color: var(--accent); }
.roll-faces { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.die { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.die.counts { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }
/* (MF-050, Don 2026-10-19) the assist's die in its own colour, so the table sees whether the help counted;
   when it is also the die that counts, it keeps the brass fill with a blue ring. */
.die.assist { border: 2px solid var(--assist); color: var(--assist); }
.die.assist.counts { color: var(--accent-ink); box-shadow: 0 0 0 2px var(--assist); }
.die-key { display: inline-flex; align-items: center; gap: 6px; }
.die-key .die { width: 14px; height: 14px; }
/* (MF-050) the character sheet's actions open the dice page: a full-height tap target */
.action-roll { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); color: inherit; }
.action-roll .roll-icon { color: var(--accent); }
.roll-log { list-style: none; margin: 0; padding: 0; }
.roll-entry { border-top: 1px solid var(--line); padding: 8px 0; overflow-wrap: anywhere; }
.roll-entry:first-child { border-top: 0; }
.roll-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.dice-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.dice-forms { display: grid; gap: 12px; min-width: 0; }
@media (min-width: 1024px) {
  .dice-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
  .dice-page #tab-log { position: sticky; top: 8px; }
}

/* ---- MF-009 campaign hub ----------------------------------------------------------
   Quick links, then cards; two columns from 1024px. Stats wrap as short chips. */
.hub-links { flex-wrap: wrap; }
.hub-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); margin-bottom: 12px; }
.hub-item { border-top: 1px solid var(--line); padding: 8px 0; display: grid; gap: 4px; overflow-wrap: anywhere; }
.hub-item:first-of-type { border-top: 0; padding-top: 0; }
.hub-title { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.hub-title a { min-height: var(--tap); display: inline-flex; align-items: center; }
.hub-stats { margin: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; }
@media (min-width: 1024px) {
  .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* ---- MF-015a clocks -----------------------------------------------------------------
   A clock face: wedges outlined; filled ones in the accent colour; complete clocks
   get a solid ring. Cards: face beside the body; a grid from tablet width. */
.clock-face { flex: none; }
.clock-face .wedge { fill: transparent; stroke: var(--line); stroke-width: 1.5; }
.clock-face .wedge.on { fill: var(--accent); stroke: var(--accent-ink); }
.clock-face.complete .wedge { stroke: var(--accent); }
.clock-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.clock-card { display: flex; gap: 12px; align-items: flex-start; }
.clock-card.complete { opacity: .75; }
.clock-body { min-width: 0; display: grid; gap: 4px; overflow-wrap: anywhere; }
@media (min-width: 768px) { .clock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .clock-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---- MF-015b scores ------------------------------------------------------------------
   Score list rows are whole-card links; plan tiles show the plan's detail under its name. */
.score-row { display: grid; gap: 4px; text-decoration: none; color: inherit; min-height: var(--tap); }
.score-row.done { opacity: .7; }
.seg .tile .hint { display: block; font-size: .8rem; }
.score-page .check input, .scores-page .check input { flex: none; }    /* long labels mustn't shrink the box */
.seg .tile:has(.hint) { flex-direction: column; justify-content: center; padding-block: 4px; }
@media (min-width: 1024px) { .score-page .sheet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- MF-016 downtime ------------------------------------------------------------------------ */
.seg.one-col { grid-template-columns: 1fr; }                 /* long choices (entanglements, overindulging) */
.seg.one-col .tile { justify-content: flex-start; text-align: left; }
.entanglement + .entanglement { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.extra-action { margin-top: 12px; }

/* ---- MF-017 factions -------------------------------------------------------------------------
   Status chips: war and the hostile side in the danger colour, the friendly side in the accent.
   Standing rows: the name takes the room, the chip and (GM) the −1/+1 buttons sit beside it and
   wrap under it on a narrow phone. Category lists collapse; desktop shows two columns. */
.status-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.status-chip.neg { border-color: var(--danger); }
.status-chip.war { border-color: var(--danger); background: var(--danger); color: var(--on-danger); }
.status-chip.pos { border-color: var(--accent); }
.standing-row, .faction-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; }
.standing-row + .standing-row, .faction-row + .faction-row { border-top: 1px solid var(--line); }
.standing-name { flex: 1 1 12rem; min-width: 0; display: grid; overflow-wrap: anywhere; }
.standing-name a { min-height: var(--tap); display: inline-flex; align-items: center; }
.standing-row .steppers { margin-left: auto; }
.war-banner { margin: 8px 0; }
.faction-cat > summary { min-height: var(--tap); display: flex; align-items: center; gap: 8px; cursor: pointer; }
.faction-cat > summary h2 { margin: 0; font-size: 1.1rem; }
.status-set { display: grid; gap: 8px; }
.log-line { margin: 0; padding: 6px 0; overflow-wrap: anywhere; }
.log-line + .log-line { border-top: 1px solid var(--line); }
.factions-grid { display: grid; gap: 0; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .factions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; } }

/* ---- MF-020 messenger ------------------------------------------------------------------------
   Phone: the list, or (thread open) only the thread with a back link; the send box sticks to the
   bottom above the tab bar. Desktop (≥1024px): the list on the left, the thread beside it.
   My messages sit to the right with the accent edge; deleted ones are faded. */
.thread-row { display: grid; gap: 2px; padding: 8px 0; min-height: var(--tap); text-decoration: none; color: inherit; }
.thread-row + .thread-row { border-top: 1px solid var(--line); }
.thread-row.active strong { color: var(--accent); }
.badge.unread { border-color: var(--accent); color: var(--accent); }
.messenger.has-open .thread-list { display: none; }
.message-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.message { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; max-width: 92%; overflow-wrap: anywhere; }
.message.mine { margin-left: auto; border-color: var(--accent); }
.message.deleted { opacity: .6; }
.message-head { margin: 0 0 4px; }
.message-text { margin: 0; white-space: pre-wrap; }
.message-delete { margin-top: 4px; text-align: right; }
.send-box { position: sticky; bottom: calc(var(--tabbar-h) + 8px); display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px; align-items: end; background: var(--surface); padding-top: 8px; }
.send-box .field { margin: 0; }
.unread-dot { display: inline-flex; min-width: 18px; height: 18px; padding: 0 4px; margin-left: 4px; border-radius: var(--radius-pill);
  background: var(--danger); color: var(--on-danger); font-size: .7rem; align-items: center; justify-content: center; }
.tab .unread-dot { position: absolute; top: 4px; margin-left: 18px; }
.tab:has(.unread-dot) { position: relative; }      /* only while a badge shows */
@media (min-width: 1024px) {
  .messenger { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
  .messenger.has-open .thread-list { display: block; }
  .thread-back { display: none; }
  .send-box { bottom: 8px; }
}
.thread-back a { display: inline-flex; align-items: center; min-height: var(--tap); }   /* a full-size tap target */

/* ---- MF-028 sessions ------------------------------------------------------------------------------
   The summary: one line per changed sheet, wrapping freely on a phone. */
.summary-lines { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; overflow-wrap: anywhere; }
.sessions-page .check input { flex: none; }

/* ---------- MF-030: the campaign's crew is central (CR-018–CR-022) ---------------------------
   Campaign list: a second line per campaign (home crew · last opened) so same-named campaigns
   can be told apart; the new-campaign form waits behind a <details> button.
   Crew list: the home crew is badged; the GM's "make home" button sits under its row.
   Hub: the home crew card leads with a larger name; other crews are a plain short list. */
.campaign-meta { display: block; font-size: 0.85rem; margin-top: 2px; }
.new-campaign > summary { list-style: none; display: inline-flex; align-items: center; min-height: var(--tap); cursor: pointer; }
.new-campaign > summary::-webkit-details-marker { display: none; }
.new-campaign[open] > summary { margin-bottom: 12px; }
.badge.badge-home { border-color: var(--accent); color: var(--accent); }
.crew-row { border-top: 1px solid var(--line); }
.campaign-list .crew-row:first-child { border-top: 0; }
.crew-row .campaign-pick { border-top: 0; text-decoration: none; }
.crew-home-form { margin: 0 0 10px; }
.sheet-head-link { margin: 4px 0 0; }
.sheet-head-link a { display: inline-flex; align-items: center; min-height: var(--tap); }
.hub-crew-others { list-style: none; margin: 0; padding: 0; }
.hub-crew-others li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: var(--tap);
  border-top: 1px solid var(--line); }
.hub-crew-others li:first-child { border-top: 0; }
.hub-crews h3 { margin: 16px 0 4px; }
.hub-crews .button-row { margin: 10px 0; }
.hub-crew-all { margin: 12px 0 0; }
.hub-crew-others a { display: inline-flex; align-items: center; min-height: var(--tap); }

/* ---------- MF-031: collapsible panels and openers (D30) --------------------------------------
   A panel is a .card <details>: its title bar (<summary>) is a full-width ≥44px tap target with a
   chevron that turns when open; a closed panel shows its one-line summary on the bar. An opener
   is a button (<summary class="btn">) that reveals a form under it. Both work without JS. */
.panel { padding: 0; align-self: start; }   /* a closed panel never stretches to fill a grid row */
/* (MF-047 review) a #fragment jump lands below the sticky top bar, not under it */
.panel { scroll-margin-top: calc(var(--topbar-h) + 8px); }
.panel > .panel-head {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px 12px; flex-wrap: nowrap;
  min-height: var(--tap); padding: 10px var(--gap); border-radius: var(--radius);
}
.panel > .panel-head::-webkit-details-marker { display: none; }
.panel > .panel-head:hover { background: var(--surface-2); }
.panel > .panel-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.panel .panel-title { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.panel .panel-summary { color: var(--ink-muted); font-size: 0.9rem; flex: 0 1 auto; min-width: 0; text-align: right;
  overflow-wrap: anywhere; }
.panel .panel-chevron { width: 10px; height: 10px; margin-left: auto; flex: none;
  border-right: 2px solid var(--ink-muted); border-bottom: 2px solid var(--ink-muted);
  transform: translateY(-3px) rotate(45deg); transition: transform 0.15s ease; }
.panel[open] > .panel-head .panel-chevron { transform: translateY(3px) rotate(-135deg); }
.panel[open] > .panel-head { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.panel > .panel-body { padding: var(--gap); }
.panel > .panel-body > :first-child { margin-top: 0; }
.panel > .panel-body > :last-child { margin-bottom: 0; }
.opener { margin: 8px 0; }
.opener > summary { list-style: none; display: inline-flex; align-items: center; cursor: pointer; }
.opener > summary::-webkit-details-marker { display: none; }
.opener[open] > summary { margin-bottom: 12px; }
.panel-tools { display: flex; gap: 8px; justify-content: flex-end; margin: 0 0 8px; }
@media (prefers-reduced-motion: reduce) { .panel .panel-chevron { transition: none; } }
.faction-page .sheet-head { margin-bottom: var(--gap); }   /* no pinned strip under it here */

/* ---------- MF-021: pictures ------------------------------------------------------------------
   The cover sits beside the name in a sheet header (left of it since MF-038); galleries are a grid of thumbnails (two across on
   phones, more on wide screens), each with its caption and a "Picture tools" opener. A picture in a
   message is a thumbnail that opens full size. Sizes come from these classes (CSP: no inline styles). */
/* (MF-038) The cover leads the header, left of the name, on every width. */
.sheet-head.has-cover { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; }
.sheet-head.has-cover > :not(.sheet-cover) { grid-column: 2; }
.sheet-cover { grid-column: 1; grid-row: 1 / span 4; align-self: start; display: block; width: 88px; height: 88px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sheet-cover img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.gallery { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery-item { min-width: 0; display: grid; gap: 4px; align-content: start; }
.gallery-pic { display: block; aspect-ratio: 1; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--bg); }
.gallery-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-cap { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.gallery-tools { display: grid; gap: 8px; }
.message-picture { display: block; margin-top: 6px; max-width: 240px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.message-picture img { display: block; width: 100%; height: auto; }
@media (min-width: 768px) { .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); } .sheet-cover { width: 120px; height: 120px; } }

/* ---------- MF-018: NPCs ----------------------------------------------------------------------
   The list is a grid of whole-card links (a thumbnail when the NPC has a picture); the NPC page
   is two columns of panels on wide screens. */
.npc-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.npc-card { display: flex; gap: 12px; align-items: flex-start; color: inherit; text-decoration: none; min-height: var(--tap); margin: 0; }
.npc-card:hover { border-color: var(--accent); }
.npc-card.gone { opacity: .7; }
.npc-thumb { flex: none; width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.npc-text { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.npc-ties { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
@media (min-width: 768px) { .npc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .npc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .npc-page .npc-grid-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }

/* ---------- MF-019: rumors ---------------------------------------------------------------------
   One card per rumor, the words in quotes first; the GM's unrevealed ones dashed; a debunked one faded. */
.rumor-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.rumor { margin: 0; display: grid; gap: 6px; overflow-wrap: anywhere; }
.rumor-text { margin: 0; font-size: 1.05rem; }
.rumor.hidden-rumor { border-style: dashed; }
.rumor.debunked .rumor-text { text-decoration: line-through; opacity: .75; }
.badge.verdict-true { border-color: var(--accent); color: var(--accent); }
.badge.verdict-false { border-color: var(--danger); color: var(--danger); }
@media (min-width: 1024px) { .rumor-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }

/* ---------- MF-038: picture visibility; the cover beside the name -----------------------------
   (The cover's place in the header is set with the MF-021 rules above.) The Public / Private switch sits under each picture; Public is marked in the accent colour. */
.picture-visibility { display: block; }
.visibility-switch { width: 100%; justify-content: flex-start; gap: 6px; }
.visibility-switch.is-public { border-color: var(--accent); color: var(--accent); }
.hub-faces { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.hub-faces li { display: grid; justify-items: center; gap: 2px; width: 64px; font-size: .8rem; text-align: center; overflow-wrap: anywhere; }
.hub-faces img, .hub-face-blank { display: block; width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--line); background: var(--bg); }
.picture-cover { display: block; }
.cover-pick { width: 100%; justify-content: flex-start; }
.cover-private { font-size: .8rem; }

/* ---------- MF-033: background specialties ----------------------------------------------------
   The chosen specialty's suggested actions get a diamond in Step 4. */
.bg-options { margin-top: 4px; }
.bg-acts { font-size: .85rem; color: var(--accent); }
.action-row.suggested legend::after { content: " \25c6"; color: var(--accent); font-size: .8em; }
.bg-suggest-note { display: block; margin-top: 4px; }

/* ---------- MF-035: random look ------------------------------------------------------------------ */
.look-field { display: grid; gap: 6px; }
.look-field .look-random { justify-self: start; }

/* ---------- MF-036: setting flavor -------------------------------------------------------------
   A playbook's or crew type's kanji (setting pack data) sits faint behind the sheet header and the
   playbook cards; contacts marked ally / rival get an edge in the matching colour. */
.sheet-head, .type-card.has-kanji { position: relative; overflow: hidden; }
.sheet-kanji, .card-kanji { position: absolute; right: 8px; top: -10px; z-index: 0; pointer-events: none; user-select: none;
  font: 700 96px/1 "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; color: var(--accent); opacity: .12; }
.card-kanji { font-size: 64px; top: -4px; }
.sheet-head > :not(.sheet-kanji), .type-card.has-kanji > :not(.card-kanji) { position: relative; z-index: 1; }
.contact-row.ally { box-shadow: inset 3px 0 0 var(--accent); padding-left: 8px; }
.contact-row.rival { box-shadow: inset 3px 0 0 var(--danger); padding-left: 8px; }
.contact-marks .btn { min-width: 64px; }
.heritage-text { margin: 0; }

/* ---------- MF-037: the GM's live calls --------------------------------------------------------
   Banners sit at the top of <main> on every page; the calls page lists the same calls. */
.call-banners { display: grid; gap: 8px; margin-bottom: 12px; }
.call-banners:empty { display: none; }
.call-banner { background: var(--surface-2); border: 1px solid var(--accent); border-left-width: 4px; border-radius: var(--radius-sm);
  padding: 10px 12px; display: grid; gap: 8px; }
.call-banner .call-text, .call .call-text { margin: 0; font-weight: 600; }
.call-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.call-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.call-icon { color: var(--accent); }

/* ---------- MF-039b1: keys & deadlocks (characters/_keys.html) ------------------------------- */
.key-list li { min-height: var(--tap); }
.key-list .key-name { font-weight: 600; }
.key-list .deadlocked s { color: var(--ink-muted); }

/* (MF-039c) Blades '68: the XP-track select under a trigger's marks takes its own full row */
.xp-marks .xp-track { grid-column: 1 / -1; }
.xp-marks .xp-track select { width: 100%; }

/* (MF-042) The dice page's "About the actions" help: name, then its summary and examples. */
.action-help { margin: 0 0 12px; }
.action-help dt { font-weight: 600; margin-top: 8px; }
.action-help dd { margin: 2px 0 0; }
.dice-page .tile .hint { display: block; font-size: 0.85em; }

/* ---------- MF-043: role banner, the GM's group in the menu, the opening page ------------------
   The banner sits under the top bar on every campaign page: which hat you're wearing there. */
.role-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: .95rem; }
.role-banner > span { flex: 1 1 auto; min-width: 0; }
.role-banner form { margin: 0; }
.role-banner .role-switch { font-size: .9rem; min-height: var(--tap); display: inline-flex; align-items: center; }
.role-banner.role-gm { border-left: 4px solid var(--accent); }
.role-banner.role-viewing { border-left: 4px solid var(--danger); }
.role-banner .role-view-as[open] { flex-basis: 100%; }
.full-menu .menu-group { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; opacity: .7; padding: 8px 12px 0; }
.opening-points { padding-left: 1.2em; display: grid; gap: 6px; margin: 12px 0 16px; }
@media (min-width: 1024px) { .full-menu .menu-group { padding: 0 4px 0 12px; align-self: center; border-left: 1px solid var(--line); } }

/* ---------- MF-046 (review M5): cards listed inside a panel -------------------------------------
   A list panel (clocks, scores, NPCs, rumors, calls, pickers) holds cards of its own; on phones its
   body drops to a slim gutter so the inner cards keep their width at 375px. */
@media (max-width: 767px) {
  .panel > .panel-body:has(> .card, > div > .card, > ol > li.card, > ul > li.card, > a.card) { padding: 8px; }
}
@media (min-width: 1024px) { :root { --topbar-h: 100px; } }   /* (MF-047) the full menu wraps to a taller bar */

/* ---------- MF-029: the entanglement table, in the open ------------------------------------------------
   A plain table of roll | heat | entanglement; a name carries a dotted underline and a help cursor to say "hover me"
   (its title says what it does), and "What each one does" lists the same text for phones, which can't hover. */
.ent-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; }
.ent-table th, .ent-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ent-table th { color: var(--ink-muted); font-weight: normal; font-size: .9rem; }
abbr.tip { text-decoration: underline dotted var(--accent); text-underline-offset: 3px; cursor: help; }
abbr.tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ent-notes { display: grid; gap: 4px; margin: 8px 0 0; }
.ent-notes dt { font-weight: bold; margin-top: 8px; }
.ent-notes dd { margin: 0; color: var(--ink-muted); }


/* ==========================================================================
   (MF-054) Clock audience badge (the picker hides dropdowns with the global [hidden] rule).
   ========================================================================== */
.badge-audience { white-space: nowrap; }


/* ==========================================================================
   (MF-066) Public pages: the launch page, About, Bios, Contact, and the superadmin's Site pages editor.
   ========================================================================== */
/* The social-media logos: a wrapping row of 44px tap targets. */
.social-row { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.social-link { display: block; width: var(--tap); height: var(--tap); border-radius: var(--radius); overflow: hidden; }
.social-link img, .social-thumb { width: var(--tap); height: var(--tap); object-fit: contain; display: block; }
.social-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Text the superadmin typed: keep their line breaks. */
.prose { white-space: pre-line; overflow-wrap: anywhere; }
/* A bio: picture above the text on phones, beside it on wide screens. */
.bio { display: grid; gap: 12px; }
.bio-picture { width: 100%; max-width: 240px; height: auto; border-radius: var(--radius); }
@media (min-width: 768px) { .bio { grid-template-columns: 240px 1fr; align-items: start; } }
/* (MF-082) The About page's Bios window: one row per person, a square thumbnail beside the name, role and text. */
.team { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 16px; }
.team-member { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; }
.team-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 50%; }
.team-thumb-empty { display: grid; place-items: center; border: 1px dashed currentColor; font-size: 1.5rem; text-transform: uppercase; }
.team-name { margin: 0 0 4px; font-weight: 700; }
.team-role { font-weight: 400; opacity: .75; }
.team-text .prose { margin: 0; }
/* (MF-082) A second heading inside one admin panel (Bios: the intro box, then the team) needs room above it. */
.admin-subhead { margin-top: 24px; }
/* The Contact form's trap field: off-screen for people, still there for programs that fill every field. */
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
/* Rows in the Site pages editor: logo, text, then the buttons (wrapping under the text on phones). */
.site-rows li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.site-row-text { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 6px; }


/* ==========================================================================
   (MF-068, reworked by MF-069) Picture rows in the Site pages editor.
   (The public pages' black-and-white look is a theme file: themes/mythforged.css.)
   ========================================================================== */
/* A slot with no picture yet (in the editor's rows): a dashed box with its number. */
.top-placeholder { display: grid; place-items: center; border: 1px dashed var(--ink-muted); border-radius: var(--radius);
  color: var(--ink-muted); font-size: .8rem; }
/* Editor rows: a small 3:2 preview, and the upload form on its own line under the row. */
.top-thumb { width: 66px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); flex: none; }
.site-row-form { flex: 1 1 100%; }


/* ==========================================================================
   (MF-069) The heading's own links (base.html `head_links`) and the launch page's banners.
   ========================================================================== */
/* Links in the heading. Phones: a second row under the name and the menu button. Wide: beside the name. */
.topbar:has(.head-links) { flex-wrap: wrap; }
.head-links { order: 3; flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 0 16px; }
.head-links a { min-height: var(--tap); display: flex; align-items: center; color: var(--ink); text-decoration: none; }
.head-links a:hover, .head-links .active { text-decoration: underline; text-underline-offset: 4px; }
@media (min-width: 768px) { .head-links { order: 0; flex: 1 1 auto; justify-content: flex-end; } }
/* Banners: one column, each the full width of the screen (the page's side padding is undone for them). */
.page:has(> .banners) { max-width: none; padding-left: 0; padding-right: 0; }
.page:has(> .banners) > .launch { max-width: 960px; margin-left: auto; margin-right: auto; border-left: 0; border-right: 0; border-radius: 0; }
.banners { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
/* Height (Don 2026-11-16, MF-070): the whole launch page fits one screen, whatever its size: the heading, the
   title banner, the logos and every game banner are all visible without scrolling. The page is a column exactly
   one screen tall (svh = the screen with a phone browser's bars showing); the title banner takes a fixed share
   of it and the game banners split what is left equally, so their height follows the screen's height and
   resolution. A banner never gets shorter than 56px (its 44px button plus room): with many banners, or on a
   very short screen, the page scrolls instead. */
body:has(.banners) { min-height: 100svh; display: flex; flex-direction: column; padding-bottom: 0; }
body:has(.banners) > .page { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; padding-top: 0; padding-bottom: 0;
  width: 100%; margin: 0; }          /* a flex child with auto side margins would shrink to its content's width */
body:has(.banners) > .page > * { width: 100%; }
.banners { flex: 1 1 auto; grid-auto-rows: minmax(56px, 1fr); }
.banner { position: relative; overflow: hidden; background: var(--surface-2); }
.banner-link { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 8px var(--gap); text-decoration: none; }
.banner-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* The button sits in the middle of the picture; a light dark wash over the picture keeps it readable. */
.banner-link::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .3); }
.banner-button { position: relative; z-index: 1; min-width: min(320px, 80%); justify-content: center; gap: 8px; }
a.banner-link:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
/* No picture yet: a dashed placeholder. Coming soon: set back, and not a link. */
.banner-empty { border-top: 1px dashed var(--ink-muted); border-bottom: 1px dashed var(--ink-muted); }
.banner-empty .banner-link::after { display: none; }
.banner-soon .banner-image { opacity: .45; }
.banner-soon .banner-link { cursor: default; }
/* Phones (Don 2026-11-16): a game banner's picture is scaled down whole, never cropped or stretched: it keeps its
   shape and any space left beside it is the page's black. From 768px pictures fill their banner (cropped, not
   stretched). (The page banner is never cropped at any width: see "Page banner" below.) */
@media (max-width: 767px) {
  .banner-image { object-fit: contain; }
}
/* On the launch page the logos card is a thin strip between the title banner and the game banners. */
.page:has(> .banners) > .launch { flex: 0 0 auto; padding-top: 4px; padding-bottom: 4px; margin-bottom: 8px; border: 0; }
.page:has(> .banners) > .launch .social-row { margin: 0; justify-content: center; }
/* (MF-069) The sign-in page: its card is one narrow column. */
.auth-page { max-width: 420px; margin: 0 auto; }
/* (MF-072) "Sign out (name)" in the site's menu: a form's button made to look and sit like the menu's links. */
.menu-signout { margin: 0; display: contents; }
.menu-signout button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; min-height: var(--tap);
  padding: 0 var(--gap); color: var(--ink); font: inherit; border-top: 1px solid var(--line); }
.menu-signout button:hover, .menu-signout button:focus-visible { background: var(--surface-2); }


/* ==========================================================================
   (MF-073) Fixes from the first blind flow test of the app (tests/logs/flow-app-2026-11-16.md).
   ========================================================================== */
/* H1: on phones a long menu (a GM has about twenty items) ran off the bottom of the screen and under the bottom
   bar with no way to reach the last items. The open menu is now at most the screen between the heading and the
   bottom bar, and scrolls inside itself. */
@media (max-width: 767px) {
  .full-menu.open { max-height: calc(100dvh - 64px - var(--tabbar-h) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
}
/* H2: from 768px the menu is a row; a GM's row was wider than the screen, pushing items off the right edge and
   making every page scroll sideways. The row now wraps onto further lines inside the heading. (MF-048, the
   desktop menu's redesign, is still open; this only stops the overflow.) */
@media (min-width: 768px) {
  .topbar { flex-wrap: wrap; }
  .full-menu { flex-wrap: wrap; justify-content: flex-end; min-width: 0; flex: 1 1 0; row-gap: 0; }
}
/* M1: a clock's card is its dial beside its body. On a phone the Edit form (two dropdowns side by side) is wider
   than the space left beside the dial, so the card ran off the screen. The body's column may now shrink to the
   space it has, and while Edit is open the body takes a full row under the dial. */
.clock-body { grid-template-columns: minmax(0, 1fr); }
.clock-body select, .clock-body input { max-width: 100%; min-width: 0; }
.clock-card:has(details.opener[open]) { flex-wrap: wrap; }
.clock-card:has(details.opener[open]) .clock-body { flex: 1 1 100%; }



/* ==========================================================================
   (MF-077) Page banner: the picture across the top of every site page (the main page's title banner, About,
   Bios, Contact Us, Sign in). Each page has its own picture (set in the Site pages editor); all of them share
   these dimensions. One template (site/_page_banner.html), drawn once by base.html, sized only by the variables
   below: change them here and every page's banner changes size with them.
   Don 2026-11-17: "the full width of the page, dynamic and not distorted when it resizes ... not the same image,
   just the same dimensions."
   ========================================================================== */
:root {
  --page-banner-ratio: 4 / 1;          /* every banner's shape (width / height): it grows and shrinks with the screen */
  --page-banner-max-height: 30svh;     /* but never taller than this share of the screen's height                    */
  --page-banner-fit: contain;          /* the picture is shown whole inside that box: never cropped, never stretched */
  --page-banner-gap: 8px;              /* space under the banner                                                     */
}
/* The same box on every page: the full width of the screen (it sits outside the page's centred column, between
   the heading and the page) and the shape above, so its height follows the screen's width. */
.page-banner { position: relative; width: 100%; flex: 0 0 auto; aspect-ratio: var(--page-banner-ratio);
  max-height: var(--page-banner-max-height); display: grid; place-items: center; overflow: hidden;
  margin-bottom: var(--page-banner-gap); background: var(--bg); }
/* The picture fills the box without changing its own shape. A picture of the box's shape (4:1) fills it exactly;
   any other shape is scaled down whole and centred, with the page's black beside it. */
.page-banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: var(--page-banner-fit); display: block; }
/* No picture yet: the same box, dashed, with a word saying what goes there. */
.page-banner-empty { border-top: 1px dashed var(--ink-muted); border-bottom: 1px dashed var(--ink-muted); color: var(--ink-muted); }
.page-banner-empty span { font-family: var(--font-head); text-transform: uppercase; }

/* ---- (MF-076) Tap targets the flow test found under 44px -------------------------------------------------------
   Every dropdown is a full tap target, wherever it sits (Clocks, Downtime, Factions, Scores, the GM's "View as a
   player"); a name that is a link inside a line of text (a scoundrel on the crew sheet, the crew on a scoundrel's
   sheet) gets the same height without changing the line around it. */
select { min-height: var(--tap); }
.tap-link { display: inline-flex; align-items: center; min-height: var(--tap); }
/* ---- (MF-084) The app's exit: the Mythforged logo at the far right of the top bar ----------------------------
   A 48px square (a full tap target), the whole logo shown, never stretched. The menu button sits just left of it
   on phones (the free space goes before the button); on desktop the inline menu fills the space before it. */
.exit-logo { flex: 0 0 auto; display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--radius);
  background: #000; overflow: hidden; }
.exit-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.exit-logo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar:has(.exit-logo) > .menu-toggle { margin-left: auto; }

/* ---- (MF-085) The app's logo lettering, where its name was the title --------------------------------------------
   White outline, see-through letters, so it sits on any theme's top bar. Height is fixed per place; width follows. */
.wordmark { display: block; width: auto; max-width: 100%; }
.brand-wordmark { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); min-width: 0; }
.brand-wordmark .wordmark-bar { height: 32px; }
.brand-tag { font-size: .7rem; letter-spacing: .1em; opacity: .75; }
.wordmark-title .wordmark-title, .wordmark-title .wordmark { height: 64px; margin: 4px 0 8px; }
/* the launch page's banner: a black plate behind the lettering, so it reads over any picture */
.banner-button-wordmark { background: rgba(0, 0, 0, .78); border-color: rgba(255, 255, 255, .6); padding: 8px 18px; height: auto; }
.banner-button-wordmark .wordmark-large { height: clamp(40px, 9vh, 96px); }


/* ---- (MF-089) The main page's banner: the Mythforged logo, front and centre ------------------------------------
   Don 2026-11-18: the logo goes "front and center ... above app banners", with an illustration behind it "the same
   aspect ratio as the other banner". So it is the same --page-banner-* box as every site page's banner; the picture
   set for Home on /admin/site is the illustration, and the logo sits over its middle at most of the box's height.
   A soft dark glow behind the logo keeps the gold readable over a busy or bright picture. */
:root { --page-banner-logo-height: 88%; }       /* the logo's height as a share of the banner's */
.page-banner .page-banner-logo { position: absolute; inset: 0; margin: auto; z-index: 2;
  width: auto; height: var(--page-banner-logo-height); max-width: 92%; object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .85)); }
.page-banner-emblem:not(.page-banner-empty)::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 30% 60% at 50% 50%, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0) 100%); }

/* ---- (MF-090) A wide logo on a launch banner (Blade Runner's is over 5:1) -----------------------------------------
   The lettering keeps MF-085's height cap but is also held to the width of the other games' buttons, so every banner's
   button is about the same size; the logo shrinks whole, never stretched. */
.banner-button-wordmark .wordmark-large { height: auto; max-height: clamp(40px, 9vh, 96px); max-width: min(240px, 46vw); }
.banner-button-wordmark .badge { white-space: nowrap; }

/* ---- (MF-091) The social logos in the heading, left of Modern Mythology ----------------------------------------
   Each stays a 44px tap target; the picture inside is smaller so the row sits level with the heading's words. */
.head-links { align-items: center; }
.head-links .social-row { margin: 0 8px 0 0; gap: 4px; flex-wrap: nowrap; }
.head-links .social-link { display: grid; place-items: center; }
.head-links .social-link img { width: 28px; height: 28px; }
/* Don 2026-11-18: on phones the logos are their own row, between MYTHFORGED and the three links; from 768px they sit
   on the heading's one line, just before Modern Mythology. */
.head-links .social-row { flex: 1 1 100%; }
@media (min-width: 768px) { .head-links .social-row { flex: 0 0 auto; } }

/* ===== (MF-092b) Echoes of the Veil runner sheet and Log a Runner ========================================================
   docs/FORMATTING.md §11. Phone: one column of closed panels. From 1024px the sheet's panels sit in two columns. */
.sheet-columns { display: grid; gap: var(--gap); }
@media (min-width: 1024px) { .sheet-columns { grid-template-columns: 1fr 1fr; align-items: start; } }
/* Log a Runner: a skill's points beside its Specialization (stacked on phones). */
.skill-row { padding: 8px 0; border-bottom: 1px solid var(--line); }   /* (MF-092o) the picker holds the whole row */
.rating-field select { max-width: 6rem; }
/* The gear list: one tap target per item, its note beside it. */
.gear-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 4px 0; }

/* ---- MF-092c: Echoes of the Veil rolls ----------------------------------------------------------------------------- */
/* A Glitch die keeps its own colour (dashed, the theme's warning colour) in the result, the log and the poller. */
.die.glitch { border: 2px dashed var(--danger); color: var(--danger); }
.die.glitch.counts { color: var(--accent-ink); box-shadow: 0 0 0 2px var(--danger); }

/* ---- MF-092e: Echoes Run page ------------------------------------------------------------------------------------ */
/* Long option text (Consequence levels, Enemy types) must not widen the page: grid children and selects may shrink. */
.run-page .sheet-columns > *, .run-page .num-row > *, .run-page details, .run-page form, .run-page .field { min-width: 0; }
.run-page select, .runner-rolls select { max-width: 100%; width: 100%; }

/* (MF-092i) an Echoes player's heading: the game's name in place of the app's lettering */
.brand-echoes { font-family: "IBM Plex Mono", ui-monospace, monospace; letter-spacing: 0.04em; text-transform: uppercase; }


/* ---------- (MF-092m) Die glyphs: levels picked and shown as dice --------------------------------------------------
   forms/_dice.html. A die is a square with a + (and a second square behind it, offset, as the book draws a cube).
   Marked dice fill with the accent. In a picker each die is the label of a hidden radio: the checked die and every
   die before it are marked (:has(~ input:checked)); each label is a full tap target. */
.dice-pick { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
.dice-pick legend { padding: 0; margin-bottom: 2px; color: var(--ink-muted); font-size: .9rem; }
.dice-row { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.dice-row .die, .dice-row .die-zero {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap); cursor: pointer; border-radius: var(--radius-sm);
}
.dice-row .die-zero { color: var(--ink-muted); font-size: .85rem; }
.die-face {
  position: relative; display: inline-block; width: 24px; height: 24px; flex: none;
  border: 2px solid var(--ink-muted); border-radius: 3px; background: var(--surface);
  box-shadow: 4px -4px 0 -2px var(--surface), 4px -4px 0 0 var(--ink-muted);      /* the cube's back face */
}
.die-face::after {                                                                   /* the + */
  content: "+"; position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 18px/1 var(--font-body); color: var(--ink-muted);
}
.die-special .die-face, .die-face.die-special { border-style: dashed; }
/* marked: the chosen die and the ones before it */
.dice-row input:checked + .die .die-face,
.dice-show .die-face.is-on {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 4px -4px 0 -2px var(--surface), 4px -4px 0 0 var(--accent);
}
.dice-row input:checked + .die .die-face::after,
.dice-show .die-face.is-on::after { color: var(--accent-ink); }
/* (review M4) the dice before the chosen one, in its own rule: a browser without :has() drops only this one */
.dice-row .die:has(~ input:checked) .die-face {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 4px -4px 0 -2px var(--surface), 4px -4px 0 0 var(--accent);
}
.dice-row .die:has(~ input:checked) .die-face::after { color: var(--accent-ink); }
/* (MF-092o) a split picker (the special dice on their own line): a special die chosen marks every die on the first
   line; within each line the rule above marks the dice before the chosen one. Any number of dice. */
.dice-pick:has(.dice-special-row input:checked) .dice-row:first-of-type .die .die-face {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 4px -4px 0 -2px var(--surface), 4px -4px 0 0 var(--accent);
}
.dice-special-row { align-items: flex-start; flex-wrap: nowrap; }
/* (MF-092t) the special die and its sentence beside the skill's dice, top-aligned, wrapping below only when narrow */
.dice-lines { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 12px; }
.dice-lines > .dice-special-row { flex: 1 1 16rem; min-width: 0; }   /* (MF-092u) its own line on a phone */
/* (MF-092u) the Specialization's words, pipe-separated and tappable, level with the dice; the box below */
.spec-field { margin: 0; }
.spec-words { margin: 0; padding-top: 6px; line-height: 1.2; }
.spec-item { white-space: nowrap; }                                   /* a word keeps its pipe; lines break between */
.spec-word { background: none; border: 0; padding: 6px 4px; min-height: var(--tap); min-width: var(--tap);
  color: var(--accent); cursor: pointer; font: inherit; white-space: nowrap;
  text-decoration: underline; text-underline-offset: 3px; }
.spec-field input { width: 100%; padding-right: 28px; }               /* room for the list's arrow */
.spec-word[aria-pressed="true"] { color: var(--ink); text-decoration-thickness: 2px; font-weight: 700; }
.spec-word:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spec-pipe { color: var(--ink-muted); }
.dice-special-body { flex: 1; min-width: 0; }
.dice-special-body .field { margin: 0; }
@media (forced-colors: active) {            /* (review L4) marked dice keep a fill in high-contrast modes */
  .dice-row input:checked + .die .die-face, .dice-show .die-face.is-on { background: Highlight; border-color: Highlight; }
  .dice-row .die:has(~ input:checked) .die-face { background: Highlight; border-color: Highlight; }
  .dice-pick:has(.dice-special-row input:checked) .dice-row:first-of-type .die .die-face { background: Highlight; border-color: Highlight; }
}
.dice-row input:checked + .die-zero { color: var(--ink); text-decoration: underline; }
.dice-row input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.dice-row .die:hover .die-face { border-color: var(--accent); }
.dice-show { display: inline-flex; gap: 8px; vertical-align: middle; padding-top: 4px; margin: 0 8px 0 6px; }
.dice-show .die-face { width: 18px; height: 18px; }
.dice-show .die-face::after { font-size: 14px; }

/* (MF-092p) an installed Aug's effect, under its name */
.aug-effect { margin: 2px 0 6px; white-space: pre-line; }
.aug-effect .eyebrow { margin-right: 6px; }
.chip-row > details.opener[open] { flex: 1 1 100%; }     /* (MF-092p review) an open editor takes the whole row */

/* ---------- (MF-092s, CR-118/119) The runner sheet as the Runner's File ---------------------------------------------
   Four columns from 1280px (the File's page 2), two from 768px (1+2, then 3+4), one on a phone in order 1 -> 4.
   Each column is a stack of the usual closed panels. Load & Gear lists its items in two columns. */
.runner-file { display: grid; gap: var(--gap); align-items: start; }
.file-col { display: grid; gap: var(--gap); min-width: 0; align-content: start; }
.file-col > *, .file-col details, .file-col form, .file-col .field { min-width: 0; }
@media (min-width: 768px) { .runner-file { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .runner-file { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.gear-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.gear-two-col > li { min-width: 0; }
.gear-two-col .move-form { display: block; }
.gear-two-col .btn { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; }
.gear-two-col .hint { display: block; font-size: .8rem; }
@media (min-width: 1280px) { .page:has(> .wide.runner-sheet) { max-width: 1600px; } }   /* room for four columns */
@media (max-width: 360px) { .gear-two-col { grid-template-columns: 1fr; } }
