/* base.css - the rules every page shares, loaded BEFORE style.css (Builder/Landing/Profile/legal pages) and
   sheet.css (the tool pages). Consistency Review v1 (2026-10-04), C3/C10 + Accessibility Review v12, A30.

   Why this file exists: style.css and sheet.css each carried their own copy of the design tokens, the nav
   drawer, the footer, the focus ring and ~40 other rules, "kept in sync by hand" - and they had drifted in the
   one place that mattered most: style.css defined what an unclassed <button> looks like (the purple primary),
   sheet.css didn't, so 29 primary actions on the tool pages ("Join Campaign", "Send invite", "Promote to
   Narrator", "Use This Character", "Apply & Complete Cycle"...) rendered as browser-default grey boxes. The
   Quick Edit panels (charSheet.js) and the inline error line (.landing-campaign-note) were likewise styled
   only in style.css but mounted on sheet.css pages.

   Contents, in order: design tokens (:root) - the element/focus baseline - the button primitives - the
   shared chrome (nav drawer, old nav row, app tool buttons, footer text, section/tier headings) - the Bring
   Character and trust & safety widgets - the Character Sheet sidebar components (.cs-*, used by the
   Builder's sidebar AND the sheet's Quick Edit modal) - the inline note/error line.

   Rule of thumb for new CSS: if two pages need it, it goes here; style.css and sheet.css keep only what is
   specific to their own layouts. Page-specific overrides of anything here still win by load order. */

/* ---- Design tokens -------------------------------------------------------------------------------- */
:root {
  --bg: #14141a;
  --bg-panel: #1c1c24;
  --bg-panel-raised: #23232e;
  --border: #33333f;
  --text: #e8e6df;
  --text-dim: #9a97a8;
  --silver: #c7c9d3;
  --silver-dim: #6f7180;
  --bronze: #b8834a;
  /* See sheet.css's matching :root for the full rationale; kept in sync since these two
     stylesheets share the same palette. */
  --bronze-dim: #9f7645;
  --accent: #8e7cc3;
  --accent-dim: #8476ad;
  /* #c0564f read at 4.09:1 on --bg - just under the 4.5:1 WCAG
     AA text-contrast minimum - and this color is used as actual text color for real functional
     content (the Delete Campaign button, the over-budget tracker pill), not just decoration.
     #c46059 clears 4.5:1 while staying the same rust-red. Matches sheet.css's --danger, which was
     missing entirely there before this same pass (see that file's comment). */
  --danger: #c46059;
  /* Consistency Review v1, C8 (2026-10-04): the one red for error/warning TEXT on dark panels. --danger (4.5:1 on
     --bg) is the control colour (destructive buttons, borders); as small text on --bg-panel/--bg-panel-raised it
     slips under AA, and the JS had grown eight different reds (#e58a8a, #e0716f, #c0584e, #c0564f, #ff5c5c...)
     compensating. #d9756d reads 5.2:1 on --bg-panel-raised and 5.6:1 on --bg. */
  --danger-text: #d9756d;
  /* Accessibility Review v13, A71: white text on --danger measures 4.07:1, so the filled (hover) state of a destructive button
     uses this darker red instead (5.38:1 with white). Hover backgrounds get darker, never lighter. */
  --danger-strong: #b04a43;
  /* A71: --text on --accent-dim was 3.25:1; a pill's hover fill is this deeper violet (5.5:1). */
  --accent-hover-bg: #5d5190;
  /* Accessibility Review v12, A41 (2026-10-04): --border (#33333f) on --bg / --bg-panel is 1.4:1 - fine for card
     edges, but a form field's border is often the only thing marking where the field is, and WCAG 1.4.11 wants 3:1
     for that. --silver-dim reads 3.8:1 on both backgrounds. Every input/select/textarea rule in sheet.css and
     style.css uses this token; cards and dividers keep --border. */
  --field-border: var(--silver-dim);
  --ok: #5c9a6e;
  /* WCAG 1.4.3 text-only variants of --accent/--silver-dim for the tier-header bands below;
     those tokens stay untouched since both are also used as non-text elements elsewhere.
     See docs/Mistfall_CharacterBuilder_DevelopmentNotes.docx for the full rationale. Kept in
     sync with sheet.css's matching tokens. */
  /* Accessibility Review v13, A70: measured on the tier bands over --bg-panel-raised (the worst surface they sit on):
     tier 1 4.25, tier 2 (bronze) 3.9, tier 3 4.01. These three clear 4.5:1 there (computed in tests/test_batch12_contrast.mjs). */
  --tier1-text: #a99bd6;
  --tier2-text: #d4a06a;
  --tier3-text: #acaeba;
  --radius: 6px;
  /* Corner-radius scale (Consistency C9): sm for chips/inputs/small buttons, the default for most controls, lg for cards,
     panels and modals, pill for badges and toggles. Circles use 50%. Nothing should hard-code a px radius. */
  --radius-sm: 4px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  /* Font-size scale (Consistency C9). Nothing is smaller than xs (0.7rem); body text is base. Icon glyphs inside fixed-size
     shapes and em-relative sizes are the only exceptions. */
  --fs-xs: 0.7rem;
  --fs-sm: 0.78rem;
  --fs-md: 0.85rem;
  --fs-lg: 0.95rem;
  --fs-base: 1rem;
  --fs-xl: 1.15rem;
  --fs-2xl: 1.6rem;
  --fs-3xl: 2rem;
  /* Visual polish pass (see docs/visual-design-polish.md items 1/3): every card/panel in
     this app used a flat 1px border with no elevation at all (the nav "More ▾" dropdown was the
     ONLY box-shadow anywhere in either stylesheet) - against a dark theme that reads as "boxes,"
     not "cards." These two tokens give cards a resting shadow and a slightly stronger one on
     hover/interaction, applied selector-by-selector below rather than globally, since not every
     bordered element (form inputs, chips, dividers) should get card-level depth. Kept in sync with
     sheet.css's matching tokens, same convention as --bg-panel-raised etc. */
  --shadow-card: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-card-hover: 0 6px 20px rgba(0, 0, 0, 0.5);
  /* Same pass, item 4 (subtle background texture, a faint noise, kept subtle): a
     procedural film-grain noise generated by an inline SVG feTurbulence filter rather than a
     sourced/commissioned texture image - this app has no asset pipeline for that yet (see the
     polish doc's items 5-7, which DO need real art production), and an inline data: URI needs no
     new file. The feColorMatrix's last row (`0 0 0 0.05 0`) is what keeps this subtle: it rewrites
     the noise's alpha channel to a flat 5%, so every pixel is white at 5% opacity at most rather
     than the harsh full-contrast static feTurbulence produces on its own. Applied only to a few
     larger content cards below (.sheet-section, .bst-card, .choice-card, .landing-campaign-box) -
     not small elements like .stat-box or .sheet-chip, where grain at that size would read as
     noise/dirt rather than parchment texture. This is a first pass tuned by reasoning about
     the math, not by eye (no way to render a live preview of a CSS-only change before deploy) - if
     it reads as too strong/weak/absent once you see it live, the fix is just this one value (either
     the 0.05 alpha, or removing --texture-grain from a selector's background-image entirely). */
  --texture-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch' result='noise'/%3E%3CfeColorMatrix in='noise' type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Cinzel", Georgia, "Segoe UI", serif;
  /* Primary-button gradient (Accessibility Review v12, A30): the old #9a87d1 -> --accent lavender read 3.11:1 /
     3.61:1 under white 13 px text - below the 4.5:1 AA minimum - and had since the first build (axe reports
     gradients as "incomplete", so it was never measured). These two are the same hue a shade deeper: white
     text reads 4.69:1 / 5.15:1 and the button itself still clears 3:1 against every panel. Every primary
     surface (base button, .sheet-actions button, .gr-add-btn, a.btn-link-primary) draws from these tokens. */
  --btn-top: #7b67b8;
  --btn-bottom: #7560b3;
}

/* ---- Element baseline + focus ring (identical in both stylesheets before this file existed) ---------- */
* { box-sizing: border-box; }
/* Standard "visually hidden but still in the accessibility tree" utility (WCAG 1.3.1/2.4.6) - for
   content a sighted user doesn't need (the app's visible branding is the wordmark image/logo, not
   plain text) but that screen readers and other assistive tech still need in the DOM, e.g. a page's
   one required <h1> landmark. display:none/visibility:hidden would hide it from assistive tech too,
   so this clips it to a 1px box instead - the standard technique (used by WordPress core, Bootstrap
   .sr-only, etc.) rather than something bespoke. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
/* WCAG 1.4.3 text-contrast fallback for any unstyled anchor - most links in this app already get a
   color from a more specific rule/class (e.g. .app-tool-btn, .nav-drawer-link), but a handful of
   plain <a> elements (e.g. index.html's footer link) inherited the browser default blue/purple,
   which fails contrast against --bg (and doesn't match the app's palette either). :not([class])
   only catches an anchor with no class of its own, so it never overrides a more specific existing
   rule regardless of source order - see sheet.css's matching rule for the full rationale;
   duplicated here because index.html/builder.html load this stylesheet instead of sheet.css. */
a:not([class]) {
  color: var(--bronze);
}
/* WCAG 2.4.7 visible focus indicator - see sheet.css's matching
   rule for the full rationale; duplicated here because index.html/builder.html load this
   stylesheet instead of sheet.css. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.app-tool-btn {
  display: inline-block;
  flex-shrink: 0; /* keeps every pill full-size rather than letting the browser squeeze it */
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-panel-raised);
  color: var(--text-dim);
  font-size: var(--fs-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}
/* Visual polish: a much smaller lift than the primary button's (-1px, no
   dedicated shadow token beyond a soft ambient one) - these are small pill links in a dense nav
   row, not standalone CTAs, so a full card-shadow lift would read as jumpy rather than tactile. */
.app-tool-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text);
  background: var(--accent-hover-bg);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}
/* Left-side collapsible nav drawer - see nav.js's
   renderNavDrawer() header comment for the full design. `.nav-drawer-host` is a plain wrapper div
   (no visible box of its own - overlay + panel are both `position:fixed`, so the host's own size
   never matters) that gets `.nav-drawer-open` toggled on it by JS; every visible transition lives in
   these two child selectors reacting to that one class, nothing animated from script. */
.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 300;
}
.nav-drawer-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 82vw;
  background: var(--bg-panel-raised);
  border-right: 1px solid var(--border);
  box-shadow: 6px 0 28px rgba(0, 0, 0, 0.45);
  transform: translateX(-100%);
  /* A25: visibility:hidden while closed takes the slid-away panel out of the tab order and the
     accessibility tree even where `inert` (nav.js) isn't supported; the 0.25s visibility delay lets the
     slide-out finish before the panel disappears, while opening flips visible immediately. */
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
  z-index: 301;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-drawer-host.nav-drawer-open .nav-drawer-overlay {
  opacity: 1;
  pointer-events: auto;
}
.nav-drawer-host.nav-drawer-open .nav-drawer-panel {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.25s ease, visibility 0s;
}
.nav-drawer-close {
  align-self: flex-end;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  margin-bottom: 10px;
}
button.nav-drawer-close:hover { color: var(--text); filter: none; transform: none; box-shadow: none; } /* no primary lift on the drawer's x */
.nav-drawer-home {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
/* Accent-tinted (not plain --text-dim) and set off by a hairline divider - now that both roles'
   drawers have several groups (see nav.js's own NAV_CATEGORIES comment), a plain gray label read too
   close to the links themselves. The first group keeps the old tight spacing/no divider, right under
   the "← Home" link's own divider - two rules back to back there would double up. */
.nav-drawer-category {
  text-transform: uppercase;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  /* Accessibility Review v12, A40 (2026-10-04): --accent (#8e7cc3) at 0.7rem on the raised panel is 3.9:1 -
     below AA for small text. --tier1-text is the same violet a step lighter (5.1:1), already used for the
     tier-1 heading bands for the same reason. */
  color: var(--tier1-text);
  /* 2026-09-09: tightened from 18px/6px margin + 12px padding-top - with 4 categories and 16
     links in the Narrator drawer, the old spacing pushed the panel past viewport height on
     typical screens, forcing a scrollbar. This (plus .nav-drawer-link's own trim below) removes
     it without visibly cramming the list. */
  margin: 14px 0 5px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}
.nav-drawer-category:first-of-type {
  margin-top: 2px;
  padding-top: 0;
  border-top: none;
}
.nav-drawer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-drawer-link {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-md);
}
.nav-drawer-link:hover { background: var(--bg-panel); }
/* C6: account footer pinned to the bottom of the drawer (margin-top:auto inside the panel's column flex). */
.nav-drawer-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.nav-drawer-footer:empty { display: none; }
.nav-drawer-account {
  margin: 0 0 8px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.nav-drawer-account-actions { display: flex; align-items: center; gap: 12px; }
button.nav-drawer-signout { font-size: var(--fs-sm); padding: 5px 12px; }
.nav-drawer-account-link { font-size: var(--fs-md); color: var(--accent); text-decoration: none; }
.nav-drawer-account-link:hover { text-decoration: underline; }
.nav-drawer-account-error { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--danger-text); }
.nav-drawer-account-error:empty { display: none; }
/* The hamburger trigger itself sits in the compact hero header (see .app-header-hero-compact above)
   - a plain three-bar icon (no pseudo-element tricks) matching this app's otherwise unadorned button
   language (e.g. the "More ▾" trigger next to it elsewhere in the app). */
.nav-hamburger-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 36px;
  background: rgba(20, 20, 26, 0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
button.nav-hamburger-btn:hover { border-color: var(--silver-dim); filter: none; transform: none; box-shadow: none; }
.nav-hamburger-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: var(--radius-sm);
}
/* Visual polish - see sheet.css's matching rule/comment for why this class
   exists (narratorToolkit.js's/homebrew.js's bare per-generator <h2>s had no styling at all). No
   style.css page uses it yet, but this app has no shared/base CSS file, so a primitive like this is
   kept in sync across both stylesheets by hand regardless - same convention as sheet.css's own
   .ghost copy of this file's button.ghost. */
.section-heading {
  margin: 20px 0 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bronze);
  border-bottom: 1px solid var(--bronze-dim);
  padding-bottom: 6px;
}
.section-heading:first-child { margin-top: 0; }
.tier-header:first-child { margin-top: 0; }
#app-footer p {
  margin: 0;
  color: var(--text-dim);
  font-size: var(--fs-sm);
  letter-spacing: 0.01em;
}
/* Trust & Safety (Public Launch Readiness v1, item 2) - Report/Block button pair next to a
   member's name (campaignInfo.js) or on a public profile view (profile.js). Kept in sync by hand
   across style.css/sheet.css like .ghost above. */
.trust-safety-actions { display: inline-flex; gap: 6px; margin-left: 8px; vertical-align: middle; }
/* Bring a character into a campaign (bringCharacter.js, docs/bring-character.md). */
.bring-section > summary { cursor: pointer; font-family: var(--font-display); color: var(--silver); padding: 10px 14px; }
.bring-list { display: flex; flex-direction: column; gap: 6px; }
.bring-row { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.bring-row input { grid-row: span 3; }
.bring-name { font-weight: 700; }
.bring-meta, .bring-where { font-size: var(--fs-sm); color: var(--text-dim); }
.bring-row:has(input:checked) { border-color: var(--accent); }
.bring-confirm { margin-top: 10px; padding: 10px 14px; border: 1px solid var(--bronze); border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bring-confirm[hidden] { display: none; }
.bring-confirm p { flex: 1 1 100%; margin: 0; }
.bring-warn { color: var(--bronze); font-size: var(--fs-md); }
.bring-status { font-size: var(--fs-sm); color: var(--bronze); margin: 6px 0 0; }
.lineage-line { font-size: var(--fs-sm); color: var(--text-dim); margin: 4px 0 0; }

/* ---- Button primitives (one definition for all 29 pages) ----------------------------------------- */
/* An unclassed <button> is the primary action. Every variant below only overrides what differs. */
button {
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bottom));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter .12s, transform .12s, box-shadow .12s;
  /* Accessibility Review v12, A37 (2026-10-04): WCAG 2.5.8 target size. ~40 inline buttons (chip x, steppers,
     Accept/Decline, .ct-mini, "+ Link") computed at 13-22 px; this floor fixes them all in one place. */
  min-height: 24px;
  min-width: 24px;
  box-sizing: border-box;
}
/* Visual polish: the primary lifts on hover with the card shadow; secondary/tertiary variants below
   deliberately don't, which keeps the hierarchy between the one primary action and everything else. */
button:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); box-shadow: var(--shadow-card-hover); }
/* A37, continued: chip-style buttons go inline-flex so the glyph centres inside the now-larger box instead of
   sitting at the top. */
.pd-condition-chip button, .sheet-chip-roll, .ref-remove, button.cs-chip-remove, .stat-box-add-link {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px;
}
/* Accessibility Review v12, A46 (2026-10-04): WCAG 2.3.3. One rule stills the drawer slide, the hover lift, the
   entity highlight flash and smooth scrolling for anyone who asked their OS for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  button:hover:not(:disabled) { transform: none; }
}
/* Accessibility Review v13, A78 (WCAG 2.2, 2.5.8): a bare <summary> was as tall as one line of text (about 16px). Styled summaries
   (.cs-section-collapsible, .pd-collapsible, .ct-add and the rest) set their own padding, which wins over this lower-specificity rule. */
.cl-history { list-style: none; padding: 0; } /* A86 */
summary { min-height: 24px; padding-block: 4px; box-sizing: border-box; }
/* Accessibility Review v12, A47: offline banner (pwa.js). role=status so it is announced once, not shouted. */
.offline-banner {
  position: sticky; top: 0; z-index: 302;
  background: var(--bg-panel-raised); color: var(--text); border-bottom: 1px solid var(--bronze-dim);
  padding: 6px 14px; font-size: var(--fs-md); text-align: center;
}
.offline-banner[hidden] { display: none; }
/* 0.5 (was 0.35 in style.css / 0.65 in sheet.css): a disabled primary's white label stays readable as
   "there but unavailable" without looking active. */
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; transform: none; box-shadow: none; }
/* Secondary: outlined. (.ghost without the element prefix so <a class="ghost"> and the test fixtures match too.) */
button.ghost, .ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
button.ghost:hover:not(:disabled), .ghost:hover:not(:disabled) { border-color: var(--silver-dim); color: var(--text); filter: none; transform: none; box-shadow: none; }
/* Destructive: outlined in --danger, filled on hover. .campaign-info-danger-btn (sheet.css) and
   .landing-danger-btn (style.css) are the two older spellings of the same intent and share this look. */
button.danger, .danger-btn, .campaign-info-danger-btn, .landing-danger-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger-text);
}
button.danger:hover:not(:disabled), .danger-btn:hover:not(:disabled), .campaign-info-danger-btn:hover:not(:disabled), .landing-danger-btn:hover:not(:disabled) {
  background: var(--danger-strong); color: #fff; border-color: var(--danger-strong); filter: none; transform: none; box-shadow: none;
}
/* Accessibility Review v11, A21: a real <button> that looks like an inline text link (sign-in page's
   "Need an account?" / "Forgot password?"). font: inherit because form controls don't inherit the
   surrounding font the way <a> does. */
button.link-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--bronze);
  text-decoration: underline;
  cursor: pointer;
}
button.link-button:hover:not(:disabled) { color: var(--text); filter: none; transform: none; box-shadow: none; }
/* WCAG 4.1.2: a real <a> styled as the primary button (navigation, not an action). */
a.btn-link-primary {
  display: inline-block;
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bottom));
  color: #fff;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: filter .12s, transform .12s, box-shadow .12s;
}
a.btn-link-primary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: var(--shadow-card-hover); }

/* ---- Character Sheet sidebar components (Builder sidebar + sheet.html Quick Edit) + inline note ------ */
.subgroup-title {
  /* Visual polish: extends the Cinzel display font to this eyebrow-style
     label too, matching .sheet-section h2/.stat-strip-title's already-Cinzel treatment in
     sheet.css - color/size/border are left untouched, since silver-dim (not bronze) here is a
     deliberate, distinct look from those, marking this as a collapsible sub-group rather than a
     full section header. */
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-dim); /* A58: --silver-dim is a border colour (3.2-3.8:1); text uses --text-dim */
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
/* Collapsible Step 11 review sections (Skills/Manifestations/Talents) - native <details>, same
   .subgroup-title look on the <summary>, plus a rotating disclosure arrow. */
summary.subgroup-title {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
}
summary.subgroup-title::-webkit-details-marker { display: none; }
summary.subgroup-title::after {
  content: "\25BE";
  margin-left: auto;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  transition: transform 0.15s ease;
}
.subgroup-collapsible:not([open]) summary.subgroup-title::after { transform: rotate(-90deg); }
.subgroup-collapsible:not([open]) summary.subgroup-title { border-bottom: none; }
.checkbox-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}
.checkbox-row:hover { background: var(--bg-panel-raised); }
.checkbox-row label { font-size: var(--fs-md); }
.checkbox-row .desc { color: var(--text-dim); font-size: var(--fs-sm); }
/* Character name - compact identity field above the tiers (not a titled .cs-section), matching
   step11_summary.js's page <h2> / sheet.js's page <h1> treatment of the name as a heading rather
   than a field bundled into "Campaign" below it. */
.cs-name-header {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.cs-name-header input {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--silver);
}
.cs-section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
/* h3, not h4: see charSheet.js's section() comment -
   this was skipping a level under the h2 that always precedes it (builder.html's sidebar or
   step11_summary.js's review step). */
.cs-section h3,
.cs-section-collapsible summary {
  /* Visual polish: the character sheet sidebar's own section titles were the
     one clear gap in this file's Cinzel coverage - #char-sheet's own h2 (above), .cs-name-header,
     .landing-section-title, and #step-container h2 all already used the display font; these
     per-section titles (Campaign, Characteristics, Skills, etc. - repeated ~15-20x down the sidebar)
     didn't. Shared with .cs-section-collapsible summary below (the collapsible sidebar sections -
     Skills/Manifestations/Talents) - same title styling, the collapsible variant just adds the
     extra layout/interaction declarations in its own rule further down. */
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 6px;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bronze);
}
.cs-section h3::before {
  content: "\2756  ";
  font-size: var(--fs-xs);
  color: var(--bronze-dim);
}
.cs-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-md);
  padding: 2px 0;
}
.cs-row .val { color: var(--silver); }
.cs-empty { color: var(--text-dim); font-size: var(--fs-sm); font-style: italic; }
/* Collapsible sidebar sections (Skills/Manifestations/Talents) - native <details>, same diamond-
   bullet title styling as .cs-section h3 above (shared rule), plus a rotating disclosure arrow. */
.cs-section-collapsible summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cs-section-collapsible summary::-webkit-details-marker { display: none; }
.cs-section-collapsible summary::before {
  content: "\2756";
  font-size: var(--fs-xs);
  color: var(--bronze-dim);
}
.cs-section-collapsible summary::after {
  content: "\25BE";
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-dim);
  transition: transform 0.15s ease;
}
.cs-section-collapsible:not([open]) summary::after { transform: rotate(-90deg); }
.cs-section-collapsible .cs-section-body { padding-top: 2px; }
/* Tier banners group sidebar sections by how often they're actually referenced at the table -
   Tier 1 "checked on every roll" (Characteristics/Skills/Status/Defense/Conditions), Tier 2
   "checked often" (Gear, Companions, Talents, Injuries), Tier 3 "background & downtime" (Origin,
   Class Features, Resources, Foundation, Nemesis arc). Purely a visual grouping aid - it doesn't
   collapse or hide anything, sections within a tier still render normally above/below it. */
.cs-tier-header {
  margin: 20px 0 10px;
  padding: 5px 10px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  border-radius: var(--radius);
}
.cs-tier-header:first-child { margin-top: 0; }
/* Shared with .cs-tier-header above (same tier accent color, deliberately) - declared once here
   rather than twice. */
.cs-tier-header.tier-1, .tier-header.tier-1 { background: rgba(142, 124, 195, 0.15); color: var(--tier1-text); border: 1px solid var(--accent-dim); }
.cs-tier-header.tier-2, .tier-header.tier-2 { background: rgba(184, 131, 74, 0.14); color: var(--tier2-text); border: 1px solid var(--bronze-dim); }
.cs-tier-header.tier-3, .tier-header.tier-3 { background: rgba(199, 201, 211, 0.08); color: var(--tier3-text); border: 1px solid var(--border); }
.char-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: center;
}
.char-grid input[type=number] {
  width: 54px;
  text-align: center;
}
/* Rank input + die-per-rank badge (Skills/Manifestations - Ch.2 Table 2-1) shown side by side
   inside a .char-grid's second column. */
.rank-with-die {
  display: flex;
  align-items: center;
  gap: 6px;
}
.die-badge {
  font-size: var(--fs-xs);
  color: var(--bronze);
  border: 1px solid var(--bronze-dim);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  white-space: nowrap;
}
.list-tag {
  display: inline-block;
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  padding: 2px 7px;
  margin: 2px 3px 2px 0;
}
.landing-campaign-note {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* A43: small visible caption above a form field (ui.js captioned()); the placeholder stays as an example. */
.field-caption-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.field-caption {
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

/* Save status (js/saveStatus.js): the one "Saved." / "Synced to ..." / "Couldn't save that" line. */
/* C-R8: a rules notice (out of the encounter at three zeroed characteristics; a locked rank behind a nemesis wall), shared by the sheet, Party Dashboard, Combat Tracker and the Advancement panel. */
.rule-notice {
  border: 1px solid var(--danger);
  border-radius: var(--radius-lg);
  padding: 6px 10px;
  margin: 0 0 10px;
  font-size: var(--fs-sm);
  background: var(--bg-panel);
}
.save-status { font-size: var(--fs-sm); line-height: 1.5; color: var(--text-dim); }
.save-status[hidden] { display: none; }
.save-status.is-error { color: var(--danger-text); }
.save-status-field { margin-left: 10px; }
.save-status-page { display: block; margin: 0; padding: 14px 28px 0; }
.save-status-toolbar { font-size: var(--fs-sm); }

/* A56 (WCAG 1.4.3): with no rule, Chrome draws placeholder text at #757575 - 3.25 to 3.98:1 on this app's surfaces.
   --text-dim is 5.3-6.4:1 on all of them. */
::placeholder { color: var(--text-dim); opacity: 1; }

/* A54 (WCAG 1.4.10 Reflow): a native select sizes to its longest option and could push the page past 320px wide. */
select { max-width: 100%; }

/* Accessibility Review v13, A77 (WCAG 2.4.1): "Skip to main content" is the first focusable thing on every page. Off-screen until it
   gets keyboard focus, then pinned top-left above everything. <main tabindex="-1"> receives the focus the link moves; the
   outline is suppressed only for that programmatic focus. */
.skip-link {
  position: absolute;
  left: 8px;
  top: -64px;
  z-index: 3000;
  padding: 10px 16px;
  background: var(--bg-panel-raised);
  color: var(--text);
  border: 2px solid var(--silver);
  border-radius: var(--radius-lg);
  font-size: var(--fs-md);
  text-decoration: underline;
}
.skip-link:focus { top: 8px; }
main[tabindex="-1"]:focus { outline: none; }

/* Accessibility Review v13, A85: Windows High Contrast ("forced colors") replaces author colours with system colours, which wiped out
   the things that were only a fill: the reaction pips, the Connections Web kind dots and the zeroed-characteristic tint. Each keeps a
   shape or a system-colour border that survives. (The spent pip's X and the Connections line patterns are already shape.) */
@media (forced-colors: active) {
  .ct-reactions .ct-reaction-pip { forced-color-adjust: none; background: Highlight; border: 2px solid CanvasText; }
  .ct-reactions .ct-reaction-pip.is-spent { background: Canvas; border-color: CanvasText; }
  .ct-reactions .ct-reaction-pip.is-spent::before,
  .ct-reactions .ct-reaction-pip.is-spent::after { background: CanvasText; }
  .ct-reactions .ct-reaction-pip:focus-visible { outline: 3px solid Highlight; outline-offset: 2px; }
  .cw-legend-dot { forced-color-adjust: none; border: 2px solid CanvasText; }
  .cw-node { border-width: 2px; }
  .cw-node--linked:hover, .cw-node--linked:focus-visible { outline: 2px solid Highlight; }
  .ct-stat-zero { border: 3px double CanvasText; }
  .profile-badge-locked { border-style: dashed; }
  .choice-card.selected { border: 3px solid Highlight; }
  .choice-card-selected-tag { forced-color-adjust: none; color: CanvasText; }
}

/* A85: "more contrast" asked for in the system settings: lift the dim text and the borders that were chosen for the default look. */
@media (prefers-contrast: more) {
  :root {
    --text-dim: #c9c6d6;
    --border: #8a8aa0;
    --field-border: #a9a9bd;
  }
}
