/* MyReLab site styles, following the MyReLab design system.
   No build step: plain CSS, mobile first. Every color is a token. */

@font-face { font-family: "et-book"; src: url("/static/fonts/et-book-roman-line-figures.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "et-book"; src: url("/static/fonts/et-book-display-italic-old-style-figures.woff") format("woff"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "et-book"; src: url("/static/fonts/et-book-semi-bold-old-style-figures.woff") format("woff"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "et-book"; src: url("/static/fonts/et-book-bold-line-figures.woff") format("woff"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
    --surface: #ffffff;
    --surface-raised: #f4f6f9;
    --surface-sunken: #e9edf2;
    --surface-code: #f5f5ee;
    --paper: #fffff8;
    --ink: #1b1f24;
    --ink-muted: #56606b;
    --rule: #d5dae0;
    --rule-strong: #7a8592;
    --brand: #0a68b4;
    --brand-strong: #084f89;
    --on-brand: #ffffff;
    --brand-tint: #e8f1fa;
    --accent: #e47400;
    --accent-text: #a85500;
    --accent-tint: #fff4e8;
    --deep: #16293b;
    --on-deep: #ffffff;
    --on-deep-muted: #b9c6d3;
    --success: #0f6b6b;
    --success-tint: #e6f4f3;
    --danger: #b3261e;
    --danger-tint: #fdeeed;
    --focus: #0a68b4;
    --logo-ground: #ffffff;
    --figure-ground: #ffffff;

    --shadow-raised: 0 1px 2px rgba(22, 41, 59, 0.08), 0 4px 16px rgba(22, 41, 59, 0.10);
    --shadow-overlay: 0 4px 16px rgba(0, 0, 0, 0.3);

    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px;
    --space-8: 32px; --space-12: 48px; --space-16: 64px; --space-24: 96px;
    --radius-sm: 2px; --radius-md: 4px; --radius-lg: 6px;
    --measure-main: 40rem; --measure-margin: 17rem; --measure-page: 48rem; --measure-wide: 76rem;

    --font-serif: "et-book", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
    --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --surface: #14171c;
        --surface-raised: #1c2027;
        --surface-sunken: #0e1014;
        --surface-code: #20232a;
        --paper: #181a1c;
        --ink: #e8eaed;
        --ink-muted: #a6aeb8;
        --rule: #343a43;
        --rule-strong: #7d8794;
        --brand: #6db3ee;
        --brand-strong: #9ccbf5;
        --on-brand: #0b1f33;
        --brand-tint: #142a40;
        --accent: #f0902e;
        --accent-text: #f5a04a;
        --accent-tint: #33230f;
        --deep: #0b141d;
        --on-deep: #e8eaed;
        --on-deep-muted: #9aa7b4;
        --success: #5cc8c0;
        --success-tint: #102b2a;
        --danger: #f28b82;
        --danger-tint: #331614;
        --focus: #9ccbf5;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body { margin: 0; font: 400 1rem/1.55 var(--font-sans); color: var(--ink); background: var(--surface); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; }
img, svg { max-width: 100%; height: auto; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; }
.muted { color: var(--ink-muted); }
.eyebrow { font: 600 0.75rem/1.3 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); margin: 0; }
.lede { font: 400 1.375rem/1.5 var(--font-serif); margin: 0; }
.more { font-weight: 600; text-decoration: none; color: var(--brand); }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem 1rem; z-index: 30; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Header and footer */
.site-header { border-bottom: 1px solid var(--rule); background: var(--surface); }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-6); max-width: var(--measure-wide); margin: 0 auto; padding: var(--space-3) var(--space-6); }
.site-nav .brand { display: flex; align-items: center; gap: var(--space-3); font: 400 1.375rem/1 var(--font-serif); color: var(--ink); text-decoration: none; margin-right: auto; white-space: nowrap; }
.site-nav .brand img { height: 2.75rem; width: auto; display: block; background: var(--logo-ground); border-radius: var(--radius-md); padding: 3px 5px; }
.site-nav ul { display: flex; gap: var(--space-6); list-style: none; margin: 0; padding: 0; }
.site-nav ul a { font: 600 0.8125rem/1 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; color: var(--ink); padding: var(--space-3) 0; display: inline-block; border-bottom: 2px solid transparent; }
.site-nav ul a:hover { color: var(--brand-strong); }
.site-nav ul a[aria-current="page"] { border-bottom-color: var(--accent); }
.site-footer { background: var(--deep); color: var(--on-deep); }
.site-footer-inner { max-width: var(--measure-wide); margin: 0 auto; padding: var(--space-8) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); font-size: 0.875rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); list-style: none; margin: 0; padding: 0; }
.site-footer a { color: var(--on-deep); }
.site-footer a:hover { color: var(--accent); }
.site-footer :focus-visible { outline-color: var(--accent); }
.site-footer .disclaimer { color: var(--on-deep-muted); font-size: 0.75rem; line-height: 1.5; margin: 0; max-width: 110ch; }

/* Generic pages */
.page { max-width: var(--measure-page); margin: 0 auto; padding: var(--space-8) var(--space-6) var(--space-16); }
.page > h1 { font: 400 clamp(1.9rem, 5vw, 2.5rem)/1.15 var(--font-serif); margin: 0 0 var(--space-4); }
.prose h1 { font: 400 2.25rem/1.15 var(--font-serif); }
.prose h2 { font: 400 1.5rem/1.2 var(--font-serif); margin-top: var(--space-8); }
.notice { padding: var(--space-3) var(--space-4); border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--surface-raised); margin: var(--space-4) 0; }
.notice.error { border-color: var(--danger); color: var(--danger); background: var(--danger-tint); }
.notice.warning { border-color: var(--accent-text); background: var(--accent-tint); }
.notice.success { border-color: var(--success); color: var(--success); background: var(--success-tint); }

/* Forms */
.stack > * + * { margin-top: var(--space-3); }
label { display: block; font: 600 0.9375rem/1.3 var(--font-sans); margin-bottom: var(--space-2); }
input[type="text"], input[type="email"], select, textarea { width: 100%; font: 400 1rem/1.4 var(--font-sans); padding: 9px 12px; border: 1px solid var(--rule-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); }
select.locked { background: var(--surface-sunken); color: var(--ink-muted); pointer-events: none; }
button, .button { display: inline-flex; align-items: center; justify-content: center; font: 600 0.9375rem/1.3 var(--font-sans); padding: 10px 20px; border: 1px solid var(--brand); border-radius: var(--radius-md); background: var(--brand); color: var(--on-brand); cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }
.button.secondary { background: transparent; color: var(--brand); }
.button.secondary:hover { background: var(--brand-tint); color: var(--brand-strong); border-color: var(--brand-strong); }
.actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-6); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.field { margin-top: var(--space-4); }
.field-note { display: block; font-size: 0.875rem; font-weight: 600; color: var(--success); margin-top: var(--space-1); }
.field-note.error { color: var(--danger); font-weight: 400; }
.field.has-error input { border-color: var(--danger); border-width: 2px; padding: 8px 11px; }
.field.solved input { border-color: var(--success); border-width: 2px; padding: 8px 11px; background: var(--success-tint); font: 500 1rem/1.4 var(--font-mono); }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius-md); padding: var(--space-2) var(--space-4) var(--space-4); margin: 0; min-width: 0; }
legend { font: 600 0.9375rem/1.3 var(--font-sans); padding: 0 var(--space-2); }
.columns { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
details.help { border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--surface-raised); padding: var(--space-2) var(--space-4); margin: var(--space-4) 0; }
details.help summary { cursor: pointer; font-weight: 600; padding: var(--space-1) 0; }
details.help h3 { margin-bottom: var(--space-1); }
.cards { list-style: none; padding: 0; display: grid; gap: var(--space-6); grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.cards li { display: flex; flex-direction: column; gap: var(--space-3); border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--surface-raised); padding: var(--space-6); }
.cards h2 { font: 400 1.5rem/1.2 var(--font-serif); margin: 0; }
.cards h2 a { color: var(--ink); text-decoration: none; }
.cards p { margin: 0; }
.cards .more { margin-top: auto; padding-top: var(--space-2); }
.results h2 { font: 400 1.5rem/1.2 var(--font-serif); }
.results dt { font-weight: 600; margin-top: var(--space-3); }
.results dd { margin: 0; }
.results .book-link { display: block; margin-top: var(--space-1); }
/* A test and its alternative: the alternative is indented under it, and each
   carries what to check first or when to use it. */
.results-note { color: var(--ink-muted); font-size: 0.9375rem; }
.results .alternative { margin-left: var(--space-6); padding-left: var(--space-3); border-left: 3px solid var(--rule); }
.results dt.alternative { margin-top: var(--space-2); }
.results .guidance { display: block; margin-top: var(--space-1); font-size: 0.9375rem; }
.badge { display: inline-block; margin-left: var(--space-2); padding: 1px 8px; border-radius: 999px; font: 600 0.75rem/1.5 var(--font-sans); vertical-align: middle; }
.badge.start { background: var(--brand-tint); color: var(--brand-strong); }
.badge.also { background: var(--surface-sunken); color: var(--ink-muted); }
/* Read by screen readers, not shown. */
.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; }
.htmx-request { opacity: .6; transition: opacity .2s; }
.page.wide { max-width: var(--measure-wide); }

/* Test explorer: questions in a sticky column, the tests as tiles that fade
   out when they no longer fit. Tiles keep their ids across HTMX swaps, so the
   fade animates. */
.explorer { display: grid; gap: var(--space-6); align-items: start; margin-top: var(--space-6); }
.explorer.htmx-request { opacity: 1; }
.ex-questions { display: grid; gap: var(--space-4); background: var(--surface-raised); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: var(--space-4); min-width: 0; }
.ex-qhead { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.ex-qhead h2, .ex-role, .ex-group h2 { font: 600 0.75rem/1.3 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); margin: 0; }
.ex-qhead a { font-size: 0.875rem; }
.ex-role { border-top: 1px solid var(--rule); padding-top: var(--space-3); }
.ex-q { border: 0; padding: 0; display: grid; gap: 6px; }
.ex-q legend { padding: 0; margin-bottom: 6px; font-size: 0.9rem; font-weight: 500; }
.ex-q .star { color: var(--accent-text); margin-left: 2px; }
.ex-q.off .ex-opts { opacity: .45; }
.ex-hint { font-size: 0.8rem; color: var(--ink-muted); margin: 0; }
.ex-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.ex-tos .ex-opts { display: grid; }
.ex-opt { display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 6px 4px 10px; border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 0.875rem; line-height: 1.3; transition: background-color .15s, border-color .15s, color .15s; }
.ex-tos .ex-opt { border-radius: var(--radius-md); }
a.ex-opt:hover { border-color: var(--brand); color: var(--ink); }
.ex-n { font: 500 0.75rem/1 var(--font-mono); min-width: 1.6em; padding: 3px 5px; border-radius: 999px; background: var(--surface-sunken); text-align: center; font-variant-numeric: tabular-nums; }
.ex-opt[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
a.ex-opt[aria-current="true"]:hover { color: var(--on-brand); border-color: var(--brand-strong); }
.ex-opt[aria-current="true"] .ex-n { background: var(--on-brand); color: var(--brand-strong); }
.ex-opt.zero { color: var(--ink-muted); border-style: dashed; }
.ex-opt.zero .ex-n { background: transparent; }
.ex-opt.locked { cursor: default; }
.ex-questions details.help { margin: 0; }

.ex-board { display: grid; gap: var(--space-6); min-width: 0; }
.ex-status { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2) var(--space-4); }
.ex-big { font: 600 2rem/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.ex-verdict { font-size: 0.875rem; padding: 4px 10px; border-radius: 999px; background: var(--surface-sunken); color: var(--ink-muted); }
.ex-verdict.done { background: var(--success-tint); color: var(--success); font-weight: 600; }
.ex-verdict.none { background: var(--danger-tint); color: var(--danger); font-weight: 600; }
.ex-group { display: grid; gap: var(--space-2); }
.ex-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: var(--space-2); }
.ex-tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; height: 100%; min-height: 5.2rem; padding: 10px 12px; background: var(--paper); color: var(--ink); text-decoration: none; border: 1px solid var(--rule); border-radius: var(--radius-md); box-shadow: var(--shadow-raised);
    transition: opacity .35s ease, filter .35s ease, transform .35s ease, box-shadow .35s ease, border-color .2s; }
.ex-tile:hover { color: var(--ink); border-color: var(--brand); }
.ex-tn { font: 400 1.0625rem/1.25 var(--font-serif); overflow-wrap: anywhere; }
.ex-meta { font: 400 0.6875rem/1 var(--font-mono); color: var(--ink-muted); }
.ex-tile.out { opacity: .32; filter: grayscale(1); transform: scale(.97); box-shadow: none; background: var(--surface); }
.ex-tile.out:hover { opacity: .6; }
.ex-tile[aria-current="true"] { border-color: var(--brand); outline: 2px solid var(--brand); outline-offset: -1px; }
.ex-tile.nodesc::after, .ex-dot { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.ex-tile.nodesc::after { position: absolute; top: 8px; right: 8px; }
.ex-dot { display: inline-block; margin-right: 6px; }
.ex-legend { font-size: 0.8125rem; color: var(--ink-muted); margin: 0; }

.ex-detail { display: grid; gap: var(--space-3); border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--surface-raised); padding: var(--space-4); min-width: 0; }
.ex-detail header { display: flex; justify-content: space-between; align-items: start; gap: var(--space-3); }
.ex-detail h2 { font: 400 1.5rem/1.2 var(--font-serif); margin: 0; }
.ex-detail .button { padding: 4px 12px; font-size: 0.875rem; }
.ex-detail p { margin: 0; max-width: var(--measure-main); }
.ex-why { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--danger-tint); color: var(--danger); font-size: 0.9rem; }
.ex-why.ok { background: var(--success-tint); color: var(--success); }
.ex-fits { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px var(--space-4); margin: 0; font-size: 0.875rem; }
.ex-fits dt { color: var(--ink-muted); }
.ex-fits dd { margin: 0; }
.ex-fits .clash { color: var(--danger); font-weight: 600; }

@media (min-width: 900px) {
    .explorer { grid-template-columns: 21rem minmax(0, 1fr); }
    .ex-questions { position: sticky; top: var(--space-4); max-height: calc(100vh - var(--space-8)); overflow-y: auto; }
}
@media (prefers-reduced-motion: reduce) { .ex-tile.out { transform: none; } }

/* Landing page */
.home .lp-wrap { max-width: var(--measure-wide); margin: 0 auto; padding-inline: var(--space-6); }
.step-icon { width: 3.5rem; height: 3.5rem; display: block; }
.step-icon .ink { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.step-icon .ink-fill { fill: currentColor; }
.step-icon .acc { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.step-icon .acc-fill { fill: var(--accent); }

.lp-hero { position: relative; background: var(--deep); color: var(--on-deep); overflow: hidden; }
.lp-hero .site-header { background: transparent; border-bottom-color: transparent; position: relative; z-index: 1; }
.lp-hero .site-nav .brand, .lp-hero .site-nav ul a { color: var(--on-deep); }
.lp-hero .site-nav ul a:hover { color: var(--accent); }
.lp-hero :focus-visible { outline-color: var(--accent); }
.lp-curve { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 18.75rem; max-width: none; }
.lp-curve path { fill: none; stroke: var(--on-deep-muted); stroke-width: 1.5; opacity: .35; vector-effect: non-scaling-stroke; }
.lp-curve line { stroke: var(--on-deep-muted); stroke-width: 1; opacity: .25; vector-effect: non-scaling-stroke; }
.lp-hero-grid { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); align-items: center; padding-block: var(--space-8) var(--space-16); }
.lp-hero-text { display: flex; flex-direction: column; gap: var(--space-6); max-width: 46rem; }
.lp-hero-text .actions { margin-top: 0; }
.lp-hero .eyebrow { color: var(--on-deep-muted); }
.lp-hero h1 { font: 400 clamp(2.5rem, 5.4vw, 4.25rem)/1.04 var(--font-serif); margin: 0; }
.lp-hero h1 em { font-style: italic; color: var(--accent); }
.lp-hero .lede { color: var(--on-deep-muted); max-width: 34rem; }
.lp-hero .lp-primary { background: var(--accent); border-color: var(--accent); color: var(--deep); }
.lp-hero .lp-primary:hover { background: var(--on-deep); border-color: var(--on-deep); color: var(--deep); }
.lp-hero .lp-ghost { background: transparent; border-color: var(--on-deep-muted); color: var(--on-deep); }
.lp-hero .lp-ghost:hover { border-color: var(--on-deep); background: transparent; color: var(--on-deep); }
.lp-proof { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); list-style: none; margin: 0; padding: 0; font-size: 0.875rem; color: var(--on-deep-muted); }
.lp-proof b { color: var(--on-deep); font: 500 0.9375rem/1 var(--font-mono); margin-right: 6px; }

.lp-section { padding-block: var(--space-12); }
.lp-head { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-8); max-width: 42rem; }
.lp-head h2, .lp-close h2 { font: 400 clamp(1.9rem, 5vw, 2.5rem)/1.15 var(--font-serif); margin: 0; }
.lp-steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); list-style: none; margin: 0; padding: 0; counter-reset: step; }
.lp-steps li { position: relative; display: flex; flex-direction: column; gap: var(--space-3); counter-increment: step; }
.lp-steps h3 { font: 400 1.75rem/1.15 var(--font-serif); margin: var(--space-2) 0 0; }
.lp-steps h3::before { content: counter(step) "\00a0"; color: var(--ink-muted); font: 600 1.125rem/1 var(--font-sans); vertical-align: 0.25em; }
.lp-steps p { margin: 0; font-size: 0.9375rem; }
.lp-steps strong { font-weight: 600; }
.lp-steps .more { font-size: 0.9375rem; }

.lp-band { background: var(--surface-raised); border-block: 1px solid var(--rule); }
.lp-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-6); }
.lp-tile { grid-column: span 12; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; text-decoration: none; }
a.lp-tile:hover { color: var(--ink); border-color: var(--brand); box-shadow: var(--shadow-raised); }
.lp-tile h3 { font: 400 1.875rem/1.15 var(--font-serif); margin: 0; }
.lp-tile p { margin: 0; }
.lp-tile > .more { margin-top: auto; padding-top: var(--space-2); }
.lp-tile--book { background: var(--paper); }
.lp-tile--next { background: var(--brand-tint); border-color: var(--brand); gap: var(--space-2); }
.lp-tile--next p:last-child { max-width: 46rem; }
.lp-badge { font: 600 0.75rem/1.3 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-strong); }
.lp-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.lp-chips li { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 1px 8px; color: var(--ink-muted); font-size: 0.8125rem; }
.lp-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4) var(--space-6); border-top: 1px solid var(--rule); padding-top: var(--space-4); }
.lp-page h4 { grid-column: 1 / -1; font: italic 400 1.375rem/1.2 var(--font-serif); margin: 0; }
.lp-page p { font: 400 1rem/1.55 var(--font-serif); }
.lp-page sup { font: 600 0.62em/0 var(--font-sans); color: var(--accent-text); }
.lp-page .lp-note { font: 400 0.8125rem/1.45 var(--font-serif); padding-left: var(--space-3); border-left: 3px solid var(--accent); }
.lp-number { color: var(--ink-muted); font-style: normal; margin-right: 0.3em; }
.lp-bars { display: flex; align-items: flex-end; gap: 4px; height: 4rem; margin-top: var(--space-3); border-bottom: 1px solid var(--rule-strong); }
.lp-bars i { flex: 1; background: var(--brand); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.lp-bars i.is-peak { background: var(--accent); }
.lp-figure { font: 500 0.9375rem/1.4 var(--font-mono); padding: var(--space-2) var(--space-3); background: var(--surface-raised); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.lp-figure b { color: var(--accent-text); font-weight: 500; }
.lp-close { text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--space-4); padding-block: var(--space-16); }
.lp-close .lede { max-width: 36rem; }
.lp-close .actions { justify-content: center; margin-top: var(--space-2); }

@media (min-width: 560px) {
    .lp-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lp-tile { padding: var(--space-8); }
    .lp-page { grid-template-columns: minmax(0, 1fr) 9.5rem; }
    .lp-page .lp-note { padding-left: 0; border-left: 0; }
}
@media (min-width: 900px) {
    .lp-hero-grid { padding-block: var(--space-16) var(--space-24); }
    .lp-section { padding-block: var(--space-16); }
    .lp-head { margin-bottom: var(--space-12); }
    .lp-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .lp-steps li::after { content: ""; position: absolute; top: 1.75rem; left: 4.5rem; right: -1rem; border-top: 1px dashed var(--rule-strong); }
    .lp-steps li:last-child::after { display: none; }
    .lp-tile--book { grid-column: span 7; grid-row: span 2; }
    .lp-tile--tool { grid-column: span 5; }
    .lp-close { padding-block: var(--space-24); }
}

/* Book: contents */
.book-title { font: 400 clamp(2rem, 6vw, 3.5rem)/1.05 var(--font-serif); margin: 0 0 var(--space-3); }
.book-title span { display: block; font-style: italic; }
.page > h2 { font: 400 1.75rem/1.2 var(--font-serif); margin: var(--space-8) 0 var(--space-3); }
.contents { list-style: none; padding-left: 0; margin: 0; }
.book-index > .contents, .book-index .contents-part > .contents { font: 400 1.1875rem/1.4 var(--font-serif); }
.book-index .contents > li { padding: var(--space-2) 0; border-bottom: 1px solid var(--rule); }
.contents-part h3 { font: 600 0.75rem/1.3 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text); margin: var(--space-8) 0 0; padding-bottom: var(--space-2); border-bottom: 2px solid var(--rule-strong); }
.chapter-sections { margin-top: var(--space-1); }
.chapter-sections summary { cursor: pointer; width: fit-content; font: 400 0.8125rem/1.4 var(--font-sans); color: var(--ink-muted); }
.chapter-sections summary:hover { color: var(--brand-strong); }
.chapter-sections ol { margin-top: var(--space-1); }
.book-index > h2 { font: 400 1.75rem/1.2 var(--font-serif); margin: var(--space-8) 0 var(--space-3); }
/* "Which chapter do I need?" is a note, styled like the chapters' sidenotes:
   above the contents on small screens, in the margin column on wide ones. */
.chapter-guide { margin: var(--space-8) 0 0; padding: 1px 0 1px var(--space-3); border-left: 3px solid var(--accent); font: 400 0.875rem/1.45 var(--font-serif); }
.chapter-guide h2 { font: 600 0.75rem/1.3 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 var(--space-2); }
.chapter-guide dl { margin: 0; }
.chapter-guide dt { font: 600 0.8125rem/1.4 var(--font-sans); margin-top: var(--space-3); }
.chapter-guide dd { margin: var(--space-1) 0 0; }
.chapter-guide p { margin: var(--space-4) 0 0; color: var(--ink-muted); }
@media (min-width: 1100px) {
    .book-home { --gap: var(--space-12); max-width: calc(var(--measure-main) + var(--gap) + var(--measure-margin) + 3rem); }
    .book-home-body { display: grid; grid-template-columns: minmax(0, var(--measure-main)) var(--measure-margin); column-gap: var(--gap); align-items: start; }
    .book-index { grid-column: 1; grid-row: 1; }
    .chapter-guide { grid-column: 2; grid-row: 1; position: sticky; top: var(--space-6); margin-top: calc(var(--space-8) + 0.4rem); padding: 0; border-left: 0; }
}
.contents a { color: var(--ink); text-decoration: none; }
.contents a:hover { color: var(--brand-strong); text-decoration: underline; }
.contents ol { list-style: none; padding-left: var(--space-6); font: 400 0.9375rem/1.4 var(--font-sans); }
.contents ol a { color: var(--ink-muted); }
.contents li { margin: var(--space-1) 0; }
.contents .level-3 { padding-left: var(--space-6); }
.contents .current > a { font-weight: 600; box-shadow: -8px 0 0 var(--surface-raised), -11px 0 0 var(--accent); }
.book-contents { margin: var(--space-4) 0; border: 1px solid var(--rule); border-radius: var(--radius-md); padding: var(--space-2) var(--space-4); background: var(--surface-raised); font-family: var(--font-sans); }
.book-contents summary { cursor: pointer; font-weight: 600; padding: var(--space-1) 0; }
/* Chapter and section titles in serif, as on the contents page; the small
   labels (Contents, part names, In this chapter) stay sans-serif. */
.book-contents .contents { font: 400 1.0625rem/1.4 var(--font-serif); }
/* et-book's semi-bold has only old-style (small) figures; its bold has full-height ones. */
.book-contents .contents .current > a { font-weight: 700; }
.book-contents .contents-part { margin: var(--space-1) 0; }
.book-contents .contents-part > summary { font: 600 0.75rem/1.3 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); padding: var(--space-2) 0 var(--space-1); }
.book-contents .contents-part > .contents { padding-left: var(--space-4); }
.book-contents h2 { font: 600 0.75rem/1.3 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); margin: var(--space-4) 0 var(--space-1); }
.chapter-nav { display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin: var(--space-12) 0 var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--rule); font: 400 0.9375rem/1.4 var(--font-sans); }
.chapter-nav a { text-decoration: none; }
.to-contents { position: fixed; z-index: 15; right: max(var(--space-4), env(safe-area-inset-right, 0px)); bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); font: 600 0.875rem/1 var(--font-sans); padding: 10px 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 999px; box-shadow: var(--shadow-raised); text-decoration: none; transition: opacity .2s, transform .2s; }
.to-contents:hover { color: var(--brand-strong); border-color: var(--brand); }
/* Hidden also from keyboard focus; visibility switches after the fade. */
.to-contents.is-hidden { opacity: 0; transform: translateY(8px); visibility: hidden; transition: opacity .2s, transform .2s, visibility 0s .2s; }
.book-toolbar { display: flex; justify-content: flex-end; margin-top: var(--space-4); font-family: var(--font-sans); }
.pdf-button { padding: 6px 14px; font-size: 0.875rem; }

/* Messages pinned to the bottom of the screen */
.toast { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; padding: 0 var(--space-4); pointer-events: none; font-family: var(--font-sans); }
.toast-message { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--space-4); max-width: 40rem; margin-bottom: var(--space-4); padding: 14px var(--space-4) 14px 20px; background: var(--deep); color: var(--on-deep); border: 1px solid var(--on-deep-muted); border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay); font-size: 1rem; line-height: 1.45; }
.toast-message p { margin: 0; }
.toast-close { background: transparent; border: 0; color: var(--on-deep); font-size: 1.4rem; line-height: 1; padding: 0 4px; cursor: pointer; }
.toast-close:hover { background: transparent; color: var(--accent); }
.toast-close:focus-visible { outline-color: var(--accent); }

/* Book: chapter text. One column on small screens. A note that is repeated
   after its paragraph (.sidenote-copy) is hidden inline there, so it does not
   interrupt the sentence. */
body:has(.book-page) { background: var(--paper); }
.book-page { max-width: 44rem; margin: 0 auto; padding: var(--space-4) var(--space-6) var(--space-12); }
.chapter { font: 400 1.1875rem/1.6 var(--font-serif); }
.chapter h1 { font: 400 2.5rem/1.15 var(--font-serif); margin: var(--space-6) 0 var(--space-4); }
.chapter h2 { font: italic 400 1.75rem/1.2 var(--font-serif); margin: var(--space-8) 0 var(--space-3); }
.chapter h3 { font: italic 400 1.375rem/1.25 var(--font-serif); margin: var(--space-6) 0 var(--space-2); }
.chapter .chapter-number, .chapter .header-section-number { color: var(--ink-muted); font-style: normal; margin-right: .3em; }
.chapter .sidenote-ref, .chapter .sidenote-number { font: 600 0.62em/0 var(--font-sans); vertical-align: super; color: var(--accent-text); }
.chapter .sidenote-ref { margin-left: .1em; }
.chapter .sidenote.has-copy { display: none; }
.chapter .sidenote, .chapter .sidenote-copy, .chapter .column-margin { display: block; font: 400 0.875rem/1.45 var(--font-serif); margin: var(--space-2) 0 var(--space-3); padding: 1px 0 1px var(--space-3); border-left: 3px solid var(--accent); }
.chapter .sidenote-copy p { margin: 0; }
.chapter .sidenotes-below { margin: -.4rem 0 1.2rem; }
.chapter li > .sidenotes-below { margin-top: .4rem; }
.chapter .column-margin > :first-child { margin-top: 0; }
.chapter .column-margin > :last-child { margin-bottom: 0; }
.chapter figure { margin: var(--space-6) 0; }
.chapter figcaption, .chapter caption { font: 400 0.875rem/1.45 var(--font-sans); color: var(--ink-muted); text-align: left; padding: var(--space-1) 0; caption-side: top; }
.chapter img { display: block; margin: 0 auto; background: var(--figure-ground); border-radius: var(--radius-sm); }
/* Wide content scrolls sideways inside its own box instead of breaking the page. */
.chapter pre, .chapter .cell-output-display, .chapter .quarto-float-tbl { overflow-x: auto; max-width: 100%; }
.chapter pre { font: 400 0.8125rem/1.45 var(--font-mono); background: var(--surface-code); border: 1px solid var(--rule); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); }
.chapter table { border-collapse: collapse; font: 400 0.875rem/1.45 var(--font-sans); font-variant-numeric: tabular-nums; margin: var(--space-2) 0; }
.chapter th, .chapter td { padding: 6px var(--space-3); border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.chapter thead th { border-bottom: 2px solid var(--rule-strong); font-weight: 600; }
.chapter .math.display { display: block; overflow-x: auto; overflow-y: hidden; padding: .25rem 0; text-align: center; }
/* KaTeX sets maths at 1.21em by default, which looks oversized next to the
   book's serif with its small x-height. Inline maths matches the text; display
   equations stay a little larger. */
.chapter .katex { font-size: 1em; }
.chapter .katex-display > .katex { font-size: 1.1em; }
.chapter .csl-entry { margin: .6rem 0; padding-left: 1.5rem; text-indent: -1.5rem; font-size: 1rem; }
.chapter details.code-fold { margin: var(--space-3) 0; font: 400 0.875rem/1.4 var(--font-sans); }
/* "At a glance" card at the top of a test's section (the book's test-cards filter):
   labels on the left, one row per characteristic; stacked on small screens. */
.chapter .test-card { margin: var(--space-4) 0 var(--space-6); padding: var(--space-3) var(--space-4) var(--space-4); background: var(--surface); border: 1px solid var(--accent); border-left: 6px solid var(--accent); border-radius: var(--radius-md); font: 400 0.9375rem/1.45 var(--font-sans); }
.chapter .test-card-title p { margin: 0 0 var(--space-3); font: 600 0.75rem/1.3 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.chapter .test-card dl { display: grid; grid-template-columns: 10.5rem minmax(0, 1fr); gap: var(--space-2) var(--space-4); margin: 0; }
.chapter .test-card dt { font-weight: 600; }
.chapter .test-card dd { margin: 0; }
.chapter .test-card dd p { margin: 0; }
.chapter .test-card dd ul { margin: 0; padding-left: 1.1em; }
@media (max-width: 559px) {
    .chapter .test-card dl { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
    .chapter .test-card dd { margin-bottom: var(--space-3); }
}

/* Wide screens: main column plus a margin column for notes. */
@media (min-width: 1100px) {
    .book-page { --gap: var(--space-12); max-width: calc(var(--measure-main) + var(--gap) + var(--measure-margin) + 3rem); }
    .book-contents, .chapter-nav, .book-toolbar { max-width: var(--measure-main); }
    .chapter { padding-right: calc(var(--measure-margin) + var(--gap)); }
    .chapter .sidenotes-below { display: none; }
    .chapter .sidenote.has-copy { display: block; }
    .chapter .sidenote, .chapter .column-margin { float: right; clear: right; width: var(--measure-margin); margin: .2rem calc(-1 * (var(--measure-margin) + var(--gap))) 1rem 0; padding: 0; border-left: 0; }
    /* Tables, R output and display maths may use the margin as well; they
       start below any note that is still sitting there. */
    .chapter pre, .chapter .cell-output-display:has(table) { clear: right; width: max-content; min-width: 100%; max-width: calc(100% + var(--gap) + var(--measure-margin)); }
    /* Figures and tables with a caption: the caption sits in the margin, level
       with the top. A table too wide for the main column (.is-wide, set by
       book.js) spans both columns, with its caption in the margin below it. */
    .chapter figure.quarto-float { clear: right; display: grid; grid-template-columns: minmax(0, 1fr) var(--measure-margin); column-gap: var(--gap); align-items: start; margin-right: calc(-1 * (var(--measure-margin) + var(--gap))); overflow: visible; max-width: none; }
    .chapter figure.quarto-float > :not(figcaption) { grid-column: 1; grid-row: 1; min-width: 0; overflow-x: auto; }
    .chapter figure.quarto-float > figcaption { grid-column: 2; grid-row: 1; padding: 0; }
    .chapter figure.quarto-float .cell-output-display { width: auto; min-width: 0; max-width: none; }
    .chapter .cell-output-display:has(figure.quarto-float) { overflow: visible; max-width: none; }
    /* A figure the book places in the margin keeps its caption below it. */
    .chapter .column-margin figure.quarto-float { display: block; margin-right: 0; }
    .chapter figure.quarto-float.is-wide > :not(figcaption) { grid-column: 1 / -1; }
    .chapter figure.quarto-float.is-wide table { margin-left: 0 !important; }
    .chapter figure.quarto-float.is-wide > figcaption { grid-row: 2; padding-top: var(--space-2); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
    .site-header, .site-footer, .book-contents, .chapter-nav, .book-toolbar, .toast, .to-contents { display: none; }
    body:has(.book-page) { background: #fff; }
}
