/* Rolling Edition, rollingedition.com.
   Mobile first: the base rules are for phones, and layouts grow at 640, 960 and 1200px.
   Colors, type, spacing, radii and measures come only from tokens.css. Borders, not shadows. */

/* ------------------------------------------------------------------ syntax palettes (D-038) */
:root {
  --syn-keyword: #8f0fa8; --syn-decl: #0b3dbd; --syn-string: #a31515; --syn-escape: #8a4b00; --syn-number: #08704a;
  --syn-comment: #55636c; --syn-function: #6f5420; --syn-type: #1a6577; --syn-variable: #0d2a6b;
  --syn-bracket-1: #0431fa; --syn-bracket-2: #1f6f1f; --syn-bracket-3: #7b3814;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --syn-keyword: #d39ad0; --syn-decl: #6fb0e6; --syn-string: #de9c80; --syn-escape: #e0c48a; --syn-number: #b5cea8;
    --syn-comment: #9aa4ae; --syn-function: #e3e3b4; --syn-type: #5fd3bb; --syn-variable: #a8dcfe;
    --syn-bracket-1: #ffd700; --syn-bracket-2: #e080dc; --syn-bracket-3: #4fb3ff;
  }
}
:root[data-theme="dark"] {
  --syn-keyword: #d39ad0; --syn-decl: #6fb0e6; --syn-string: #de9c80; --syn-escape: #e0c48a; --syn-number: #b5cea8;
  --syn-comment: #9aa4ae; --syn-function: #e3e3b4; --syn-type: #5fd3bb; --syn-variable: #a8dcfe;
  --syn-bracket-1: #ffd700; --syn-bracket-2: #e080dc; --syn-bracket-3: #4fb3ff;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
[hidden] { display: none !important; }
body { display: flex; flex-direction: column; min-height: 100vh; margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-sans); font-size: var(--type-ui-size); line-height: var(--type-ui-line); -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; }
a { color: var(--link); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; text-wrap: pretty; }
button { font: inherit; color: inherit; }
::selection { background: var(--edition-soft); color: var(--ink); }
.code-scroll, .tape-scroll, .code-block { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; z-index: 50; padding: var(--space-2) var(--space-3); background: var(--paper-raised); }
.skip:focus { left: var(--space-4); top: var(--space-2); }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; line-height: 20px; }
.code { font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.icon { flex: none; display: inline-block; vertical-align: middle; }
.ico { width: 14px; height: 14px; flex: none; }

/* ------------------------------------------------------------------ layout */
.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--space-4); }
main { display: block; flex: 1 0 auto; }
.page { padding-block: var(--space-8) var(--space-12); }
.page-head { display: grid; gap: var(--space-3); margin-bottom: var(--space-8); max-width: var(--measure-reading); }
.section { padding-block: var(--space-12); }
.section-alt { background: var(--paper-raised); border-block: 1px solid var(--rule); }
.section-intro { display: grid; gap: var(--space-3); max-width: var(--measure-reading); margin-bottom: var(--space-8); }
.section-intro h2, .split-intro h2 { font-size: clamp(1.75rem, 1.35rem + 1.5vw, 2.5rem); line-height: 1.15; letter-spacing: -0.015em; }

/* ------------------------------------------------------------------ type */
.kicker { font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: var(--type-label-weight); letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
.kicker a { color: inherit; text-decoration: underline; }
.display, .page-title { font-family: var(--font-serif); font-weight: 600; color: var(--press); }
.display { font-size: clamp(2.5rem, 1.55rem + 4vw, 4.5rem); line-height: 1.04; letter-spacing: -0.025em; }
.display em { font-style: italic; font-weight: 600; color: var(--edition); }
.page-title { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.75rem); line-height: 1.12; letter-spacing: -0.015em; }
.section h2, .section-title, .contents h2 { font-family: var(--font-serif); font-size: var(--type-heading-size); line-height: var(--type-heading-line); font-weight: 600; }
.section-title { margin-bottom: var(--space-4); }
.lede { font-family: var(--font-serif); font-size: var(--type-reading-size); line-height: var(--type-reading-line); color: var(--ink); }
.tagline { font-weight: 600; }
.summary { font-family: var(--font-serif); font-size: var(--type-reading-size); line-height: var(--type-reading-line); max-width: var(--measure-reading); }

/* ------------------------------------------------------------------ header */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--rule); }
@supports (backdrop-filter: blur(1px)) {
  .site-header { background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); }
}
.header-row { display: flex; align-items: center; gap: var(--space-4); min-height: 56px; }
.lockup { display: inline-flex; align-items: center; gap: 8px; color: var(--press); margin-right: auto; }
.lockup:hover { text-decoration: none; }
.lockup img { display: block; width: 26px; height: 26px; }   /* the icon at 1.4 times the wordmark's 19px (D-060) */
.wordmark { font-family: var(--font-serif); font-weight: 600; font-size: 19px; line-height: 1; color: var(--press); }
.nav-inline { display: none; gap: var(--space-1); }
.nav-inline a { color: var(--ink); padding: 6px var(--space-3); border-radius: var(--radius-pill); }
.nav-inline a:hover { background: var(--paper-sunken); text-decoration: none; }
.nav-inline a[aria-current="page"] { color: var(--edition); background: var(--edition-soft); }
.header-tools { display: flex; align-items: center; gap: var(--space-1); }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); cursor: pointer; list-style: none; }
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { background: var(--paper-sunken); }
.theme-toggle .when-light, .theme-toggle .when-dark { display: none; }
:root[data-theme-choice="light"] .theme-toggle .when-system, :root[data-theme-choice="dark"] .theme-toggle .when-system { display: none; }
:root[data-theme-choice="light"] .theme-toggle .when-light, :root[data-theme-choice="dark"] .theme-toggle .when-dark { display: inline; }
.menu { position: static; }
.menu[open] > summary { background: var(--paper-sunken); }
.menu-panel { position: absolute; left: 0; right: 0; top: 100%; display: grid; padding: var(--space-2) var(--space-4) var(--space-4); background: var(--paper-raised); border-bottom: 1px solid var(--rule); }
.menu-panel a { display: block; padding: var(--space-3) 0; color: var(--ink); border-bottom: 1px solid var(--rule); font-size: 16px; }
.menu-panel a.sub { padding-left: var(--space-4); color: var(--ink-muted); font-size: 15px; }
.menu-panel a:last-child { border-bottom: 0; }

/* ------------------------------------------------------------------ footer */
.site-footer { margin-top: var(--space-16); padding-block: var(--space-12); border-top: 1px solid var(--rule); background: var(--paper-sunken); font-size: 14px; line-height: 21px; }
.footer-grid { display: grid; gap: var(--space-8); }
.footer-brand { display: grid; gap: var(--space-2); max-width: 26rem; }
.footer-lockup { margin-right: 0; margin-bottom: var(--space-1); }
.footer-col { display: grid; align-content: start; gap: var(--space-2); }
.footer-col h2 { font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); margin-bottom: var(--space-1); }
.footer-col a { color: var(--ink); }

/* ------------------------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-4); border: 1px solid transparent; border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: 15px; font-weight: 600; line-height: 1; text-decoration: none; cursor: pointer; }
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover { opacity: 0.9; }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--ink-muted); }
.btn.secondary:hover { background: var(--paper-sunken); }
.btn.quiet { background: transparent; color: var(--ink); }
.btn.quiet:hover { background: var(--paper-sunken); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.tool-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 var(--space-2); border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--paper-raised); color: var(--ink); font-family: var(--font-sans); font-size: 13px; font-weight: 600; line-height: 1; cursor: pointer; text-decoration: none; }
.tool-btn:hover { background: var(--paper-sunken); text-decoration: none; }
.tool-btn.done { color: var(--edition); border-color: var(--edition); }
.field-label { display: block; margin-bottom: 6px; font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
input[type="text"], textarea { width: 100%; min-width: 0; padding: 10px var(--space-3); border: 1px solid var(--ink-muted); border-radius: var(--radius-sm); background: var(--paper-raised); color: var(--ink); font-family: var(--font-mono); font-size: 16px; }
input[type="text"] { height: 44px; letter-spacing: 0.06em; text-transform: uppercase; }
input::placeholder { color: var(--ink-muted); opacity: 0.7; text-transform: uppercase; }
textarea { font-family: var(--font-sans); font-size: 14px; line-height: 21px; resize: vertical; }
.field { display: flex; gap: var(--space-2); }

/* chips and tags */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.chip-link { display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--space-3); border: 1px solid var(--rule); border-radius: var(--radius-pill); background: var(--paper-raised); color: var(--ink); font-size: 14px; }
.chip-link:hover { border-color: var(--edition); color: var(--edition); text-decoration: none; }
.chips.small .chip-link { min-height: 26px; padding: 0 10px; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px var(--space-2); border-radius: var(--radius-pill); font-family: var(--font-sans); font-size: 12px; line-height: 18px; font-weight: 600; white-space: nowrap; }
.chip.pass, .chip.current { background: var(--pass-soft); color: var(--pass); }
.chip.warn { border: 1px solid var(--warn); color: var(--warn); }
.chip.fail, .chip.missing { background: var(--fail-soft); color: var(--fail); }
.chip.older { border: 1px solid var(--ink-muted); color: var(--ink); }
.tag { display: inline-block; padding: 0 var(--space-2); border-radius: var(--radius-pill); background: var(--edition-soft); color: var(--edition); font-size: 12px; line-height: 20px; font-weight: 600; white-space: nowrap; }

/* ------------------------------------------------------------------ components */
/* EditionStamp */
.stamp { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: 10px var(--space-3); max-width: 680px; background: var(--paper-sunken); border: 1px solid var(--rule); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: var(--type-stamp-size); line-height: var(--type-stamp-line); font-weight: var(--type-stamp-weight); font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.stamp .ed { color: var(--ink); }
.stamp a { text-decoration: underline; }
.pass { display: inline-flex; align-items: center; gap: 6px; color: var(--pass); }

/* Disclosure */
.disclosure { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); color: var(--ink-muted); max-width: 680px; }
.disclosure .mark { display: inline-block; padding: 1px var(--space-2); border: 1px solid var(--rule); border-radius: var(--radius-pill); background: var(--paper-sunken); color: var(--ink); font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; }
.disclosure a { text-decoration: underline; }

/* "Looks right" (D-055): how many people have checked a book or a chapter, or the invitation, with links to report
   or fix an error. Counts only, never names; never in the pass colour, which belongs to examples passing. */
.checked { margin-top: var(--space-2); color: var(--ink-muted); max-width: 680px; }
.checked a { text-decoration: underline; }

/* notices and breadcrumbs */
.notice { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3) var(--space-4); background: var(--paper-sunken); border: 1px solid var(--rule); border-radius: var(--radius-sm); max-width: 680px; }
.notice .icon { margin-top: 2px; color: var(--ink-muted); }
.notice.draft { border-color: var(--warn); margin-bottom: var(--space-6); }
.notice.draft .icon { color: var(--warn); }
/* The preview banner opens every page of a book that isn't verified yet. Like the draft notice above, it is
   marked in warn, with words and an icon. */
.preview-band { border-bottom: 1px solid var(--warn); background: var(--paper-sunken); }
.preview-banner { display: flex; gap: var(--space-2); align-items: center; margin-block: 0; padding-block: var(--space-3); font-family: var(--font-sans); font-size: var(--type-ui-strong-size); line-height: var(--type-ui-strong-line); font-weight: var(--type-ui-strong-weight); color: var(--ink); }
.preview-banner .icon { flex: none; color: var(--warn); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 20px; }
.breadcrumb li + li::before { content: "›"; margin-right: var(--space-2); color: var(--ink-muted); }
.breadcrumb span { color: var(--ink-muted); }

/* covers: images that never change with the theme */
.cover-frame svg, .hero-cover svg, .book-card-cover svg { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); outline: 1px solid var(--rule); }

/* HistoryTape: cover tokens in both themes */
.tape-panel { margin-block: var(--space-6); padding: var(--space-4); background: var(--cover-ground); border-radius: var(--radius-md); display: flex; flex-direction: column; gap: 14px; }
.tape-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12px; line-height: 16px; color: var(--cover-muted); }
.tape-head b { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.tape-head a { margin-left: auto; color: var(--cover-tail); text-decoration: underline; }
.tape-body { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; }
.tape-legend { position: relative; flex: none; width: 104px; height: 140px; }
.tape-legend span { position: absolute; right: 0; font-size: 12px; line-height: 16px; white-space: nowrap; color: var(--cover-paper); }
.tape-scroll { flex: 0 1 auto; min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; padding: 6px 4px 2px; }
/* More history beyond an edge: the strip fades into the panel there (tape.js) */
.tape-scroll.more-before { mask-image: linear-gradient(to right, transparent, #000 48px); }
.tape-scroll.more-after { mask-image: linear-gradient(to left, transparent, #000 48px); }
.tape-scroll.more-before.more-after { mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent); }
.tape { position: relative; display: inline-block; vertical-align: top; }
.tape svg { display: block; max-width: none; }
.tape .strip { fill: var(--cover-paper); }
.tape .hole { fill: var(--cover-ground); }
.tape-cols { position: absolute; top: 0; display: flex; }
.tape-col { width: 20px; height: 140px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.tape-col.newest { outline: 2px solid var(--cover-tail); outline-offset: 2px; border-radius: 4px; }
.tape-col:focus-visible { outline: 2px solid var(--cover-paper); outline-offset: 2px; }
.tape-ends { display: flex; justify-content: space-between; gap: var(--space-3); margin-top: 10px; white-space: nowrap; font-family: var(--font-mono); font-size: 10px; line-height: 14px; font-weight: 500; color: var(--cover-muted); }
.tape-card { flex: 1 1 180px; max-width: 240px; padding: 10px 12px; background: var(--paper-raised); border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 4px; }
.tape-card .when { font-family: var(--font-mono); font-size: 11px; line-height: 16px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink); }
.tape-card .kinds { font-size: 13px; line-height: 18px; color: var(--ink); }
.tape-card .count { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--edition); }

/* CodeExample */
.example { position: relative; margin: var(--space-6) calc(var(--space-4) * -1); font-family: var(--font-sans); }
.example-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "file actions" "ver ver"; align-items: center; gap: 2px var(--space-3); padding: var(--space-2) var(--space-4); background: var(--paper-raised); border-block: 1px solid var(--rule); }
.example-head .file { grid-area: file; font-family: var(--font-mono); font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.example-head .ver { grid-area: ver; font-family: var(--font-mono); font-size: 12px; line-height: 18px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.example-actions { grid-area: actions; display: flex; align-items: center; gap: var(--space-2); }
.code-frame { position: relative; background: var(--paper-sunken); }
.code-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.code-scroll:focus-visible { outline-offset: -2px; }
.code-frame.can-scroll:not(.at-end)::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 40px; background: linear-gradient(to right, transparent, var(--paper-sunken)); pointer-events: none; }
.example pre { margin: 0; font-family: var(--font-mono); font-size: var(--type-code-size); line-height: var(--type-code-line); color: var(--ink); letter-spacing: 0; tab-size: 4; }
.example .code { padding: var(--space-3) 0; font-weight: var(--type-code-weight); }
.example code { font-family: inherit; font-size: inherit; padding: 0; background: none; border-radius: 0; }
.ln { display: block; padding: 0 var(--space-4); white-space: pre; min-width: max-content; }
.ln i { display: inline-block; width: 2.5ch; margin-right: var(--space-3); color: var(--ink-muted); font-style: normal; text-align: right; user-select: none; -webkit-user-select: none; }
.ln.changed { background: var(--changed); }
/* Syntax (D-038): an editor's palette, one per theme. Every color is 4.5:1 or better on the code ground
   and on the changed-line ground. */
.syntax .k { color: var(--syn-keyword); }
.syntax .kd { color: var(--syn-decl); }
.syntax .s { color: var(--syn-string); }
.syntax .se { color: var(--syn-escape); }
.syntax .n { color: var(--syn-number); }
.syntax .c { color: var(--syn-comment); font-style: italic; }
.syntax .f { color: var(--syn-function); }
.syntax .t { color: var(--syn-type); }
.syntax .v { color: var(--syn-variable); }
.syntax .p { color: var(--syn-decl); font-style: italic; }
.syntax .d { color: var(--syn-function); }
.syntax .b1 { color: var(--syn-bracket-1); }
.syntax .b2 { color: var(--syn-bracket-2); }
.syntax .b3 { color: var(--syn-bracket-3); }
.margin-note { display: none; }
.output { border-bottom: 1px solid var(--rule); }
.output-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); background: var(--paper-raised); border-top: 1px solid var(--rule); }
.output-head .label { font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
.output-head .cmd { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); padding: 0; background: none; }
.output-head .cmd::before { content: "$ "; }
.output .code-frame { background: var(--paper-raised); }
.output .code-frame.can-scroll:not(.at-end)::after { background: linear-gradient(to right, transparent, var(--paper-raised)); }
.output pre { padding: var(--space-1) var(--space-4) var(--space-3) calc(var(--space-4) + 2.5ch + var(--space-3)); white-space: pre; width: max-content; min-width: 100%; }
.example-note { padding: var(--space-2) var(--space-4) 0; font-size: 12px; line-height: 18px; color: var(--ink-muted); }
.mark-changed { padding: 0 var(--space-1); background: var(--changed); color: var(--ink); }
.example > .code-frame { border-bottom: 1px solid var(--rule); }

/* section heading tools */
.h-tools { display: inline-flex; gap: 2px; vertical-align: middle; opacity: 0.6; transform: translateY(-2px); }
.prose h2:hover .h-tools, .prose h3:hover .h-tools, .h-tools:focus-within { opacity: 1; }
.h-tool { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-muted); cursor: pointer; }
.h-tool:hover { background: var(--paper-sunken); color: var(--edition); text-decoration: none; }
.changed-tag { display: block; width: fit-content; margin-top: var(--space-2); padding: 0 var(--space-2); background: var(--changed); color: var(--ink); border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: 12px; line-height: 22px; font-weight: 600; }
.changed-tag.earlier { background: transparent; color: var(--ink-muted); border: 1px solid var(--rule); line-height: 20px; }   /* changed before this edition (D-061) */
.checked-tag { display: block; width: fit-content; margin-top: var(--space-2); padding: 0 var(--space-2); background: var(--paper-sunken); color: var(--ink-muted); border: 1px solid var(--rule); border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: 12px; line-height: 20px; font-weight: 600; }

/* cite dialog and toast */
.cite-dialog { width: min(40rem, calc(100vw - 2 * var(--space-4))); padding: var(--space-4) var(--space-6) var(--space-6); border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--paper-raised); color: var(--ink); }
.cite-dialog::backdrop { background: rgb(15 20 27 / 0.55); }
.cite-dialog form { display: grid; gap: var(--space-3); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { font-family: var(--font-serif); font-size: var(--type-heading-size); line-height: var(--type-heading-line); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.cite-what { margin: 0; font-family: var(--font-serif); font-size: 17px; line-height: 26px; color: var(--ink); }
.cite-styles { margin: 0; padding: 0; border: 0; min-width: 0; }
.segmented { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: var(--radius-md); background: var(--paper-sunken); }
.segmented label { position: relative; flex: 1 1 auto; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; color: var(--ink-muted); white-space: nowrap; }
.segmented input:hover + span { color: var(--ink); }
.segmented input:checked + span { background: var(--paper-raised); color: var(--ink); box-shadow: 0 1px 2px rgb(15 20 27 / 0.12), inset 0 0 0 1px var(--rule); }
.segmented input:focus-visible + span { outline: 2px solid var(--edition); outline-offset: 1px; }
.cite-dialog textarea { field-sizing: content; min-height: calc(4 * 21px + 22px); max-height: 50vh; font-size: 15px; line-height: 23px; }
.cite-dialog textarea[data-style="bibtex"] { font-family: var(--font-mono); font-size: 13px; line-height: 20px; white-space: pre; overflow-x: auto; }
.cite-note, .cite-hint { margin: calc(-1 * var(--space-1)) 0 0; }
.cite-hint { font-size: 14px; line-height: 21px; color: var(--ink); }
.cite-foot { margin: 0; padding-top: var(--space-3); border-top: 1px solid var(--rule); }
.toast { position: fixed; left: 50%; bottom: var(--space-6); z-index: 60; transform: translate(-50%, 8px); padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill); background: var(--ink); color: var(--paper); font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* book cards */
.book-grid { display: grid; gap: var(--space-4); }
.book-card { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: var(--space-4); padding: var(--space-4); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.book-card:hover, .chapter-item:hover, .pager-link:hover, .steps li:hover, .pillar:hover { border-color: color-mix(in srgb, var(--edition) 45%, var(--rule)); }
.section-alt .book-card { background: var(--paper); }
.book-card-body { display: grid; align-content: start; gap: var(--space-2); }
.book-card h3 { font-family: var(--font-serif); font-size: 20px; line-height: 26px; font-weight: 600; }
.book-card h3 a { color: var(--ink); }
.book-card-summary { color: var(--ink-muted); }
.card-stamp { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; font-family: var(--font-mono); font-size: 12px; line-height: 18px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
/* A preview's tile (D-051): no cover and no stamp until the first edition is stamped. A dashed, hatched slot
   keeps the cover's place and shape, reserved, and the preview banner's words and icon open the tile. */
.book-card-slot { display: block; align-self: start; aspect-ratio: 5 / 8; border: 1px dashed var(--ink-muted); border-radius: var(--radius-sm); background: repeating-linear-gradient(-45deg, var(--paper-sunken) 0 7px, var(--rule) 7px 8px); }
.card-preview { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; color: var(--ink); }
.card-preview .icon { color: var(--warn); }
.card-preview strong { font-weight: 600; }

/* ------------------------------------------------------------------ home */
.hero { position: relative; overflow: hidden; padding-block: var(--space-8) var(--space-8); }
.hero::before { content: ""; position: absolute; inset: -30% -20% auto auto; width: 80vmax; height: 80vmax; background: radial-gradient(closest-side, var(--edition-soft), transparent); opacity: 0.75; pointer-events: none; }
.hero > .wrap { position: relative; }
.eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); width: fit-content; padding: 4px var(--space-3) 4px var(--space-2); border: 1px solid var(--rule); border-radius: var(--radius-pill); background: var(--paper-raised); font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink); }
.eyebrow .icon { color: var(--edition); }
.hero-grid { display: grid; gap: var(--space-8); align-items: end; }
.hero-copy { display: grid; gap: var(--space-5, 20px); max-width: 44rem; }
.hero-lede { font-size: clamp(1.125rem, 1.05rem + 0.35vw, 1.3rem); line-height: 1.6; color: var(--ink); max-width: 38rem; }
.hero-copy .actions { margin-top: var(--space-2); }
.hero-copy .actions .btn { flex: 1 1 auto; }
.hero-book { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: var(--space-4); padding: var(--space-3); border: 1px solid var(--rule); border-radius: var(--radius-md); background: color-mix(in srgb, var(--paper-raised) 80%, transparent); color: var(--ink); }
.hero-book:hover { text-decoration: none; border-color: color-mix(in srgb, var(--edition) 45%, var(--rule)); }
.hero-cover { display: block; }
.hero-book-caption { display: grid; gap: var(--space-1); font-size: 13px; line-height: 20px; }
.hero-book-title { font-family: var(--font-serif); font-size: 19px; line-height: 26px; font-weight: 600; width: fit-content; }

/* The signature: a band of real punched tape, spelling a phrase anyone can decode. */
.tape-band { margin: 0; padding-block: var(--space-6) var(--space-4); background: var(--cover-ground); overflow: hidden; }
.tape-band-strip { padding-left: max(var(--space-4), calc((100vw - 1200px) / 2 + var(--space-4))); }
.tape-band-strip svg { display: block; height: clamp(64px, 7vw + 30px, 104px); width: auto; max-width: none; }
.tape-band figcaption { margin-top: var(--space-3); font-size: 13px; line-height: 20px; color: var(--cover-muted); }
.tape-band q { color: var(--cover-paper); quotes: "\201C" "\201D"; }

.facts { border-bottom: 1px solid var(--rule); background: var(--paper-raised); }
.facts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6) var(--space-4); margin: 0; padding-block: var(--space-8); }
.facts-grid div { display: grid; gap: var(--space-1); align-content: start; }
.facts-grid dd { margin: 0; font-family: var(--font-serif); font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem); line-height: 1.1; font-weight: 600; color: var(--press); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.facts-grid dt { font-size: 14px; line-height: 20px; color: var(--ink-muted); }

/* Bento: the proof, one tile per thing a reader can check */
.bento { display: grid; gap: var(--space-4); }
.tile { position: relative; display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-6) var(--space-4); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius-md); min-width: 0; }
.tile .step-icon { flex: none; }
.tile:hover { border-color: color-mix(in srgb, var(--edition) 45%, var(--rule)); }
.tile h3 { font-family: var(--font-serif); font-size: 20px; line-height: 27px; font-weight: 600; }
.tile > p:not(.kicker) { color: var(--ink-muted); }
.tile .tape-panel { margin: var(--space-2) 0 0; }
.tile-link { display: inline-flex; align-items: center; gap: var(--space-1); width: fit-content; margin-top: auto; padding-top: var(--space-2); font-weight: 600; }
.legend { display: grid; gap: var(--space-3); margin: 0; }
.legend div { display: grid; gap: 2px; padding-left: var(--space-3); border-left: 2px solid var(--rule); }
.legend dt { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--ink); }
.legend dd { margin: 0; color: var(--ink-muted); }
.legend-compact { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--space-3) var(--space-4); }
.legend-compact dd { font-size: 14px; line-height: 20px; }
.tier-list { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; color: var(--ink-muted); }
.tier-list b { color: var(--ink); font-weight: 600; }
.mini-example { display: grid; border: 1px solid var(--rule); border-radius: var(--radius-sm); overflow: hidden; background: var(--paper-sunken); }
.mini-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--paper-raised); border-bottom: 1px solid var(--rule); }
.mini-head .file { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.mini-example pre { margin: 0; padding: var(--space-3); overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 21px; color: var(--ink); }
.mini-ln { display: block; white-space: pre; }
.mini-output { border-top: 1px solid var(--rule); background: var(--paper-raised); }
.mini-output .label { display: block; padding: var(--space-2) var(--space-3) 0; font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
.mini-output pre { padding-top: var(--space-1); color: var(--ink); }
.mini-ver { padding: var(--space-2) var(--space-3); border-top: 1px solid var(--rule); background: var(--paper-raised); font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }
.inline-check { display: flex; gap: var(--space-2); }

.steps { position: relative; display: grid; gap: var(--space-4); margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; display: grid; gap: var(--space-2); align-content: start; padding: var(--space-6) var(--space-4); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-md); counter-increment: step; }
.steps li::before { content: counter(step, decimal-leading-zero); position: absolute; top: var(--space-6); right: var(--space-4); font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--ink-muted); }
.steps h3 { font-family: var(--font-serif); font-size: 19px; line-height: 26px; font-weight: 600; }
.steps p { color: var(--ink-muted); }
.step-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-pill); background: var(--edition-soft); color: var(--edition); }

/* ------------------------------------------------------------------ book page */
.book-hero-band { position: relative; overflow: hidden; border-bottom: 1px solid var(--rule); background: var(--paper-raised); }
.book-hero-band::before { content: ""; position: absolute; inset: -40% -25% auto auto; width: 60vmax; height: 60vmax; background: radial-gradient(closest-side, var(--edition-soft), transparent); opacity: 0.6; pointer-events: none; }
.book-hero { position: relative; display: grid; grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: "crumb crumb" "cover title" "stamp stamp" "disc disc" "sum sum" "act act"; gap: var(--space-3) var(--space-4); align-items: center; padding-block: var(--space-6) var(--space-8); }
.bh-crumb { grid-area: crumb; }
.bh-cover { grid-area: cover; align-self: start; }
.bh-title { grid-area: title; }
.byline { margin: var(--space-2) 0 0; font-size: 17px; line-height: 26px; color: var(--ink-muted); }
.bh-stamp { grid-area: stamp; }
.bh-disc { grid-area: disc; }
.bh-summary { grid-area: sum; }
.reader { margin: var(--space-3) 0 0; max-width: var(--measure-reading); }
.reader .rail-title { display: block; margin-bottom: var(--space-1); }
.bh-actions { grid-area: act; margin-top: var(--space-2); }
/* A preview's hero has no cover, stamp or disclosure: one column at every width */
.book-hero.preview { grid-template-columns: minmax(0, 1fr); grid-template-areas: "crumb" "title" "sum" "act"; grid-template-rows: none; }
/* minmax(0, 1fr): a long history tape scrolls inside its panel instead of widening the page */
.book-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); padding-block: var(--space-8) var(--space-12); }
.book-body { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); align-content: start; }
.book-body .tape-panel { margin: 0; }
.book-aside { min-width: 0; }
.aside-sticky { display: grid; gap: var(--space-4); }
.aside-block { display: grid; gap: var(--space-2); }
.rail-title { font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
.rail-facts { display: grid; gap: var(--space-3); margin: 0; min-width: 0; }
.rail-facts dt { font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
.rail-facts dd { margin: 0; font-size: 14px; line-height: 21px; }
.rail-facts .code { margin-right: var(--space-1); }
.rail-note { display: block; margin-top: var(--space-1); font-size: 13px; line-height: 20px; }
.chapter-list { display: grid; gap: var(--space-3); margin: var(--space-4) 0 0; padding: 0; list-style: none; }
.chapter-item { border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--paper-raised); }
.chapter-link { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); font-family: var(--font-serif); font-size: 19px; line-height: 26px; font-weight: 600; color: var(--ink); }
.chapter-link:hover { text-decoration: none; color: var(--edition); }
.chapter-link .icon { margin-left: auto; color: var(--edition); }
.chapter-n { display: inline-grid; place-items: center; min-width: 32px; height: 32px; border-radius: var(--radius-pill); background: var(--edition-soft); color: var(--edition); font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.section-list { margin: 0; padding: 0 var(--space-4) var(--space-4) calc(var(--space-4) + 32px + var(--space-3)); list-style: none; display: grid; gap: var(--space-2); }
.section-list .level-3 { padding-left: var(--space-4); }

/* ------------------------------------------------------------------ chapter page */
.chapter-page { display: grid; gap: var(--space-8); padding-block: var(--space-6) var(--space-12); }
.chapter { min-width: 0; }
.chapter-head { display: grid; gap: var(--space-3); margin-bottom: var(--space-8); }
.chapter-tools-mobile { display: grid; gap: var(--space-2); margin-top: var(--space-2); max-width: var(--measure-reading); }
.toc-mobile { border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--paper-raised); }
.toc-mobile summary { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-3); cursor: pointer; list-style: none; font-weight: 600; }
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile summary .icon:last-child { margin-left: auto; }
.toc-mobile .toc { padding: var(--space-2) var(--space-3) var(--space-3); border-top: 1px solid var(--rule); }
.toc { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; font-size: 14px; line-height: 20px; }
.toc a { display: flex; align-items: center; gap: var(--space-2); padding: 6px var(--space-3); color: var(--ink-muted); border-left: 2px solid var(--rule); }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a[aria-current="true"] { color: var(--edition); border-left-color: var(--edition); font-weight: 600; }
.toc .level-3 a { padding-left: var(--space-6); }
.dot-changed { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--changed); box-shadow: 0 0 0 1px var(--warn); }
.chapter-rail { display: none; }
.prose { font-family: var(--font-serif); font-size: var(--type-reading-size); line-height: var(--type-reading-line); max-width: var(--measure-reading); }
.prose p, .prose ul, .prose ol { margin: 0 0 var(--space-6); }
.prose ul, .prose ol { padding-left: var(--space-6); }
.prose li + li { margin-top: var(--space-2); }
.prose h2, .prose h3 { font-family: var(--font-serif); font-weight: 600; color: var(--ink); scroll-margin-top: 80px; }
.prose h2 { font-size: var(--type-heading-size); line-height: var(--type-heading-line); margin: var(--space-12) 0 var(--space-4); }
.prose h3 { font-size: 19px; line-height: 28px; margin: var(--space-8) 0 var(--space-3); }
.prose > :first-child { margin-top: 0; }
.prose :not(pre) > code:not(.cmd) { font-family: var(--font-mono); font-size: 0.82em; padding: 1px 5px; background: var(--code-inline); border: 1px solid var(--code-inline-edge); border-radius: var(--radius-sm); color: var(--ink); white-space: nowrap; }
.prose a { text-decoration: underline; }
.prose > pre { position: relative; margin: 0 0 var(--space-6); padding: var(--space-3) var(--space-4); overflow-x: auto; background: var(--paper-sunken); border: 1px solid var(--rule); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: var(--type-code-size); line-height: var(--type-code-line); }
.prose > pre code { font-family: inherit; }
.code-block[data-lang]:not([data-lang=""])::before { content: attr(data-lang); display: block; margin: calc(var(--space-3) * -1) calc(var(--space-4) * -1) var(--space-3); padding: 4px var(--space-4); border-bottom: 1px solid var(--rule); background: var(--paper-raised); font-family: var(--font-sans); font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); position: sticky; left: 0; }
.pager { display: grid; gap: var(--space-3); margin-top: var(--space-12); padding-top: var(--space-6); border-top: 1px solid var(--rule); max-width: var(--measure-reading); }
.pager-link { display: grid; gap: var(--space-1); padding: var(--space-4); border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--paper-raised); }
.pager-link:hover { border-color: var(--edition); text-decoration: none; }
.pager-label { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--type-label-size); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
.pager-title { font-family: var(--font-serif); font-size: 18px; line-height: 26px; font-weight: 600; color: var(--ink); }
.pager-link.next { text-align: right; justify-items: end; }

.progress { position: fixed; top: 0; left: 0; right: 0; z-index: 30; height: 2px; background: var(--edition); transform: scaleX(0); transform-origin: 0 50%; pointer-events: none; }

/* ------------------------------------------------------------------ changelog, check, editorial */
.changelog { display: grid; gap: var(--space-4); margin: var(--space-8) 0 0; padding: 0; list-style: none; max-width: 52rem; }
.change-card { display: grid; gap: var(--space-3); padding: var(--space-4); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius-md); scroll-margin-top: 80px; }
.change-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2) var(--space-3); }
.change-head h2 { font-family: var(--font-mono); font-size: 18px; line-height: 26px; font-weight: 500; }
.change-head h2 a { color: var(--ink); }
.change-date { margin-left: auto; font-size: 13px; color: var(--ink-muted); }
.kind-list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.kind-list li { padding: 0 var(--space-2); border: 1px solid var(--rule); border-radius: var(--radius-pill); font-size: 12px; line-height: 22px; font-weight: 600; color: var(--ink); }
.change-list { margin: 0; padding-left: var(--space-6); display: grid; gap: var(--space-1); }
.change-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); margin: 0; padding-top: var(--space-3); border-top: 1px solid var(--rule); }
.change-meta dt { font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
.change-meta dd { margin: 0; font-size: 14px; }
.change-source { margin: 0; font-size: 14px; }
.check-layout { display: grid; gap: var(--space-12); }
.check-main { max-width: var(--measure-ui); }
.check-form { display: grid; }
.result { margin: var(--space-4) 0; padding: var(--space-4); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius-md); display: grid; gap: 10px; }
.result .line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.result strong { font-size: 15px; font-weight: 600; }
.result ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 21px; }
.result .book { font-family: var(--font-serif); font-style: italic; font-weight: 600; }
.result a { font-weight: 600; }
.answers { display: grid; gap: var(--space-4); margin: 0 0 var(--space-6); }
.answers div { display: grid; gap: var(--space-1); }
.answers dd { margin: 0; color: var(--ink-muted); }
.editorial .prose { margin-bottom: var(--space-6); }
.table-frame { position: relative; max-width: var(--measure-reading); margin: 0 0 var(--space-6); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.table-frame.can-scroll:not(.at-end)::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 40px; background: linear-gradient(to right, transparent, var(--paper-raised)); pointer-events: none; border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.prose table { min-width: 100%; border-collapse: collapse; font-family: var(--font-sans); font-size: 15px; line-height: 22px; font-variant-numeric: tabular-nums; }
.prose th { text-align: left; padding: var(--space-3) var(--space-4); font-size: var(--type-label-size); font-weight: 600; letter-spacing: var(--type-label-tracking); color: var(--ink-muted); border-bottom: 1px solid var(--rule); vertical-align: bottom; }
.prose td { padding: var(--space-3) var(--space-4); vertical-align: top; border-bottom: 1px solid var(--rule); }
.prose tr:last-child td { border-bottom: 0; }
.prose th { min-width: 5.5rem; }
.prose td { white-space: nowrap; }                  /* values never break; tables are short-celled (W-53) */
.prose td:first-child { min-width: 9rem; white-space: normal; }
.table-wrap { max-width: var(--measure-reading); overflow-x: auto; margin: 0 0 var(--space-8); border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--paper-raised); }
.tiers { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 22px; }
.tiers th { text-align: left; padding: var(--space-3) var(--space-4); font-size: var(--type-label-size); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); border-bottom: 1px solid var(--rule); }
.tiers td { padding: var(--space-3) var(--space-4); vertical-align: top; border-bottom: 1px solid var(--rule); }
.tiers tr:last-child td { border-bottom: 0; }
.tiers td:last-child { font-weight: 600; white-space: nowrap; }
.related { display: grid; gap: var(--space-8); margin-top: var(--space-12); }

/* ------------------------------------------------------------------ 640px and up */
@media (min-width: 640px) {
  .wrap { padding-inline: var(--space-6); }
  .display { font-size: var(--type-display-size); line-height: var(--type-display-line); }
  .section-intro h2, .split-intro h2 { font-size: var(--type-title-size); line-height: var(--type-title-line); }
  .example { margin-inline: 0; }
  .example-head { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "file ver actions"; border: 1px solid var(--rule); border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding-inline: var(--space-3); }
  .example > .code-frame, .example .output { border-inline: 1px solid var(--rule); }
  .example > :last-child.code-frame, .example .output:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
  .example-note { padding-inline: 0; }
  .ln { padding-inline: var(--space-3); }
  .output pre { padding-left: calc(var(--space-3) + 2.5ch + var(--space-3)); }
  .output-head { padding-inline: var(--space-3); }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); }
  .book-card { grid-template-columns: 120px minmax(0, 1fr); padding: var(--space-6); gap: var(--space-6); }
  .facts-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pager { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-copy .actions .btn { flex: 0 0 auto; }
  .pager-link.next:only-child { grid-column: 2; }
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-stamp, .tile-tape { grid-column: span 2; }
  .tile { padding: var(--space-6); }
  .book-hero { grid-template-columns: 160px minmax(0, 1fr); grid-template-areas: "crumb crumb" "cover title" "cover stamp" "cover disc" "sum sum" "act act"; }
  .change-meta { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .change-card { padding: var(--space-6); }
  .footer-grid { grid-template-columns: 2fr 1fr 1fr; }
}

/* ------------------------------------------------------------------ 768px and up: the inline navigation */
@media (min-width: 768px) {
  .header-row { min-height: 64px; }
  .nav-inline { display: flex; }
  .menu { display: none; }
  .hero-grid { grid-template-columns: minmax(0, 1fr) 240px; gap: var(--space-8); }
  .hero-book { grid-template-columns: 1fr; padding: var(--space-4); }
  .hero-cover { width: 100%; }
}

/* ------------------------------------------------------------------ 960px and up */
@media (min-width: 960px) {
  .wrap { padding-inline: var(--space-8); }
  .hero { padding-block: var(--space-16) var(--space-12); }
  .hero-grid { grid-template-columns: minmax(0, 1fr) 280px; gap: var(--space-12); }
  .section { padding-block: var(--space-16); }
  .book-hero { grid-template-columns: 240px minmax(0, 1fr); grid-template-areas: "cover crumb" "cover title" "cover stamp" "cover disc" "cover sum" "cover act"; grid-template-rows: auto auto auto auto auto 1fr; column-gap: var(--space-12); align-items: start; padding-block: var(--space-12); }
  .bh-title { margin-top: var(--space-1); }
  .book-page { grid-template-columns: minmax(0, 1fr) 280px; column-gap: var(--space-12); }
  .aside-sticky { position: sticky; top: 88px; }
  .check-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 22rem); align-items: start; }
}

/* ------------------------------------------------------------------ 1200px and up: the chapter's margins */
@media (min-width: 1100px) {
  .bento { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tile-stamp, .tile-tape { grid-column: span 4; }
  .tile-code { grid-column: span 2; grid-row: span 2; }
  .tile-people, .tile-check, .tile-free { grid-column: span 2; }
}

@media (min-width: 1200px) {
  .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .steps::before { content: ""; position: absolute; left: 36px; right: 36px; top: 36px; border-top: 1px dashed var(--rule); }
  .facts-grid > div + div { padding-left: var(--space-6); border-left: 1px solid var(--rule); }
  .chapter-page { grid-template-columns: 150px minmax(0, var(--measure-reading)) 256px; justify-content: space-between; column-gap: var(--space-8); }
  .chapter { grid-column: 2; }
  .chapter-tools-mobile { display: none; }
  .chapter-rail { display: block; grid-column: 3; }
  .rail-sticky { position: sticky; top: 88px; display: grid; gap: var(--space-4); }
  .rail-title { font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: 600; letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--ink-muted); }
  .rail-actions { display: grid; gap: var(--space-2); justify-items: start; }
  .chapter-page .margin-note { display: block; position: absolute; right: calc(100% + var(--space-4)); top: calc(var(--space-3) + var(--line) * var(--type-code-line)); width: 140px; text-align: right; font-size: 12px; line-height: var(--type-code-line); font-weight: 600; color: var(--ink); }
  .chapter-page .margin-note::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: var(--space-2); border-radius: 50%; background: var(--changed); box-shadow: 0 0 0 1px var(--warn); vertical-align: 1px; }
}

/* ------------------------------------------------------------------ motion (D-039)
   Every effect has a purpose and a reduced-motion fallback: with reduced motion, pages swap instantly,
   nothing reveals and the tape doesn't feed. Content is complete with all of it stripped out. */
.site-header { view-transition-name: site-header; }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(*) { animation-duration: 340ms; animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1); }
  ::view-transition-old(root) { animation: 160ms ease-out both re-fade-out; }
  ::view-transition-new(root) { animation: 280ms cubic-bezier(0.2, 0.7, 0.2, 1) 60ms both re-rise-in; }
  ::view-transition-old(book-title), ::view-transition-new(book-title),
  ::view-transition-old(chapter-title), ::view-transition-new(chapter-title) { height: 100%; width: auto; object-fit: none; object-position: left top; }
  html:active-view-transition-type(forwards) { &::view-transition-old(root) { animation: 220ms ease-in both re-slide-out-left; } &::view-transition-new(root) { animation: 300ms cubic-bezier(0.2, 0.7, 0.2, 1) both re-slide-in-right; } }
  html:active-view-transition-type(backwards) { &::view-transition-old(root) { animation: 220ms ease-in both re-slide-out-right; } &::view-transition-new(root) { animation: 300ms cubic-bezier(0.2, 0.7, 0.2, 1) both re-slide-in-left; } }

  .tape-band-strip svg { animation: re-feed 1600ms cubic-bezier(0.16, 0.8, 0.2, 1) 120ms both; }

  @supports (animation-timeline: view()) {
    .reveal { animation: re-reveal linear both; animation-timeline: view(); animation-range: entry 0% cover 22%; }
  }

  @supports (interpolate-size: allow-keywords) {
    :root { interpolate-size: allow-keywords; }
    details::details-content { block-size: 0; overflow: clip; transition: block-size 220ms cubic-bezier(0.2, 0.7, 0.2, 1), content-visibility 220ms allow-discrete; }
    details[open]::details-content { block-size: auto; }
  }

  .segmented span { transition: background-color 150ms, color 150ms, box-shadow 150ms; }
  .cite-dialog, .cite-dialog::backdrop { transition: opacity 180ms ease, transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1), overlay 200ms allow-discrete, display 200ms allow-discrete; }
  .cite-dialog:not([open]) { opacity: 0; transform: translateY(8px) scale(0.98); }
  @starting-style { .cite-dialog[open] { opacity: 0; transform: translateY(8px) scale(0.98); } .cite-dialog[open]::backdrop { opacity: 0; } }

  html { scroll-behavior: smooth; }
  .book-card, .chapter-item, .pager-link, .steps li, .tile, .hero-book { transition: border-color 150ms; }
  a, .btn, .tool-btn, .icon-btn, .h-tools, .chip-link, .toast { transition: opacity 150ms, color 150ms, background-color 150ms, border-color 150ms, transform 150ms; }
}
@keyframes re-fade-out { to { opacity: 0; } }
@keyframes re-rise-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes re-slide-out-left { to { opacity: 0; transform: translateX(-40px); } }
@keyframes re-slide-in-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes re-slide-out-right { to { opacity: 0; transform: translateX(40px); } }
@keyframes re-slide-in-left { from { opacity: 0; transform: translateX(-40px); } }
@keyframes re-feed { from { transform: translateX(30vw); opacity: 0; } 30% { opacity: 1; } }
@keyframes re-reveal { from { opacity: 0; transform: translateY(18px); } }
@keyframes re-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* The chapter's reading progress follows the scroll position itself where the browser can. */
@supports (animation-timeline: scroll()) {
  .progress { animation: re-progress linear both; animation-timeline: scroll(root); }
}

@media print {
  .site-header, .site-footer, .h-tools, .example-actions .tool-btn, .chapter-rail, .chapter-tools-mobile, .pager, .tape-panel, .actions { display: none !important; }
  .code-scroll { overflow: visible; }
  .ln { white-space: pre-wrap; }
}
