/* gm-apprentice-publish — Mobile-first base stylesheet
   Theme presets set CSS custom properties; this file reads them with defaults.
   Dark-first design: light mode via prefers-color-scheme in preset CSS. */

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Core palette — overridden by genre presets and theme.css */
  --bg: #1a1f25;
  --bg-card: #232830;
  --bg-header: #0d1117;
  --bg-hero: #0d1117;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-on-header: var(--accent);   /* the accent on the dark header and hero (a preset sets its own) */
  --accent-dim: rgba(88, 166, 255, 0.15);
  --border: #30363d;
  --danger: #f85149;
  --warning: #d29922;
  --success: #3fb950;

  /* #363: the rest of the look, named. Each default is the colour the rule used before it was named; a theme sets any
     of them in its own :root (docs/theme-tokens.md lists them; lib/theme-tokens.js is the list). */
  --text-on-image: #fff;                         /* words laid over a picture: an entity banner, the lightbox */
  --story-muted: #888;                           /* the story page's small labels (read through --muted) */
  --badge-draft: #e8b84d;
  --quick-link-border: rgba(0, 0, 0, 0.15);      /* read through --color-border */
  --search-mark-bg: rgba(88, 166, 255, 0.2);
  --needs-dev-bg: rgba(210, 153, 34, 0.1);
  --on-warning: #1a1a1a;                         /* the GM site's band, on --warning */
  /* status badges */
  --status-alive: #3fb950; --status-alive-bg: rgba(46,160,67,0.2);
  --status-dead: #f85149; --status-dead-bg: rgba(218,54,51,0.2);
  --status-missing: #d29922; --status-missing-bg: rgba(210,153,34,0.2);
  --status-captured: #a371f7; --status-captured-bg: rgba(130,80,223,0.2);
  --status-presumed-dead: #da6d6a; --status-presumed-dead-bg: rgba(218,54,51,0.15);
  --status-retired: #8b949e; --status-retired-bg: rgba(110,118,129,0.2);
  --status-kia-bg: rgba(248, 81, 73, 0.15); --status-mia-bg: rgba(210, 153, 34, 0.15);
  /* chapters and the timeline */
  --chapter-complete: #50c878; --chapter-complete-bg: rgba(80, 200, 120, 0.15);
  --chapter-active-bg: rgba(184, 150, 46, 0.15); --chapter-upcoming-bg: rgba(150, 150, 150, 0.15);
  --tl-session: #3fb950; --tl-session-bg: rgba(46,160,67,0.2);
  /* the bestiary and the locations list */
  --bestiary-edge: #c0392b;
  --threat-extreme: #e74c3c; --threat-extreme-bg: rgba(192, 57, 43, 0.2); --threat-extreme-border: rgba(192, 57, 43, 0.4);
  --threat-high: #e67e22; --threat-high-bg: rgba(230, 126, 34, 0.2); --threat-high-border: rgba(230, 126, 34, 0.4);
  --threat-moderate: #f1c40f; --threat-moderate-bg: rgba(241, 196, 15, 0.2); --threat-moderate-border: rgba(241, 196, 15, 0.4);
  --threat-unknown-bg: rgba(150, 150, 150, 0.15);
  --creature-killed: #50c878; --creature-killed-bg: rgba(80, 200, 120, 0.15); --creature-killed-border: rgba(80, 200, 120, 0.3);
  --creature-active: #e74c3c; --creature-active-bg: rgba(192, 57, 43, 0.15); --creature-active-border: rgba(192, 57, 43, 0.3);
  --creature-unknown-bg: rgba(150, 150, 150, 0.1);
  --bestiary-ability-bg: rgba(184, 150, 46, 0.12); --bestiary-ability-border: rgba(184, 150, 46, 0.3);
  --bestiary-weakness: #50c878; --bestiary-weakness-bg: rgba(80, 200, 120, 0.1); --bestiary-weakness-border: rgba(80, 200, 120, 0.25);
  --loc-type-bg: rgba(184, 150, 46, 0.12); --loc-type-border: rgba(184, 150, 46, 0.25);
  /* factions and items */
  --intel-military: #9ab856; --intel-military-bg: rgba(107, 142, 35, 0.2);
  --intel-corporation: #7ab4d9; --intel-corporation-bg: rgba(70, 130, 180, 0.2);
  --intel-government: #a0b0c0; --intel-government-bg: rgba(112, 128, 144, 0.2);
  --intel-other-bg: rgba(139, 148, 158, 0.15); --intel-canon-bg: rgba(139, 148, 158, 0.1);
  --armory-tl: #9ab856; --armory-tl-bg: rgba(107, 142, 35, 0.2);
  /* the live party board (GURPS and Call of Cthulhu) */
  --live-reeling: #ef7c3a; --live-reeling-bg: rgba(239,124,58,0.14);
  --live-tired: #5b9bd5; --live-tired-bg: rgba(91,155,213,0.15);
  --live-bar-bg: rgba(128,128,128,0.2); --live-bar-third: rgba(255,255,255,0.3);
  --live-bar-fp: #5b9bd5; --live-bar-san: #9d7bd8; --live-bar-mp: #4ba3c7;
  --live-insanity: #b98be0; --live-insanity-bg: rgba(157,123,216,0.16);
  --live-wound: #e06b5c; --live-wound-bg: rgba(192,57,43,0.18);
  --live-unconscious: #d4a017; --live-unconscious-bg: rgba(212,160,23,0.18);
  --live-dying: #ff6b6b; --live-dying-bg: rgba(192,57,43,0.28);
  --live-row-mad: rgba(157,123,216,0.14); --live-row-hurt: rgba(192,57,43,0.15);
  /* the Story page's Memorable Moments: the colour of each kind's row. The plain look keeps its dark card in the light
     scheme, so these stay; a genre preset with a light card sets deeper ones in its light block. */
  --moment-dramatic: #ff8f80; --moment-intriguing: #7fc8ff; --moment-funny: #ffc857; --moment-epic: #c9a7ff; --moment-tragic: #b8c2d1;

  /* Fonts */
  --font-heading: system-ui, -apple-system, sans-serif;
  --font-body: system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Monaco, Consolas, monospace;
  --font-serif: Georgia, "Times New Roman", serif;
  /* The face a PC's backstory and hook are read in: a genre preset or a theme heading font sets its own. */
  --font-reading: Georgia, 'Iowan Old Style', 'Times New Roman', serif;

  /* #363: type sizes, spacing and corner radii that recur exactly in the site's own rules (the character sheets keep
     their own). The number is the size in thousandths of a rem: --font-size-875 is 0.875rem. */
  --font-size-650: 0.65rem; --font-size-700: 0.7rem; --font-size-750: 0.75rem; --font-size-800: 0.8rem; --font-size-850: 0.85rem;
  --font-size-875: 0.875rem; --font-size-900: 0.9rem; --font-size-950: 0.95rem; --font-size-1000: 1rem; --font-size-1100: 1.1rem;
  --space-250: 0.25rem; --space-500: 0.5rem; --space-750: 0.75rem; --space-1000: 1rem; --space-1250: 1.25rem;
  --space-1500: 1.5rem; --space-2000: 2rem;
  --radius-200: 0.2rem; --radius-250: 0.25rem; --radius-375: 0.375rem; --radius-500: 0.5rem; --radius-750: 0.75rem;

  /* Scrollbars and form controls follow the palette (#260). */
  color-scheme: dark;
}

@media screen and (prefers-color-scheme: light) {
  :root:not(:where([data-theme="dark"])) {
    color-scheme: light;
  }
}
@media screen {
  :root:where([data-theme="light"]) {
    color-scheme: light;
  }
}
@media print {
  :root {
    color-scheme: light;
  }
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  line-height: 1.3;
  color: var(--text);
}

p { margin-bottom: var(--space-1000); }
ul, ol { margin: 0 0 var(--space-1000) var(--space-1250); }
li { margin-bottom: var(--space-250); }

img {
  max-width: 100%;
  height: auto;
}

/* The label face (#363): the menu, labels, table heads, badges, buttons, meta lines and date labels. A theme sets
   --font-label, or player_site.theme.fonts.label writes it into theme.css. It is unset by default, and this rule has
   no fallback on purpose: an unset var() makes the declaration invalid at computed-value time, so font-family acts as
   unset and these elements inherit their face exactly as they did before (from a sheet, a backstory, or a site's own
   body or container face). :where() keeps it at zero specificity, so any rule that sets a face on one of them still
   wins; those rules read var(--font-label, <their own face>). (The DRAFT, STUB and SUPERSEDED badges sit in a title and
   take its face, so they are not in this list.) */
:where(.top-nav, .breadcrumbs, .meta, .label, .date-label, .recap-link, .metadata-badge, .status-badge, .story-begin, .cr-send, th) {
  font-family: var(--font-label);
}

/* ===== TOP NAV BAR ===== */
.top-nav {
  background: var(--bg-header);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 var(--space-1000);
  height: 3.5rem;
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  color: var(--text-on-header, var(--text));
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--font-size-1100);
  white-space: nowrap;
  text-decoration: none;
  margin-right: var(--space-2000);
}
.nav-brand:hover {
  color: var(--accent-on-header);
  text-decoration: none;
}

.nav-groups {
  display: none;
  align-items: center;
  gap: 0;
  flex: 1;
}

.nav-group {
  position: relative;
}

.nav-group-toggle {
  background: none;
  border: none;
  color: var(--text-muted-on-header, var(--text-muted));
  font-family: var(--font-label, var(--font-body));
  font-size: var(--font-size-875);
  font-weight: 600;
  padding: var(--space-1000) var(--space-1000);
  cursor: pointer;
  white-space: nowrap;
  height: 3.5rem;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-group-toggle:hover,
.nav-group.open .nav-group-toggle {
  color: var(--text-on-header, var(--text));
  border-bottom-color: var(--accent-on-header);
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-500) var(--radius-500);
  min-width: 12rem;
  padding: var(--space-500) 0;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.nav-group.open .nav-dropdown {
  display: block;
}

.nav-dropdown a {
  display: block;
  padding: var(--space-500) var(--space-1000);
  color: var(--text-on-header, var(--text));
  font-size: var(--font-size-875);
  text-decoration: none;
}
.nav-dropdown a:hover {
  background: var(--accent-dim);
  color: var(--accent-on-header);
  text-decoration: none;
}

.nav-search-btn {
  background: none;
  border: 1px solid var(--text-muted-on-header, var(--border));
  border-radius: var(--radius-375);
  color: var(--text-muted-on-header, var(--text-muted));
  font-size: var(--font-size-800);
  padding: 0.35rem var(--space-750);
  cursor: pointer;
  margin-left: auto;
  white-space: nowrap;
  display: none;
}
.nav-search-btn:hover {
  border-color: var(--accent-on-header);
  color: var(--text-on-header, var(--text));
}

.nav-mobile-toggle {
  background: none;
  border: none;
  color: var(--text-on-header, var(--text));
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-250);
  line-height: 1;
  margin-left: auto;
}

/* Mobile nav overlay */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-header);
  z-index: 300;
  padding: var(--space-1000);
  overflow-y: auto;
}
.mobile-nav-overlay.open {
  display: block;
}
.mobile-nav-close {
  background: none;
  border: none;
  color: var(--text-on-header, var(--text));
  font-size: 2rem;
  cursor: pointer;
  position: absolute;
  top: 0.75rem;
  right: 1rem;
}
.mobile-nav-overlay h3 {
  color: var(--accent-on-header);
  font-size: var(--font-size-800);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: var(--space-1500) 0 var(--space-500);
  padding-bottom: var(--space-250);
  border-bottom: 1px solid var(--border);
}
.mobile-nav-overlay h3:first-of-type {
  margin-top: 3rem;
}
.mobile-nav-overlay ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mobile-nav-overlay li a {
  display: block;
  padding: 0.6rem 0;
  color: var(--text-on-header, var(--text));
  font-size: var(--font-size-1000);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.mobile-nav-overlay li a:hover {
  color: var(--accent-on-header);
  text-decoration: none;
}
.mobile-nav-search {
  margin-top: var(--space-2000);
}

/* Light/dark toggle (#260). It shows the mode it switches TO: the sun while the
   dark palette is up, the moon while the light one is. The light block below is
   rewritten at build time to follow the reader's choice as well as the OS, so the
   glyph is right on first paint. */
.nav-color-mode-btn {
  background: none;
  border: 1px solid var(--text-muted-on-header, var(--border));
  border-radius: var(--radius-375);
  color: var(--text-muted-on-header, var(--text-muted));
  font-size: var(--font-size-950);
  line-height: 1;
  padding: 0.3rem 0.55rem;
  margin-left: var(--space-500);
  cursor: pointer;
  display: none;
}
.nav-color-mode-btn:hover {
  border-color: var(--accent-on-header);
  color: var(--text-on-header, var(--text));
}
.mobile-color-mode-btn {
  display: block;
  margin-top: var(--space-2000);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-375);
  color: var(--text);
  font-size: var(--font-size-1000);
  padding: 0.6rem var(--space-1000);
  min-height: 44px;
  cursor: pointer;
}
.nav-color-mode-btn .to-dark,
.mobile-color-mode-btn .to-dark { display: none; }

@media screen and (prefers-color-scheme: light) {
  :where(:root:not([data-theme="dark"])) .nav-color-mode-btn .to-light, :where(:root:not([data-theme="dark"])) .mobile-color-mode-btn .to-light { display: none; }
  :where(:root:not([data-theme="dark"])) .nav-color-mode-btn .to-dark, :where(:root:not([data-theme="dark"])) .mobile-color-mode-btn .to-dark { display: inline; }
}
@media screen {
  :where(:root[data-theme="light"]) .nav-color-mode-btn .to-light, :where(:root[data-theme="light"]) .mobile-color-mode-btn .to-light { display: none; }
  :where(:root[data-theme="light"]) .nav-color-mode-btn .to-dark, :where(:root[data-theme="light"]) .mobile-color-mode-btn .to-dark { display: inline; }
}
@media print {
  .nav-color-mode-btn .to-light, .mobile-color-mode-btn .to-light { display: none; }
  .nav-color-mode-btn .to-dark, .mobile-color-mode-btn .to-dark { display: inline; }
}

/* Phone-width search trigger (#267): the text button above is desktop-only. */
.nav-search-icon-btn {
  background: none;
  border: none;
  color: var(--text-on-header, var(--text));
  cursor: pointer;
  padding: var(--space-500);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}
.nav-search-icon-btn:hover,
.nav-search-icon-btn[aria-expanded="true"] {
  color: var(--accent-on-header);
}
.nav-search-icon-btn + .nav-mobile-toggle { margin-left: var(--space-250); }

/* Desktop responsive */
@media (min-width: 768px) {
  .nav-groups { display: flex; }
  .nav-mobile-toggle { display: none; }
  .nav-search-icon-btn { display: none; }
  .nav-search-btn { display: block; }
  .nav-color-mode-btn { display: block; }
}

/* ===== BREADCRUMBS ===== */
.breadcrumbs {
  font-size: var(--font-size-850);
  color: var(--text-muted);
  margin-bottom: var(--space-1000);
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.breadcrumbs a {
  color: var(--accent);
}
.breadcrumbs .sep {
  margin: 0 0.35rem;
  opacity: 0.5;
}

/* ===== MAIN CONTENT ===== */
.content {
  max-width: 52rem;
  margin: 0 auto;
  padding: var(--space-1500) var(--space-1000) 3rem;
}

/* ===== TYPOGRAPHY ===== */
.page-title {
  font-size: 1.75rem;
  margin-bottom: var(--space-500);
}
/* A prop note's link to its prop, under the title */
.prop-link { margin: 0 0 var(--space-1000); }
.prop-btn {
  display: inline-block;
  padding: 0.4rem var(--space-1000);
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.prop-btn:hover, .prop-btn:focus-visible { background: var(--accent); color: var(--on-accent, var(--bg)); }
/* A listing of props: what a container holds */
.prop-list { list-style: none; margin: var(--space-1000) 0; padding: 0; }
h3.prop-group { margin: var(--space-1250) 0 0; font-size: 1.05rem; }
.prop-item { padding: var(--space-500) 0; border-bottom: 1px solid var(--border); }
.prop-item:last-child { border-bottom: none; }
.prop-line { display: block; color: var(--text-muted); font-size: var(--font-size-950); }
.prop-arrived, .gm-unrevealed { display: inline-block; margin-left: var(--space-500); font-size: var(--font-size-850); color: var(--text-muted); }
.gm-unrevealed { font-style: italic; }
.prop-sealed .prop-title { color: var(--text-muted); }
.prop-seal {
  margin-left: var(--space-500);
  padding: 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: var(--font-size-750);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
/* The props page: every prop the site shows, by where it sits */
.props-cover {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 20rem;
  margin: 0 0 var(--space-1000);
  object-fit: contain;
  border-radius: var(--radius-500);
}
.props-intro { color: var(--text-muted); margin: 0 0 var(--space-1500); }
.prop-group h2 a { color: inherit; text-decoration: none; }
.prop-group h2 a:hover, .prop-group h2 a:focus-visible { text-decoration: underline; }
.props-latest h2 a { color: inherit; text-decoration: none; }
.page-subtitle {
  color: var(--text-muted);
  font-size: var(--font-size-1000);
  margin-bottom: var(--space-1500);
}
h2 {
  font-size: 1.3rem;
  color: var(--accent);
  margin: var(--space-2000) 0 var(--space-750);
  padding-bottom: var(--space-250);
  border-bottom: 2px solid var(--accent);
}
h3 {
  font-size: var(--font-size-1100);
  margin: var(--space-1500) 0 var(--space-500);
}

/* ===== HERO BANNER (entity pages) ===== */
.hero-banner {
  position: relative;
  background: var(--bg-hero);
  border-radius: var(--radius-750);
  overflow: hidden;
  margin-bottom: var(--space-1500);
  min-height: 12rem;
  display: flex;
  align-items: flex-end;
}
.hero-banner-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
}
.hero-banner-overlay {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 3rem var(--space-1500) var(--space-1500);
  background: linear-gradient(transparent 0%, rgba(0,0,0,0.7) 50%, rgba(0,0,0,0.85) 100%);
  color: var(--text-on-image);
  /* The overlay stacks above .hero-banner-img and would otherwise swallow
     every click over the lower banner, so the lightbox never opened where a
     reader actually clicks (#183). Interactive children get hit-testing back. */
  pointer-events: none;
}
.hero-banner-overlay a,
.hero-banner-overlay button,
.hero-banner-overlay input,
.hero-banner-overlay select {
  pointer-events: auto;
}
.hero-banner h1 {
  font-size: 1.75rem;
  color: var(--text-on-image);
  margin-bottom: var(--space-250);
}
.hero-banner .meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-500) var(--space-1250);
  font-size: var(--font-size-875);
  opacity: 0.9;
}
.hero-banner .meta .label {
  color: var(--accent-on-header);
  font-size: var(--font-size-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hero-banner-no-img {
  background: linear-gradient(135deg, var(--bg-hero) 0%, var(--bg-card) 100%);
  padding: 2.5rem var(--space-1500) var(--space-1500);
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
}
.hero-banner-no-img h1 {
  color: var(--text);
}
.hero-banner-no-img .pc-portrait {
  flex-shrink: 0;
  margin: 0 0 var(--space-750);
}

/* Cinematic banner (PCs) */
.hero-cinematic {
  display: flex;
  align-items: center;
  gap: var(--space-1500);
  padding: var(--space-1500);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  margin-bottom: var(--space-1500);
}
.hero-cinematic-img {
  width: 10rem;
  height: 14rem;
  object-fit: cover;
  border-radius: var(--radius-500);
  flex-shrink: 0;
}
.hero-cinematic-overlay {
  flex: 1;
}
.hero-cinematic-overlay h1 {
  margin: 0 0 var(--space-500);
}
.hero-cinematic-overlay .meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-500) var(--space-1250);
  font-size: var(--font-size-900);
  color: var(--text-muted);
}
.hero-cinematic-overlay .meta .label {
  color: var(--accent-on-header);
  font-weight: 600;
}
.hero-cinematic-no-img {
  justify-content: flex-start;
}
.hero-cinematic-no-img .pc-portrait {
  width: 5rem;
  height: 5rem;
  font-size: 2rem;
}
@media (max-width: 600px) {
  .hero-cinematic { flex-direction: column; text-align: center; }
  .hero-cinematic-img { width: 8rem; height: 11rem; }
  .hero-cinematic-overlay .meta { justify-content: center; }
}

/* ===== PULL QUOTE ===== */
.pull-quote {
  font-family: var(--font-reading);
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--text-muted);
  border-left: 3px solid var(--accent);
  padding: var(--space-750) 0 var(--space-750) var(--space-1250);
  margin: 0 0 var(--space-1500);
}
/* A quote taken from the backstory steps aside while the Story tab, which opens on it, is open */
body:has(#tab-story.active) .pull-quote-backstory {
  display: none;
}

/* ===== PC PAGE WITHOUT A SHEET ===== */
.pc-identity {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-500) var(--space-1500);
  font-size: var(--font-size-950);
  margin: 0 0 var(--space-750);
}
.pc-identity .label {
  color: var(--accent);
  font-size: var(--font-size-750);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.35rem;
}
.sheet-withheld {
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 var(--space-1500);
}

/* ===== CHARACTER HEADER CARD (legacy, used by simple entities) ===== */
.char-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-1250);
  margin-bottom: var(--space-1500);
}
.char-header h1 {
  font-size: 1.5rem;
  margin-bottom: var(--space-250);
}
.char-header .concept {
  font-style: italic;
  opacity: 0.85;
  margin-bottom: var(--space-750);
  line-height: 1.4;
}
.char-header .meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-750) var(--space-1500);
  font-size: var(--font-size-900);
}
.char-header .meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.char-header .meta .meta-value {
  display: inline;
}
.char-header .meta .label {
  color: var(--accent);
  font-size: var(--font-size-750);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== PORTRAIT ===== */
.portrait {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-375);
  margin: var(--space-500) 0 var(--space-1000);
  cursor: pointer;
}
.char-header .portrait {
  display: block;
  width: 100%;
  max-width: 20rem;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center top;
  border-radius: var(--radius-375);
  margin-bottom: var(--space-750);
}
.content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-250);
  margin: var(--space-750) 0;
}
.img-lightbox-wrap {
  position: relative;
  display: inline-block;
  cursor: pointer;
}
.img-lightbox-wrap::after {
  content: "\1F50D";
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.6);
  color: var(--text-on-image);
  font-size: var(--font-size-750);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-250);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.img-lightbox-wrap:hover::after,
.img-lightbox-wrap:focus-within::after {
  opacity: 1;
}

/* ===== SECTION NAV ===== */
.section-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-750);
  margin-bottom: var(--space-1500);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.section-nav a {
  font-size: var(--font-size-800);
  padding: 0.3rem 0.6rem;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: var(--radius-250);
  white-space: nowrap;
}
.section-nav a:hover {
  background: var(--accent);
  color: var(--on-accent, var(--bg));
  text-decoration: none;
}

/* ===== ACCORDION ===== */
.accordion {
  margin-bottom: var(--space-750);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  overflow: hidden;
}
.accordion-header {
  background: var(--bg-card);
  color: var(--text);
  padding: var(--space-750) var(--space-1000);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: var(--font-size-1000);
  user-select: none;
  -webkit-user-select: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-label, var(--font-body));
}
.accordion-header:hover {
  background: var(--accent-dim);
}
.accordion-header::after {
  content: "+";
  font-size: 1.25rem;
  font-weight: 400;
  flex-shrink: 0;
  margin-left: var(--space-500);
  color: var(--accent);
}
.accordion.open .accordion-header::after {
  content: "\2212";
}
.accordion-body {
  display: none;
  padding: var(--space-1000);
  background: var(--bg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.accordion.open .accordion-body {
  display: block;
}

/* ===== TAB BAR ===== */
.tab-bar {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: 0;
  margin-bottom: var(--space-1500);
  gap: 0;
  overflow-x: auto;
}
.pc-tab {
  padding: var(--space-750) var(--space-1250);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-label, var(--font-body));
  font-size: var(--font-size-900);
  font-weight: 600;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  min-height: 44px;
}
.pc-tab:hover {
  color: var(--text);
}
.pc-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
/* On a phone the bar scrolls sideways and the last tabs sit off screen with nothing to say so.
   An edge shadow shows on whichever side has more to scroll to and disappears at the end
   (the "local" layers cover the "scroll" shadows once that edge is reached). */
@media (max-width: 600px) {
  .tab-bar {
    background:
      linear-gradient(to right, var(--bg-card) 30%, transparent) 0 0 / 2.5rem 100% no-repeat local,
      linear-gradient(to left, var(--bg-card) 30%, transparent) 100% 0 / 2.5rem 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--text) 40%, transparent), transparent) 0 0 / 0.9rem 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--text) 40%, transparent), transparent) 100% 0 / 0.9rem 100% no-repeat scroll,
      var(--bg-card);
  }
}
/* A wide table written straight into a tab (the PF2e Strikes table, five no-wrap headers) is wider than a phone and
   made the whole page scroll sideways. On a phone its headers and cells may wrap, so it shrinks to the panel and keeps
   being a table; one that already fits is unchanged. A header word may break too, but only where the table would
   otherwise run past the panel (a 360px phone, or wider system fonts), and no header is wider than 45% of the screen. */
@media (max-width: 600px) {
  .tab-panel > table th { white-space: normal; max-width: 45vw; overflow-wrap: anywhere; }
  .tab-panel > table td { overflow-wrap: anywhere; }
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ===== STORY PROSE ===== */
.story-prose {
  max-width: 42rem;
  margin: 0 auto;
}
.story-prose h3 {
  font-size: 1.15rem;
  margin: var(--space-2000) 0 var(--space-750);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.story-prose h3:first-child {
  margin-top: 0;
}
.story-prose p {
  font-family: var(--font-serif);
  font-size: var(--font-size-1000);
  line-height: 1.85;
  margin-bottom: var(--space-1000);
}
.story-prose a {
  border-bottom: 1px dotted var(--accent);
}
.story-prose a:hover {
  border-bottom-style: solid;
}

/* Pictures of the people and places a recap names, floated beside the paragraph that first names them. */
.story-prose::after {
  content: "";
  display: block;
  clear: both;
}
.story-figures {
  float: right;
  clear: right;
  width: 184px;
  margin: 8px 0 12px 24px;
}
.story-figures--left {
  float: left;
  clear: left;
  margin: 8px 24px 12px 0;
}
.story-figures--two {
  width: 204px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.story-figure {
  margin: 0;
}
.story-figure__open {
  display: block;
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
  color: var(--text);
}
.story-prose .story-figure__open {
  border-bottom: 1px solid var(--border);
}
.story-figure__open img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  aspect-ratio: 3 / 4;
  margin: 0;
  border-radius: 0;
}
.story-figure--place .story-figure__open img {
  aspect-ratio: 4 / 3;
}
.story-figures--two .story-figure__open img {
  aspect-ratio: 1 / 1;
}
.story-figure figcaption {
  font-family: var(--font-label, var(--font-body));
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-muted);
  margin-top: 5px;
}
.story-figure__zoom {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .35);
  color: rgb(244, 244, 244);
  opacity: .45;
}
.story-figure__open:hover .story-figure__zoom, .story-figure__open:focus-visible .story-figure__zoom {
  opacity: 1;
  background: rgba(0, 0, 0, .55);
}
/* A plate: a picture across the full width of the story, between paragraphs, like a plate in a book. A scene's picture
   after its paragraph (`player_site.story.scene_pictures`), and any picture the GM embeds in the recap. */
.story-figures--plate {
  float: none;
  clear: both;
  width: auto;
  margin: 18px 0;
  display: block;
}
.story-figure--plate {
  clear: both;
  margin: 18px 0;
}
.story-figures--plate .story-figure--plate {
  margin: 0;
}
.story-figures--plate .story-figure--plate + .story-figure--plate {
  margin-top: 14px;
}
.story-figure--plate .story-figure__open {
  max-width: 100%;
}
.story-figure--plate .story-figure__open img {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
}
.story-figure--plate figcaption {
  font-size: 13px;
  text-align: center;
  margin-top: 6px;
}
.story-figure--plate .story-figure__zoom {
  width: 22px;
  height: 22px;
  border-radius: 11px;
  top: 8px;
  right: 8px;
}
@media (max-width: 600px) {
  .story-figures {
    width: 110px;
    margin: 6px 0 8px 14px;
  }
  .story-figures--left {
    margin: 6px 14px 8px 0;
  }
  .story-figures--two {
    width: 110px;
    grid-template-columns: 1fr;
  }
  .story-figures--two .story-figure:nth-child(2) {
    display: none;
  }
  .story-figure figcaption {
    font-size: 11px;
  }
  .story-figures--plate {
    width: auto;
    margin: 14px 0;
  }
  .story-figure--plate figcaption {
    font-size: 12px;
  }
  .story-figure__zoom {
    width: 16px;
    height: 16px;
    top: 4px;
    right: 4px;
    opacity: .4;
  }
}

/* ===== STORY MEMORABLE MOMENTS =====
   A grid of cards under the story: the kind, the moment (narration or speech, one style), its speaker, then the
   context. The note is shown as written: no quote marks are added. */
section.story-moments {
  clear: both;
  max-width: 52rem;
  margin: 1rem auto 0;
  padding: 2.5rem 0 1rem;
  border-top: 1px solid var(--border);
}
.story-moments__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 1.5rem;
}
.story-moments__head h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  letter-spacing: .02em;
  margin: 0;
}
.story-moments__head p {
  font-family: var(--font-label, var(--font-body));
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}
.story-moments__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}
article.moment-card {
  box-sizing: border-box;
  height: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
p.moment-kind {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-family: var(--font-label, var(--font-body));
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
p.moment-kind[data-kind="dramatic"] { color: var(--moment-dramatic); }
p.moment-kind[data-kind="intriguing"] { color: var(--moment-intriguing); }
p.moment-kind[data-kind="funny"] { color: var(--moment-funny); }
p.moment-kind[data-kind="epic"] { color: var(--moment-epic); }
p.moment-kind[data-kind="tragic"] { color: var(--moment-tragic); }
.moment-main {
  font-family: var(--font-serif);
  font-size: 18.5px;
  line-height: 1.5;
  font-weight: 400;
  margin: 0;
  color: var(--text);
}
.moment-main p, .moment-main blockquote {
  font: inherit;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}
.moment-main p + p { margin-top: .6em; }
.moment-main p::before, .moment-main p::after, .moment-main blockquote::before, .moment-main blockquote::after { content: none; }
.moment-speaker {
  font-family: var(--font-label, var(--font-body));
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: -4px 0 0;
}
hr.moment-rule {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 2px 0 0;
}
.moment-context {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
}
article.moment-card a {
  color: inherit;
  border-bottom: 1px dotted var(--accent);
  text-decoration: none;
}
/* GM site only: the wrap-up's GM-only parts that follow the cards (its GM Notes, its Source), then its Play Notes. */
section.story-gm-after {
  max-width: 52rem;
  margin: 1.5rem auto 0;
}
p.story-playnotes {
  max-width: 52rem;
  margin: 1.25rem auto 0;
  font-family: var(--font-label, var(--font-body));
  font-size: 15px;
}
p.story-playnotes a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
}
@media (max-width: 600px) {
  .story-moments__grid { grid-template-columns: 1fr; gap: 14px; }
  article.moment-card { padding: 16px 18px 18px; }
  .moment-main { font-size: 17px; }
  .story-moments__head { flex-direction: column; gap: 4px; }
}
/* ===== PC STORY TAB =====
   The backstory as a prologue (eyebrow, title, byline, reading face, drop capital), then
   how they look, what drives them and the story so far. The sheet tab opens on a teaser. */
.pc-prologue, .pc-story-box, .pc-backstory-teaser {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  margin: 0 0 var(--space-1000);
}
.pc-prologue { padding: clamp(1.25rem, 5vw, 3rem); }
.pc-prologue-eyebrow {
  margin: 0;
  font-size: var(--font-size-750); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent);
}
.pc-prologue-title {
  margin: 0.4rem 0 var(--space-250); padding: 0; border: 0;
  font-family: var(--font-reading); font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.1rem); line-height: 1.2; text-wrap: balance;
  color: var(--text);
  overflow-wrap: anywhere;
}
.pc-prologue-byline { margin: 0 0 var(--space-1500); font-size: var(--font-size-850); color: var(--text-muted); }
.pc-prologue-prose {
  max-width: 64ch;
  font-family: var(--font-reading); font-size: 1.125rem; line-height: 1.7;
  overflow-wrap: break-word;
}
.pc-prologue-prose p, .pc-prologue-prose ul, .pc-prologue-prose ol { margin: 0 0 1em; }
.pc-prologue-prose :is(ul, ol) { padding-left: 1.4em; }
.pc-prologue-prose > p:first-child::first-letter {
  float: left;
  font-size: 3.6em; line-height: 0.85; font-weight: 600;
  padding: 0.1em 0.12em 0 0;
  color: var(--accent);
}
.pc-prologue-prose blockquote {
  margin: 1.4em 0; padding: 0 0 0 var(--space-1250);
  border-left: 3px solid var(--accent);
  font-style: italic;
}
.pc-story-box { padding: var(--space-1000) 1.15rem; }
.pc-story-label {
  margin: 0 0 0.6rem;
  font-family: var(--font-label, var(--font-body));
  font-size: var(--font-size-700); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}
.pc-look-grid { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--space-1250); align-items: start; }
@media (max-width: 520px) { .pc-look-grid { grid-template-columns: minmax(0, 1fr); } }
.pc-look-portrait {
  width: 7.5rem; height: 7.5rem; border-radius: 0.6rem;
  object-fit: cover; object-position: top;
}
.pc-look-initials {
  display: grid; place-items: center;
  background: var(--bg-hero); color: var(--accent-on-header);
  font-family: var(--font-heading); font-size: 2.5rem; font-weight: 700;
}
.pc-look-text p { margin: 0 0 0.6rem; font-family: var(--font-reading); font-size: 1.05rem; line-height: 1.6; }
.pc-facts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: var(--space-250) 0 0; padding: 0; list-style: none; }
.pc-facts li { font-size: var(--font-size-800); border: 1px solid var(--border); border-radius: 999px; padding: 0.1rem 0.65rem; }
.pc-facts .label { color: var(--text-muted); margin-right: var(--space-250); }
.pc-drives-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-750); }
@media (max-width: 560px) { .pc-drives-grid { grid-template-columns: minmax(0, 1fr); } }
.pc-drive { background: var(--bg); border-radius: 0.4rem; padding: var(--space-750) 0.9rem; min-width: 0; }
.pc-drive h4 {
  margin: 0 0 var(--space-250);
  font-family: var(--font-label, var(--font-body));
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent);
}
.pc-drive p { margin: 0; font-family: var(--font-reading); font-size: var(--font-size-1000); line-height: 1.5; overflow-wrap: break-word; }
/* A field written as a list (a CoC investigator's Significant People, one per line). */
.pc-drive :is(ul, ol) { margin: 0; padding-left: 1.1em; font-family: var(--font-reading); font-size: var(--font-size-1000); line-height: 1.5; overflow-wrap: break-word; }
.pc-drive li { margin: 0 0 var(--space-250); }
.pc-drive p + :is(ul, ol) { margin-top: var(--space-250); }
.pc-sofar ol { list-style: none; margin: 0; padding: 0; }
.pc-sofar li {
  display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.9rem;
  padding: var(--space-750) 0; border-top: 1px solid var(--border);
}
.pc-sofar li:first-child { border-top: 0; padding-top: 0; }
.pc-sofar-when { font-size: var(--font-size-750); color: var(--text-muted); font-variant-numeric: tabular-nums; padding-top: 0.2rem; }
.pc-sofar-what { color: var(--text); font-family: var(--font-reading); font-size: var(--font-size-1000); }
.pc-sofar-what:hover { text-decoration: none; }
.pc-sofar-what b { display: block; font-family: var(--font-label, var(--font-body)); font-size: var(--font-size-875); color: var(--accent); }
.pc-sofar-what:hover b, .pc-sofar-what:focus-visible b { text-decoration: underline; }
.pc-sofar-more { margin: 0.6rem 0 0; }
.pc-sofar-more .story-read-link { margin: 0; font-weight: 600; }
.pc-sofar ol + .pc-sofar-more { padding-top: 0.6rem; border-top: 1px solid var(--border); }
.pc-story-none { margin: var(--space-1000) 0; }
.pc-backstory-teaser {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.9rem; align-items: end;
  padding: var(--space-1000) 1.15rem;
}
.pc-backstory-teaser-label {
  margin: 0 0 0.4rem;
  font-size: var(--font-size-700); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}
.pc-backstory-teaser-text { margin: 0; font-family: var(--font-reading); font-size: var(--font-size-1000); line-height: 1.55; }
.pc-backstory-teaser a { font-weight: 600; font-size: var(--font-size-900); white-space: nowrap; }
@media (max-width: 420px) { .pc-backstory-teaser { grid-template-columns: minmax(0, 1fr); } }
.pc-background-rest { margin: var(--space-750) 0; }
.pc-background-rest p { margin: 0 0 0.4rem; }
/* A PC's hook on a Characters index card. */
.entity-card .card-hook {
  margin: 0.35rem 0 0;
  font-family: var(--font-reading); font-style: italic; font-size: var(--font-size-875); line-height: 1.45;
  color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ===== STORY SESSION LINKS (#465) =====
   Session headings carry an id (#session-N), a copy-link icon, and a "Sessions" row of number
   chips sits above the first. scroll-margin-top clears the sticky .top-nav (3.5rem). */
.story-session, .story-entry { scroll-margin-top: 5rem; }
.story-session {
  margin: 3rem 0 var(--space-1250); padding-top: var(--space-1250);
  border-top: 1px solid var(--border);
  font-size: 1.5rem; line-height: 1.2; text-wrap: balance;
}
.story-jump + .story-session { margin-top: var(--space-1500); }
.story-session-n {
  display: block; margin-bottom: 0.4rem;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
}
.story-anchor {
  display: inline-flex; align-items: center; vertical-align: -0.2em; margin-left: var(--space-500); padding: 0.15rem;
  color: var(--accent); opacity: 0.35; border-radius: 3px; text-decoration: none;
  font-size: var(--font-size-750); font-weight: 600; letter-spacing: 0.04em; text-transform: none;
}
.story-prose .story-anchor { border-bottom: 0; }
.story-session:hover .story-anchor, .story-entry:hover .story-anchor,
.story-anchor:hover, .story-anchor:focus-visible { opacity: 1; }
.story-anchor:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.story-anchor.copied { opacity: 1; color: var(--text); }
.story-anchor.copied::after { content: "Copied"; margin-left: 0.35rem; }
@media (hover: none) { .story-anchor { opacity: 0.7; } }
.story-jump { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-500) var(--space-750); margin: var(--space-1000) 0 0; }
.story-jump-label {
  font-size: var(--font-size-700); font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-muted);
}
.story-jump ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.story-jump li { margin: 0; }
.story-prose .story-jump a, .story-jump a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; height: 1.75rem; padding: 0 0.45rem; border: 1px solid var(--border); border-radius: 999px;
  font-size: var(--font-size-800); font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--accent); text-decoration: none; transition: background-color .15s, color .15s, border-color .15s;
}
.story-jump a:hover, .story-jump a:focus-visible { background: var(--accent); border-color: var(--accent); color: var(--on-accent, var(--bg)); }
.story-jump a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .story-jump a { transition: none; } }

/* Standalone Story pages: label/cross-link chrome (the centred reading column is
   handled by the .story-prose rule above). */
.story-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--muted, var(--story-muted));
  margin: 0 0 var(--space-250);
}
.story-sheet-link, .story-read-link {
  display: inline-block;
  margin: var(--space-500) 0 var(--space-1500);
  font-size: var(--font-size-950);
}
/* A wrap-up section after the recap (Loot, Notes ...): part of the same prose, set off by its heading, and below any
   picture floated beside the recap. */
.story-section { margin-top: var(--space-1500); clear: both; }

/* Story landing */
.story-branch { max-width: 46rem; margin: 0 auto 2.5rem; }
.story-begin {
  display: inline-block;
  padding: 0.6rem var(--space-1250);
  background: var(--accent);
  color: var(--on-accent, var(--bg));
  border-radius: var(--radius-375);
  font-weight: 600;
  text-decoration: none;
}
.story-begin:hover { opacity: 0.9; }
.story-branch h3 {
  font-size: var(--font-size-900);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, var(--story-muted));
  margin: var(--space-1500) 0 var(--space-500);
}

/* chapter pages: start */
/* The Story So Far (story.html) and each chapter's own Story page. Built from theme tokens only, so a preset or a
   campaign stylesheet reaches every colour and face; each preset adds its own ornaments in its file. The closing
   line's words are `content` here, so a stylesheet can change them. */
.story-contents { max-width: 46rem; margin: 0 auto 2.5rem; }
.story-contents > h2 { text-align: center; font-family: var(--font-heading); }
.story-contents > p:has(> .story-begin) { text-align: center; }
.story-contents-chapter { margin: var(--space-2000) 0; text-align: center; }
.story-contents-chapter h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  line-height: 1.25;
  margin: var(--space-250) 0;
  text-wrap: balance;
}
.story-contents-chapter h3 a { color: var(--text); text-decoration: none; }
.story-contents-chapter h3 a:hover { color: var(--accent); }
.story-contents-chapter[data-chapter-status="active"] h3 a { color: var(--accent); }
p.story-chapter-label, p.story-chapter-dates {
  font-family: var(--font-label, var(--font-body));
  font-size: var(--font-size-875);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
p.story-chapter-label { letter-spacing: 0.08em; }
p.story-chapter-now {
  font-family: var(--font-label, var(--font-body));
  font-size: var(--font-size-850);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: var(--space-250) 0;
}
.story-contents .story-chapter-teaser, .story-contents p.story-chapter-overview {
  max-width: 54ch;
  margin: var(--space-500) auto;
}
.story-contents .story-chapter-teaser p { margin: 0 0 var(--space-500); }
p.story-chapter-overview, .story-contents .story-chapter-teaser p { font-family: var(--font-serif); font-size: var(--font-size-1000); }
.story-contents-sessions, .story-contents-sessions li { list-style: none; }
.story-contents-sessions {
  margin: var(--space-750) 0 0;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 2px;
}
.story-contents-sessions li {
  display: grid;
  grid-template-columns: 2.6em auto 1fr auto;
  align-items: baseline;
  gap: var(--space-500);
}
.story-contents-sessions li::after {
  content: "";
  grid-column: 3;
  grid-row: 1;
  min-width: 12px;
  border-bottom: 1px dotted var(--border);
  transform: translateY(-0.3em);
}
.story-contents-sessions .n { grid-column: 1; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.story-contents-sessions a { grid-column: 2; color: var(--text); text-decoration: none; }
.story-contents-sessions a:hover { color: var(--accent); }
.story-contents-sessions .d {
  grid-column: 4;
  font-size: var(--font-size-875);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.story-contents-one { color: var(--text-muted); }
.story-contents-one a { color: var(--accent); }
.story-contents-end { text-align: center; color: var(--text-muted); font-style: italic; margin-top: var(--space-2000); }
.story-contents-end[data-ending="continues"]::before { content: "To be continued…"; }
.story-contents-end[data-ending="ended"]::before { content: "The end"; }
/* The chapter's own page: its heading centred, like a chapter opening in a book. */
.story-chapter > p.story-chapter-label, .story-chapter > .page-title, .story-chapter > p.story-chapter-dates,
.story-chapter > p.story-chapter-now, .story-chapter > p.story-chapter-overview { text-align: center; }
.story-chapter > .page-title { margin-bottom: var(--space-250); }
.story-chapter > p.story-chapter-overview { margin: var(--space-1000) auto var(--space-1500); max-width: 54ch; }
.story-chapter-teaser { margin-top: var(--space-1500); }
.story-chapter-more { margin: 0 0 var(--space-1000); }
.story-chapter-more > summary {
  cursor: pointer;
  color: var(--accent);
  font-family: var(--font-label, var(--font-body));
  font-size: var(--font-size-950);
  margin-bottom: var(--space-1000);
}
.story-chapter-sessions-title { clear: both; margin-top: var(--space-2000); }
.story-chapter-sessions { padding-left: var(--space-1500); }
.story-chapter-sessions li { margin: var(--space-250) 0; }
.story-chapter-date { color: var(--text-muted); font-size: var(--font-size-875); margin-left: var(--space-500); }
@media (max-width: 520px) {
  .story-contents-sessions li { grid-template-columns: 2em 1fr; }
  .story-contents-sessions li::after { display: none; }
  .story-contents-sessions .d { grid-column: 2; }
}
/* chapter pages: end */

/* ===== TABLES ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-875);
}
th {
  background: var(--bg-card);
  color: var(--text);
  text-align: left;
  padding: var(--space-500) 0.6rem;
  font-weight: 600;
  font-size: var(--font-size-800);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:nth-child(even) {
  background: var(--accent-dim);
}

.stat {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ===== CONFIDENCE BADGES ===== */
.badge-stub,
.badge-draft,
.badge-superseded {
  display: inline-block;
  font-size: var(--font-size-700);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem var(--space-500);
  border-radius: var(--radius-200);
  vertical-align: middle;
  margin-left: var(--space-500);
}
.badge-stub { background: var(--warning); color: var(--bg); }
.badge-draft { background: var(--badge-draft); color: var(--bg); }
.badge-superseded { background: var(--border); color: var(--text-muted); }

/* ===== METADATA BADGES ===== */
.metadata-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: var(--space-1000);
}
.metadata-badge {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: var(--font-size-750);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-200);
}

/* ===== STATUS BADGES ===== */
.status-badge {
  display: inline-block;
  font-size: var(--font-size-700);
  padding: 0.15rem var(--space-500);
  border-radius: 1rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.status-alive { background: rgba(63, 185, 80, 0.15); color: var(--success); }
.status-kia { background: var(--status-kia-bg); color: var(--danger); }
.status-mia { background: var(--status-mia-bg); color: var(--warning); }
.status-retired { background: var(--accent-dim); color: var(--text-muted); }

/* ===== CARDS ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--space-1000);
  margin-top: var(--space-1000);
}

.entity-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-1000);
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
}
.entity-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  text-decoration: none;
}
.entity-card h3, .entity-card h4 {
  font-size: var(--font-size-1000);
  margin: 0 0 var(--space-250);
  color: var(--text);
}
.entity-card .card-subtitle {
  font-size: var(--font-size-850);
  color: var(--text-muted);
  margin-bottom: var(--space-500);
}
.entity-card .card-excerpt {
  font-size: var(--font-size-800);
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* PC card (landing page) */
.pc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  text-decoration: none;
  color: var(--text);
  display: block;
  padding: var(--space-1000);
  text-align: center;
  transition: border-color 0.15s;
}
.pc-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.pc-portrait {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--bg-header);
  margin: 0 auto var(--space-750);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.5rem;
  overflow: hidden;
}
.pc-portrait img,
.pc-portrait img.portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  margin: 0;
}
.pc-card h3 {
  font-size: var(--font-size-1000);
  margin-bottom: var(--space-250);
  color: var(--text);
}
.pc-traits {
  font-size: var(--font-size-800);
  color: var(--text-muted);
  line-height: 1.4;
}

/* NPC card */
.npc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-750) var(--space-1000);
  display: flex;
  align-items: center;
  gap: var(--space-750);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
  min-height: 44px;
}
.npc-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.npc-icon {
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  border-radius: 50%;
  background: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: var(--font-size-900);
  overflow: hidden;
}
.npc-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.npc-card h4 {
  font-size: var(--font-size-900);
  margin: 0 0 0.1rem;
  color: var(--text);
}
.npc-role {
  font-size: var(--font-size-750);
  color: var(--text-muted);
}

/* Fallen icon */
.fallen-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.3em;
  opacity: 0.7;
}

/* ===== LANDING PAGE ===== */
.landing-hero {
  background: var(--bg-hero);
  border-radius: var(--radius-750);
  padding: 3rem var(--space-1500) var(--space-2000);
  margin-bottom: var(--space-2000);
  text-align: center;
  overflow: hidden;
  position: relative;
}
.landing-hero-img {
  max-width: 100%;
  width: 32rem;
  height: auto;
  border-radius: var(--radius-500);
  margin-bottom: var(--space-1500);
}
.landing-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-750);
  margin-bottom: var(--space-2000);
  padding: var(--space-1250) var(--space-1500);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-750);
  color: var(--text);
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}
a.landing-banner:hover,
a.landing-banner:focus-visible {
  border-color: var(--accent);
  background: var(--accent-dim);
}
/* A tall picture is capped on a phone too, and shown whole; the desktop rule below crops it to its box. */
.landing-banner-img {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 18rem;
  object-fit: contain;
  border-radius: var(--radius-500);
}
.landing-banner-title {
  margin: 0 0 var(--space-250);
  font-size: 1.4rem;
  color: var(--accent);
}
.landing-banner-text {
  margin: 0;
  color: var(--text-muted);
}
@media (min-width: 700px) {
  .landing-banner { flex-direction: row; text-align: left; }
  /* The picture takes a fixed share whatever its own size; the words take the rest and may shrink. */
  .landing-banner-img { flex: 0 0 40%; width: 40%; max-width: 40%; min-width: 0; max-height: 16rem; object-fit: cover; }
  .landing-banner-img:only-child { flex: 0 1 auto; width: auto; max-width: 100%; }
  .landing-banner-body { flex: 1 1 0; min-width: 0; }
}
.landing-hero h1 {
  font-size: 2rem;
  margin-bottom: var(--space-500);
  color: var(--accent-on-header);
}
.landing-hero .hero-tagline {
  font-size: var(--font-size-1100);
  color: var(--text-on-header, var(--text));
  opacity: 0.85;
  margin-bottom: var(--space-1000);
}
.hero-dates {
  display: flex;
  justify-content: center;
  gap: var(--space-2000);
  margin-top: var(--space-1000);
  font-size: var(--font-size-900);
  color: var(--text-on-header, var(--text));
  opacity: 0.85;
}
.hero-dates .date-label {
  display: block;
  font-size: var(--font-size-700);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-on-header);
}

/* ===== FULL-BLEED LANDING HERO =====
   player_site.landing.hero.layout: full-bleed (#530). The build writes `landing-full-bleed` on the landing page's <body>
   and `landing-hero--full-bleed` on its hero, so none of this needs :has(). The main column is widened (never 100vw,
   which adds a sideways scrollbar, and no overflow-x on html or body, which breaks the sticky menu) and every other
   section of the page is brought back to the column's width with margins, keeping its own padding. */
body.landing-full-bleed > .top-nav {
  /* Over the picture on this page only, and scrolled away with it: it never floats see-through over the page. */
  position: absolute;
  left: 0;
  right: 0;
  background: transparent;
  border-bottom-color: transparent;
}
body.landing-full-bleed > main.content {
  max-width: none;
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}
body.landing-full-bleed > main.content > :not(.landing-hero) {
  margin-left: max(1rem, calc((100% - 52rem) / 2 + 1rem));
  margin-right: max(1rem, calc((100% - 52rem) / 2 + 1rem));
}
.landing-hero.landing-hero--full-bleed {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: clamp(24rem, 46vw, 44rem);
  margin: 0 0 var(--space-2000);
  border-radius: 0;
  padding: 6.5rem max(1rem, calc((100% - 52rem) / 2 + 1rem)) 2rem;
  isolation: isolate;
}
.landing-hero--full-bleed .landing-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  border-radius: 0;
  object-fit: cover;
  object-position: var(--hero-focus, center);
  z-index: -2;
}
/* The shade over the picture, mixed toward the hero colour so it follows the palette in light and dark: nearly solid
   behind the menu bar (its words read over a white picture too), fading out below it, and a soft rise from the foot.
   A browser without color-mix() keeps the plain dark shade. */
.landing-hero--full-bleed::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0, rgba(0, 0, 0, 0.9) 3.5rem, transparent 8rem),
    linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.3) 55%, transparent 85%);
  background:
    linear-gradient(to bottom, color-mix(in srgb, var(--bg-hero) 95%, transparent) 0, color-mix(in srgb, var(--bg-hero) 95%, transparent) 3.5rem, transparent 8rem),
    linear-gradient(to top, color-mix(in srgb, var(--bg-hero) 92%, transparent) 0%, color-mix(in srgb, var(--bg-hero) 35%, transparent) 55%, transparent 85%);
}
.landing-hero.landing-hero--full-bleed h1 {
  position: relative;
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  line-height: 1.05;
  margin-bottom: var(--space-750);
  overflow-wrap: anywhere;
  color: var(--hero-title, var(--text-on-image));
}
/* The words' own shade: from 3rem above the title down to the foot of the hero and across its full width (it reaches
   far past every edge and the hero, overflow: hidden, clips it), 80% of the hero colour, so a light ink reads over any
   picture, even a white one. A browser without color-mix() keeps a plain dark shade. */
.landing-hero.landing-hero--full-bleed h1::before {
  content: "";
  position: absolute;
  top: -3rem;
  bottom: -1000rem;
  left: -1000rem;
  right: -1000rem;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 0, rgba(0, 0, 0, 0.8) 3rem);
  background: linear-gradient(to bottom, transparent 0, color-mix(in srgb, var(--bg-hero) 80%, transparent) 3rem);
}
.landing-hero--full-bleed .hero-tagline {
  max-width: 46rem;
  margin-left: auto;
  margin-right: auto;
}
.landing-hero--full-bleed .hero-tagline,
.landing-hero--full-bleed .hero-dates,
.landing-hero--full-bleed .hero-dates .date-label {
  color: var(--hero-title, var(--text-on-image));
  opacity: 1;
}
.landing-hero--full-bleed .hero-dates {
  flex-wrap: wrap;
  gap: var(--space-500) var(--space-2000);
}
.landing-hero--align-left {
  text-align: left;
}
.landing-hero--align-left .hero-tagline {
  margin-left: 0;
}
.landing-hero--align-left .hero-dates {
  justify-content: flex-start;
}
@media (min-width: 768px) {
  body.landing-full-bleed > main.content > :not(.landing-hero) {
    margin-left: max(2rem, calc((100% - 52rem) / 2 + 2rem));
    margin-right: max(2rem, calc((100% - 52rem) / 2 + 2rem));
  }
  .landing-hero.landing-hero--full-bleed {
    padding-left: max(2rem, calc((100% - 52rem) / 2 + 2rem));
    padding-right: max(2rem, calc((100% - 52rem) / 2 + 2rem));
  }
}
@media (max-width: 767px) {
  .landing-hero--full-bleed .landing-hero-img {
    object-position: var(--hero-focus-narrow, var(--hero-focus, center));
  }
}
/* ===== END FULL-BLEED LANDING HERO ===== */

/* Dashboard sections */
.dashboard-section {
  margin: 2.5rem 0;
}
.dashboard-section h2 {
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.3rem;
  margin-bottom: var(--space-1000);
}

/* Recap */
.recap {
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  padding: var(--space-1250) var(--space-1500);
  border-radius: 0 var(--radius-500) var(--radius-500) 0;
  font-size: var(--font-size-950);
  line-height: 1.7;
}
.recap-link {
  display: inline-block;
  margin-top: var(--space-750);
  color: var(--accent);
  font-weight: 600;
  font-size: var(--font-size-850);
}

/* ===== LINK PREVIEW CARD (js/previews.js appends it to <body>) =====
   Above the top nav (100) and its dropdown (200); below the phone menu (300) and the search overlay (400).
   Every text colour is --text on --bg-card (--text-muted and an accent fill fall under 4.5:1 on some themes);
   the Open page button is marked by its accent border, not an accent fill. */
.link-preview {
  position: absolute;
  z-index: 250;
  box-sizing: border-box;
  width: min(320px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.875rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  font-family: var(--font-body);
  font-size: var(--font-size-875);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.lp-head { display: flex; gap: var(--space-750); align-items: center; }
.lp-img {
  width: 56px;
  height: 56px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-375);
  object-fit: cover;
  object-position: top center;
}
.lp-name {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.125rem;
  line-height: 1.2;
}
.lp-kind {
  display: flex;
  gap: var(--space-500);
  align-items: center;
  margin-top: 0.2rem;
  font-family: var(--font-heading);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}
.lp-draft {
  padding: 0 0.3rem;
  border: 1px solid var(--text);
  border-radius: 3px;
  letter-spacing: 0.06em;
}
.lp-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.2rem 0.6rem;
  margin: 0;
  font-size: 0.8125rem;
}
.lp-facts dt {
  padding-top: 0.125rem;
  font-family: var(--font-heading);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.lp-facts dd { margin: 0; }
.lp-text { margin: 0; color: var(--text); }
.lp-open {
  align-self: flex-start;
  padding: var(--space-500) 0.875rem;
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--accent);
  border-radius: var(--radius-375);
  font-family: var(--font-heading);
  font-size: var(--font-size-875);
  font-weight: 600;
  text-decoration: none;
}
@media (prefers-reduced-motion: no-preference) {
  .link-preview { animation: lp-in 0.12s ease-out; }
  @keyframes lp-in { from { opacity: 0; transform: translateY(3px); } }
}

/* PC roster grid */
.pc-roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: var(--space-1000);
}

/* In Memoriam (compact) */
.in-memoriam {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-500) var(--space-1250);
  font-size: var(--font-size-900);
  color: var(--text-muted);
}
.in-memoriam a {
  color: var(--text-muted);
}
.in-memoriam a:hover {
  color: var(--accent);
}
.in-memoriam .memorial-context {
  font-size: var(--font-size-750);
  opacity: 0.7;
}

/* NPC grid */
.npc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-750);
}

/* Quick links — a short GM-pinned row, so a wrapping flex line rather than a
   card grid: these are destinations, not entities to browse. */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-500);
}

.quick-link {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--color-border, var(--quick-link-border));
  border-radius: 999px;
  background: var(--color-surface, transparent);
  color: inherit;
  text-decoration: none;
  font-size: var(--font-size-900);
}

.quick-link:hover,
.quick-link:focus-visible {
  border-color: var(--color-accent, currentColor);
  text-decoration: none;
}

/* Location grid */
.location-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--space-750);
}

/* Explore grid */
.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--space-750);
}
.explore-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-1000) var(--space-1250);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
  display: block;
  min-height: 44px;
}
.explore-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.explore-card h4 {
  font-size: var(--font-size-900);
  margin-bottom: var(--space-250);
}
.explore-card .card-flavour {
  font-size: var(--font-size-800);
  color: var(--text-muted);
  line-height: 1.4;
}
.explore-card .count {
  font-size: var(--font-size-700);
  color: var(--text-muted);
  margin-top: var(--space-250);
}

/* ===== INDEX PAGE ===== */
.index-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-1000);
  margin-bottom: var(--space-1500);
}
.index-count {
  font-size: var(--font-size-850);
  color: var(--text-muted);
}

/* Pill filters */
.pill-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: var(--space-1000);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.pill-filter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.35rem 0.85rem;
  font-size: var(--font-size-800);
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-label, var(--font-body));
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}
.pill-filter:hover {
  border-color: var(--accent);
  color: var(--text);
}
.pill-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent, var(--bg));
}

/* Name filter */
.name-filter {
  width: 100%;
  max-width: 24rem;
  padding: var(--space-500) var(--space-750);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-375);
  color: var(--text);
  font-size: var(--font-size-875);
  font-family: var(--font-body);
  margin-bottom: var(--space-1000);
}
.name-filter:focus {
  outline: none;
  border-color: var(--accent);
}
.name-filter::placeholder {
  color: var(--text-muted);
}

/* Sort control */
.sort-control {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-375);
  color: var(--text);
  font-size: var(--font-size-800);
  padding: 0.35rem 0.6rem;
  font-family: var(--font-label, var(--font-body));
}

/* NPC table */
.npc-table-filters {
  display: flex;
  gap: var(--space-750);
  margin-bottom: var(--space-1000);
  flex-wrap: wrap;
}
.npc-filter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-375);
  color: var(--text);
  padding: 0.4rem var(--space-750);
  font-size: var(--font-size-850);
}
.npc-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: var(--space-500);
}
.npc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-900);
}
.npc-table th,
.npc-table td {
  padding: 0.6rem var(--space-750);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.npc-table th {
  background: var(--bg-header, var(--bg-card));
  color: var(--text-on-header, var(--text));
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  user-select: none;
}
.npc-table th[data-sort-col] {
  cursor: pointer;
}
.npc-table th[data-sort-col]:hover {
  color: var(--accent);
}
.npc-table th.sort-active::after {
  margin-left: 0.4rem;
  font-size: var(--font-size-700);
}
.npc-table th.sort-asc::after {
  content: '\25B2';
}
.npc-table th.sort-desc::after {
  content: '\25BC';
}
.npc-table td:first-child a {
  color: var(--accent);
  font-weight: 500;
}
.npc-table tbody tr:hover {
  background: var(--accent-dim, rgba(255,255,255,0.04));
}
.status-badge {
  display: inline-block;
  padding: 0.15rem var(--space-500);
  border-radius: 1rem;
  font-size: 0.78rem;
  font-weight: 500;
}
.status-alive { background: var(--status-alive-bg); color: var(--status-alive); }
.status-dead, .status-deceased { background: var(--status-dead-bg); color: var(--status-dead); }
.status-missing, .status-unknown { background: var(--status-missing-bg); color: var(--status-missing); }
.status-captured, .status-captive { background: var(--status-captured-bg); color: var(--status-captured); }
.status-presumed_dead { background: var(--status-presumed-dead-bg); color: var(--status-presumed-dead); }
.status-retired { background: var(--status-retired-bg); color: var(--status-retired); }

/* Location hierarchy */
.location-tree {
  margin-top: var(--space-1000);
}
.location-tree-item {
  padding: var(--space-500) 0;
  border-bottom: 1px solid var(--border);
}
.location-tree-item a {
  color: var(--text);
  font-weight: 500;
}
.location-tree-item a:hover {
  color: var(--accent);
}
.location-tree-children {
  padding-left: var(--space-1500);
}

/* Story sequential */
.story-progression {
  display: flex;
  flex-direction: column;
  gap: var(--space-1500);
  margin-top: var(--space-1000);
}
.chapter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-1500);
}
.chapter-card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1000);
  margin-bottom: var(--space-1000);
}
.chapter-card-header .chapter-number {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 2.5rem;
  line-height: 1;
}
.chapter-card-title {
  flex: 1;
}
.chapter-card-title h2 {
  font-size: 1.25rem;
  margin: 0 0 var(--space-250);
}
.chapter-card-title h2 a {
  color: var(--text);
}
.chapter-card-title h2 a:hover {
  color: var(--accent);
}
.chapter-status {
  font-size: var(--font-size-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem var(--space-500);
  border-radius: var(--radius-200);
  font-weight: 600;
}
.chapter-complete {
  background: var(--chapter-complete-bg);
  color: var(--chapter-complete);
}
.chapter-active {
  background: var(--chapter-active-bg);
  color: var(--accent);
}
.chapter-upcoming {
  background: var(--chapter-upcoming-bg);
  color: var(--text-muted);
}
.chapter-overview {
  font-size: var(--font-size-900);
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 var(--space-1000);
}
.chapter-sessions {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border);
  padding-top: var(--space-750);
}
.chapter-sessions li {
  display: flex;
  align-items: center;
  gap: var(--space-500);
  padding: 0.4rem 0;
  font-size: var(--font-size-875);
}
.chapter-sessions .session-icon {
  font-size: var(--font-size-750);
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}
.chapter-sessions .session-played .session-icon {
  color: var(--chapter-complete);
}
.chapter-sessions .session-pending .session-icon {
  color: var(--text-muted);
}
.chapter-sessions a {
  color: var(--text);
}
.chapter-sessions a:hover {
  color: var(--accent);
}
.story-nav {
  display: flex;
  justify-content: space-between;
  margin: var(--space-2000) 0;
  gap: var(--space-1000);
}
.story-nav a {
  padding: var(--space-500) var(--space-1000);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-375);
  color: var(--text);
  text-decoration: none;
  font-size: var(--font-size-875);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.story-nav a:hover {
  border-color: var(--accent);
}

/* ===== ENTITY PAGE ZONES ===== */

/* Sub-location cards */
.sub-locations {
  margin: var(--space-2000) 0;
}
.sub-locations h2 {
  margin-bottom: var(--space-1000);
}

/* Who's here / Known figures */
.whos-here {
  margin: var(--space-2000) 0;
}

/* Event timeline (compact vertical) */
.entity-timeline {
  margin: var(--space-2000) 0;
  position: relative;
  padding-left: var(--space-1500);
}
.entity-timeline::before {
  content: '';
  position: absolute;
  left: 0.35rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-node {
  position: relative;
  padding: var(--space-500) 0 var(--space-1000);
}
.timeline-node::before {
  content: '';
  position: absolute;
  left: -1.25rem;
  top: 0.75rem;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.timeline-node a {
  font-weight: 500;
}
.timeline-node .timeline-date {
  font-size: var(--font-size-750);
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.timeline-node .timeline-summary {
  font-size: var(--font-size-850);
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Where to find them (NPC location card) */
.npc-location-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-750) var(--space-1000);
  display: flex;
  align-items: center;
  gap: var(--space-750);
  margin: var(--space-1500) 0;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.npc-location-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.npc-location-card .loc-label {
  font-size: var(--font-size-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

/* ===== SEARCH OVERLAY ===== */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 400;
  padding: 10vh var(--space-1000) var(--space-1000);
  backdrop-filter: blur(4px);
}
.search-overlay.open {
  display: block;
}
.search-modal {
  max-width: 36rem;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-750);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.search-input-wrap {
  display: flex;
  align-items: center;
  padding: var(--space-750) var(--space-1000);
  border-bottom: 1px solid var(--border);
}
.search-input {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: var(--font-size-1000);
  font-family: var(--font-body);
  outline: none;
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  margin: -0.5rem -0.75rem -0.5rem 0;
}
.search-close:hover { color: var(--accent); }
.search-kbd {
  font-size: var(--font-size-700);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-200);
  padding: 0.15rem 0.4rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: var(--space-500) 0;
}
.search-results-empty {
  padding: var(--space-2000) var(--space-1000);
  text-align: center;
  color: var(--text-muted);
}
.search-result-group h4 {
  font-size: var(--font-size-750);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  padding: var(--space-500) var(--space-1000);
  margin: 0;
}
.search-result-item {
  display: block;
  padding: var(--space-500) var(--space-1000);
  color: var(--text);
  text-decoration: none;
  font-size: var(--font-size-900);
}
.search-result-item:hover {
  background: var(--accent-dim);
  text-decoration: none;
}
.search-result-item mark {
  background: var(--search-mark-bg);
  color: var(--accent);
  border-radius: 0.125rem;
  padding: 0 0.125rem;
}

/* Phone width: the search box becomes a full-screen panel (#267). */
@media (max-width: 767px) {
  .search-overlay {
    padding: 0;
    background: var(--bg);
    backdrop-filter: none;
  }
  .search-modal {
    max-width: none;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .search-input-wrap { padding: var(--space-500) var(--space-1000); }
  .search-input { min-height: 44px; }
  .search-kbd { display: none; }
  .search-close { display: block; }
  .search-results { flex: 1; max-height: none; }
  .search-result-item { padding: var(--space-750) var(--space-1000); min-height: 44px; }
}

/* ===== LIGHTBOX ===== */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 500;
  cursor: pointer;
  padding: var(--space-2000);
  justify-content: center;
  align-items: center;
}
.lightbox-overlay.open {
  display: flex;
}
.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-500);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-on-image);
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover {
  opacity: 1;
}

/* ===== CAMPAIGN ROUTE MAP ===== */
.route-map {
  margin: var(--space-2000) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.route-map svg {
  width: 100%;
  min-width: 20rem;
  height: auto;
}
.route-map svg a text {
  fill: var(--text);
}
.route-map svg a:hover text {
  fill: var(--accent);
}

/* ===== SVG TIMELINE ===== */
/* Vertical timeline — two-column split */
.tl-timeline {
  position: relative;
  margin: var(--space-2000) 0;
}
.tl-entry {
  display: grid;
  grid-template-columns: 7rem 3rem 1fr;
  gap: 0;
  min-height: 5rem;
}
.tl-entry:last-child .tl-line-col::before {
  display: none;
}

/* Left column: date */
.tl-date-col {
  text-align: right;
  padding-right: var(--space-1250);
  padding-top: 0.2rem;
}
.tl-year {
  font-family: var(--font-heading, sans-serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.tl-monthday {
  font-size: var(--font-size-750);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Center column: line + dot */
.tl-line-col {
  position: relative;
  display: flex;
  justify-content: center;
}
.tl-line-col::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--border);
  transform: translateX(-50%);
}
.tl-dot {
  position: relative;
  z-index: 1;
  width: 0.875rem;
  height: 0.875rem;
  margin-top: var(--space-500);
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--border);
  flex-shrink: 0;
}
.tl-session .tl-dot {
  border-radius: 0.15rem;
}

/* Right column: details */
.tl-detail-col {
  padding-left: var(--space-1250);
  padding-bottom: 2.5rem;
}
.tl-type {
  display: inline-block;
  font-size: var(--font-size-650);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem var(--space-500);
  border-radius: var(--radius-200);
  margin-bottom: 0.35rem;
}
.tl-session .tl-type {
  background: var(--tl-session-bg);
  color: var(--tl-session);
}
.tl-event .tl-type {
  background: var(--accent-dim, rgba(88,166,255,0.15));
  color: var(--accent);
}
.tl-detail-col h3 {
  margin: 0;
  font-size: var(--font-size-1100);
  line-height: 1.3;
}
.tl-detail-col h3 a {
  color: var(--text);
}
.tl-detail-col h3 a:hover {
  color: var(--accent);
}
.tl-detail-col p {
  margin: 0.35rem 0 0;
  font-size: var(--font-size-850);
  color: var(--text-muted);
  line-height: 1.5;
}

/* Compact strip (landing page, PC journey) */
.tl-compact .tl-entry {
  grid-template-columns: 5rem 2rem 1fr;
  min-height: 2.5rem;
}
.tl-compact .tl-year {
  font-size: var(--font-size-1000);
}
.tl-compact .tl-monthday {
  font-size: var(--font-size-650);
}
.tl-compact .tl-dot {
  width: 0.625rem;
  height: 0.625rem;
  margin-top: 0.35rem;
  border-width: 2px;
}
.tl-compact .tl-detail-col {
  padding-bottom: var(--space-1000);
}
.tl-compact .tl-detail-col h3 {
  font-size: var(--font-size-900);
}
.tl-compact .tl-type {
  display: none;
}
.timeline-full {
  margin: var(--space-1500) 0;
}
.timeline-strip {
  margin: var(--space-2000) 0;
}

@media (max-width: 480px) {
  .tl-entry {
    grid-template-columns: 2rem 1fr;
  }
  .tl-date-col {
    display: none;
  }
  .tl-detail-col::before {
    content: attr(data-date);
    display: block;
    font-size: var(--font-size-750);
    color: var(--text-muted);
    margin-bottom: var(--space-250);
  }
}

/* ===== STAT BLOCK ===== */
.stat-block {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr));
  gap: var(--space-500);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-1000);
  margin-bottom: var(--space-1000);
}
.stat-block .stat-item { text-align: center; }
.stat-block .stat-label {
  display: block;
  font-size: var(--font-size-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.stat-block .stat-value {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
}

/* Quick stats */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: var(--space-500);
  margin-bottom: var(--space-1000);
}
.quick-stats .stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-375);
  padding: var(--space-500) var(--space-750);
  text-align: center;
}
.quick-stats .stat-item .stat-label {
  font-size: var(--font-size-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.quick-stats .stat-item .stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--font-size-1100);
}

/* ===== BESTIARY ===== */
.bestiary {
  display: flex;
  flex-direction: column;
  gap: var(--space-1500);
  margin-top: var(--space-1000);
}
.bestiary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--bestiary-edge);
  border-radius: var(--radius-500);
  padding: var(--space-1500);
}
.bestiary-header {
  margin-bottom: var(--space-1000);
}
.bestiary-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1000);
  flex-wrap: wrap;
}
.bestiary-title-row h2 {
  font-size: 1.3rem;
  margin: 0;
}
.bestiary-title-row h2 a {
  color: var(--text);
}
.bestiary-title-row h2 a:hover {
  color: var(--accent);
}
.bestiary-badges {
  display: flex;
  gap: var(--space-500);
  flex-shrink: 0;
}
.threat-badge {
  font-size: var(--font-size-650);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-200);
}
.threat-extreme {
  background: var(--threat-extreme-bg);
  color: var(--threat-extreme);
  border: 1px solid var(--threat-extreme-border);
}
.threat-high {
  background: var(--threat-high-bg);
  color: var(--threat-high);
  border: 1px solid var(--threat-high-border);
}
.threat-moderate {
  background: var(--threat-moderate-bg);
  color: var(--threat-moderate);
  border: 1px solid var(--threat-moderate-border);
}
.threat-unknown {
  background: var(--threat-unknown-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.creature-status-badge {
  font-size: var(--font-size-650);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-200);
}
.creature-killed {
  background: var(--creature-killed-bg);
  color: var(--creature-killed);
  border: 1px solid var(--creature-killed-border);
}
.creature-active {
  background: var(--creature-active-bg);
  color: var(--creature-active);
  border: 1px solid var(--creature-active-border);
}
.creature-unknown {
  background: var(--creature-unknown-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.bestiary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-500) var(--space-1500);
  margin-top: var(--space-500);
  font-size: var(--font-size-800);
  color: var(--text-muted);
}
.bestiary-meta-item .label {
  color: var(--accent);
  font-weight: 600;
  margin-right: var(--space-250);
}
.bestiary-section {
  margin-top: var(--space-750);
}
.bestiary-section-label {
  font-size: var(--font-size-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 0.4rem;
}
.bestiary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.bestiary-ability {
  font-size: var(--font-size-750);
  padding: 0.2rem var(--space-500);
  background: var(--bestiary-ability-bg);
  color: var(--accent);
  border: 1px solid var(--bestiary-ability-border);
  border-radius: var(--radius-200);
}
.bestiary-pills-weak .bestiary-weakness {
  font-size: var(--font-size-750);
  padding: 0.2rem var(--space-500);
  background: var(--bestiary-weakness-bg);
  color: var(--bestiary-weakness);
  border: 1px solid var(--bestiary-weakness-border);
  border-radius: var(--radius-200);
}

/* ===== LOCATIONS PAGE ===== */
.locations-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-2000);
  margin-top: var(--space-1000);
}
.loc-region-title {
  font-size: var(--font-size-800);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-500);
  margin-bottom: var(--space-1000);
}
.loc-region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: var(--space-750);
}
.loc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-1000);
}
.loc-card-main h3 {
  font-size: var(--font-size-1000);
  margin: 0 0 0.35rem;
}
.loc-card-main h3 a {
  color: var(--text);
}
.loc-card-main h3 a:hover {
  color: var(--accent);
}
.loc-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-500);
  align-items: center;
}
.loc-card-thumb {
  float: right;
  margin: 0 0 var(--space-500) var(--space-750);
}
.loc-card-thumb img.portrait,
.intel-card-thumb img.portrait {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: cover;
  border-radius: var(--radius-375);
  display: block;
}
.loc-type-badge {
  font-size: var(--font-size-700);
  padding: 0.15rem 0.4rem;
  background: var(--loc-type-bg);
  color: var(--accent);
  border: 1px solid var(--loc-type-border);
  border-radius: var(--radius-200);
  text-transform: capitalize;
}
.loc-first-seen {
  font-size: var(--font-size-700);
  color: var(--text-muted);
}
.loc-children {
  margin-top: var(--space-750);
  padding-top: var(--space-500);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.loc-child {
  display: flex;
  align-items: center;
  gap: var(--space-500);
  padding: 0.2rem 0 0.2rem var(--space-750);
  border-left: 2px solid var(--border);
  font-size: var(--font-size-850);
  color: var(--text);
}
.loc-child:hover {
  color: var(--accent);
  border-left-color: var(--accent);
  text-decoration: none;
}
.loc-child-type {
  font-size: var(--font-size-650);
  color: var(--text-muted);
}

/* ===== SECTION INDEX BANNER ===== */
.section-banner {
  margin: 0 0 var(--space-1500);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  overflow: hidden;
  line-height: 0; /* kill the descender gap under an inline-level child */
}
.section-banner-img,
.section-banner svg,
.section-banner-inline svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}
.section-banner-link {
  display: block;
}
.section-banner-link:hover {
  opacity: 0.92;
}

/* ===== LOCATIONS: PIVOT-GROUPED VIEW ===== */
/* Sections flow in columns so the page width does the work, instead of one tall,
   deeply-indented tree rooted at a single political node. */
.loc-system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: var(--space-1000);
  align-items: start;
  margin-top: var(--space-1000);
}
.loc-system {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-1000);
}
.loc-system-header {
  display: flex;
  align-items: center;
  gap: var(--space-500);
  flex-wrap: wrap;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.loc-system-title {
  font-size: var(--font-size-1000);
  margin: 0;
  flex: 1 1 auto;
}
.loc-system-title a {
  color: var(--text);
}
.loc-system-title a:hover {
  color: var(--accent);
}
.loc-system-count {
  font-size: var(--font-size-700);
  color: var(--text-muted);
  white-space: nowrap;
}
.loc-system-thumb img.portrait,
.loc-node-thumb img.portrait {
  object-fit: cover;
  border-radius: var(--radius-250);
  display: block;
}
/* Sized on the span, not just the img, so the empty spacer occupies the same box. */
.loc-system-thumb,
.loc-system-thumb img.portrait {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 2.25rem;
}
/* Reserve the column so section titles align across the grid; a system with no portrait
   shouldn't be advertised by a placeholder box. */
.loc-system-thumb-empty {
  visibility: hidden;
}
/* The collapsed political scaffolding (Republic › Sector): context, not navigation. */
.loc-context {
  font-size: var(--font-size-700);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--space-750);
}
.loc-system .loc-context {
  margin: 0.6rem 0 0;
}
.loc-system-body {
  margin-top: 0.6rem;
}
.loc-node-row {
  display: flex;
  align-items: center;
  gap: var(--space-500);
  padding: var(--space-250) 0;
}
.loc-node-thumb,
.loc-node-thumb img.portrait {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 1.5rem;
}
/* Reserve the column so names stay aligned; an entity with no portrait shouldn't be
   advertised by a placeholder box. */
.loc-node-thumb-empty {
  visibility: hidden;
}
.loc-node-name {
  color: var(--text);
  font-size: var(--font-size-900);
}
.loc-node-name:hover {
  color: var(--accent);
}
.loc-node-children {
  margin-left: var(--space-750);
  padding-left: var(--space-750);
  border-left: 1px solid var(--border);
}

/* ===== CAMPAIGN DEEP DIVE ===== */
.campaign-deep-dive {
  display: flex;
  flex-direction: column;
  gap: var(--space-2000);
}
.cdd-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-750);
}
.cdd-params {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-750);
}
.cdd-param {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.6rem var(--space-1000);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 8rem;
}
.cdd-param-label {
  font-size: var(--font-size-650);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.cdd-param-value {
  font-size: var(--font-size-1100);
  font-weight: 600;
  color: var(--text);
}
.cdd-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.cdd-genre {
  font-size: var(--font-size-700);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
}
.cdd-section {
  border-top: 1px solid var(--border);
  padding-top: var(--space-1250);
}
.cdd-section-title {
  font-family: var(--font-heading);
  font-size: var(--font-size-850);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-750);
}
.cdd-prose {
  color: var(--text);
  line-height: 1.7;
  font-size: var(--font-size-950);
}
.cdd-prose p {
  margin-bottom: var(--space-750);
}
.cdd-prose strong {
  color: var(--text);
}
.cdd-prose ul, .cdd-prose ol {
  margin: var(--space-500) 0;
  padding-left: var(--space-1500);
}
.cdd-prose li {
  margin-bottom: 0.35rem;
}
.cdd-themes ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-500);
}
.cdd-themes li {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  padding: 0.6rem var(--space-1000);
  border-radius: 0 0.3rem 0.3rem 0;
  font-size: var(--font-size-900);
  color: var(--text);
  margin: 0;
}
.cdd-threats ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-500);
}
.cdd-threats li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  padding: 0.6rem var(--space-1000);
  border-radius: 0 0.3rem 0.3rem 0;
  font-size: var(--font-size-900);
  color: var(--text);
  margin: 0;
}
.cdd-threats strong {
  color: var(--danger);
}
.cdd-full-link {
  padding-top: var(--space-500);
}
.cdd-full-link a {
  font-size: var(--font-size-900);
  color: var(--accent);
}
.cdd-full-link a:hover {
  text-decoration: underline;
}

/* ===== FACTIONS / INTEL BRIEFING ===== */
.intel-briefing {
  display: flex;
  flex-direction: column;
  gap: var(--space-2000);
}
.intel-section-title {
  font-family: var(--font-heading);
  font-size: var(--font-size-850);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-500);
  margin-bottom: var(--space-750);
}
.intel-section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1000);
}
@media (min-width: 768px) {
  .intel-section-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.intel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-500);
  padding: var(--space-1250);
  display: flex;
  flex-direction: column;
  gap: var(--space-750);
}
.intel-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-750);
}
.intel-card-header h2 {
  font-size: var(--font-size-1100);
  margin: 0;
  /* Absorb space-between free space when a thumb precedes the title,
     keeping the title snug against its thumbnail and the badge pinned right. */
  margin-right: auto;
}
.intel-card-header h2 a {
  color: var(--text);
}
.intel-card-header h2 a:hover {
  color: var(--accent);
}
.intel-type-badge {
  font-size: var(--font-size-650);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem var(--space-500);
  border-radius: 3px;
  white-space: nowrap;
}
.intel-type-military {
  background: var(--intel-military-bg);
  color: var(--intel-military);
}
.intel-type-corporation {
  background: var(--intel-corporation-bg);
  color: var(--intel-corporation);
}
.intel-type-government {
  background: var(--intel-government-bg);
  color: var(--intel-government);
}
.intel-type-other {
  background: var(--intel-other-bg);
  color: var(--text-muted);
}
.intel-leadership {
  font-size: var(--font-size-850);
  color: var(--text-muted);
}
.intel-leadership strong {
  color: var(--text);
  font-weight: 500;
}
.intel-goals {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-250);
}
.intel-goals li {
  font-size: var(--font-size-800);
  color: var(--text-muted);
  padding-left: var(--space-1000);
  position: relative;
}
.intel-goals li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
}
.intel-connections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-top: var(--space-250);
  border-top: 1px solid var(--border);
}
.intel-conn {
  font-size: var(--font-size-700);
  padding: 0.15rem var(--space-500);
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}
.intel-conn-type {
  opacity: 0.7;
  margin-right: var(--space-250);
}
.intel-canon-badge {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  background: var(--intel-canon-bg);
  color: var(--text-muted);
  align-self: flex-start;
}

/* ===== ITEMS / ARMORY ===== */
.armory {
  display: flex;
  flex-direction: column;
  gap: var(--space-2000);
}
.armory-section-title {
  font-family: var(--font-heading);
  font-size: var(--font-size-850);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-500);
  margin-bottom: var(--space-750);
}
.armory-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-500);
}
.armory-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.85rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-500) var(--space-1250);
}
.armory-item-draft {
  border-style: dashed;
}
.armory-item-name {
  font-size: var(--font-size-1000);
  font-weight: 600;
  flex-shrink: 0;
}
.armory-item-name a {
  color: var(--text);
}
.armory-item-name a:hover {
  color: var(--accent);
}
.armory-item-type {
  font-size: var(--font-size-650);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}
.armory-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem var(--space-1000);
  margin-left: auto;
  font-size: var(--font-size-800);
  color: var(--text-muted);
}
.armory-meta-label {
  font-weight: 500;
  color: var(--text);
  margin-right: 0.2rem;
}
.armory-tl {
  font-size: var(--font-size-650);
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--armory-tl-bg);
  color: var(--armory-tl);
  white-space: nowrap;
}
@media (max-width: 600px) {
  .armory-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .armory-item-meta {
    margin-left: 0;
  }
}

/* ===== MISC COMPONENTS ===== */
.needs-dev {
  background: var(--needs-dev-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-500);
  padding: var(--space-1000);
  margin-top: var(--space-2000);
}
.needs-dev h3 {
  color: var(--warning);
  margin-top: 0;
  font-size: var(--font-size-1000);
}

.contact-box {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-500);
  padding: var(--space-1000);
  margin-bottom: var(--space-1000);
}
.contact-box h4 {
  color: var(--accent);
  margin: 0 0 var(--space-500);
  font-size: var(--font-size-850);
  text-transform: uppercase;
}

.event-outcome {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-250);
  padding: var(--space-750) var(--space-1000);
  margin-bottom: var(--space-1000);
  font-size: var(--font-size-950);
  line-height: 1.5;
}
.event-outcome strong { color: var(--accent); }

.event-participants { margin-bottom: var(--space-1000); }
.event-participants h3 { margin-top: 0; margin-bottom: var(--space-500); }
.event-participants ul { margin: 0; }

.abilities, .weaknesses { margin-bottom: var(--space-1000); }
.abilities h3, .weaknesses h3 { margin-top: 0; margin-bottom: var(--space-500); }

.goals { margin-bottom: var(--space-1000); }
.goals h3 { margin-top: 0; margin-bottom: var(--space-500); }

.entity-link {
  color: var(--accent);
  font-weight: 500;
}

/* ===== SYSTEM-SPECIFIC CHARACTER SHEETS ===== */

/* CoC 7e — "Regency Refined" parchment investigator sheet.
   Ported from docs/superpowers/specs/coc-investigator-sheet-mockup/index.html.
   SCOPING (multi-page themed site — these differ from the standalone mockup):
   - The mockup's global `body{...}` dark repaint is DROPPED; the parchment
     background + engraved double frame live on the `.coc-sheet-root` wrapper.
   - The mockup's `*{box-sizing}` is dropped (the global reset already sets it).
   - The mockup's `:root{ --paper… }` custom props are declared on a scoped
     selector group so they never override the site's global :root tokens.
   - The `.cr-*` correspondence widget + `.tab-panel` + `.portrait` + bare `.pip`
     collide with existing site rules, so their parchment versions are scoped to
     a CoC ancestor (`.coc-sheet-root` / `.cr-modal`) to win the cascade AND to
     leave every other system's sheet untouched. */
/* Custom props live on the two CoC roots only; every CoC element is a descendant
   of one of these and inherits them, so no other page sees the parchment tokens. */
.coc-sheet-root,
.cr-modal-backdrop.coc {
  --paper:#e7ddc3; --paper-2:#f3ecd8;
  --ink:#241d13; --ink-soft:#5a4b36; --ink-mid:#6f5c40;
  --rule:#7c6a4d; --rule-soft:#b6a483;
  --oxblood:#6e2318; --oxblood-2:#8a3222;
  --seal:#7c2114;
  --box:#fbf6e7;
  /* #363: the sheet's other inks, named so a theme can retint them (docs/theme-tokens.md). */
  --on-oxblood:#f3e6df; --sheet-edge:#100c06; --portrait-mat:#fbf6e7; --input-paper:#fffdf6; --ink-live:#3d6b3a;
  --oxblood-3:#7c2a1e; --sanbar-from:#8a3b2c22; --sanbar-to:#8a3b2c0a; --tab-paper:#dccfae; --tab-paper-2:#d0c3a0;
  --didone:"Didot","Bodoni 72","Bodoni MT","Playfair Display","Hoefler Text","Georgia",serif;
  --body:"Baskerville","Libre Baskerville","Hoefler Text","Georgia","Times New Roman",serif;
}
/* The CoC sheet is a full 1060px dossier, not body text — let it break out of
   the site's narrow reading column (main.content max-width:52rem) on CoC pages
   only (scoped via :has()). Guard against horizontal overflow at phone widths. */
/* Match the reference's tight 1rem gutter (the site's .content bumps to 2rem on
   desktop, which reads as an over-thick margin around the dossier). */
.content:has(.coc-sheet-root){ max-width:none; padding:1rem 1rem 3rem; overflow-x:hidden; }
/* No portrait → the backstory strip spans the whole row instead of leaving a gap. */
.coc-sheet-root .portrait-row:not(:has(img.portrait)){ grid-template-columns:1fr; }
.coc-sheet-root{ max-width:1060px; margin:0 auto; position:relative; color:var(--ink);
  font-family:var(--body); line-height:1.36;
  background:
    radial-gradient(circle at 22% 18%, rgba(150,120,70,.07), transparent 42%),
    radial-gradient(circle at 78% 68%, rgba(150,118,60,.06), transparent 38%),
    radial-gradient(circle at 60% 90%, rgba(120,90,50,.05), transparent 40%),
    repeating-linear-gradient(90deg, rgba(124,106,77,.05) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(0deg, rgba(124,106,77,.03) 0 2px, transparent 2px 27px),
    radial-gradient(120% 92% at 20% 0%, var(--paper-2), var(--paper) 72%);
  border:1px solid var(--sheet-edge);
  box-shadow:0 12px 44px rgba(0,0,0,.6), inset 0 0 0 6px var(--paper), inset 0 0 0 7px var(--rule);
  padding:2.4rem 2.3rem 2.6rem;}
/* engraved double frame + corner flourishes */
.coc-sheet-root::before{ content:""; position:absolute; inset:13px; border:1.5px solid var(--rule); pointer-events:none;}
.coc-sheet-root::after{ content:""; position:absolute; inset:16px; border:1px solid var(--rule-soft); pointer-events:none;}
.coc-sheet-root .corner{ position:absolute; color:var(--oxblood); font-size:1.3rem; line-height:1; opacity:.72; pointer-events:none; z-index:2;}
.coc-sheet-root .corner.tl{ top:7px; left:11px;} .coc-sheet-root .corner.tr{ top:7px; right:11px;}
.coc-sheet-root .corner.bl{ bottom:5px; left:11px;} .coc-sheet-root .corner.br{ bottom:5px; right:11px;}
/* configurable Order crest / wax seal — renders only when an image is supplied */
.coc-sheet-root .seal-img{ position:absolute; top:10px; right:16px; width:104px; height:auto; z-index:3;
  transform:rotate(-6deg); filter:drop-shadow(0 3px 5px rgba(0,0,0,.45));}
/* masthead */
.coc-sheet-root .masthead{ text-align:center; margin-bottom:.4rem; position:relative;}
.coc-sheet-root .masthead .kicker{ font-family:var(--body); font-style:italic; font-size:.9rem; letter-spacing:.06em; color:var(--ink-mid);}
.coc-sheet-root .masthead h1{ margin:.15rem 0 .05rem; font-family:var(--didone); font-size:3rem; letter-spacing:.03em; font-weight:700; color:var(--ink);
  text-shadow:0 1px 0 rgba(255,250,235,.5);}
.coc-sheet-root .masthead .era{ font-family:var(--didone); font-size:.82rem; letter-spacing:.34em; text-transform:uppercase; color:var(--oxblood-2);}
.coc-sheet-root .fleuron{ text-align:center; color:var(--oxblood); font-size:1rem; margin:.5rem 0 1rem; letter-spacing:.5em;
  display:flex; align-items:center; gap:1rem; justify-content:center;}
.coc-sheet-root .fleuron::before,.coc-sheet-root .fleuron::after{ content:""; height:1px; background:linear-gradient(90deg,transparent,var(--rule) 40%,var(--rule)); flex:1; max-width:220px;}
.coc-sheet-root .fleuron::after{ background:linear-gradient(270deg,transparent,var(--rule) 40%,var(--rule));}
.coc-sheet-root .identity{ display:grid; grid-template-columns:repeat(3,1fr); gap:0 1.5rem; margin:0 0 1.4rem;}
.coc-sheet-root .fld{ border-bottom:1px solid var(--rule); padding:.15rem .1rem .05rem; margin-bottom:.6rem; min-height:1.65rem;}
.coc-sheet-root .fld .lab{ display:block; font-family:var(--didone); font-size:.62rem; letter-spacing:.14em; text-transform:uppercase; color:var(--oxblood); font-weight:700;}
.coc-sheet-root .fld .val{ font-size:1.04rem;}
.coc-sheet-root .grid-main{ display:grid; grid-template-columns:252px 1fr; gap:1.7rem; align-items:start;}
/* characteristics */
.coc-sheet-root .char-list{ display:flex; flex-direction:column; gap:.5rem;}
.coc-sheet-root .char{ display:grid; grid-template-columns:1fr 52px; grid-template-rows:auto auto;
  border:1.5px solid var(--rule); background:var(--box); border-radius:2px; overflow:hidden;
  box-shadow:inset 0 0 0 1px rgba(255,250,235,.5);}
.coc-sheet-root .char .cname{ grid-column:1; grid-row:1/3; display:flex; align-items:center; gap:.55rem; padding:.3rem .6rem;
  font-family:var(--didone); font-weight:700; letter-spacing:.12em; text-transform:uppercase; font-size:.88rem;}
.coc-sheet-root .char .cname b{ font-size:1.7rem; letter-spacing:0; color:var(--oxblood); min-width:2.4ch; text-align:right;}
.coc-sheet-root .char .half,.coc-sheet-root .char .fifth{ padding:.05rem .3rem; font-size:.9rem; text-align:center; border-left:1px solid var(--rule-soft); font-weight:600;}
.coc-sheet-root .char .half{ border-bottom:1px solid var(--rule-soft);}
.coc-sheet-root .char .half span,.coc-sheet-root .char .fifth span{ display:block; font-size:.5rem; letter-spacing:.12em; color:var(--ink-mid); text-transform:uppercase; font-weight:400;}
.coc-sheet-root .vitals{ display:grid; grid-template-columns:repeat(2,1fr); gap:.7rem; margin-top:1rem;}
.coc-sheet-root .vital{ border:1.5px solid var(--rule); background:var(--box); border-radius:2px; padding:.45rem .55rem; text-align:center;}
.coc-sheet-root .vital .vlab{ font-family:var(--didone); font-size:.6rem; letter-spacing:.16em; text-transform:uppercase; color:var(--oxblood); font-weight:700;}
.coc-sheet-root .vital .vnum{ font-size:1.5rem; font-weight:700; font-family:var(--didone);}
.coc-sheet-root .vital .vnum small{ font-size:.66rem; color:var(--ink-mid); font-weight:400; font-family:var(--body);}
.coc-sheet-root .track{ display:flex; gap:3px; justify-content:center; margin-top:.3rem; flex-wrap:wrap;}
/* pips/exp are <button>s (keyboard-operable): reset native chrome, keep the circle */
.coc-sheet-root .pip{ width:9px; height:9px; border:1px solid var(--rule); border-radius:50%; padding:0; box-sizing:border-box; -webkit-appearance:none; appearance:none;}
.coc-sheet-root .pip.on{ background:var(--oxblood);}
.coc-sheet-root .vital.sanity{ grid-column:1/3; text-align:left;}
.coc-sheet-root .sanbar{ position:relative; height:16px; margin-top:.4rem; border:1.5px solid var(--rule); border-radius:8px; background:linear-gradient(90deg,var(--sanbar-from),var(--sanbar-to)); overflow:hidden;}
.coc-sheet-root .sanbar .fill{ position:absolute; inset:0 auto 0 0; width:38%; background:repeating-linear-gradient(45deg,var(--oxblood) 0 6px,var(--oxblood-3) 6px 12px);}
.coc-sheet-root .sanbar .mark{ position:absolute; top:-3px; width:2px; height:22px; background:var(--ink);}
.coc-sheet-root .san-scale{ display:flex; justify-content:space-between; font-size:.58rem; color:var(--ink-mid); margin-top:.25rem;}
.coc-sheet-root .badge-insane{ display:inline-block; margin-top:.45rem; font-family:var(--didone); font-size:.64rem; letter-spacing:.14em; text-transform:uppercase; font-weight:700; color:var(--on-oxblood); background:var(--oxblood); padding:.16rem .55rem; border-radius:2px;}
.coc-sheet-root .rep{ margin-top:1rem; border:1.5px dashed var(--rule); border-radius:2px; padding:.5rem .65rem; display:flex; justify-content:space-between; align-items:center;}
.coc-sheet-root .rep .rlab{ font-family:var(--didone); font-size:.6rem; letter-spacing:.16em; text-transform:uppercase; color:var(--oxblood); font-weight:700;}
.coc-sheet-root .rep .rnum{ font-size:1.5rem; font-weight:700; font-family:var(--didone);} .coc-sheet-root .rep .rnum small{ font-size:.66rem; color:var(--ink-mid); font-weight:400; font-family:var(--body);}
.coc-sheet-root .portrait-row{ display:grid; grid-template-columns:1fr 152px; gap:1.2rem; margin-bottom:.6rem;}
.coc-sheet-root .backstory{ display:grid; grid-template-columns:1fr 1fr; gap:.45rem .9rem; align-content:start;}
/* empty backstory (all discrete fields live in the Record tab) — collapse so the
   portrait keeps its column instead of leaving a wide empty grid cell */
.coc-sheet-root .backstory:empty{ display:none;}
.coc-sheet-root .portrait-row:has(.backstory:empty){ grid-template-columns:152px; justify-content:end;}
.coc-sheet-root .bs{ border-bottom:1px dotted var(--rule); padding-bottom:.24rem;}
.coc-sheet-root .bs .lab{ font-family:var(--didone); font-size:.6rem; letter-spacing:.13em; text-transform:uppercase; color:var(--oxblood); font-weight:700; display:block;}
.coc-sheet-root .bs .val{ font-size:.86rem; color:var(--ink-soft);}
.coc-sheet-root .portrait{ border:6px solid var(--portrait-mat); box-shadow:0 2px 10px rgba(0,0,0,.4), 0 0 0 1px var(--rule); aspect-ratio:3/4; object-fit:cover; object-position:top center; width:100%; filter:sepia(.12);}
.coc-sheet-root h2.section{ font-family:var(--didone); font-size:1rem; letter-spacing:.14em; text-transform:uppercase; color:var(--oxblood);
  margin:1.5rem 0 .55rem; font-weight:700; display:flex; align-items:center; gap:.7rem;}
.coc-sheet-root h2.section::before{ content:"❧"; color:var(--oxblood-2); font-size:1rem; -webkit-transform:scaleX(-1); transform:scaleX(-1);}
.coc-sheet-root h2.section .rule{ flex:1; height:0; border-top:2px solid var(--rule); border-bottom:1px solid var(--rule-soft); align-self:center; margin-top:3px;}
.coc-sheet-root h2.section .hint{ font-family:var(--body); font-size:.62rem; letter-spacing:.02em; text-transform:none; color:var(--ink-mid); font-weight:400; font-style:italic;}
/* SKILLS — full list, alphabetical, larger reg / half / fifth */
.coc-sheet-root .skills-wrap{ display:grid; grid-template-columns:1fr 1fr; gap:0 2.4rem;}
.coc-sheet-root .colcap{ display:grid; grid-template-columns:16px 1fr 34px 30px 28px; gap:.4rem; font-family:var(--didone); font-size:.58rem; letter-spacing:.1em; text-transform:uppercase; color:var(--oxblood); font-weight:700; border-bottom:1.5px solid var(--rule); padding-bottom:.22rem; margin-bottom:.35rem;}
.coc-sheet-root .colcap span:nth-child(n+3){ text-align:right;}
.coc-sheet-root .skill{ display:grid; grid-template-columns:16px 1fr 34px 30px 28px; align-items:baseline; gap:.4rem; break-inside:avoid; padding:.13rem 0; border-bottom:1px dotted var(--rule-soft);}
/* experience-check bubble — a <button> ticked on a successful roll (reset native chrome) */
.coc-sheet-root .skill .exp{ width:12px; height:12px; border:1.5px solid var(--oxblood-2); border-radius:50%; position:relative; top:2px; background:var(--box); padding:0; box-sizing:border-box; cursor:pointer; -webkit-appearance:none; appearance:none;}
.coc-sheet-root .skill.checked .exp{ background:var(--oxblood); box-shadow:inset 0 0 0 2px var(--box);}
.coc-sheet-root .skill .sname{ font-size:.9rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0;}
.coc-sheet-root .skill.dev .sname{ font-weight:600;}
.coc-sheet-root .skill .sname em{ color:var(--ink-mid); font-style:italic; font-size:.78rem;}
.coc-sheet-root .skill .reg{ font-weight:700; font-size:1.06rem; text-align:right; font-family:var(--didone);}
.coc-sheet-root .skill.dev .reg{ color:var(--oxblood);}
.coc-sheet-root .skill .h,.coc-sheet-root .skill .f{ font-size:.92rem; text-align:right; color:var(--ink-mid); font-weight:600; font-family:var(--didone);}
.coc-sheet-root table.weap{ width:100%; border-collapse:collapse; font-size:.86rem;}
.coc-sheet-root table.weap th{ text-align:left; font-family:var(--font-label, var(--didone)); font-size:.6rem; letter-spacing:.1em; text-transform:uppercase; color:var(--oxblood); background:transparent; border-bottom:1.5px solid var(--rule); padding:.32rem .4rem;}
.coc-sheet-root table.weap td{ padding:.32rem .4rem; border-bottom:1px solid var(--rule-soft);}
.coc-sheet-root table.weap td:first-child{ font-weight:600;}
/* ---- Correspondence (change-request / comms) widget — same #cr-root/.cr-* structure as the
   live site, reskinned to parchment. Scoped to .coc-sheet-root / .cr-modal so the parchment skin
   wins over the site's generic .cr-* widget AND never touches other systems' correspondence bar. ---- */
.coc-sheet-root #cr-root{ margin:0 0 1.5rem;}
.coc-sheet-root .cr-bar{ border:1.5px solid var(--rule); border-radius:3px; padding:.35rem .55rem; background:rgba(255,250,235,.55);}
.coc-sheet-root .cr-barhead{ display:flex; flex-wrap:wrap; align-items:center; gap:.3rem .5rem;}
.coc-sheet-root .cr-toggle{ flex:1 1 auto; text-align:left; background:none; border:none; cursor:pointer; font-family:var(--body); font-style:italic; font-size:.95rem; color:var(--ink-soft); padding:.4rem .3rem; min-height:44px;}
.coc-sheet-root .cr-log-btn{ flex:0 0 auto; background:none; cursor:pointer; font-family:var(--didone); font-size:.64rem; letter-spacing:.14em; text-transform:uppercase; color:var(--oxblood); border:1px solid var(--rule); border-radius:3px; padding:.4rem .8rem; min-height:44px;}
.coc-sheet-root .cr-panel{ display:flex; flex-direction:column; gap:.55rem; margin-top:.55rem;}
.coc-sheet-root .cr-panel[hidden]{ display:none;}
.coc-sheet-root .cr-toggle::before{ content:"▸ "; color:var(--oxblood-2); font-style:normal;}
.coc-sheet-root .cr-toggle[aria-expanded="true"]::before{ content:"▾ ";}
/* History modal — neutral fallback (any system). Uses existing site tokens so a
   non-CoC modal is a clean, usable dialog without inheriting the parchment skin. */
.cr-modal-backdrop{ position:fixed; inset:0; z-index:60; display:flex; align-items:center; justify-content:center; padding:1.2rem;
  background:rgba(0,0,0,.5);}
.cr-modal-backdrop[hidden]{ display:none;}
.cr-modal{ width:100%; max-width:580px; max-height:84vh; display:flex; flex-direction:column; border-radius:6px;
  background:var(--bg-card, #fff); border:1px solid var(--border, #ccc); color:var(--text, #111);
  box-shadow:0 24px 60px rgba(0,0,0,.4);}
.cr-modal-head{ display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:1rem 1.3rem .7rem; border-bottom:1px solid var(--border, #ccc);}
.cr-modal-title{ font-weight:700;}
.cr-modal-close{ background:none; border:1px solid var(--border, #ccc); border-radius:3px; cursor:pointer; color:var(--text-muted, #666); font-size:1rem; line-height:1; width:30px; height:30px;}
.cr-modal-body{ overflow-y:auto; padding:1rem 1.3rem 1.3rem;}

/* History modal — CoC parchment skin (gated to the `.coc` backdrop). */
.cr-modal-backdrop.coc{ background:rgba(24,18,10,.66); backdrop-filter:blur(2px);}
.cr-modal-backdrop.coc .cr-modal{ border-radius:4px; border:1px solid var(--sheet-edge);
  background:
    radial-gradient(circle at 22% 12%, rgba(150,120,70,.07), transparent 45%),
    repeating-linear-gradient(0deg, rgba(124,106,77,.03) 0 2px, transparent 2px 27px),
    radial-gradient(120% 92% at 20% 0%, var(--paper-2), var(--paper) 72%);
  box-shadow:0 24px 60px rgba(0,0,0,.6), inset 0 0 0 5px var(--paper), inset 0 0 0 6px var(--rule);}
.cr-modal-backdrop.coc .cr-modal-head{ padding:1rem 1.3rem .7rem; border-bottom:2px double var(--rule);}
.cr-modal-backdrop.coc .cr-modal-title{ font-family:var(--didone); font-size:.82rem; letter-spacing:.2em; text-transform:uppercase; color:var(--oxblood); font-weight:700;}
.cr-modal-backdrop.coc .cr-modal-close{ border:1px solid var(--rule); color:var(--ink-soft);}
.cr-modal-backdrop.coc .cr-modal-close:hover{ background:rgba(110,35,24,.08); color:var(--oxblood);}
.coc-sheet-root .cr-hint{ font-size:.82rem; color:var(--ink-mid); margin:0; font-style:italic;}
.coc-sheet-root .cr-text{ width:100%; box-sizing:border-box; min-height:5rem; resize:vertical; font-family:var(--body); font-size:.98rem; line-height:1.4; padding:.6rem .7rem; border:1px solid var(--rule); border-radius:3px; background:var(--input-paper); color:var(--ink);}
.coc-sheet-root .cr-text::placeholder{ color:var(--ink-mid); opacity:.7;}
.coc-sheet-root .cr-send{ align-self:flex-start; cursor:pointer; font-family:var(--font-label, var(--didone)); font-weight:700; letter-spacing:.12em; text-transform:uppercase; font-size:.7rem; min-height:44px; padding:.5rem 1.6rem; border-radius:3px; border:1px solid var(--oxblood); background:var(--oxblood); color:var(--on-oxblood);}
.cr-modal-backdrop.coc .cr-logpanel{ margin-top:.65rem; border-top:1px solid var(--rule); padding-top:.65rem;}
.cr-modal-backdrop.coc .cr-loglabel{ font-family:var(--didone); font-size:.6rem; letter-spacing:.16em; text-transform:uppercase; color:var(--oxblood); margin:0 0 .5rem;}
.cr-modal-backdrop.coc .cr-logentry{ margin-bottom:.75rem; font-size:.9rem;}
.cr-modal-backdrop.coc .cr-you{ font-weight:600; color:var(--ink);}
.cr-modal-backdrop.coc .cr-you::before{ content:"❧ "; color:var(--oxblood-2);}
.cr-modal-backdrop.coc .cr-reply{ margin-top:.18rem; white-space:pre-wrap; color:var(--ink-soft); padding-left:1rem; border-left:2px solid var(--rule-soft);}
.cr-modal-backdrop.coc .cr-reply.cr-live{ color:var(--ink-live); border-left-color:var(--ink-live);}
.cr-modal-backdrop.coc .cr-reply.cr-rejected{ color:var(--oxblood); border-left-color:var(--oxblood);}
.cr-modal-backdrop.coc .cr-reply.cr-waiting{ opacity:.55; font-style:italic;}
/* ---- Live status bar (mutable vitals + conditions) — designed editable ---- */
.coc-sheet-root .statusbar{ border:1.5px solid var(--rule); border-radius:4px; margin:0 0 1.2rem; padding:.75rem .85rem;
  background:linear-gradient(180deg, rgba(255,250,235,.72), rgba(251,246,231,.5));
  box-shadow:inset 0 0 0 1px rgba(255,250,235,.6);}
.coc-sheet-root .sb-grid{ display:grid; grid-template-columns:auto auto 1fr auto auto; gap:1rem 1.3rem; align-items:start;}
.coc-sheet-root .sb-cell{ min-width:0; display:flex; flex-direction:column; gap:.3rem;}
.coc-sheet-root .sb-lab{ font-family:var(--didone); font-size:.58rem; letter-spacing:.14em; text-transform:uppercase; color:var(--oxblood); font-weight:700; white-space:nowrap;}
.coc-sheet-root .sb-num,.coc-sheet-root .sb-count{ font-family:var(--didone); font-weight:700; display:inline-flex; align-items:baseline; gap:.28rem; white-space:nowrap;}
.coc-sheet-root .sb-num b,.coc-sheet-root .sb-count b{ font-size:1.6rem; color:var(--ink); min-width:1.6ch; text-align:center;}
.coc-sheet-root .sb-of{ font-size:.6rem; color:var(--ink-mid); font-weight:400; letter-spacing:.02em;}
.coc-sheet-root .step{ font-family:var(--body); width:21px; height:21px; line-height:1; border:1px solid var(--rule); border-radius:50%; background:var(--box); color:var(--oxblood); cursor:pointer; font-size:.95rem; padding:0; align-self:center; -webkit-appearance:none; appearance:none;}
.coc-sheet-root .step:hover{ background:var(--oxblood); color:var(--on-oxblood);}
.coc-sheet-root .pips{ display:flex; gap:3px; margin-top:.4rem; flex-wrap:wrap;}
.coc-sheet-root .pips .pip{ width:14px; height:14px; border:1.5px solid var(--rule); border-radius:50%; cursor:pointer; background:var(--box);}
.coc-sheet-root .pips .pip.on{ background:var(--oxblood); border-color:var(--oxblood);}
.coc-sheet-root .pips .pip:hover{ box-shadow:0 0 0 2px rgba(110,35,24,.25);}
.coc-sheet-root .sb-cell .sanbar{ margin-top:.5rem;}
.coc-sheet-root .sb-conditions{ display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; margin-top:.75rem; padding-top:.65rem; border-top:1px dotted var(--rule);}
.coc-sheet-root .sb-condlab{ font-family:var(--didone); font-size:.58rem; letter-spacing:.14em; text-transform:uppercase; color:var(--oxblood); font-weight:700; margin-right:.2rem;}
.coc-sheet-root .cond-chip{ font-family:var(--didone); font-size:.58rem; letter-spacing:.08em; text-transform:uppercase; font-weight:700; color:var(--ink-mid); background:none; border:1.5px solid var(--rule-soft); border-radius:20px; padding:.24rem .62rem; cursor:pointer;}
.coc-sheet-root .cond-chip:hover{ border-color:var(--oxblood); color:var(--oxblood);}
.coc-sheet-root .cond-chip.on{ color:var(--on-oxblood); background:var(--oxblood); border-color:var(--oxblood);}
.coc-sheet-root .sb-hint{ display:block; margin:.55rem 0 0; font-size:.7rem; color:var(--ink-mid); font-style:italic;}
/* static combat box (left column, replaces the moved vitals) */
.coc-sheet-root .combatbox{ display:grid; grid-template-columns:repeat(2,1fr); gap:.5rem; margin-top:1rem;}
.coc-sheet-root .cb{ border:1.5px solid var(--rule); background:var(--box); border-radius:2px; padding:.4rem .55rem; text-align:center;}
.coc-sheet-root .cb-l{ display:block; font-family:var(--didone); font-size:.55rem; letter-spacing:.13em; text-transform:uppercase; color:var(--oxblood); font-weight:700;}
.coc-sheet-root .cb-v{ font-family:var(--didone); font-size:1.3rem; font-weight:700;} .coc-sheet-root .cb-v small{ font-size:.64rem; color:var(--ink-mid); font-weight:400;}
@media (max-width:720px){ .coc-sheet-root .sb-grid{ grid-template-columns:1fr 1fr;} .coc-sheet-root .sb-cell.sb-wide{ grid-column:1/3;} }

/* ---- Tabs + page-2 record accordions ---- */
.coc-sheet-root .folio{ margin:.3rem 0 0;}
.coc-sheet-root .foliotabs{ display:flex; gap:.3rem; padding:0 .5rem; overflow-x:auto; scrollbar-width:none; position:relative; z-index:2;}
.coc-sheet-root .foliotabs::-webkit-scrollbar{ display:none;}
.coc-sheet-root .foliotab{ flex:0 0 auto; font-family:var(--didone); font-size:.7rem; letter-spacing:.1em; text-transform:uppercase; font-weight:700; color:var(--ink-mid); cursor:pointer; white-space:nowrap;
  background:linear-gradient(180deg,var(--tab-paper),var(--tab-paper-2)); border:1.5px solid var(--rule); border-bottom:none; border-radius:9px 9px 0 0;
  padding:.6rem 1.05rem .75rem; margin-bottom:-2px; transform:translateY(4px); box-shadow:inset 0 3px 5px rgba(0,0,0,.08); transition:transform .12s, color .12s;}
.coc-sheet-root .foliotab:hover{ transform:translateY(2px); color:var(--oxblood);}
.coc-sheet-root .foliotab.active{ color:var(--oxblood); background:linear-gradient(180deg,var(--paper-2),var(--box)); transform:translateY(0);
  box-shadow:0 -3px 9px rgba(0,0,0,.12); z-index:3; position:relative;}
.coc-sheet-root .foliopanel{ position:relative; z-index:1; border:1.5px solid var(--rule); border-radius:0 6px 6px 6px;
  background:linear-gradient(180deg,var(--box),rgba(255,250,235,.35)); padding:1.5rem 1.4rem;
  box-shadow:inset 0 1px 0 rgba(255,250,235,.6), 0 8px 20px rgba(0,0,0,.13);}
.coc-sheet-root .foliotab{ -webkit-user-select:none; user-select:none; -webkit-tap-highlight-color:transparent;}
.coc-sheet-root .t-short{ display:none;}
/* the site's global `.tab-panel{display:none}` (default-hidden, .active shows) would hide every folio
   panel; inside the folio the mockup toggles [hidden] instead, so re-establish that here. */
.coc-sheet-root .folio .tab-panel{ display:block;}
.coc-sheet-root .folio .tab-panel[hidden]{ display:none;}
/* the Story and Journey panels hold the site's own parts (story link, route, timeline,
   connections), drawn in the site's colours: a dark theme's pale text on many sites. On
   the folio's paper the site's colour names stand for the sheet's inks instead. */
/* #483: the backstory's parts on the folio (the hook under the masthead, the sheet's teaser, the
   Story tab's prologue and boxes) read the same names; the boxes sit on the paper, the cards
   inside them a shade lighter, in the sheet's own faces. The paper is light in both modes. */
.coc-sheet-root :is(#p-story, #p-journey, .pc-backstory-teaser, .pull-quote){
  --text:var(--ink); --text-muted:var(--ink-soft); --accent:var(--oxblood);
  --border:var(--rule-soft); --bg:var(--box); --bg-card:var(--box);
  --font-reading:var(--body); --bg-hero:var(--oxblood); --accent-on-header:var(--on-oxblood);}
.coc-sheet-root :is(.pc-prologue, .pc-story-box, .pc-backstory-teaser){ --bg-card:var(--paper-2); --bg:var(--box);}
.coc-sheet-root .pull-quote{ max-width:48rem; margin:.4rem auto .2rem; text-align:left;}
.coc-sheet-root .pc-backstory-teaser{ margin-bottom:1.2rem;}
.coc-sheet-root .pc-prologue-title{ font-family:var(--didone);}
/* the folio toggles [hidden] rather than .active, so its Story tab hides the backstory quote this way */
body:has(.coc-sheet-root #p-story:not([hidden])) .pull-quote-backstory{ display:none;}
.coc-sheet-root .rechead{ font-family:var(--didone); text-align:center; color:var(--oxblood); font-size:.72rem; letter-spacing:.28em; text-transform:uppercase; margin:1.6rem 0 .4rem; display:flex; align-items:center; gap:1rem; justify-content:center;}
.coc-sheet-root .rechead::before,.coc-sheet-root .rechead::after{ content:""; height:1px; background:var(--rule-soft); flex:1;}
.coc-sheet-root details.acc{ border:1px solid var(--rule-soft); border-radius:3px; margin-top:.6rem; background:rgba(255,250,235,.4);}
.coc-sheet-root details.acc>summary{ list-style:none; cursor:pointer; font-family:var(--didone); font-size:.82rem; letter-spacing:.1em; text-transform:uppercase; color:var(--oxblood); font-weight:700; padding:.6rem .8rem; display:flex; align-items:center; gap:.5rem;}
.coc-sheet-root details.acc>summary::-webkit-details-marker{ display:none;}
.coc-sheet-root details.acc>summary::before{ content:"▸"; color:var(--oxblood-2); font-size:.7rem;}
.coc-sheet-root details.acc[open]>summary::before{ content:"▾";}
.coc-sheet-root details.acc>summary:hover{ background:rgba(110,35,24,.05);}
.coc-sheet-root .acc-body{ padding:.2rem 1rem 1rem; font-size:.9rem; color:var(--ink-soft); line-height:1.55;}
.coc-sheet-root .acc-body p{ margin:.45rem 0;} .coc-sheet-root .acc-body strong{ color:var(--ink);}
.coc-sheet-root .acc-body .lead{ font-family:var(--didone); font-size:.62rem; letter-spacing:.12em; text-transform:uppercase; color:var(--oxblood); font-weight:700;}
.coc-sheet-root .empty-note{ color:var(--ink-mid); font-style:italic;}
.coc-sheet-root .gear-list{ margin:.4rem 0; padding-left:1.1rem;} .coc-sheet-root .gear-list li{ margin:.22rem 0;}
.coc-sheet-root table.wealth{ border-collapse:collapse; margin-top:.6rem;}
.coc-sheet-root table.wealth td{ padding:.32rem 1.2rem .32rem 0; border-bottom:1px dotted var(--rule-soft); font-size:.9rem;}
.coc-sheet-root table.wealth td:first-child{ font-family:var(--didone); font-size:.6rem; letter-spacing:.12em; text-transform:uppercase; color:var(--oxblood);}
.coc-sheet-root .story-link{ font-family:var(--didone); letter-spacing:.06em; color:var(--oxblood); text-decoration:none; font-weight:700; border-bottom:1px solid var(--rule-soft);}
@media (max-width:720px){ .coc-sheet-root .grid-main{grid-template-columns:1fr;} .coc-sheet-root .skills-wrap{grid-template-columns:1fr;} .coc-sheet-root .identity,.coc-sheet-root .portrait-row,.coc-sheet-root .backstory{grid-template-columns:1fr;} .coc-sheet-root .seal-img{position:static;display:block;margin:0 auto 1rem;transform:none;}
  /* mobile folio: tidy wrapping pill row, no scroll/bounce/bleed */
  .coc-sheet-root .foliotabs{ flex-wrap:wrap; overflow:visible; padding:0; gap:.35rem;}
  .coc-sheet-root .foliotab{ transform:none; margin-bottom:0; box-shadow:none; border:1.5px solid var(--rule); border-radius:7px; padding:.42rem .8rem; font-size:.64rem; letter-spacing:.05em;}
  .coc-sheet-root .foliotab.active{ transform:none; box-shadow:none; background:var(--oxblood); color:var(--on-oxblood); border-color:var(--oxblood);}
  .coc-sheet-root .foliopanel{ border-radius:7px; margin-top:.55rem; padding:1.1rem;}
  .coc-sheet-root .t-full{ display:none;} .coc-sheet-root .t-short{ display:inline;}
  .coc-sheet-root .skill .sname{ white-space:normal;} /* wrap full skill names instead of truncating */
  .coc-sheet-root table.weap{ font-size:.72rem;} .coc-sheet-root table.weap th,.coc-sheet-root table.weap td{ padding:.28rem .3rem;}
}

/* The phone's single-column grids used bare 1fr, which cannot shrink below its content's
   minimum width: the characteristic boxes and skill columns held the column wider than the
   sheet and the overflow was clipped on the right. minmax(0, 1fr) lets the column be the
   sheet's width. */
@media (max-width:720px){
  .coc-sheet-root .grid-main, .coc-sheet-root .skills-wrap, .coc-sheet-root .identity, .coc-sheet-root .portrait-row, .coc-sheet-root .backstory{ grid-template-columns:minmax(0,1fr);}
  .coc-sheet-root .sb-grid{ grid-template-columns:repeat(2,minmax(0,1fr));}
  /* A wide table in an accordion scrolls inside its body instead of running past the panel. */
  .coc-sheet-root .acc-body{ overflow-x:auto;}
  /* Seven weapon columns share about 245px: headers in lower case, tighter cells, long words may break. */
  .coc-sheet-root table.weap{ font-size:.7rem;}
  .coc-sheet-root table.weap th{ font-size:.6rem; letter-spacing:0; text-transform:none; padding:.28rem .15rem;}
  .coc-sheet-root table.weap td{ padding:.28rem .15rem; overflow-wrap:anywhere;}
}

/* ===== GURPS 4e — Modern Sheet ===== */

/* Category hue tokens — dark mode defaults.
   Solid colors are LIGHT shades so category text/labels/borders stay legible
   on dark cards; the -bg tints are low-alpha overlays. Light mode (below)
   swaps both for deeper solids + opaque pastels. */
:root {
  --gc-attr:   #4ade80; --gc-attr-bg:   rgba(22, 163, 74, 0.14);
  --gc-social: #fbbf24; --gc-social-bg: rgba(217, 119, 6, 0.14);
  --gc-trait:  #fb923c; --gc-trait-bg:  rgba(234, 115, 23, 0.14);
  --gc-skill:  #818cf8; --gc-skill-bg:  rgba(99, 102, 241, 0.14);
  --gc-spell:  #a78bfa; --gc-spell-bg:  rgba(139, 92, 246, 0.14);
  --gc-table:  #38bdf8; --gc-table-bg:  rgba(2, 132, 199, 0.14);
  --gc-points: #94a3b8; --gc-points-bg: rgba(100, 116, 139, 0.12);
  --gc-def:    #f87171; --gc-def-bg:    rgba(220, 38, 38, 0.14);
  /* the encumbrance ramp (level 1 has no tint), the damage column, the live panel's two badges */
  --gc-enc-0: rgba(22, 163, 74, 0.10); --gc-enc-2: rgba(217, 119, 6, 0.10); --gc-enc-3: rgba(234, 115, 23, 0.12); --gc-enc-4: rgba(220, 38, 38, 0.14);
  --gc-dmg-bg: rgba(2, 132, 199, 0.10);
  --gc-reeling: #f85149; --gc-reeling-bg: rgba(218,54,51,0.18);
  --gc-tired: #d29922; --gc-tired-bg: rgba(210,153,34,0.2);
}

/* Light mode: deeper solid hues (good contrast on white) + opaque pastel tints */
@media screen and (prefers-color-scheme: light) {
  :root:not(:where([data-theme="dark"])) {
    --gc-attr:   #15803d; --gc-attr-bg:   #eafaf0;
    --gc-social: #b45309; --gc-social-bg: #fdf4e7;
    --gc-trait:  #c2410c; --gc-trait-bg:  #fdf1e7;
    --gc-skill:  #4f46e5; --gc-skill-bg:  #eef0fe;
    --gc-spell:  #7c3aed; --gc-spell-bg:  #f3eefe;
    --gc-table:  #0369a1; --gc-table-bg:  #e8f5fc;
    --gc-points: #475569; --gc-points-bg: #eef1f5;
    --gc-def:    #b91c1c; --gc-def-bg:    #fdecec;
    --gc-enc-0: #eafaf0; --gc-enc-2: #fdf4e7; --gc-enc-3: #fdf1e7; --gc-enc-4: #fdecec;
    --gc-dmg-bg: rgba(2, 132, 199, 0.08);
  }
}
@media screen {
  :root:where([data-theme="light"]) {
    --gc-attr:   #15803d; --gc-attr-bg:   #eafaf0;
    --gc-social: #b45309; --gc-social-bg: #fdf4e7;
    --gc-trait:  #c2410c; --gc-trait-bg:  #fdf1e7;
    --gc-skill:  #4f46e5; --gc-skill-bg:  #eef0fe;
    --gc-spell:  #7c3aed; --gc-spell-bg:  #f3eefe;
    --gc-table:  #0369a1; --gc-table-bg:  #e8f5fc;
    --gc-points: #475569; --gc-points-bg: #eef1f5;
    --gc-def:    #b91c1c; --gc-def-bg:    #fdecec;
    --gc-enc-0: #eafaf0; --gc-enc-2: #fdf4e7; --gc-enc-3: #fdf1e7; --gc-enc-4: #fdecec;
    --gc-dmg-bg: rgba(2, 132, 199, 0.08);
  }
}
@media print {
  :root {
    --gc-attr:   #15803d; --gc-attr-bg:   #eafaf0;
    --gc-social: #b45309; --gc-social-bg: #fdf4e7;
    --gc-trait:  #c2410c; --gc-trait-bg:  #fdf1e7;
    --gc-skill:  #4f46e5; --gc-skill-bg:  #eef0fe;
    --gc-spell:  #7c3aed; --gc-spell-bg:  #f3eefe;
    --gc-table:  #0369a1; --gc-table-bg:  #e8f5fc;
    --gc-points: #475569; --gc-points-bg: #eef1f5;
    --gc-def:    #b91c1c; --gc-def-bg:    #fdecec;
    --gc-enc-0: #eafaf0; --gc-enc-2: #fdf4e7; --gc-enc-3: #fdf1e7; --gc-enc-4: #fdecec;
    --gc-dmg-bg: rgba(2, 132, 199, 0.08);
  }
}

/* === Sheet container === */
.gurps-sheet {
  max-width: 1180px;
  margin: 0 auto;
}

/* === Status banner === */
.status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text);
}
.status .tag {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  color: var(--gc-def);
  padding-right: 6px;
}
.status .pip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.status .pip b { font-weight: 700; }
.status .condition { color: var(--text-muted); font-style: italic; }
.status .location { color: var(--text-muted); }
.status .status-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-right: 3px;
}

/* === Masonry flow === */
.flow { column-count: 2; column-gap: 16px; }
@media (max-width: 760px) { .flow { column-count: 1; } }

/* === Identity band ===
   Physical description (height/weight/hair/eyes/...). Spans the full sheet width
   above the two-column flow, so it stays wide and thin instead of becoming a tall
   tile inside one column. */
.identity-band { margin: 0 0 16px; }
.identity-band .id-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 1px;
  background: var(--border);
}
.identity-band .id-cell {
  background: var(--bg-card);
  padding: 6px 11px 7px;
  min-width: 0;
}
.identity-band .id-l {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.identity-band .id-v {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
@media (max-width: 480px) {
  .identity-band .id-grid { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); }
}

/* === Block tiles === */
.blk {
  break-inside: avoid;
  margin: 0 0 16px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.blk h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 7px 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}
.blk h2::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--cat, var(--text-muted));
}
.blk table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.blk td, .blk th { padding: 3px 11px; text-align: left; }
.blk th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.blk tbody tr:nth-child(even) { background: var(--cat-bg, var(--bg)); }

/* === Category assignments === */
.cat-attr   { --cat: var(--gc-attr);   --cat-bg: var(--gc-attr-bg);   } .cat-attr   h2 { color: var(--gc-attr);   }
.cat-social { --cat: var(--gc-social); --cat-bg: var(--gc-social-bg); } .cat-social h2 { color: var(--gc-social); }
.cat-trait  { --cat: var(--gc-trait);  --cat-bg: var(--gc-trait-bg);  } .cat-trait  h2 { color: var(--gc-trait);  }
/* Disadvantages and quirks, the trait lists that cost points back: the trait colour unless a theme sets their own */
:is(.cat-disadv, .cat-quirk) { --cat: var(--gc-disadv, var(--gc-trait)); --cat-bg: var(--gc-disadv-bg, var(--gc-trait-bg)); } :is(.cat-disadv, .cat-quirk) h2 { color: var(--gc-disadv, var(--gc-trait)); }
.cat-skill  { --cat: var(--gc-skill);  --cat-bg: var(--gc-skill-bg);  } .cat-skill  h2 { color: var(--gc-skill);  }
.cat-spell  { --cat: var(--gc-spell);  --cat-bg: var(--gc-spell-bg);  } .cat-spell  h2 { color: var(--gc-spell);  }
.cat-table  { --cat: var(--gc-table);  --cat-bg: var(--gc-table-bg);  } .cat-table  h2 { color: var(--gc-table);  }
.cat-points { --cat: var(--gc-points); --cat-bg: var(--gc-points-bg); } .cat-points h2 { color: var(--gc-points); }
.cat-def    { --cat: var(--gc-def);    --cat-bg: var(--gc-def-bg);    } .cat-def    h2 { color: var(--gc-def);    }

/* === Common cell classes (shared by .blk and .wide) === */
.nm  { color: var(--accent); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rel { color: var(--text-muted); font-size: 12px; }
.cost {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-muted);
}
.cost::before { content: "["; opacity: 0.6; }
.cost::after  { content: "]"; opacity: 0.6; }
.cite {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-left: 4px;
}
.subline {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* === Attribute grid === */
.attr-sublabel {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 5px 11px 2px;
  font-weight: 600;
}

.attrgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  padding: 1px;
}
.attrgrid .a {
  background: var(--bg-card);
  text-align: center;
  padding: 8px 4px;
}
.attrgrid .a .v { font-size: 22px; font-weight: 700; line-height: 1; color: var(--text); }
.attrgrid .a .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text); margin-top: 2px; font-weight: 600; }
.attrgrid .a .p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.subgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  padding: 1px 1px 0;
}
.subgrid .a {
  background: var(--bg-card);
  text-align: center;
  padding: 6px 4px;
}
.subgrid .a .v { font-size: 16px; font-weight: 700; color: var(--text); }
.subgrid .a .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

/* Derived stats row (BL / Thr / Sw / SM inline spans) */
.derived {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--text);
  border-top: 1px solid var(--border);
}
.derived .der-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 3px;
}

/* === Defense chips === */
.defrow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 11px;
}
.def-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--gc-def);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.def-chip-label { color: var(--gc-def); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; margin-right: 4px; font-weight: 700; }

/* Hit location table inside defenses block */
.hit-loc { width: 100%; border-collapse: collapse; font-size: 12px; }
.hit-loc th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); border-bottom: 1px solid var(--border); padding: 3px 11px; }
.hit-loc td { padding: 2px 11px; }
.hit-loc tbody tr:nth-child(even) { background: var(--gc-def-bg); }

/* === Lifting Feats table === */
.lift-feats { width: 100%; border-collapse: collapse; font-size: 12px; }
.lift-feats th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); border-bottom: 1px solid var(--border); padding: 3px 11px; }
.lift-feats td { padding: 2px 11px; }
.lift-feats tbody tr:nth-child(even) { background: var(--gc-attr-bg); }

/* === Slam table === */
.slam-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 11px 4px;
}
.slam-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 40px;
}
.slam-v { font-size: 13px; font-weight: 700; color: var(--text); }
.slam-l { font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.slam-note { font-size: 11px; color: var(--text-muted); padding: 2px 11px 6px; }

/* === Encumbrance table === */
.enc td { font-size: 12px; padding: 3px 8px; }
.enc thead th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); border-bottom: 1px solid var(--border); padding: 3px 8px; }
/* Level colour ramp — dark mode: tints blend with dark card bg */
.enc .e0 { background: var(--gc-enc-0); }
.enc .e1 { background: transparent; }
.enc .e2 { background: var(--gc-enc-2); }
.enc .e3 { background: var(--gc-enc-3); }
.enc .e4 { background: var(--gc-enc-4); }
.enc .cur { outline: 2px solid var(--gc-attr); outline-offset: -2px; }

/* Equipment toggle column: hidden until the live-loadout JS activates, so a PC
   with an equipment table but no encumbrance table never shows dead checkboxes. */
.eq-toggle-cell { display: none; }
.gl-active .eq-toggle-cell { display: table-cell; }

/* --- GURPS live status panel (SP2) --- */
.gl-status-panel { display: none; }
.gl-active .gl-status-panel {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem;
  margin: 0 0 1rem; padding: 0.6rem 0.9rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface, rgba(127,127,127,0.06));
}
.gl-vitals { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; }
/* Scoped to the status panel: the party board reuses .gl-vital on <td> cells,
   and a bare `display: inline-flex` here would knock those out of the table's
   column layout (HP + FP would collapse into one cell). */
.gl-vitals .gl-vital { display: inline-flex; align-items: center; gap: 0.35rem; }
.gl-vital-label { font-weight: 700; letter-spacing: 0.03em; }
.gl-vital-input {
  width: 3.5ch; text-align: center; font: inherit; padding: 2px 4px;
  border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text);
  -moz-appearance: textfield;
}
.gl-vital-input::-webkit-outer-spin-button, .gl-vital-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.gl-vital-max { color: var(--text-muted); }
.gl-step {
  font: inherit; line-height: 1; padding: 2px 9px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--bg); color: var(--text); cursor: pointer;
}
.gl-step:hover { background: var(--accent-dim); }
/* Encumbrance footer: the four readouts were bare inline spans (no gap, so "Carried: 43 lbEnc: Light..."
   ran together) and Reset was an unstyled browser button. Space them and style Reset like the step buttons. */
.gl-readout { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1rem; padding: 0.5rem 0.75rem; }
.gl-readout[hidden] { display: none; }
/* Local gravity (B350): one line under the encumbrance table saying why the level moved. */
.gl-grav-note { margin: 0.4rem 0.75rem 0; font-size: 0.85em; color: var(--text-muted, inherit); }
/* The gravity warning at the top of a PC sheet (#629): the theme's warning colour, so it reads in light and dark. */
.gl-grav-alert { margin: 0 0 0.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--warning); border-left-width: 4px; border-radius: 4px; background: var(--needs-dev-bg); color: var(--text); }
.gl-grav-alert b { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.85em; margin-right: 0.35em; }
#gl-reset {
  font: inherit; font-size: 0.85em; line-height: 1; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--bg); color: var(--text); cursor: pointer;
}
#gl-reset:hover { background: var(--accent-dim); }
.gl-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 1px 7px; border-radius: 999px;
}
.gl-badge-reeling { background: var(--gc-reeling-bg); color: var(--gc-reeling); }
.gl-badge-tired { background: var(--gc-tired-bg); color: var(--gc-tired); }
.gl-status-effects { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; color: var(--text-muted); font-size: 13px; }
.gl-delta-after { font-weight: 700; color: var(--text); }
.gl-status-note { font-style: italic; color: var(--warning); }


/* === Wide tables (melee / ranged / grimoire / equipment) === */
.wide {
  margin: 0 0 16px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow-x: auto;
}
.wide h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 7px 11px;
  color: var(--gc-table);
  display: flex;
  align-items: center;
  gap: 7px;
}
.wide h2::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--cat, var(--gc-table));
}
.wide table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.wide th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding: 4px 9px;
  text-align: left;
}
.wide td { padding: 3px 9px; border-bottom: 1px solid var(--border); color: var(--text); }
.wide tbody tr:nth-child(even) { background: var(--gc-table-bg); }
.wide .nm { color: var(--accent); }
.wide .num { text-align: center; font-variant-numeric: tabular-nums; }
.wide .dmg { background: var(--gc-dmg-bg); font-weight: 600; }

/* === Points summary — row highlights === */
.blk tr.total  td { font-weight: 700; color: var(--text); border-top: 1px solid var(--border); }
.blk tr.unspent td { color: var(--gc-attr); font-weight: 600; }

/* === Footnotes === */
sup.fn { font-size: 9px; color: var(--text-muted); vertical-align: super; line-height: 0; margin-left: 1px; }
.fn-legend {
  padding: 5px 11px 6px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
.fn-line { margin: 1px 0; }

/* === Equipment container === */
.gurps-equipment { margin-bottom: 1rem; }
.equip-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.equip-table th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); border-bottom: 1px solid var(--border); padding: 4px 9px; text-align: left; }
.equip-table td { padding: 3px 9px; border-bottom: 1px solid var(--border); color: var(--text); }
.equip-table tbody tr:nth-child(even) { background: var(--gc-table-bg); }
.equip-table .totals-row td { font-weight: 700; border-top: 1px solid var(--border); }
.loadout-table { margin-top: 8px; }

/* === Combat view container === */
.gurps-combat {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* === To-hit calculator (GURPS Combat tab) ===
   Left, the situation in named groups, each header carrying its own subtotal;
   right, the answer and the itemised list. Under 780px it is one column, answer first. */
.tohit { overflow: visible; }
.tohit h2 { justify-content: space-between; }
.tohit .th-mode {
  font-size: 11px; letter-spacing: 0.06em; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-dim); color: var(--text); text-transform: none;
}
.tohit .th-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; padding: 12px; }
.tohit .th-ctrls, .tohit .th-out, .tohit .th-groups { display: grid; gap: 8px; align-content: start; min-width: 0; }
.tohit .th-out { gap: 10px; }
.tohit .th-weapon { display: grid; gap: 4px; min-width: 0; }
.tohit .th-lbl { font-size: 11.5px; color: var(--text); }
.tohit select, .tohit input[type="number"] {
  font: inherit; font-size: 13px; width: 100%; min-width: 0; box-sizing: border-box;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 7px;
}
.tohit input::placeholder { color: var(--text-muted); opacity: 1; }
.tohit select:focus-visible, .tohit input:focus-visible, .tohit button:focus-visible, .tohit summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.tohit .th-wline { margin: 0; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tohit .th-sugg { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; color: var(--text); }
.tohit .th-sugg:empty { display: none; }
.tohit .th-chip {
  font: inherit; font-size: 12px; cursor: pointer; border: 1px solid var(--accent); color: var(--text);
  background: transparent; border-radius: 999px; padding: 3px 10px; max-width: 100%;
}
.tohit .th-chip[aria-pressed="true"] { background: var(--accent-dim); border-width: 2px; padding: 2px 9px; font-weight: 700; }

.tohit details.th-grp { border: 1px solid var(--border); border-radius: 6px; background: var(--bg); min-width: 0; }
.tohit details.th-grp > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 8px; padding: 7px 10px; min-width: 0;
}
.tohit details.th-grp > summary::-webkit-details-marker { display: none; }
.tohit .th-gname { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; }
.tohit .th-gname::before { content: "\25B8"; display: inline-block; width: 1em; color: var(--text-muted); }
.tohit details[open] > summary .th-gname::before { content: "\25BE"; }
.tohit .th-gwhat { flex: 1; min-width: 0; font-size: 11.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tohit .th-gsum { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; min-width: 2.5em; text-align: right; }
.tohit .th-gfields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; padding: 4px 10px 10px; }
.tohit .th-f { display: grid; gap: 3px; align-content: start; min-width: 0; }
.tohit .th-f.th-wide, .tohit .th-checks { grid-column: 1 / -1; }
.tohit .th-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.tohit .th-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; min-width: 0; }
.tohit .th-c { font-size: 12.5px; color: var(--text); display: inline-flex; align-items: center; gap: 5px; cursor: pointer; min-width: 0; }
.tohit .th-c input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex-shrink: 0; }
.tohit .th-c input:disabled + span { color: var(--text-muted); }
.tohit .th-hint { font-size: 11.5px; color: var(--text); font-style: italic; }
.tohit .th-hint[hidden] { display: none; }
.tohit select:disabled { opacity: 0.55; }
.tohit .th-from { font-size: 10px; letter-spacing: 0.04em; color: var(--text); border: 1px solid var(--accent); border-radius: 3px; padding: 0 4px; }

.tohit .th-big { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: flex-end; }
.tohit .th-stick, .tohit .th-sub { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: flex-end; }
.tohit .th-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tohit .th-k { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.tohit .th-v { font-size: 32px; font-weight: 700; line-height: 1.05; color: var(--accent); font-variant-numeric: tabular-nums; }
.tohit .th-v.th-sm { font-size: 17px; color: var(--text); }
.tohit .th-strip { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 2px; }
.tohit .th-cell { border-radius: 3px; text-align: center; font-size: 11px; padding: 4px 0; font-variant-numeric: tabular-nums; border: 1px solid transparent; }
/* Critical cells are filled (a tint of the card, so the digit keeps the page's own text colour on it),
   a plain hit is outlined in the accent, a miss is muted: not colour alone. */
.tohit .th-CS { background: color-mix(in srgb, var(--success) 40%, var(--bg-card)); color: var(--text); font-weight: 700; border-color: var(--success); }
.tohit .th-S { background: transparent; color: var(--text); border: 2px solid var(--accent); padding: 3px 0; }
.tohit .th-F { background: transparent; color: var(--text-muted); border-color: var(--border); }
.tohit .th-CF { background: color-mix(in srgb, var(--danger) 40%, var(--bg-card)); color: var(--text); font-weight: 700; border-color: var(--danger); }
.tohit table.th-lines { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tohit .th-lines tbody tr, .tohit .th-lines tbody tr:nth-child(even) { background: none; }
.tohit .th-lines td { padding: 3px 6px; border-bottom: 1px solid var(--border); background: none; overflow-wrap: anywhere; }
.tohit .th-lines .th-n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.tohit .th-lines .th-gh td { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); padding-top: 8px; border-bottom: 0; }
.tohit .th-lines .th-included td { font-size: 11.5px; color: var(--text); }
.tohit .th-lines .th-total td { border-top: 2px solid var(--accent); border-bottom: 0; font-weight: 700; color: var(--text); }
.tohit .th-notes { display: grid; gap: 4px; font-size: 12px; color: var(--text); line-height: 1.45; }
.tohit .th-notes:empty { display: none; }
.tohit .th-dmg { display: grid; gap: 4px; font-size: 12.5px; color: var(--text); line-height: 1.45; }
.tohit .th-dmg:empty { display: none; }
.tohit .th-dmg p { margin: 0; }
.tohit .th-dmg .th-dmg-row { font-weight: 600; }
.tohit .th-actions button {
  font: inherit; font-size: 12px; background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; cursor: pointer;
}
.tohit .th-actions button:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 780px) {
  /* One column, the answer first. The roll and the hit chance stay at the top of the screen
     (under the sticky site header, 3.5rem) while the groups below are changed. */
  .tohit .th-body { display: flex; flex-direction: column; gap: 10px; }
  .tohit .th-out, .tohit .th-big { display: contents; }
  .tohit .th-ctrls { order: 1; margin-top: 6px; }
  .tohit .th-stick {
    position: sticky; top: 3.5rem; z-index: 4; background: var(--bg-card); padding: 6px 0;
    border-bottom: 1px solid var(--border); align-items: baseline; flex-wrap: nowrap;
  }
  .tohit .th-stick .th-v { font-size: 26px; }
  .tohit .th-stick .th-v.th-sm { font-size: 17px; }
  .tohit .th-stick, .tohit .th-stick .th-sub { gap: 6px 14px; }
  .tohit .th-stick .th-sub { flex-wrap: nowrap; align-items: baseline; }
  /* Tap targets: at least 40px. */
  .tohit select, .tohit input[type="number"], .tohit .th-actions button, .tohit .th-chip { min-height: 40px; }
  .tohit .th-c { min-height: 40px; }
  .tohit .th-c input { width: 20px; height: 20px; }
  .tohit details.th-grp > summary { min-height: 40px; align-items: center; }
}
@media (max-width: 440px) {
  .tohit .th-gfields { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 360px) {
  .tohit .th-strip { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; }
  .tohit .th-cell { font-size: 12px; padding: 6px 0; }
  .tohit .th-S { padding: 5px 0; }
}

/* === Combat action chains === */
.chain-group { margin-bottom: 8px; }
.chain-group h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.chain-entry { margin-bottom: 6px; }
.chain-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.chain-steps { font-size: 12px; color: var(--text-muted); }
.chain-step {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
}
.chain-arrow { color: var(--text-muted); margin: 0 2px; }

/* === Rules reference appendix === */
details.rules-ref {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
}
details.rules-ref > summary {
  cursor: pointer;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  list-style: none;
  user-select: none;
}
details.rules-ref > summary::-webkit-details-marker { display: none; }
.rules-ref-body {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  align-items: flex-start;
}
.ref-table { border-collapse: collapse; font-size: 12px; min-width: 200px; width: auto; }
.ref-table caption {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: left;
  margin-bottom: 4px;
  caption-side: top;
}
.ref-table th { font-size: 10px; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); padding: 3px 8px; text-align: left; }
.ref-table td { padding: 2px 8px; color: var(--text); }
.ref-table tbody tr:nth-child(even) { background: var(--bg); }
.ref-table + p.cite { margin: 4px 0 0; font-size: 10px; color: var(--text-muted); font-style: italic; }

/* D&D 5e */
.dnd-sheet { background: var(--bg-card); border-radius: 0.5rem; padding: 1.5rem; }
.dnd-ability-scores {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.dnd-ability-card {
  text-align: center;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem 0.5rem;
}
.dnd-ability-card .ability-name {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.dnd-ability-card .ability-score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.5rem;
}
.dnd-ability-card .ability-mod {
  font-size: 0.8rem;
  color: var(--accent);
}
.dnd-ability-card { display: flex; flex-direction: column; align-items: center; }
.dnd-ability-card.has-save { border-color: var(--accent); }
.dnd-ability-card .ability-save {
  margin-top: 0.25rem;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.dnd-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-heading);
  font-size: 1.1rem;
}
.dnd-header span + span::before { content: "·"; margin-right: 0.75rem; color: var(--text-muted); }
.dnd-sheet .quick-stats .stat-item { background: var(--bg); display: flex; flex-direction: column; }
.dnd-sheet h3 { margin: 1.5rem 0 0.75rem; }
.dnd-sheet h4 { margin: 1rem 0 0.5rem; }
.dnd-caption { font-size: 0.7rem; font-weight: 400; color: var(--text-muted); margin-left: 0.5rem; }
.dnd-skills {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  columns: 2 15rem;
  column-gap: 1.5rem;
}
.dnd-skill {
  display: grid;
  grid-template-columns: 0.75rem 1fr auto 2.5rem;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  break-inside: avoid;
}
.dnd-skill.is-proficient { color: var(--text); font-weight: 600; }
.dnd-skill .skill-mark {
  width: 0.6rem;
  height: 0.6rem;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
}
.dnd-skill.is-proficient .skill-mark { background: var(--accent); border-color: var(--accent); }
.dnd-skill.is-expert .skill-mark { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px var(--accent); }
.dnd-skill:has(.skill-rank) { grid-template-columns: 0.75rem 1fr 1.25rem auto 2.5rem; }
.dnd-skill .skill-rank {
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 0.2rem;
}
.dnd-skill.is-proficient .skill-rank { color: var(--accent); border-color: var(--accent); }
.dnd-skill .skill-ability { font-size: 0.65rem; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 400; }
.dnd-skill .skill-mod { font-family: var(--font-mono); text-align: right; }
.dnd-proficiency-list p { margin: 0 0 0.35rem; }
.dnd-proficiency {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.2rem;
}

/* D&D 5e full sheet (dnd5e-*): one phone-width column of plain blocks under a pinned vitals strip */
.dnd5e-sheet { display: flex; flex-direction: column; gap: 0.9rem; }
.dnd5e-header { display: flex; flex-wrap: wrap; gap: 0.15rem 0.75rem; font-family: var(--font-heading); font-size: 1.05rem; }
.dnd5e-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; }
/* Small text is the body colour: a palette's muted grey falls under 4.5:1 at this size, so size, weight and spacing carry the hierarchy. */
.dnd5e-lbl { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text); }
.dnd5e-why { font-size: 0.7rem; color: var(--text); margin-left: 0.3rem; font-weight: 400; }
.dnd5e-entry-name, .dnd5e-entry-text, .dnd5e-tag, .dnd5e-v { overflow-wrap: anywhere; min-width: 0; }
/* a long unbroken word in a reason, a damage line, a rest phrase or a track name wraps in its box too */
.dnd5e-entry-big, .dnd5e-why, .dnd5e-dmg, .dnd5e-recovers, .dnd5e-uses, .dnd5e-track-name, .dnd5e-count { overflow-wrap: anywhere; min-width: 0; }
.dnd5e-as-written { overflow-x: auto; }
.dnd5e-recovers, .dnd5e-cap, .dnd5e-of, .dnd5e-temp { color: var(--text); font-size: 0.8rem; font-weight: 400; }
/* a fly, swim, climb or burrow speed under the Speed tile's number */
.dnd5e-sub { font-size: 0.7rem; line-height: 1.25; overflow-wrap: anywhere; min-width: 0; }

/* pinned vitals: sits under the sticky site header (.top-nav, 3.5rem) */
.dnd5e-vitals {
  position: sticky; top: 3.5rem; z-index: 5; margin-bottom: 0.9rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}
.dnd5e-vrow { display: grid; grid-template-columns: 2.2fr 1fr 1fr 1fr 1fr; gap: 6px; }
.dnd5e-v { background: var(--bg); border-radius: 6px; padding: 6px 4px; text-align: center; display: flex; flex-direction: column; }
.dnd5e-v .dnd5e-num { font-size: 1.15rem; }
.dnd5e-hp { text-align: left; padding-inline: 10px; }
.dnd5e-hp-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.dnd5e-hp .dnd5e-num { font-size: 1.35rem; }
.dnd5e-chips { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.8rem; align-items: center; }
.dnd5e-chip { border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; background: var(--bg); overflow-wrap: anywhere; min-width: 0; }
/* lit by its border and fill; the text stays the body colour, which an accent on its own tint cannot match for contrast */
.dnd5e-chip.is-on { border-color: var(--accent); background: var(--accent-dim); font-weight: 700; }

/* blocks */
.dnd5e-blk { background: var(--bg-card); border-radius: 8px; padding: 12px; min-width: 0; }
.dnd5e-blk > h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text); margin: 0 0 8px; font-weight: 700; }
.dnd5e-blk > h3 .dnd5e-cap { text-transform: none; letter-spacing: 0; }

.dnd5e-abilities { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.dnd5e-ab { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; text-align: center; padding: 8px 4px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dnd5e-ab-mod { font-family: var(--font-mono); font-weight: 700; font-size: 1.5rem; line-height: 1.1; }
.dnd5e-ab-score { color: var(--text); font-size: 0.8rem; }
.dnd5e-ab-save { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); font-size: 0.8rem; }
.dnd5e-ab.is-prof { border-color: var(--accent); }
.dnd5e-ab.is-prof .dnd5e-ab-save { border-top-color: var(--accent); font-weight: 700; }
/* a reason under a modifier or a save reads as small body text on its own line, wrapping at word breaks */
.dnd5e-ab .dnd5e-why { display: block; margin: 2px 0 0; line-height: 1.25; font-family: var(--font-body); font-weight: 400; overflow-wrap: break-word; }
.dnd5e-abilities + .dnd5e-kv { margin-top: 8px; }

.dnd5e-skills { list-style: none; margin: 0; padding: 0; columns: 2 14rem; column-gap: 20px; }
.dnd5e-skill { display: grid; grid-template-columns: 12px 1fr auto 2.4rem; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); break-inside: avoid; color: var(--text); }
.dnd5e-skill.is-prof, .dnd5e-skill.is-expert { font-weight: 700; }
.dnd5e-skill-name { overflow-wrap: anywhere; min-width: 0; }
.dnd5e-dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--text-muted); }
.dnd5e-skill.is-prof .dnd5e-dot, .dnd5e-skill.is-expert .dnd5e-dot { background: var(--accent); border-color: var(--accent); }
.dnd5e-skill.is-expert .dnd5e-dot { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px var(--accent); }
.dnd5e-skill.is-half .dnd5e-dot { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.dnd5e-skill .dnd5e-num { text-align: right; }
/* a reason is its own row under the name and ability, across the columns after the dot */
.dnd5e-skill .dnd5e-why { grid-column: 2 / -1; margin-left: 0; }

.dnd5e-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 6px; }
.dnd5e-kv .dnd5e-v { text-align: left; padding-inline: 10px; }
.dnd5e-lines p { margin: 0 0 4px; font-size: 0.92rem; overflow-wrap: anywhere; }
.dnd5e-lines strong { color: var(--text); font-weight: 700; }

/* one entry shape for features, actions, attacks, spells and gear */
.dnd5e-entry { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dnd5e-entry:last-child { border-bottom: 0; padding-bottom: 0; }
.dnd5e-entry:first-of-type { padding-top: 0; }
.dnd5e-entry-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.dnd5e-entry-name { font-weight: 700; }
.dnd5e-entry-big { margin-left: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.dnd5e-dmg { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; }
.dnd5e-entry-text { font-size: 0.88rem; color: var(--text); }
.dnd5e-entry-text p { margin: 0; }
.dnd5e-tags { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.dnd5e-tag { font-size: 0.7rem; border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; color: var(--text); }
.dnd5e-tag.is-conc { border-color: var(--warning); }
/* where a spell comes from when it is not the class's own: an item, a feat, a species trait */
.dnd5e-tag.is-source { border-style: dashed; border-color: var(--accent); }
.dnd5e-tag a, .dnd5e-entry-name a { overflow-wrap: anywhere; }
.dnd5e-stat { display: inline-flex; align-items: baseline; gap: 4px; }

/* marks are read from the note, not tapped */
.dnd5e-marks { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.dnd5e-mark { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent); background: var(--accent); padding: 0; }
.dnd5e-mark.is-spent { background: transparent; border-color: var(--text-muted); }
.dnd5e-live { cursor: pointer; }
.dnd5e-count { font-size: 0.85rem; color: var(--text); }
.dnd5e-uses { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text); }
.dnd5e-track { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 6px 0; }
/* a track's label keeps to one line ("Hit Dice"); only a word too long for the block breaks */
.dnd5e-track-name { min-width: 4.5rem; max-width: 100%; font-weight: 700; flex: 0 1 auto; }
.dnd5e-coins { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }

/* live controls (js/dnd-live.js draws and paints them; without the script the page reads as above).
   Text stays the body colour throughout: a control's meaning is carried by its border and fill. */
button.dnd5e-mark { font: inherit; cursor: pointer; position: relative; }
button.dnd5e-mark:focus-visible, .dnd5e-live:focus-visible, .dnd5e-btn:focus-visible, button.dnd5e-chip:focus-visible,
.dnd5e-field:focus-visible, [data-live="hp"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.dnd5e-count { font: inherit; font-size: 0.85rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 10px; }
.dnd5e-marks.is-fail .dnd5e-mark:not(.is-spent) { background: var(--danger); border-color: var(--danger); }
.dnd-live-active [data-live="hp"] { cursor: pointer; border: 1px solid var(--border); }
.dnd-live-active [data-live="hp"]:hover, button.dnd5e-chip:hover, button.dnd5e-count:hover { border-color: var(--accent); }
/* the hit point tile says it can be tapped, and shows how much is left as a bar */
.dnd5e-tap { margin-left: auto; font-size: 0.7rem; font-weight: 400; color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 2px; white-space: nowrap; }
.dnd5e-bar { display: block; height: 5px; border-radius: 3px; background: var(--border); margin-top: 4px; overflow: hidden; }
.dnd5e-bar-fill { display: block; height: 100%; background: var(--success); }
/* an open drawer must never push the pinned strip's own buttons off a short screen */
.dnd-live-active .dnd5e-vitals { max-height: calc(100vh - 3.5rem - 8px); max-height: calc(100dvh - 3.5rem - 8px); overflow-y: auto; overscroll-behavior: contain; }
.dnd5e-vitals [hidden] { display: none; }
button.dnd5e-chip { font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.dnd5e-chip.is-bad { border-color: var(--warning); font-weight: 700; }
.dnd5e-rest { margin-left: auto; display: flex; gap: 6px; }
.dnd5e-btn { font: inherit; font-size: 0.85rem; font-weight: 700; color: var(--text); cursor: pointer; border: 1px solid var(--accent); background: var(--accent-dim); border-radius: 6px; padding: 4px 12px; }
.dnd5e-btn.is-damage { border-color: var(--danger); background: transparent; }
.dnd5e-btn.is-heal { border-color: var(--success); background: transparent; }
.dnd5e-btn.is-quiet { border-color: var(--border); background: transparent; font-weight: 400; }
.dnd5e-end { margin-left: auto; }
.dnd5e-death { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 0.85rem; font-weight: 700; border-left: 3px solid var(--danger); padding-left: 8px; }
.dnd5e-drawer { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 10px; font-size: 0.9rem; }
.dnd5e-drawer-title { margin: 0; font-size: 0.95rem; font-family: var(--font-body); font-weight: 700; color: var(--text); text-transform: none; letter-spacing: 0; }
.dnd5e-drawer p, .dnd5e-drawer ul { margin: 0; font-size: 0.85rem; overflow-wrap: anywhere; }
/* what a long rest brings back can be a long list: two columns keep the drawer short on a phone */
.dnd5e-drawer ul { padding-left: 18px; columns: 2 9rem; column-gap: 28px; }
.dnd5e-drawer li { break-inside: avoid; }
.dnd5e-frow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.dnd5e-ask { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.85rem; min-width: 0; }
.dnd5e-field { font: inherit; font-family: var(--font-mono); font-weight: 700; font-size: 1.2rem; width: 5.5rem; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
/* the browser's own placeholder grey is under 4.5:1 on most palettes; this is the field's text colour, thinned towards the field */
.dnd5e-field::placeholder { color: color-mix(in srgb, var(--text) 70%, var(--bg)); opacity: 1; }
.dnd5e-stepper { display: inline-flex; align-items: center; gap: 8px; }
.dnd5e-stepper .dnd5e-btn { width: 32px; height: 32px; padding: 0; font-weight: 700; background: var(--bg); }
.dnd5e-stepper .dnd5e-num { min-width: 1.2ch; text-align: center; }
.dnd5e-said { border-top: 1px solid var(--border); padding-top: 8px; font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dnd5e-said-text { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
/* nothing said yet: the line takes no room but stays in the page, so a screen reader hears its first message */
.dnd5e-said.is-empty { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 480px) {
  .dnd5e-abilities { grid-template-columns: repeat(3, 1fr); }
  /* the pinned strip on a phone: one row of small tiles, and chips only when they have something to say */
  .dnd5e-vitals { padding: 6px; gap: 6px; }
  .dnd5e-vrow { grid-template-columns: 1.7fr 1fr 1fr 1.2fr 1fr; gap: 4px; }
  .dnd5e-vitals .dnd5e-v { padding: 4px 2px; }
  .dnd5e-vitals .dnd5e-hp { padding-inline: 6px; }
  .dnd5e-vitals .dnd5e-lbl { font-size: 0.56rem; letter-spacing: 0.04em; }
  .dnd5e-vitals .dnd5e-v .dnd5e-num { font-size: 0.95rem; }
  .dnd5e-vitals .dnd5e-hp .dnd5e-num { font-size: 1.05rem; }
  .dnd5e-vitals .dnd5e-of, .dnd5e-vitals .dnd5e-temp { font-size: 0.72rem; }
  .dnd5e-vitals .dnd5e-why.is-dup { display: none; }
  .dnd5e-vitals .dnd5e-why, .dnd5e-vitals .dnd5e-sub { margin-left: 0; font-size: 0.62rem; line-height: 1.15; }
  .dnd5e-chips.is-quiet, .dnd5e-chip.is-quiet { display: none; }
  /* live controls on a phone: a mark is 24px with an 8px gap, and its tap area fills the gap (32px); buttons are 32px high */
  .dnd5e-live .dnd5e-mark { width: 24px; height: 24px; }
  .dnd5e-marks.dnd5e-live { gap: 8px; }
  .dnd5e-live button.dnd5e-mark::after { content: ""; position: absolute; inset: -4px; }
  .dnd5e-btn, button.dnd5e-chip, button.dnd5e-count { min-height: 32px; }
  .dnd5e-vitals .dnd5e-tap { font-size: 0.6rem; }
}
/* the same tap sizes on any touch screen, so a phone on its side or a tablet is not left with 16px marks */
@media (pointer: coarse) {
  .dnd5e-live .dnd5e-mark { width: 24px; height: 24px; }
  .dnd5e-marks.dnd5e-live { gap: 8px; }
  .dnd5e-live button.dnd5e-mark::after { content: ""; position: absolute; inset: -4px; }
  .dnd5e-btn, button.dnd5e-chip, button.dnd5e-count { min-height: 32px; }
}
@media print {
  .dnd5e-vitals { position: static; box-shadow: none; }
  .dnd-live-active .dnd5e-vitals { max-height: none; overflow: visible; }
  .dnd5e-drawer, .dnd5e-said, .dnd5e-rest, .dnd5e-tap { display: none; }
}

/* PF2e */
.pf2e-attributes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.pf2e-attribute-card {
  text-align: center;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem 0.5rem;
}
.pf2e-attribute-card .ability-name {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.pf2e-attribute-card .ability-mod {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent);
}

/* FitD */
.fitd-sheet { background: var(--bg-card); border-radius: 0.5rem; padding: 1.5rem; }
.fitd-action-ratings { margin-bottom: 1.5rem; }
.fitd-attribute h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 1rem 0 0.5rem;
}
.fitd-action-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.875rem;
}
.fitd-dots {
  display: flex;
  gap: 0.2rem;
}
.fitd-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
}
.fitd-dot.filled {
  background: var(--accent);
}
.fitd-tracker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.fitd-identity {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0 0 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.fitd-identity dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.fitd-identity dd { margin: 0.15rem 0 0; font-weight: 600; }
.fitd-attribute { break-inside: avoid; }
.fitd-action-ratings { columns: 3 11rem; column-gap: 2rem; }
.fitd-attribute h4 { margin-top: 0; }
.fitd-tracker { flex-wrap: wrap; }
.fitd-sheet table { margin-bottom: 1rem; }
.fitd-armor { display: inline-flex; align-items: center; gap: 0.35rem; margin-right: 0.75rem; }
.fitd-box {
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid var(--accent);
  border-radius: 0.15rem;
}
.fitd-box.filled { background: var(--accent); }
.fitd-sheet h3 { margin: 1.5rem 0 0.75rem; }
.fitd-sheet .quick-stats .stat-item { background: var(--bg); display: flex; flex-direction: column; }
.fitd-abilities p { margin: 0 0 0.5rem; }

/* ===== FOOTER ===== */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ===== BACK TO TOP ===== */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 50;
}
.back-to-top.visible {
  opacity: 0.85;
  visibility: visible;
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--accent);
  color: var(--on-accent, var(--bg));
  opacity: 1;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  .content { padding: var(--space-2000) var(--space-2000) 4rem; }
  .hero-banner h1 { font-size: 2.25rem; }
  .landing-hero h1 { font-size: 2.5rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
  .dnd-ability-scores { gap: 0.75rem; }
  .pf2e-attributes { gap: 0.75rem; }
}

@media (max-width: 480px) {
  .dnd-ability-scores { grid-template-columns: repeat(3, 1fr); }
  .pf2e-attributes { grid-template-columns: repeat(3, 1fr); }
}

/* Connections */
/* Colour. Without the page script everything here is the plain text colour. The script
   (js/connections.js, inks) reads the palette's muted, accent, success and danger colours,
   moves each toward the text colour only as far as it must to be read on what it is drawn on
   (4.5 to 1 for words, 3 to 1 for marks and lines), and hands the results over as --cxi-* for
   the page and --cxc-* for a card and the strip, which a sheet skin gives inks of their own.
   A tone is a shape as well: filled round (warm), hollow diamond (hostile), hollow round (neutral). */
.cx {
  --cx-muted: var(--cxi-muted, var(--text));
  --cx-accent: var(--cxi-accent, var(--text));
  --cx-warm-ink: var(--cxi-warm-ink, var(--text));
  --cx-hostile-ink: var(--cxi-hostile-ink, var(--text));
  --cx-warm: var(--cxi-warm, var(--text));
  --cx-hostile: var(--cxi-hostile, var(--text));
  --cx-trunk: var(--cxi-trunk, var(--text));
  --cx-ground: var(--cxi-ground, var(--bg));
  --cx-hover: var(--cxi-hover, transparent);
  --cx-neutral: var(--cx-muted);
}
.cx-card, .cx-strip {
  --cx-muted: var(--cxc-muted, var(--text));
  --cx-accent: var(--cxc-accent, var(--text));
  --cx-warm-ink: var(--cxc-warm-ink, var(--text));
  --cx-hostile-ink: var(--cxc-hostile-ink, var(--text));
  --cx-warm: var(--cxc-warm, var(--text));
  --cx-hostile: var(--cxc-hostile, var(--text));
  --cx-neutral: var(--cx-muted);
}
.cx { margin-top: 2.5rem; min-width: 0; max-width: 100%; }
.cx #cx-heading { margin: 0 0 0.75rem; color: var(--cx-accent); }
.cx-app { position: relative; min-width: 0; }
.cx-panel { min-width: 0; }
.cx-panel[hidden] { display: none; }

/* the lists, for a reader without the script, the search index and a printer */
.cx.cx-live .cx-plain { display: none; }
.cx-plain :is(h3, h4, h5, h6) { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cx-muted); font-weight: 600; margin: 1rem 0 0.4rem; }
.cx-plain :is(h3, h4, h5, h6):has(+ :is(h3, h4, h5, h6)) { font-size: 1.05rem; letter-spacing: 0; text-transform: none; color: var(--text); font-family: var(--font-heading); margin: 1.4rem 0 0; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }
.cx-plain a { color: var(--cx-accent); text-decoration: underline; text-underline-offset: 2px; }
.cx-plain ul { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.cx-plain li, .cx-mentions li, .cx-mlist li { overflow-wrap: anywhere; }
.cx-plain li { margin: 0 0 0.5rem; }
.cx-line, .cx-sess { display: block; min-width: 0; overflow-wrap: anywhere; color: var(--cx-muted); }
.cx-plain .cx-line { font-size: 0.92rem; }
.cx-sess { font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.cx-from { color: var(--cx-muted); }
.cx-kind { display: inline-block; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cx-muted); border: 1px solid var(--border); border-radius: 3px; padding: 0 5px; margin-left: 6px; font-weight: 600; line-height: 1.5; vertical-align: baseline; }
.cx-tone { font-weight: 600; }
.cx-tone.cx-warm { color: var(--cx-warm-ink); }
.cx-tone.cx-hostile { color: var(--cx-hostile-ink); }
.cx-tone.cx-neutral { color: var(--cx-neutral); }
.cx-mentions, .cx-mlist { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 0.5rem; padding: 0; list-style: none; }
.cx-plain .cx-mentions li, .cx-mlist li { margin: 0; }
.cx-mlist a { color: var(--cx-accent); text-decoration: none; }
.cx-mlist a:hover { text-decoration: underline; }
.cx-probe, .cx-strip.cx-probe { display: none; }

/* the mark: shape first (filled round warm, hollow diamond hostile, hollow round neutral), colour second */
span.cx-mark { display: inline-block; flex: none; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--cx-neutral); background: transparent; }
span.cx-mark.cx-warm { background: var(--cx-warm); border-color: var(--cx-warm); }
span.cx-mark.cx-hostile { width: 9px; height: 9px; margin: 1px; border-radius: 0; border-color: var(--cx-hostile); transform: rotate(45deg); }
span.cx-mark.cx-neutral { border-color: var(--cx-neutral); }
.cx-key { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.85rem; color: var(--cx-muted); margin: 0.9rem 0 0; }
.cx-key-item { display: inline-flex; align-items: center; gap: 7px; }

/* tabs: one row that scrolls sideways inside its own box; an edge with more tabs beyond it fades */
.cx-tabs { position: relative; display: flex; gap: 4px; overflow-x: auto; max-width: 100%; border-bottom: 1px solid var(--border); margin-bottom: 1rem; scrollbar-width: thin; }
.cx-tabs.cx-more-end { -webkit-mask-image: linear-gradient(to left, transparent, currentColor 3rem); mask-image: linear-gradient(to left, transparent, currentColor 3rem); }
.cx-tabs.cx-more-start { -webkit-mask-image: linear-gradient(to right, transparent, currentColor 3rem); mask-image: linear-gradient(to right, transparent, currentColor 3rem); }
.cx-tabs.cx-more-start.cx-more-end { -webkit-mask-image: linear-gradient(to right, transparent, currentColor 3rem, currentColor calc(100% - 3rem), transparent); mask-image: linear-gradient(to right, transparent, currentColor 3rem, currentColor calc(100% - 3rem), transparent); }
.cx-tab { flex: none; font: 600 0.9rem/1.5 var(--font-body); color: var(--cx-muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 0.6rem 0.65rem; min-height: 44px; cursor: pointer; white-space: nowrap; }
.cx-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--cx-accent); }
.cx-tab:hover { color: var(--text); }
.cx-n { font-weight: 400; color: var(--cx-muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
/* the ring is drawn inside the tab and the row: the tab row clips what is outside it, and a row fills its column */
.cx-tab:focus-visible, .cx-row:focus-visible { outline: 2px solid var(--cx-accent); outline-offset: -2px; border-radius: 3px; }
.cx-open:focus-visible, .cx-card a:focus-visible, .cx-mlist a:focus-visible { outline: 2px solid var(--cx-accent); outline-offset: 2px; }
.cx-tab, .cx-row, .cx-open, .cx-card a, .cx-mlist a { scroll-margin-top: 4.5rem; }

/* the tree: rows in the page's flow; the script draws the lines behind them from where they landed */
.cx-tree-wrap { position: relative; padding-bottom: 0.25rem; }
svg.cx-lines { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
.cx-subject, .cx-tree { position: relative; z-index: 1; }
.cx-subject { margin: 0 0 1rem; padding-left: 28px; font: 600 1.2rem/1.2 var(--font-heading); color: var(--text); overflow-wrap: anywhere; }
.cx-tree, .cx-leaves { list-style: none; margin: 0; padding: 0; }
.cx-branch { margin: 0 0 14px; }
.cx-branch:last-child { margin-bottom: 0; }
.cx-group { margin: 0; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cx-muted); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.cx-item { margin: 0; }
a.cx-row, span.cx-row { display: flex; align-items: flex-start; gap: 10px; padding: 4px 8px; min-height: 30px; color: var(--text); text-decoration: none; border-radius: 3px; cursor: pointer; }
span.cx-row.cx-text { cursor: default; }
a.cx-row:hover, .cx-row.cx-sel { text-decoration: none; background: var(--cx-hover); }
.cx-row .cx-mark { margin-top: 5px; }
.cx-row .cx-mark.cx-hostile { margin: 6px 1px 0; }
.cx-name { min-width: 0; overflow-wrap: anywhere; font-size: 0.95rem; line-height: 1.45; }
a.cx-row .cx-name { color: var(--text); }
.cx-row.cx-sel .cx-name { color: var(--cx-accent); text-decoration: underline; text-underline-offset: 3px; }
.cx-row.cx-sel .cx-mark { outline: 2px solid var(--cx-accent); outline-offset: 2px; }
/* a name with no page is not a link, and is not underlined like one */
.cx-row.cx-text.cx-sel .cx-name, svg.cx-web .cx-node.cx-text.cx-sel text, svg.cx-web .cx-node.cx-text:focus-visible text { text-decoration: none; }
.cx-meta { display: none; margin-left: auto; padding-left: 12px; flex: none; white-space: nowrap; font-size: 0.78rem; line-height: 1.7; color: var(--cx-muted); text-align: right; font-variant-numeric: tabular-nums; }
.cx-roomy .cx-meta { display: block; }
/* In a column that is only just roomy the meta may not fit beside a long name, and the name would
   be broken inside a word to make room: the meta goes under the name instead. */
.cx-roomy a.cx-row, .cx-roomy span.cx-row { flex-wrap: wrap; }
/* its own width, so a name that fits the row on its own line is not broken; never wider than the row beside its mark */
.cx-roomy .cx-row .cx-name { flex: 1 1 auto; max-width: calc(100% - 21px); }
.cx-row.cx-stacked .cx-meta { margin-left: 0; padding-left: 0; text-align: left; }
/* wide: the subject, then the groups' headings, then the names, in three columns. The gaps between
   the columns are where the curves run, so no curve meets a word. A heading is set in the top half of
   its cell; the line to the group's dot runs level through the middle of the cell, under the heading. */
.cx-wide.cx-tree-wrap { display: grid; grid-template-columns: fit-content(26%) minmax(0, 1fr); column-gap: clamp(48px, 9%, 96px); align-items: center; }
.cx-wide .cx-subject { margin: 0; padding: 0; text-align: right; font-size: 1.3rem; }
.cx-wide .cx-tree { display: grid; grid-template-columns: fit-content(max(30%, 12rem)) minmax(0, 1fr); column-gap: 56px; row-gap: 14px; }
.cx-wide .cx-branch { display: grid; grid-column: 1 / -1; grid-template-columns: max(30%, 12rem) minmax(0, 1fr); column-gap: 56px; align-items: center; margin: 0; }
@supports (grid-template-columns: subgrid) {
  .cx-wide .cx-branch { grid-template-columns: subgrid; }
}
.cx-wide .cx-group { display: grid; grid-template-rows: 1fr 1fr; row-gap: 10px; text-align: right; }
.cx-wide .cx-group::after { content: ""; }
/* narrow: an indented tree */
.cx-narrow .cx-group { margin: 0 0 2px 34px; padding: 6px 0; }
.cx-narrow .cx-leaves { margin-left: 42px; }
path.cx-edge, line.cx-edge, circle.cx-edge { fill: none; stroke: var(--cx-neutral); stroke-width: 1.4; }
.cx-edge.cx-warm { stroke: var(--cx-warm); }
.cx-edge.cx-hostile { stroke: var(--cx-hostile); stroke-dasharray: 5 3; }
.cx-edge.cx-trunk { stroke: var(--cx-trunk); }
circle.cx-dot { fill: var(--cx-ground); stroke: var(--cx-neutral); stroke-width: 2; }
circle.cx-branch-dot { stroke: var(--cx-trunk); }
circle.cx-root-dot { fill: var(--cx-accent); stroke: var(--cx-accent); }

/* the web: drawn at its own size, one unit to a pixel, and shrunk only when the column is narrower */
svg.cx-web { display: block; max-width: 100%; height: auto; margin-inline: auto; }
svg.cx-ruler { position: absolute; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none; }
svg.cx-web text, svg.cx-ruler text { font-family: var(--font-body); fill: var(--text); }
:is(svg.cx-web, svg.cx-ruler) text.cx-name { font-size: 13px; }
:is(svg.cx-web, svg.cx-ruler) text.cx-band { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; fill: var(--cx-muted); font-weight: 600; }
:is(svg.cx-web, svg.cx-ruler) text.cx-root { font-family: var(--font-heading); font-size: 15px; font-weight: 700; fill: var(--cx-ground); }
/* on a narrow screen the drawing is shrunk to the column: heavier lines there */
svg.cx-web.cx-small .cx-edge { stroke-width: 2; }
svg.cx-web.cx-small .cx-mark { stroke-width: 2.6; }
.cx-node { cursor: pointer; outline: none; }
.cx-node.cx-text { cursor: default; }
.cx-hit { fill: transparent; stroke: none; }
.cx-ring { fill: none; stroke: none; stroke-width: 2; }
svg.cx-web .cx-mark { fill: var(--cx-ground); stroke: var(--cx-neutral); stroke-width: 2; }
svg.cx-web .cx-mark.cx-warm { fill: var(--cx-warm); stroke: var(--cx-warm); }
svg.cx-web .cx-mark.cx-hostile { stroke: var(--cx-hostile); }
svg.cx-web .cx-node.cx-sel text, svg.cx-web .cx-node:focus-visible text { fill: var(--cx-accent); text-decoration: underline; }
.cx-node.cx-sel .cx-mark { stroke-width: 3.5; }
/* keyboard focus: a ring round the mark as well as the underlined name */
.cx-node:focus-visible .cx-ring { stroke: var(--cx-accent); }

/* the line under a tree or a web. The page script lets it keep to the bottom of the window (cx-float) only
   while the chosen name is clear above it, so the line for a name chosen near the top of a tall drawing can
   be read without scrolling to the end. While it floats, the pointer passes through it to the names it
   covers (choosing one of them puts it back under the drawing); its own link still takes a click. */
.cx-strip.cx-float { position: sticky; bottom: 0; pointer-events: none; }
.cx-strip.cx-float a { pointer-events: auto; }
.cx-strip { position: relative; z-index: 2; max-height: 50vh; overflow-y: auto; margin-top: 14px; padding: 12px 14px; background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 4px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; }
.cx-strip:empty { display: none; }
.cx-strip p { margin: 0; }
.cx-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); display: grid; place-items: center; font: 600 1rem var(--font-heading); color: var(--cx-muted); grid-row: span 2; object-fit: cover; }
/* .content img (above) would square the portrait and add its margin */
.cx img.cx-avatar { display: block; border-radius: 50%; margin: 0; max-width: none; width: 44px; height: 44px; }
.cx .cx-card img.cx-avatar { width: 38px; height: 38px; }
.cx-strip-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.cx-strip-rel { color: var(--cx-muted); font-size: 0.9rem; min-width: 0; overflow-wrap: anywhere; }
.cx-strip .cx-line, .cx-strip .cx-sess, .cx-strip .cx-open { grid-column: 1 / -1; }
.cx-strip .cx-line { color: var(--text); margin-top: 6px; }
.cx-strip .cx-line + .cx-line { margin-top: 0; }
.cx-open { color: var(--cx-accent); justify-self: start; font-size: 0.9rem; font-weight: 600; padding: 4px 0; text-decoration: underline; text-underline-offset: 2px; }

/* cards */
.cx-cards { min-width: 0; }
.cx-cards .cx-group, .cx-mentions-wrap .cx-group { margin: 1.25rem 0 0.5rem; }
.cx-cards .cx-group:first-child, .cx-mentions-wrap .cx-group:first-child { margin-top: 0; }
.cx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.cx-card { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 10px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: center; align-content: start; min-width: 0; }
.cx-card p { margin: 0; }
.cx-card .cx-avatar { width: 38px; height: 38px; font-size: 0.9rem; }
.cx-card-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.cx-card-name .cx-name { font-size: 1rem; }
.cx-card-name a.cx-name { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.cx-card-name a.cx-name:hover { color: var(--cx-accent); }
.cx-card-tone { display: flex; align-items: center; gap: 7px; font-size: 0.85rem; }
.cx-card .cx-line, .cx-card .cx-sess { grid-column: 1 / -1; font-size: 0.9rem; }
.cx-card .cx-line { margin-top: 4px; }

@media (pointer: coarse) {
  a.cx-row, span.cx-row { min-height: 44px; padding-top: 11px; padding-bottom: 11px; }
}
/* on a phone the site's back-to-top button sits over the window's bottom right corner */
@media (max-width: 640px) {
  .cx-strip { padding-right: 4rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .cx-tab, a.cx-row { transition: color 0.15s, background-color 0.15s; }
}
@media (prefers-reduced-motion: reduce) {
  .cx, .cx * { transition: none; animation: none; }
}
/* end Connections */

/* ===== PRINT ===== */
@media print {
  /* Connections: the lists, not the tabs; in the paper's own text colour, not the screen's inks */
  .cx .cx-app { display: none; }
  .cx.cx-live .cx-plain { display: block; }
  .cx { --cx-muted: var(--text); --cx-accent: var(--text); --cx-warm-ink: var(--text); --cx-hostile-ink: var(--text); }

  .top-nav,
  .mobile-nav-overlay,
  .nav-search-btn,
  .nav-search-icon-btn,
  .nav-color-mode-btn,
  .section-nav,
  .site-footer,
  .back-to-top,
  .search-overlay,
  .lightbox-overlay,
  .pill-filters,
  .name-filter,
  .sort-control {
    display: none !important;
  }
  .accordion-body, .card-body, .tab-panel { display: block !important; }
  .tab-bar { display: none; }
  #tab-combat, #tab-equipment { display: block !important; }
  body {
    font-size: 10pt;
    color: #000;
    background: #fff;
  }
  .story-prose { break-before: page; }

  /* GURPS sheet print rules */
  .flow { column-count: 2; }
  .blk, .wide {
    border: 1px solid #ccc !important;
    background: #fff !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
  .blk h2, .wide h2 { border-bottom: 1px solid #ccc; }
  .status { border: 1px solid #ccc !important; background: #fff !important; box-shadow: none !important; }
  /* The to-hit calculator is for the table, not the printed sheet */
  .tohit { display: none !important; }
  /* Force rules-ref open in print regardless of open attribute */
  details.rules-ref > summary { display: none; }
  details.rules-ref > .rules-ref-body { display: flex !important; }
  /* Encumbrance colour ramp in print */
  .enc .e0 { background: #eafaf0 !important; }
  .enc .e2 { background: #fdf4e7 !important; }
  .enc .e3 { background: #fdf1e7 !important; }
  .enc .e4 { background: #fdecec !important; }
  /* Category backgrounds for print */
  .cat-attr   { --gc-attr-bg:   #eafaf0; }
  .cat-social { --gc-social-bg: #fdf4e7; }
  .cat-trait  { --gc-trait-bg:  #fdf1e7; }
  .cat-skill  { --gc-skill-bg:  #eef0fe; }
  .cat-spell  { --gc-spell-bg:  #f3eefe; }
  .cat-table  { --gc-table-bg:  #e8f5fc; }
  .cat-points { --gc-points-bg: #eef1f5; }
  .cat-def    { --gc-def-bg:    #fdecec; }
}

/* NPC table row avatars */
.npc-row-link { display: inline-flex; align-items: center; gap: 0.5rem; }
.npc-row-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  overflow: hidden; flex-shrink: 0; background: var(--accent-dim);
}
.npc-row-avatar img.portrait { width: 100%; height: 100%; object-fit: cover; }
.npc-row-initials { font-size: 0.65rem; font-weight: 700; color: var(--accent); }

/* A long inline code word (a file name in a Source callout) breaks at the edge on a phone rather than running past it. */
:not(pre) > code { overflow-wrap: anywhere; }

/* A code block wraps; a long unbroken line (a URL, an image prompt) would otherwise widen the whole page. */
pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- Obsidian callouts (> [!type] Title) --- */
.callout {
  --callout-color: var(--accent);
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--callout-color);
  border-radius: 0 0.375rem 0.375rem 0;
  background: var(--bg-card);
}
.callout-title {
  font-weight: 700;
  color: var(--callout-color);
  margin-bottom: 0.25rem;
}
.callout-title:last-child { margin-bottom: 0; }
.callout > p { margin: 0.5rem 0 0; }
.callout > p:last-child { margin-bottom: 0; }

.callout-warning, .callout-caution, .callout-attention { --callout-color: var(--warning); }
.callout-danger, .callout-error, .callout-bug, .callout-failure, .callout-missing {
  --callout-color: var(--danger);
}
.callout-success, .callout-check, .callout-done, .callout-tip, .callout-hint {
  --callout-color: var(--success);
}
.callout-quote, .callout-cite, .callout-abstract, .callout-summary, .callout-example {
  --callout-color: var(--text-muted);
}

/* --- Change-request widget (Part 2). Scoped to .cr-*; touches no sheet styles. --- */
#cr-root { margin: 0 0 1rem; }
.cr-bar { border: 1px solid var(--border, #ccc); border-radius: 6px; padding: .25rem .5rem; font-size: .9rem; }
.cr-barhead { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.cr-toggle { flex: 1 1 auto; text-align: left; background: none; border: none; cursor: pointer; color: inherit; font: inherit; padding: .35rem .25rem; min-height: 44px; }
.cr-panel { display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem; }
.cr-panel .cr-code { width: 6rem; text-transform: uppercase; }
.cr-msg { font-size: .85rem; opacity: .85; }

/* --- Comms widget: hint, resizable input, chat log (Part: advice+log) --- */
.cr-hint { font-size: .8rem; opacity: .8; margin: 0 0 .25rem; }
.cr-text {
  width: 100%; box-sizing: border-box; min-height: 8rem; resize: vertical;
  font: inherit; font-size: 16px; /* 16px keeps iOS from zooming on focus */
  line-height: 1.4; padding: .6rem .7rem;
  border: 1px solid var(--border, #ccc); border-radius: 6px;
  background: var(--bg-card, #fff); color: var(--text, #111);
}
.cr-text::placeholder { color: var(--text-muted, #888); }
.cr-send {
  align-self: flex-start; cursor: pointer; font: inherit; font-weight: 600;
  font-family: var(--font-label);   /* after the shorthand, no fallback: unset inherits, as font: inherit did */
  min-height: 44px; padding: .5rem 1.4rem; border-radius: 6px;
  border: 1px solid var(--border, #ccc); background: var(--accent, #3b82f6); color: var(--on-accent, var(--bg, #fff));
}
.cr-send:hover { filter: brightness(1.08); }
.cr-log-btn {
  flex: 0 0 auto; background: none; cursor: pointer; font: inherit; color: inherit;
  border: 1px solid var(--border, #ccc); border-radius: 6px;
  min-height: 44px; padding: .35rem .7rem;
}
.cr-log-btn:focus-visible { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }
.cr-logpanel { margin-top: .5rem; max-height: 16rem; overflow-y: auto; border-top: 1px solid var(--border, #ccc); padding-top: .5rem; }
.cr-logentry { margin-bottom: .6rem; font-size: .85rem; }
.cr-you { font-weight: 600; }
.cr-reply { margin-top: .15rem; white-space: pre-wrap; }
.cr-reply.cr-rejected { color: var(--danger, #b00); }
.cr-reply.cr-waiting { opacity: .6; }
.cr-empty { opacity: .6; font-size: .85rem; }

/* Mobile: the back-to-top in the corner; the change-request form's Send full width */
@media (max-width: 767px) {
  /* In the corner, a little smaller, with room under the page so its last lines scroll clear of it. */
  .back-to-top { right: 0.75rem; bottom: 0.75rem; width: 2.5rem; height: 2.5rem; }
  .back-to-top.visible { opacity: 0.7; }
  body { padding-bottom: 3.5rem; }
  /* Full-width Send on phones so it's an easy thumb target. */
  .cr-send { align-self: stretch; text-align: center; }
  .cr-text { min-height: 9rem; }
}

/* ---- SP3 live party board ---- */
.gl-party { margin: 0 0 28px; }
.gl-party-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.gl-party-head h2 { margin: 0; }
.gl-party-live { display: inline-flex; align-items: center; gap: 7px; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--success, #3fd0d8); }
.gl-party-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success, #3fd0d8); animation: gl-party-pulse 2s infinite; }
@keyframes gl-party-pulse { 0% { box-shadow: 0 0 0 0 rgba(63,208,216,0.5); } 70% { box-shadow: 0 0 0 7px rgba(63,208,216,0); } 100% { box-shadow: 0 0 0 0 rgba(63,208,216,0); } }
.gl-party-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.gl-party-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.gl-party-table thead th { text-align: right; font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.gl-party-table thead th.gl-pc { text-align: left; }
.gl-party-table td { text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.gl-party-table tbody tr:last-child td { border-bottom: 0; }
.gl-party-row.reeling { background: linear-gradient(90deg, var(--live-reeling-bg), transparent 55%); }
.gl-party-row.tired { background: linear-gradient(90deg, var(--live-tired-bg), transparent 55%); }
.gl-party-row.both { background: linear-gradient(90deg, var(--live-reeling-bg), var(--live-tired-bg) 70%); }
td.gl-pc { text-align: left; }
td.gl-pc a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.gl-av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; color: var(--accent); background: var(--accent-dim, rgba(240,162,58,0.12)); border: 1px solid var(--border); }
/* Override .gl-av's grid layout: a plain block lets the img fill the circle
   (height:100% doesn't resolve against a grid track, which left the portrait
   rendering as a clipped sliver). */
.gl-av-img { display: block; padding: 0; overflow: hidden; background: none; }
.gl-av-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gl-pc-txt { display: flex; flex-direction: column; line-height: 1.15; }
.gl-pc-name { font-weight: 600; }
.gl-pc-sub { font-size: 0.7rem; color: var(--text-muted); min-height: 0; }
.gl-enc-chip { font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }
/* Basic Speed column — the initiative sort key, right-aligned like the stats. */
.gl-speed { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gl-party-table .gl-vital { min-width: 78px; }
.gl-vnum { font-weight: 700; }
.gl-vnum.gl-low { color: var(--danger); }
.gl-max { color: var(--text-muted); font-weight: 500; font-size: 0.82em; }
.gl-bar { display: block; height: 4px; margin-top: 4px; border-radius: 2px; background: var(--live-bar-bg); position: relative; overflow: hidden; }
.gl-bar > i { display: block; height: 100%; border-radius: 2px; }
.gl-bar-hp > i { background: var(--danger); }
.gl-bar-fp > i { background: var(--live-bar-fp); }
.gl-third { position: absolute; top: -1px; bottom: -1px; left: 33%; width: 1px; background: var(--live-bar-third); }
.gl-stat { font-weight: 700; min-width: 56px; }
.gl-was { color: var(--text-muted); font-weight: 500; font-size: 0.78em; text-decoration: line-through; margin-right: 4px; }
.gl-of { color: var(--text-muted); font-weight: 500; font-size: 0.82em; }
.gl-status { white-space: nowrap; }
.gl-badge { display: inline-block; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; }
.gl-badge.reeling { color: var(--live-reeling); background: var(--live-reeling-bg); }
.gl-badge.tired { color: var(--live-tired); background: var(--live-tired-bg); }
.gl-badge.ok { color: var(--text-muted); font-weight: 600; }
/* The status panel's Reeling/Tired badges and effects row are rendered into the
   DOM with the `hidden` attribute and toggled by the live client. An author
   `display` rule (e.g. .gl-badge { display: inline-block }) outranks the UA
   `[hidden] { display: none }`, which would leave both badges permanently
   visible even at full HP/FP. Make `hidden` win for these live-toggled elements. */
.gl-badge[hidden],
.gl-status-effects[hidden],
.gl-delta[hidden],
.gl-status-note[hidden] { display: none !important; }
@media (max-width: 640px) { .gl-col-st { display: none; } }

/* --- CoC party board skin (SP3) --- */
.gl-bar-san > i { background: var(--live-bar-san); }   /* Sanity — violet */
.gl-bar-mp  > i { background: var(--live-bar-mp); }   /* Magic points — cyan */
.gl-dex { color: var(--text-muted); font-weight: 600; }
.gl-rep { font-weight: 700; }
.gl-badge.cond-insanity    { color: var(--live-insanity); background: var(--live-insanity-bg); }
.gl-badge.cond-wound       { color: var(--live-wound); background: var(--live-wound-bg); }
.gl-badge.cond-unconscious { color: var(--live-unconscious); background: var(--live-unconscious-bg); }
.gl-badge.cond-dying       { color: var(--live-dying); background: var(--live-dying-bg); }
.gl-party-row.mad  { background: linear-gradient(90deg, var(--live-row-mad), transparent 60%); }
.gl-party-row.hurt { background: linear-gradient(90deg, var(--live-row-hurt), transparent 60%); }
.gl-party-row.mad.hurt { background: linear-gradient(90deg, var(--live-row-hurt), var(--live-row-mad) 70%); }

/* Party board on a phone: the table's width is its content's width, which is wider than
   the screen, so the Status column (always last) sat off the right edge. Each row becomes a
   flex line: the name, then the numbers sharing the rest evenly, then Status on a full-width
   line of its own under the row. Header and body cells carry identical sizing and padding so
   every header sits over its column; the name column is a fixed share, the others equal.
   The table roles are written in the markup because these display types drop them. A
   vital's maximum drops under its current value so three-digit pairs fit a narrow column.
   Speed (GURPS) and Rep (CoC) are the columns left out, as ST already is below 640px. */
@media (max-width: 600px) {
  .gl-party-scroll { overflow-x: visible; }
  .gl-party-table, .gl-party-table thead, .gl-party-table tbody { display: block; }
  .gl-party-table tr { display: flex; flex-wrap: wrap; align-items: center; padding: 0 6px; }
  .gl-party-table thead { background: var(--bg-card); }
  .gl-party-table thead tr { align-items: stretch; }
  .gl-party-table th, .gl-party-table td { flex: 1 1 0; min-width: 0; box-sizing: border-box; padding: 10px 2px; text-align: center; border-bottom: 0; }
  .gl-party-table thead th { white-space: normal; letter-spacing: 0.02em; font-size: 0.62rem; padding: 8px 2px; text-align: center; }
  .gl-party-table thead th.gl-pc { text-align: left; padding-left: 4px; padding-right: 4px; }
  .gl-party-table th.gl-pc, .gl-party-table td.gl-pc { flex: 0 0 38%; text-align: left; padding-left: 4px; padding-right: 4px; }
  .gl-party-table th.gl-pc { letter-spacing: 0; }
  .gl-party-table thead tr { position: relative; }
  .gl-party-table th:last-child { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }
  .gl-party-table td[data-gl-party-field="status"] { flex: 0 0 100%; text-align: left; padding: 0 4px 10px; }
  .gl-party-table .gl-vital, .gl-party-table .gl-stat { min-width: 0; }
  .gl-party-table .gl-vital .gl-max, .gl-party-table .gl-stat .gl-of { display: block; }
  .gl-party-table .gl-pc-txt { min-width: 0; }
  .gl-party-table .gl-pc-name { overflow-wrap: break-word; }
  .gl-party-table .gl-av { width: 28px; height: 28px; font-size: 0.7rem; }
  .gl-party-table td.gl-pc a { gap: 6px; }
  .gl-party-table .gl-speed, .gl-party-table th.gl-col-speed,
  .gl-party-table td[data-gl-party-field="rep"], .gl-party-table th.gl-col-rep { display: none; }
  .gl-party-table tbody tr { border-bottom: 1px solid var(--border); }
  .gl-party-table tbody tr:last-child { border-bottom: 0; }
}

/* World Rules, in the page under the title */
.world-rules { margin: 1.5rem 0; padding: 1rem 1.25rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; }
.world-rules h2 { margin-top: 0; font-size: 1.1rem; }
.world-rules ul { margin: 0; padding-left: 1.2rem; }
