/* HEARSAY documentation site. One palette, one type scale, light and dark, phone first.
   Tokens: the product palette (navy, blue, gold, amber) on a pale canvas; gold and amber are
   accents only, never text on white. No webfont, no external URL anywhere in this file. */

:root {
  --navy: #00254b;
  --blue: #005493;
  --blue-deep: #003d6e;
  --gold: #c37530;
  --amber: #ffb800;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #e9eff6;
  --ink: #101a2b;
  --ink-2: #3b4a60;
  --muted: #62718a;
  --line: #d6deea;
  --link: #005493;
  --link-hover: #003d6e;
  --code-bg: #eef2f7;
  --code-ink: #1d2a3d;
  --tip-bg: #00254b;
  --tip-fg: #f6f8fb;
  --mark: #fff3d1;
  --good: #1e7a4a;
  --warn: #a1541d;
  --shadow: 0 1px 2px rgba(16, 26, 43, 0.06), 0 6px 20px -8px rgba(16, 26, 43, 0.14);
  --radius: 12px;
  --gutter: 16px;
  --nav-w: 264px;
  --max: 72ch;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #121c2e;
    --surface-2: #182539;
    --ink: #e7edf6;
    --ink-2: #b9c5d8;
    --muted: #8d9bb1;
    --line: #26354d;
    --link: #7fc0f5;
    --link-hover: #a9d6fb;
    --code-bg: #0f1727;
    --code-ink: #d8e2f0;
    --tip-bg: #e7edf6;
    --tip-fg: #0b1220;
    --mark: #3a2f10;
    --gold: #e6a35a;
    --amber: #ffcc4d;
    --good: #5fcf8a;
    --warn: #f0a868;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121c2e;
  --surface-2: #182539;
  --ink: #e7edf6;
  --ink-2: #b9c5d8;
  --muted: #8d9bb1;
  --line: #26354d;
  --link: #7fc0f5;
  --link-hover: #a9d6fb;
  --code-bg: #0f1727;
  --code-ink: #d8e2f0;
  --tip-bg: #e7edf6;
  --tip-fg: #0b1220;
  --mark: #3a2f10;
  --gold: #e6a35a;
  --amber: #ffcc4d;
  --good: #5fcf8a;
  --warn: #f0a868;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---- base ------------------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4 { line-height: 1.2; color: var(--ink); margin: 1.6em 0 0.5em; letter-spacing: -0.025em; }
h1 { font-size: clamp(2rem, 3vw, 2.6rem); margin: 0 0 0.55em; }
h2 { font-size: 1.5rem; padding-top: 0.6em; border-top: 1px solid var(--line); margin-top: 2.2em; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; color: var(--ink-2); }
p, ul, ol, dl, blockquote, pre, figure, table { margin: 0 0 1em; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--amber); outline-offset: 2px;
}
ul, ol { padding-left: 1.4em; }
li { margin: 0.25em 0; }
li > ul, li > ol { margin-bottom: 0.2em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
blockquote {
  margin-left: 0; padding: 0.4em 1em; border-left: 4px solid var(--gold);
  background: var(--surface-2); color: var(--ink-2); border-radius: 0 8px 8px 0;
}
blockquote p:last-child { margin-bottom: 0; }
strong { font-weight: 650; }
img { max-width: 100%; height: auto; }
code, pre, kbd { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--code-bg); color: var(--code-ink); padding: 0.1em 0.35em; border-radius: 5px; }
pre {
  background: var(--code-bg); color: var(--code-ink); padding: 0.9em 1em; border-radius: 10px;
  overflow-x: auto; line-height: 1.45; border: 1px solid var(--line);
}
pre code { background: none; padding: 0; font-size: 0.85rem; }
.table-wrap { position: relative; overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; vertical-align: top; padding: 0.65em 0.8em; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); color: var(--ink-2); font-weight: 650; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td code, th code { white-space: nowrap; }
dl.glossary dt, .cost-legend dt { font-weight: 650; margin-top: 0.8em; }
dl dd { margin-left: 0; color: var(--ink-2); }
sub, sup { line-height: 0; }
.sr { position: absolute; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--amber); color: #101a2b; padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
input[type="checkbox"][disabled] { vertical-align: middle; }

/* ---- header ---------------------------------------------------------------------------- */

.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--gutter);
  background: var(--navy); color: #f6f8fb;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px -10px rgba(0, 0, 0, 0.5);
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--blue), #0b66b2); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 5px; right: 5px; top: 12px; height: 3px; border-radius: 3px; background: var(--amber); }
.brand-sub { font-weight: 400; font-size: 0.82rem; color: #c9d6e6; }
.header-tools { display: flex; align-items: center; gap: 8px; }
.search input {
  width: 200px; max-width: 40vw; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1); color: #fff; font: inherit; font-size: 0.92rem;
}
.search input::placeholder { color: #c9d6e6; }
.theme-toggle, .gh, .menu-toggle {
  color: #fff; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 0.88rem; text-decoration: none; cursor: pointer;
  white-space: nowrap; flex: none;
}
.lead-small { font-size: 0.95rem; }
.theme-toggle[aria-pressed="true"] { background: var(--amber); color: #101a2b; border-color: var(--amber); }
.menu-toggle { display: none; }
.menu-toggle[aria-expanded="true"] { background: var(--amber); border-color: var(--amber); color: #101a2b; }

/* ---- layout ---------------------------------------------------------------------------- */

.layout { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); gap: 0; min-height: calc(100vh - 56px); }
.nav-wrap { border-right: 1px solid var(--line); background: var(--surface); }
.site-nav { position: sticky; top: 56px; max-height: calc(100vh - 56px); overflow-y: auto; padding: 18px 14px 30px; font-size: 0.92rem; }
.nav-section { margin-bottom: 14px; }
.nav-title { display: block; font-weight: 700; color: var(--ink); text-decoration: none; padding: 6px 8px; border-radius: 8px; }
.nav-section.current-section > .nav-title { background: var(--surface-2); color: var(--blue-deep); }
:root:not([data-theme="light"]) .nav-section.current-section > .nav-title { color: var(--link); }
:root[data-theme="dark"] .nav-section.current-section > .nav-title { color: var(--link); }
.site-nav ul { list-style: none; padding: 4px 0 0 8px; margin: 0; border-left: 2px solid var(--line); margin-left: 10px; }
.site-nav li { margin: 0; }
.site-nav li a { display: block; padding: 4px 8px; color: var(--ink-2); text-decoration: none; border-radius: 6px; }
.site-nav li a:hover { background: var(--surface-2); color: var(--ink); }
.site-nav li a[aria-current="page"] { color: var(--blue-deep); font-weight: 650; background: var(--surface-2); }
:root:not([data-theme="light"]) .site-nav li a[aria-current="page"] { color: var(--link); }
:root[data-theme="dark"] .site-nav li a[aria-current="page"] { color: var(--link); }
.content { padding: 38px var(--gutter) 60px; min-width: 0; }
article { max-width: var(--max); margin: 0 auto; min-width: 0; }
article > * { min-width: 0; }
.page-kicker { margin: 0 0 0.55em; color: var(--gold); font-size: 0.76rem; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
.cost-explorer code, .cost-derive { overflow-wrap: anywhere; }
.lead { font-size: 1.1rem; line-height: 1.65; color: var(--ink-2); margin-bottom: 1.7em; }
.toc { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: var(--radius); padding: 14px 18px; margin: 0 0 1.8em; font-size: 0.9rem; }
.toc h2 { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); border: 0; margin: 0 0 8px; padding: 0; }
.toc ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 3px 16px; list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: 3px 0; text-decoration: none; }
.toc a:hover { text-decoration: underline; }
article [id] { scroll-margin-top: 76px; }
details.toc summary { cursor: pointer; font-weight: 650; }
.prev-next { display: flex; justify-content: space-between; gap: 12px; max-width: var(--max); margin: 2.5em auto 0; padding-top: 1em; border-top: 1px solid var(--line); font-size: 0.95rem; }
.prev-next .next { margin-left: auto; text-align: right; }
.page-footer { max-width: var(--max); margin: 2.5em auto 0; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); padding-top: 1em; }
.page-footer code { font-size: 0.8rem; }
.hash { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.doc-list { list-style: none; padding: 0; }
.doc-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.doc-list .path { display: block; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.lead-short { color: var(--ink-2); }

/* ---- home page ------------------------------------------------------------------------- */

.home { --home-ink: #292e33; --home-muted: #626a70; }
.home .layout { display: block; }
.home .nav-wrap { display: none; }
.home .content { padding: 0 0 80px; }
.home article { max-width: none; }
.home .site-header { background: #142c43; box-shadow: none; }
.home-hero {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: min(880px, calc(100svh - 58px)); color: #fff;
  background: #738d9d;
}
.home-hero::before {
  content: ""; position: absolute; z-index: -2; inset: -80px;
  background:
    radial-gradient(ellipse 38% 65% at 30% 23%, #4476b9 2%, transparent 100%),
    radial-gradient(ellipse 32% 58% at 80% 22%, #b89574 4%, transparent 100%),
    radial-gradient(ellipse 38% 58% at 83% 78%, #d8c589 0%, transparent 100%),
    radial-gradient(ellipse 38% 48% at 16% 90%, #869c73 0%, transparent 100%),
    linear-gradient(110deg, #829697, #a8afb1 50%, #b9a481);
  filter: blur(48px); transform: scale(1.08);
}
.home-hero::after { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(90deg, rgba(15, 36, 57, .27), rgba(35, 40, 46, .04) 80%); }
.home-cover-content { width: min(100%, 1450px); margin: 0 auto; padding: clamp(72px, 11vh, 135px) clamp(24px, 5vw, 90px) 80px; }
.home-eyebrow { margin: 0 0 clamp(24px, 5vh, 56px); font: 650 .73rem var(--mono); letter-spacing: .12em; }
.home-eyebrow span { opacity: .58; margin: 0 .5em; }
.home-hero h1 { max-width: 12ch; margin: 0; color: #fff; font-size: clamp(4rem, 8.6vw, 8.5rem); font-weight: 460; line-height: .98; letter-spacing: -.065em; }
.home-hero .lead { max-width: 42ch; margin: clamp(26px, 5vh, 58px) 0 0; color: #f6f8f8; font-size: clamp(1.07rem, 1.7vw, 1.48rem); line-height: 1.52; text-wrap: pretty; }
.home-actions { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; margin-top: 32px; }
.home-actions a { display: inline-flex; gap: 18px; align-items: center; min-height: 46px; color: #fff; font-size: .91rem; font-weight: 650; text-decoration: none; }
.home-actions a:hover { text-decoration: underline; }
.home-primary { padding: 8px 18px; border: 1px solid rgba(255,255,255,.85); border-radius: 4px; background: rgba(255,255,255,.1); }
.home-secondary { padding: 8px 0; }
.home-cover-footer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; width: 100%; margin-top: auto; padding: 28px clamp(24px, 5vw, 90px) 34px; border-top: 1px solid rgba(255,255,255,.35); background: rgba(30,48,61,.09); }
.home-cover-footer div { min-width: 0; }
.home-cover-footer span, .home-cover-footer strong { display: block; }
.home-cover-footer span { margin-bottom: 9px; font: .65rem var(--mono); letter-spacing: .08em; opacity: .82; }
.home-cover-footer strong { color: #fff; font-size: clamp(.95rem, 1.4vw, 1.25rem); font-weight: 500; line-height: 1.3; }
.home .toc { max-width: 1250px; margin: 0 auto; padding: clamp(78px, 10vw, 150px) clamp(24px, 5vw, 80px); border: 0; border-radius: 0; background: transparent; }
.home .toc h2 { margin: 0 0 28px; color: var(--muted); font: .73rem var(--mono); letter-spacing: .1em; }
.home .toc ul { display: grid; grid-template-columns: 1fr; gap: 0; padding: 0; counter-reset: home-agenda; }
.home .toc li { counter-increment: home-agenda; display: flex; align-items: baseline; gap: clamp(18px, 2vw, 30px); min-width: 0; padding: 7px 0; }
.home .toc li::before { content: counter(home-agenda, decimal-leading-zero); display: grid; place-items: center; flex: none; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font: 1.25rem var(--font); }
.home .toc a { min-width: 0; color: var(--ink); font-size: clamp(1.5rem, 4.5vw, 4rem); font-weight: 400; line-height: 1.15; letter-spacing: -.045em; text-decoration: none; }
.home .toc a:hover { color: var(--link); text-decoration: none; }
.home-body { max-width: 1360px; margin: 0 auto; padding: 0 clamp(24px, 5vw, 80px) 80px; counter-reset: home-section; }
.home-body > h2 { counter-increment: home-section; display: flex; align-items: baseline; gap: 16px; margin: clamp(90px, 12vw, 170px) 0 24px; padding: 0; border: 0; font-size: clamp(2.4rem, 5vw, 5rem); font-weight: 450; line-height: 1.06; letter-spacing: -.055em; }
.home-body > h2::before { content: counter(home-section, decimal-leading-zero); flex: none; color: var(--muted); font: .78rem var(--mono); letter-spacing: 0; }
.home-body > h2:first-child { margin-top: 0; }
.home-body > p { max-width: 75ch; color: var(--ink-2); font-size: 1.08rem; line-height: 1.75; }
.home .verdict-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-top: 50px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.home .stat { padding: 24px 22px 30px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; }
.home .stat:first-child { padding-left: 0; }
.home .stat:last-child { border-right: 0; }
.home .stat .label { color: var(--muted); font: .7rem var(--mono); letter-spacing: .045em; text-transform: uppercase; }
.home .stat .value { margin: 16px 0; font-size: clamp(2rem, 3vw, 3.5rem); font-weight: 480; letter-spacing: -.05em; }
.home .stat .note { font-size: .82rem; line-height: 1.5; }
.home .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: 36px; border-top: 1px solid var(--line); }
.home .card { padding: 28px 28px 28px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; }
.home .card:nth-child(even) { padding-left: 28px; border-left: 1px solid var(--line); }
.home .card h3 { font-size: 1.22rem; }
.home .card h3 a { text-decoration: none; }
.home .card h3 a:hover { text-decoration: underline; }
.home .prev-next, .home .page-footer { max-width: 1200px; padding-left: 24px; padding-right: 24px; }
@media (max-width: 900px) {
  .home.nav-open .nav-wrap { display: block; }
  .home-cover-content { padding-top: 90px; }
  .home .verdict-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home .stat:nth-child(2) { border-right: 0; }
  .home .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 600px) {
  .home-hero { min-height: calc(100svh - 58px); }
  .home-cover-content { padding: 68px 24px 50px; }
  .home-hero h1 { font-size: clamp(3.45rem, 13vw, 5.2rem); }
  .home-hero .lead { margin-top: 28px; font-size: 1.08rem; }
  .home-cover-footer { grid-template-columns: 1fr 1fr; gap: 18px; padding: 20px 24px 26px; }
  .home-cover-footer div:last-child { grid-column: 1 / -1; }
  .home-cover-footer span { font-size: .56rem; }
  .home-cover-footer strong { font-size: .85rem; }
  .home .toc { padding: 82px 24px; }
  .home .toc li { gap: 16px; padding: 9px 0; }
  .home .toc li::before { width: 36px; height: 36px; border-radius: 9px; font-size: 1rem; }
  .home .toc a { font-size: clamp(1.3rem, 6.4vw, 2rem); }
  .home-body { padding: 0 24px 60px; }
  .home-body > h2 { margin-top: 90px; font-size: 2.4rem; }
  .home .verdict-row, .home .cards { grid-template-columns: 1fr; }
  .home .stat, .home .stat:first-child, .home .stat:last-child { padding: 22px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .home .card, .home .card:nth-child(even) { padding: 22px 0; border-left: 0; }
}

@media (max-width: 899px) {
  .layout { display: block; }
  .nav-wrap { border-right: 0; border-bottom: 1px solid var(--line); }
  .js .nav-wrap { display: none; }
  .js .nav-open .nav-wrap { display: block; }
  .site-nav { position: static; max-height: min(65vh, 560px); }
  .js .menu-toggle { display: inline-block; }
  .brand-sub { display: none; }
  .search input { width: 130px; }
  .content { padding-top: 24px; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.25rem; }
}
@media (max-width: 560px) {
  .gh { display: none; }
  .search input { width: 110px; }
  .lead { font-size: 1rem; }
  .toc { padding: 12px 14px; }
}

/* ---- search results -------------------------------------------------------------------- */

.search-results {
  position: fixed; top: 56px; left: 0; right: 0; z-index: 19; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); padding: 12px var(--gutter);
}
.search-results ol { list-style: none; padding: 0; margin: 0; max-width: 78ch; }
.search-results li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.search-results .s-section { color: var(--muted); font-size: 0.8rem; margin-left: 8px; }
.search-results .s-head { color: var(--ink-2); font-size: 0.85rem; display: block; }
.search-results .s-none { color: var(--muted); }

/* ---- citations and tooltips ------------------------------------------------------------ */

.num { font-variant-numeric: tabular-nums; }
a.src { text-decoration: none; margin-left: 1px; }
a.src::after {
  content: "§"; font-size: 0.7em; vertical-align: super; color: var(--gold); padding: 0 1px;
}
a.src:hover::after { color: var(--link-hover); }
a.srclink { font-size: 0.92em; }
.term { display: inline; border-bottom: 1px dotted currentColor; cursor: help; text-decoration: none; }
.term > .tip-body {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: 16px; margin: 0 auto; max-width: 480px;
  padding: 10px 12px; border-radius: 8px; background: var(--tip-bg); color: var(--tip-fg);
  font-size: 0.9rem; line-height: 1.4; z-index: 30; visibility: hidden; opacity: 0; transition: opacity 0.12s;
  box-shadow: var(--shadow); font-weight: 400; text-align: left;
}
.term > .tip-body a, .term > .tip-body code { color: inherit; }
.term > .tip-body code { background: rgba(127, 127, 127, 0.25); }
.term:hover > .tip-body, .term:focus > .tip-body, .term:focus-within > .tip-body { visibility: visible; opacity: 1; }
@supports (anchor-name: --tip) and (position-try-fallbacks: flip-block) {
  @media (min-width: 641px) {
    .term { anchor-name: --tip; anchor-scope: --tip; }
    .term > .tip-body {
      position: fixed; position-anchor: --tip; position-area: block-end; inset: auto; margin: 6px 0;
      width: max-content; max-width: 340px;
      position-try-fallbacks: --below-start, --below-end, flip-block, --above-start, --above-end;
    }
    @position-try --below-start { position-area: block-end span-inline-end; }
    @position-try --below-end { position-area: block-end span-inline-start; }
    @position-try --above-start { position-area: block-start span-inline-end; }
    @position-try --above-end { position-area: block-start span-inline-start; }
  }
}

/* ---- diagrams -------------------------------------------------------------------------- */

figure.diagram { margin: 1.4em 0 1.8em; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
img.diagram-img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
img.diagram-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) img.diagram-light { display: none; }
  :root:not([data-theme="light"]) img.diagram-dark { display: block; }
}
:root[data-theme="dark"] img.diagram-light { display: none; }
:root[data-theme="dark"] img.diagram-dark { display: block; }
figure.diagram figcaption { color: var(--muted); font-size: 0.88rem; margin-top: 8px; }
figure.diagram .fullsize { margin-left: 8px; white-space: nowrap; }
figure.diagram details { margin-top: 8px; font-size: 0.85rem; }
figure.diagram details pre { margin: 6px 0 0; }
figure.diagram-missing pre { margin: 0; }

/* ---- cards and callouts ---------------------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 14px; margin: 1em 0 1.6em; padding: 0; list-style: none; }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin: 0; }
.card h3, .card h2 { margin-top: 0; border: 0; padding: 0; font-size: 1.05rem; }
.card .role { display: inline-block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); margin-bottom: 6px; }
.card .role.fused { background: var(--navy); color: #fff; }
.card .role.evidence { border: 1px solid var(--gold); }
.card p:last-child { margin-bottom: 0; }
.evidence-line { min-width: 0; font-family: var(--mono); font-size: 0.82rem; background: var(--code-bg); color: var(--code-ink); padding: 8px 10px; border-radius: 8px; border-left: 3px solid var(--gold); white-space: pre-wrap; }
.callout { background: var(--surface-2); border-left: 4px solid var(--blue); padding: 10px 14px; border-radius: 0 10px 10px 0; margin: 1.2em 0; }
.callout.warn { border-left-color: var(--gold); }
.callout p:last-child { margin-bottom: 0; }
.verdict-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; margin: 1em 0 1.6em; }
.stat { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .label { display: block; font-size: 0.8rem; color: var(--muted); }
.stat .value { display: block; font-size: 1.9rem; font-weight: 650; line-height: 1.1; margin: 4px 0; color: var(--ink); }
.stat .note { display: block; font-size: 0.8rem; color: var(--ink-2); }
.stat.pending .value { color: var(--muted); font-size: 1.2rem; }
.timeline { list-style: none; padding: 0; margin: 1em 0 1.6em; border-left: 3px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 18px; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: 6px; width: 13px; height: 13px; border-radius: 50%; background: var(--blue); border: 2px solid var(--surface); }
.timeline time { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); display: block; }
.badge { display: inline-block; font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); vertical-align: middle; }
.badge.ok { background: var(--good); color: #fff; }
.badge.warn { background: var(--gold); color: #fff; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }

/* ---- the cost function ----------------------------------------------------------------- */

.cost-panel {
  margin: 1.4em 0 2em; padding: 22px 22px 18px; border-radius: 16px; color: #f6f8fb;
  background: radial-gradient(120% 160% at 100% 0%, rgba(255, 184, 0, 0.18), transparent 55%), linear-gradient(135deg, #00254b, #003d6e 60%, #005493);
  box-shadow: var(--shadow);
}
.cost-panel h2 { color: #fff; border: 0; margin: 0 0 12px; padding: 0; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.9; }
.cost-formula {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35em 0.5em;
  font-size: clamp(1.5rem, 4.5vw, 2.6rem); font-weight: 650; line-height: 1.15; margin: 0 0 14px; letter-spacing: -0.01em;
}
.cost-lhs { color: #fff; }
.cost-eq, .cost-plus { color: #c9d6e6; font-weight: 400; }
.cost-term { display: inline-flex; align-items: baseline; gap: 0.25em; padding: 0.1em 0.45em; border-radius: 10px; }
.cost-fa { background: rgba(255, 184, 0, 0.16); border: 1px solid rgba(255, 184, 0, 0.55); }
.cost-miss { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.25); }
.cost-w { color: var(--amber); font-variant-numeric: tabular-nums; }
.cost-fa .cost-var, .cost-miss .cost-var { color: #fff; font-weight: 500; }
.cost-read { font-size: 1.1rem; margin: 0 0 12px; color: #e9eff6; }
.cost-read strong { color: var(--amber); }
.cost-legend { display: grid; grid-template-columns: minmax(0, max-content) 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: 0.92rem; color: #d7e1ee; }
.cost-legend dt { margin: 0; font-weight: 650; color: #fff; }
.cost-legend dd { margin: 0; color: #d7e1ee; }
.cost-derive { font-size: 0.88rem; color: #c9d6e6; margin: 0; line-height: 1.5; }
.cost-derive .num { color: #fff; }
.cost-panel a.src::after { color: var(--amber); }
.cost-explorer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 1em 0 1.8em; box-shadow: var(--shadow); }
.cost-controls { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); margin: 10px 0; }
.cost-controls label { display: block; font-weight: 650; }
.cost-controls output { font-family: var(--mono); font-weight: 400; margin-left: 6px; color: var(--ink-2); }
.cost-controls input[type="range"] { width: 100%; margin-top: 6px; accent-color: var(--blue); }
.cost-result { font-size: 1.3rem; margin: 8px 0 0; }
.cost-result output { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.cost-note { font-size: 0.85rem; color: var(--muted); display: block; }
.score-line { display: block; margin: 1em 0 1.6em; }

/* ---- print ----------------------------------------------------------------------------- */

@media print {
  .site-header, .nav-wrap, .search-results, .prev-next, .skip, .menu-toggle { display: none !important; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
  a { color: #000; }
  .term > .tip-body { display: none; }
}
