/* ==========================================================================
   Contextual Agentic — design system
   Restrained technical-publishing identity: warm neutral ground, deep ink,
   one teal accent, generous whitespace, editorial hierarchy.

   Typeface decision: system stacks only. Webfont hosting was not available
   during the build (no external font CDN is reachable, and the site's CSP
   forbids third-party font origins), and system stacks give zero layout shift
   and no licence exposure. docs/OWNER-GUIDE.md documents how to swap in a
   licensed self-hosted face without touching any template.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* — palette (light) — */
  --bg:            #fcfbf8;
  --bg-sunken:     #f5f3ed;
  --surface:       #ffffff;
  --surface-alt:   #faf8f3;
  --ink:           #131a24;
  --ink-strong:    #0a0f16;
  --muted:         #565f6c;
  --muted-soft:    #5d6673;
  --rule:          #e2ded4;
  --rule-strong:   #cdc8bb;
  /* Borders of interactive controls must reach 3:1 (WCAG 1.4.11);
     --rule-strong stays decorative. */
  --border-strong: #8d8674;
  --accent:        #0d6661;
  --accent-strong: #0a534f;
  --accent-soft:   #e3f0ee;
  --accent-ink:    #ffffff;
  --warn:          #8a5a10;
  --warn-soft:     #fbf1de;
  --danger:        #9a2c28;
  --danger-soft:   #fbeceb;
  --focus:         #0d6661;
  --shadow:        0 1px 2px rgba(19, 26, 36, .05), 0 8px 24px -16px rgba(19, 26, 36, .28);

  /* — type — */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;

  --step--1: clamp(.82rem, .79rem + .12vw, .875rem);
  --step-0:  clamp(1rem, .97rem + .16vw, 1.0625rem);
  --step-1:  clamp(1.15rem, 1.09rem + .3vw, 1.3rem);
  --step-2:  clamp(1.35rem, 1.24rem + .55vw, 1.65rem);
  --step-3:  clamp(1.6rem, 1.4rem + 1vw, 2.15rem);
  --step-4:  clamp(1.95rem, 1.6rem + 1.75vw, 3rem);

  /* — space & shape — */
  --sp-1: .25rem; --sp-2: .5rem;  --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem;   --sp-7: 3rem;   --sp-8: 4rem; --sp-9: 6rem;
  --radius: 4px;
  --radius-lg: 8px;
  --measure: 68ch;
  --gutter: 1rem;
  --wrap: 72rem;
  --wrap-narrow: 46rem;
}

@media (min-width: 48rem) { :root { --gutter: 2rem; } }
@media (min-width: 64rem) { :root { --gutter: 2.5rem; } }

/* Dark: system preference unless the reader has explicitly forced light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0e1319;
    --bg-sunken:     #0a0e13;
    --surface:       #151c24;
    --surface-alt:   #1a222c;
    --ink:           #e7e5e0;
    --ink-strong:    #f5f4f1;
    --muted:         #a2abb7;
    --muted-soft:    #8b94a0;
    --rule:          #262f3a;
    --rule-strong:   #37424f;
    --border-strong: #626f81;
    --accent:        #56b8b1;
    --accent-strong: #79cdc7;
    --accent-soft:   #16302f;
    --accent-ink:    #06201f;
    --warn:          #e0b269;
    --warn-soft:     #2e2413;
    --danger:        #e79a95;
    --danger-soft:   #341c1b;
    --focus:         #79cdc7;
    --shadow:        0 1px 2px rgba(0,0,0,.4), 0 10px 28px -18px rgba(0,0,0,.8);
  }
}
:root[data-theme="dark"] {
  --bg:#0e1319; --bg-sunken:#0a0e13; --surface:#151c24; --surface-alt:#1a222c;
  --ink:#e7e5e0; --ink-strong:#f5f4f1; --muted:#a2abb7; --muted-soft:#8b94a0;
  --rule:#262f3a; --rule-strong:#37424f; --border-strong:#626f81;
  --accent:#56b8b1; --accent-strong:#79cdc7; --accent-soft:#16302f; --accent-ink:#06201f;
  --warn:#e0b269; --warn-soft:#2e2413; --danger:#e79a95; --danger-soft:#341c1b;
  --focus:#79cdc7;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -18px rgba(0,0,0,.8);
}

/* ========================= base ========================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink-strong); line-height: 1.18; font-weight: 600; letter-spacing: -.008em; margin: 0 0 var(--sp-4); text-wrap: balance; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); margin-top: var(--sp-7); }
h3 { font-size: var(--step-2); margin-top: var(--sp-6); }
h4 { font-size: var(--step-1); margin-top: var(--sp-5); }
p, ul, ol, dl, blockquote, figure, table { margin: 0 0 var(--sp-4); }
p { text-wrap: pretty; }
small, .small { font-size: var(--step--1); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent-strong); }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px;
}
img, svg, video { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--sp-7) 0; }

.skip-link {
  position: absolute; left: var(--sp-3); top: var(--sp-3); z-index: 100;
  transform: translateY(-160%); background: var(--accent); color: var(--accent-ink);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--radius); font-weight: 600;
  text-decoration: none; transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); color: var(--accent-ink); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ========================= layout ========================= */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.wrap--narrow { max-width: var(--wrap-narrow); }
main { flex: 1 0 auto; }
.section { padding-block: var(--sp-7); }
.section + .section { border-top: 1px solid var(--rule); }
@media (min-width: 64rem) { .section { padding-block: var(--sp-8); } }

.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
@media (min-width: 48rem) { .grid--2, .grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }
.stack > * + * { margin-top: var(--sp-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }

/* ========================= header ========================= */
.masthead { border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--bg) 88%, transparent); position: sticky; top: 0; z-index: 40; backdrop-filter: saturate(140%) blur(8px); }
/* Always allowed to wrap: with text-only zoom, or a large default font size, the
   navigation must fall onto a second line rather than push past the viewport. */
.masthead__inner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4); min-height: 4rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; min-width: 0; font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; color: var(--ink-strong); text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.brand__mark { width: 1.45rem; height: 1.45rem; flex: none; }
.brand:hover { color: var(--accent); }

.nav { margin-left: auto; min-width: 0; }
.nav__list { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); list-style: none; margin: 0; padding: 0; }
.nav__link { color: var(--muted); text-decoration: none; font-size: var(--step--1); font-weight: 500; letter-spacing: .01em; padding-block: .35rem; border-bottom: 2px solid transparent; }
.nav__link:hover { color: var(--ink); }
.nav__link[aria-current="page"] { color: var(--ink-strong); border-bottom-color: var(--accent); }

.nav-toggle { display: none; }
.theme-toggle { background: none; border: 1px solid var(--border-strong); color: var(--muted); border-radius: var(--radius); width: 2.1rem; height: 2.1rem; display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.theme-toggle svg { width: 1rem; height: 1rem; }

@media (max-width: 47.99rem) {
  .nav-toggle {
    display: inline-grid; place-items: center; margin-left: auto;
    width: 2.4rem; height: 2.4rem; background: none; border: 1px solid var(--border-strong);
    border-radius: var(--radius); color: var(--ink); cursor: pointer;
  }
  .nav-toggle svg { width: 1.15rem; height: 1.15rem; }
  .nav { margin-left: 0; order: 10; flex-basis: 100%; display: none; }
  .nav[data-open="true"] { display: block; }
  .nav__list { flex-direction: column; gap: 0; padding-bottom: var(--sp-4); }
  .nav__link { display: block; padding: var(--sp-3) 0; border-bottom: 1px solid var(--rule); font-size: var(--step-0); }
  .nav__link[aria-current="page"] { border-bottom-color: var(--accent); }
  .masthead__inner { flex-wrap: wrap; }
}

/* ========================= hero ========================= */
.hero { padding-block: var(--sp-7) var(--sp-7); }
@media (min-width: 64rem) { .hero { padding-block: var(--sp-9) var(--sp-8); } }
.hero__eyebrow { font-size: var(--step--1); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: var(--sp-4); }
.hero__title { font-size: var(--step-4); max-width: 21ch; margin-bottom: var(--sp-5); }
.hero__lede { font-size: var(--step-1); color: var(--muted); max-width: 54ch; margin-bottom: var(--sp-6); }
.hero__layout { display: grid; gap: var(--sp-7); align-items: center; }
@media (min-width: 64rem) { .hero__layout { grid-template-columns: 1.15fr .85fr; gap: var(--sp-8); } }

/* ========================= buttons ========================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-size: var(--step--1); font-weight: 600; letter-spacing: .01em;
  padding: .7rem 1.15rem; border-radius: var(--radius); border: 1px solid transparent;
  text-decoration: none; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-strong); color: var(--accent-ink); }
.btn--secondary { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn--quiet { background: transparent; color: var(--accent); padding-inline: 0; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 1em; height: 1em; }

/* ========================= status pills ========================= */
.pill {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; padding: .28rem .6rem;
  border-radius: 999px; border: 1px solid var(--rule-strong); color: var(--muted); background: var(--surface-alt);
  /* Not nowrap: a pill carrying a long chapter reference would otherwise push the page
     sideways on a phone. Short pills stay on one line by themselves. */
  white-space: normal; max-width: 100%; overflow-wrap: anywhere;
}
.pill--accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }
.pill--warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.pill--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }

/* ========================= cards ========================= */
.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3);
}
.card--link { transition: border-color .15s ease, transform .15s ease; }
.card--link:hover { border-color: var(--rule-strong); }
.card__meta { font-size: var(--step--1); color: var(--muted-soft); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.card__title { font-size: var(--step-1); margin: 0; }
.card__title a { color: var(--ink-strong); text-decoration: none; }
.card__title a:hover { color: var(--accent); text-decoration: underline; }
.card__body { color: var(--muted); margin: 0; }
.card__foot { margin-top: auto; padding-top: var(--sp-2); font-size: var(--step--1); }

/* ========================= book ========================= */
.bookcover {
  --cover-w: 15rem;
  width: var(--cover-w); aspect-ratio: 5 / 8; position: relative;  /* the cover art is 1600 x 2560 */
  border-radius: 2px 5px 5px 2px;
  box-shadow: 0 1px 1px rgba(0,0,0,.14), 0 10px 20px -8px rgba(0,0,0,.35), 0 22px 44px -22px rgba(0,0,0,.4);
  overflow: hidden; background: var(--surface-alt); flex: none;
}
.bookcover::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: .55rem;
  background: linear-gradient(to right, rgba(0,0,0,.26), rgba(0,0,0,.05) 55%, rgba(255,255,255,.14));
  pointer-events: none;
}
.bookcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bookcover--placeholder {
  display: grid; align-content: space-between; padding: 1.4rem 1.2rem;
  background: linear-gradient(160deg, var(--surface-alt), var(--bg-sunken));
  border: 1px solid var(--rule);
}
.bookcover__ph-title { font-family: var(--font-display); font-size: 1.05rem; line-height: 1.25; color: var(--ink-strong); }
.bookcover__ph-note { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-soft); }
@media (min-width: 64rem) { .bookcover { --cover-w: 17rem; } }

.bookpanel { display: grid; gap: var(--sp-6); align-items: start; }
@media (min-width: 48rem) { .bookpanel { grid-template-columns: auto 1fr; gap: var(--sp-7); } }

.specs { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
.specs th, .specs td { text-align: left; padding: .55rem .75rem .55rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.specs th { font-weight: 600; color: var(--muted); width: 12rem; }
/* Inside a narrow sidebar card the fixed label column would wrap every word. */
.card .specs th { width: 45%; }

/* ========================= prose ========================= */
.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }
.prose h2 { padding-top: var(--sp-2); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose blockquote {
  margin-inline: 0; padding: var(--sp-2) 0 var(--sp-2) var(--sp-5);
  border-left: 3px solid var(--accent); color: var(--muted); font-style: italic;
}
.prose :not(pre) > code {
  font-family: var(--font-mono); font-size: .875em; background: var(--bg-sunken);
  border: 1px solid var(--rule); border-radius: 3px; padding: .1em .35em;
  /* Long identifiers — a test name, a permission, a path — have no spaces to break at. */
  overflow-wrap: anywhere;
}
.prose figure { margin: var(--sp-6) 0; }
.prose figcaption { font-size: var(--step--1); color: var(--muted-soft); margin-top: var(--sp-2); }
.prose .footnote { font-size: var(--step--1); color: var(--muted); border-top: 1px solid var(--rule); margin-top: var(--sp-7); }

.table-scroll { overflow-x: auto; margin-bottom: var(--sp-4); border: 1px solid var(--rule); border-radius: var(--radius); }
.table-scroll table { width: 100%; border-collapse: collapse; font-size: var(--step--1); margin: 0; }
.table-scroll th, .table-scroll td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--rule); }
.table-scroll thead th { background: var(--surface-alt); font-weight: 600; white-space: nowrap; }
.table-scroll tr:last-child td { border-bottom: 0; }

/* ========================= code ========================= */
.codeblock { margin: var(--sp-5) 0; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--surface-alt); }
.codeblock__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: .35rem .5rem .35rem .8rem; border-bottom: 1px solid var(--rule); background: var(--bg-sunken); }
.codeblock__lang { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-soft); }
.codeblock__copy { font: inherit; font-size: .72rem; font-weight: 600; letter-spacing: .04em; background: none; border: 1px solid var(--border-strong); color: var(--muted); border-radius: 3px; padding: .2rem .55rem; cursor: pointer; }
.codeblock__copy:hover { color: var(--ink); border-color: var(--ink); }
.codeblock__copy[data-state="copied"] { color: var(--accent); border-color: var(--accent); }
.codeblock pre { margin: 0; padding: var(--sp-4); overflow-x: auto; font-family: var(--font-mono); font-size: .845rem; line-height: 1.6; background: transparent; }
.codeblock pre code { font-family: inherit; background: none; border: 0; padding: 0; }

/* ========================= table of contents ========================= */
.article-layout { display: grid; gap: var(--sp-6); }
/* A grid item's automatic minimum size is its content, so one long code line or a wide
   table drags the whole column past the viewport. min-width:0 lets the scroll containers
   inside do their job. */
.article-layout > *, .grid > *, .bookpanel > * { min-width: 0; }
@media (min-width: 64rem) { .article-layout { grid-template-columns: minmax(0,1fr) 15rem; gap: var(--sp-8); } }
.toc { font-size: var(--step--1); }
@media (min-width: 64rem) { .toc { position: sticky; top: 5.5rem; align-self: start; max-height: calc(100vh - 8rem); overflow-y: auto; } }
.toc__title { font-family: var(--font-body); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-soft); margin: 0 0 var(--sp-3); font-weight: 700; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li { margin: 0; }
.toc a { display: block; padding: .3rem 0 .3rem var(--sp-4); margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--ink); border-left-color: var(--rule-strong); }
.toc ol ol a { padding-left: var(--sp-6); font-size: .95em; }

/* ========================= forms ========================= */
.field { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.field label { font-size: var(--step--1); font-weight: 600; color: var(--ink); }
.field .hint { font-size: var(--step--1); color: var(--muted-soft); }
input[type="text"], input[type="email"], input[type="url"], select, textarea {
  font: inherit; font-size: var(--step-0); color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: .6rem .7rem; width: 100%;
}
textarea { min-height: 9rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.field__error { font-size: var(--step--1); color: var(--danger); font-weight: 600; }
.field--check { display: flex; gap: var(--sp-3); align-items: flex-start; }
.field--check input { width: auto; margin-top: .3rem; flex: none; }
.field--check label { font-weight: 400; color: var(--muted); }
.form-status { padding: var(--sp-4); border-radius: var(--radius); border: 1px solid var(--rule); font-size: var(--step--1); margin-bottom: var(--sp-4); }
.form-status[data-tone="ok"] { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); color: var(--accent-strong); }
.form-status[data-tone="error"] { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); color: var(--danger); }
.form-status[data-tone="warn"] { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); color: var(--warn); }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ========================= notices & empty states ========================= */
.notice { border: 1px solid var(--rule); border-left: 3px solid var(--accent); background: var(--surface-alt); border-radius: var(--radius); padding: var(--sp-4) var(--sp-5); font-size: var(--step--1); }
.notice--warn { border-left-color: var(--warn); background: var(--warn-soft); }
.notice__title { font-weight: 700; display: block; margin-bottom: var(--sp-2); color: var(--ink-strong); }
.notice p:last-child { margin-bottom: 0; }
.prose .notice, .prose .empty { margin-block: var(--sp-5); }

.empty {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: var(--sp-7) var(--sp-5);
  text-align: center; color: var(--muted); background: var(--surface-alt);
}
.empty h2, .empty h3 { margin-top: 0; font-size: var(--step-1); color: var(--ink); }
.empty p { max-width: 46ch; margin-inline: auto; }

/* ========================= filters ========================= */
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; margin-bottom: var(--sp-5); padding-bottom: var(--sp-5); border-bottom: 1px solid var(--rule); }
.filters .field { margin: 0; min-width: 11rem; }
.filters__count { font-size: var(--step--1); color: var(--muted-soft); margin-left: auto; }

/* ========================= search ========================= */
.search-results { list-style: none; margin: var(--sp-5) 0 0; padding: 0; display: grid; gap: var(--sp-4); }
.search-results mark { background: var(--accent-soft); color: inherit; padding: 0 .15em; border-radius: 2px; }

/* ========================= footer ========================= */
.sitefoot { border-top: 1px solid var(--rule); background: var(--bg-sunken); padding-block: var(--sp-7); margin-top: var(--sp-8); font-size: var(--step--1); color: var(--muted); }
.sitefoot__grid { display: grid; gap: var(--sp-6); }
@media (min-width: 48rem) { .sitefoot__grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.sitefoot h2 { font-family: var(--font-body); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-soft); margin: 0 0 var(--sp-3); font-weight: 700; }
.sitefoot ul { list-style: none; margin: 0; padding: 0; }
.sitefoot li + li { margin-top: .45rem; }
.sitefoot a { color: var(--muted); text-decoration: none; }
.sitefoot a:hover { color: var(--accent); text-decoration: underline; }
.sitefoot__legal { margin-top: var(--sp-6); padding-top: var(--sp-4); border-top: 1px solid var(--rule); color: var(--muted-soft); display: flex; flex-wrap: wrap; gap: var(--sp-4); justify-content: space-between; }

/* ========================= misc ========================= */
.page-head { padding-block: var(--sp-7) var(--sp-5); border-bottom: 1px solid var(--rule); }
.page-head__lede { font-size: var(--step-1); color: var(--muted); max-width: 56ch; margin-bottom: 0; }
.breadcrumbs { font-size: var(--step--1); color: var(--muted-soft); margin-bottom: var(--sp-4); }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; }
.breadcrumbs li + li::before { content: "/"; margin-right: .4rem; color: var(--rule-strong); }
.breadcrumbs a { color: var(--muted-soft); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.lede { font-size: var(--step-1); color: var(--muted); }
.meta-list { list-style: none; margin: 0; padding: 0; font-size: var(--step--1); color: var(--muted); }
.meta-list li + li { margin-top: .35rem; }
.draft-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); padding: var(--sp-2) 0; font-size: var(--step--1); font-weight: 600; text-align: center; }
.figure-note { font-size: var(--step--1); color: var(--muted-soft); font-style: italic; }
.diagram { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--sp-5); }
.diagram svg { display: block; width: 100%; height: auto; }
@media print {
  .masthead, .sitefoot, .toc, .codeblock__copy, .skip-link, .theme-toggle { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ==========================================================================
   Utilities
   The Content-Security-Policy forbids inline styles (style-src 'self' with no
   'unsafe-inline'), so every layout adjustment is a class. This is not a
   utility framework: it is the small, closed set the templates actually use.
   ========================================================================== */
.mt-0  { margin-top: 0 !important; }
.mt-4  { margin-top: var(--sp-4); }
.mt-5  { margin-top: var(--sp-5); }
.mt-6  { margin-top: var(--sp-6); }
.mt-7  { margin-top: var(--sp-7); }
.mt-gap{ margin-top: 1.5rem; }
.mb-0  { margin-bottom: 0 !important; }
.mb-xs { margin-bottom: .35rem; }
.mb-3  { margin-bottom: var(--sp-3); }
.mb-4  { margin-bottom: var(--sp-4); }
.mb-5  { margin-bottom: var(--sp-5); }
.mb-6  { margin-bottom: var(--sp-6); }
.mb-7  { margin-bottom: var(--sp-7); }
.m-0   { margin: 0; }
.pt-4  { padding-top: var(--sp-4); }
.pt-5  { padding-top: var(--sp-5); }
.pb-6  { padding-bottom: var(--sp-6); }
.pb-0  { padding-bottom: 0; }
.p-6   { padding: var(--sp-6); }
.tall  { padding-block: var(--sp-9); }

.measure-22 { max-width: 22ch; }
.measure-34 { max-width: 34ch; }
.measure-48 { max-width: 48ch; }
.measure-56 { max-width: 56ch; }
.measure-none { max-width: none; }
.center-text { text-align: center; }
.center-block { margin-inline: auto; }
.center-flex { display: flex; justify-content: center; }
.split { justify-content: space-between; }
.cluster--center { justify-content: center; }
.grow { flex: 1 1 20rem; }

.t-1 { font-size: var(--step-1); }
.t-2 { font-size: var(--step-2); }
.t-sm { font-size: var(--step--1); }
.c-muted { color: var(--muted); }
.c-muted-soft { color: var(--muted-soft); }
.link-plain { color: inherit; text-decoration: none; }
.link-plain:hover { color: var(--accent); }
.list-plain { list-style: none; padding: 0; margin: 0; }
.fieldset-plain { border: 0; padding: 0; margin: 0 0 var(--sp-4); }
.fieldset-plain legend { padding: 0; margin-bottom: var(--sp-2); }
.filters--bare { border: 0; padding-bottom: 0; }

/* ==========================================================================
   Diagram styles
   Inline <style> inside an SVG is blocked by style-src 'self', so diagram rules
   live here and the SVG carries only class names.
   ========================================================================== */
.diagram .frame { fill: none; stroke: currentColor; opacity: .28; }
.diagram .lbl { fill: currentColor; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; opacity: .62; font-weight: 600; }
.diagram .box { fill: none; stroke: currentColor; stroke-width: 1.4; opacity: .5; }
.diagram .boxfill { fill: currentColor; opacity: .045; }
.diagram .t { fill: currentColor; font-size: 14.5px; }
.diagram .tb { fill: currentColor; font-size: 15.5px; font-weight: 600; }
.diagram .sm { fill: currentColor; font-size: 12.5px; opacity: .72; }
.diagram .agent { fill: currentColor; opacity: .07; }
.diagram .agentline { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-dasharray: 6 5; opacity: .7; }
.diagram .flow { stroke: currentColor; stroke-width: 1.4; fill: none; opacity: .75; }

/* ==========================================================================
   Labs
   ========================================================================== */
.realsim { margin-block: var(--sp-5); }
.realsim__real { border-left: 3px solid var(--accent); }
.realsim__sim { border-left: 3px solid var(--rule-strong); }
.realsim .meta-list { margin-top: var(--sp-2); }
.realsim .meta-list li { line-height: 1.55; }

.lab { border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; margin-top: var(--sp-5); }
.lab__bar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--rule); background: var(--surface-alt); }
.lab__budget { margin: 0; font-size: var(--step--1); color: var(--muted); font-family: var(--font-mono); }
.lab__grid { display: grid; gap: 0; }
@media (min-width: 64rem) { .lab__grid { grid-template-columns: 1fr 1fr; } }
.lab__panel { padding: var(--sp-5); min-width: 0; }
.lab__panel + .lab__panel { border-top: 1px solid var(--rule); }
@media (min-width: 64rem) { .lab__panel + .lab__panel { border-top: 0; border-left: 1px solid var(--rule); } }
.lab__panel h3 { font-family: var(--font-body); font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-soft); font-weight: 700; margin-bottom: var(--sp-3); }
.lab__controls li { font-size: var(--step--1); color: var(--muted); padding: .5rem 0; border-bottom: 1px solid var(--rule); }
.lab__controls li:last-child { border-bottom: 0; }
.lab__controls strong { color: var(--ink); }

.lab__evidence { font-size: var(--step--1); max-height: 26rem; overflow-y: auto; }
.lab__record { display: grid; grid-template-columns: 4.5rem 1fr; gap: .2rem var(--sp-3); padding: .55rem 0 .55rem var(--sp-3); border-left: 3px solid var(--rule-strong); border-bottom: 1px solid var(--rule); }
.lab__record:last-child { border-bottom: 0; }
.lab__record-seq { font-family: var(--font-mono); font-size: .72rem; color: var(--muted-soft); grid-row: span 2; }
.lab__record-event { font-weight: 700; letter-spacing: .02em; color: var(--ink); }
.lab__record-detail { color: var(--muted); grid-column: 2; }
.lab__record--executed, .lab__record--approved, .lab__record--allowed { border-left-color: var(--accent); }
.lab__record--refused, .lab__record--rejected { border-left-color: var(--danger); }
.lab__record--escalate, .lab__record--escalated, .lab__record--held, .lab__record--unavailable, .lab__record--exercise { border-left-color: var(--warn); }
.lab__record--executed .lab__record-event { color: var(--accent); }
.lab__record--refused .lab__record-event, .lab__record--rejected .lab__record-event { color: var(--danger); }
.lab__record--escalated .lab__record-event, .lab__record--held .lab__record-event { color: var(--warn); }

.lab__export { margin: var(--sp-5); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--sp-4); }
.lab__export summary { cursor: pointer; font-weight: 600; font-size: var(--step--1); }
.lab__export pre { margin: var(--sp-4) 0 0; max-height: 22rem; overflow: auto; font-family: var(--font-mono); font-size: .78rem; background: var(--bg-sunken); padding: var(--sp-4); border-radius: var(--radius); }

.checksum { font-size: .78em; word-break: break-all; }

/* Copyright and reuse note at the foot of every article */
.article-rights { margin-top: var(--sp-7, 3rem); padding-top: var(--sp-4); border-top: 1px solid var(--rule); font-size: var(--step--1); color: var(--muted); }
.article-rights p { margin: 0 0 var(--sp-2); }
.article-rights a { overflow-wrap: anywhere; }

.article-share { margin-top: var(--sp-6); }

/* Book contents, grouped by part */
.toc-book h3 { font-size: var(--step-0); margin: var(--sp-5) 0 var(--sp-2); color: var(--ink-strong); }
.toc-book__front, .toc-book__list { list-style: none; padding: 0; margin: 0; }
.toc-book__list li, .toc-book__front li { padding: .3rem 0; border-bottom: 1px solid var(--rule); }
.toc-book__no { display: inline-block; min-width: 7.5em; color: var(--muted); font-size: var(--step--1); }
