/* Desk design v4: tokens and components, ported from docs/design/mockups/v4/v4.css (UI-SPEC v4).
   Navy ink on a paper ground, light by default. Gold means "next": the step waiting on you and the
   money it will take. Red only for failure, refusal and money at risk.
   Rules for markup that later cards add (TASK-038, TASK-045, TASK-046) are ported already and wait unused. */

/* ---- Fonts: Hanken Grotesk (desk), Literata (the book's voice), Fredoka + Nunito (inside the book only). OFL 1.1. ---- */
@font-face { font-family: "Hanken Grotesk"; src: url("fonts/HankenGrotesk-Variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/Literata-Variable.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/Literata-Italic-Variable.woff2") format("woff2"); font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("fonts/Fredoka-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  /* Type: px size / line height, every line height a multiple of 4 (the baseline unit). */
  --text-xs: 0.75rem;     /* 12 / 16 */
  --text-sm: 0.875rem;    /* 14 / 20 */
  --text-md: 1rem;        /* 16 / 24 */
  --text-lg: 1.125rem;    /* 18 / 28 */
  --text-xl: 1.375rem;    /* 22 / 28 */
  --text-2xl: 1.75rem;    /* 28 / 36 */
  --text-3xl: 2.25rem;    /* 36 / 44 */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 2rem; --space-7: 3rem; --space-8: 4rem;
  /* Near-square: the book is trimmed square, controls barely soften. */
  --radius-paper: 0;
  --radius-chip: 2px;
  --radius-control: 3px;
  --radius-panel: 4px;
  --shadow-paper: 0 1px 1px var(--shade), 0 8px 20px var(--shade);
  --shadow-overlay: 0 6px 24px var(--shade);
  --font-house: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-page: "Literata", Georgia, "Times New Roman", serif;
  --font-code: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-book-display: "Fredoka", "Nunito", sans-serif;
  --font-book-text: "Nunito", sans-serif;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
}

/* Light: the default. */
:root, [data-theme="light"] {
  color-scheme: light;
  --desk: oklch(97.4% 0.004 85);          /* #F8F6F3 page */
  --surface: oklch(99.3% 0.002 85);       /* #FDFDFB panels */
  --raised: oklch(94.6% 0.006 262);       /* #EBEDF1 hover, neutral chips, meter track */
  --well: oklch(95.4% 0.007 262);         /* #EDF0F5 rail, proof wells: the cool layer */
  --field: oklch(99.6% 0.002 85);         /* #FEFEFC inputs */
  --line: oklch(89.5% 0.008 262);         /* #D9DCE2 hairlines */
  --line-strong: oklch(60.5% 0.02 262);   /* #7B828E control borders */
  --ink: oklch(23.5% 0.05 262);           /* #111D36 text */
  --ink-2: oklch(37.5% 0.035 262);        /* #374154 secondary */
  --ink-3: oklch(51.5% 0.025 262);        /* #606876 captions */
  --pencil: oklch(25% 0.08 263);          /* #0C1F47 primary action, links, current step: navy ink */
  --pencil-hi: oklch(34% 0.09 263);       /* #1E3666 hover, focus ring */
  --pencil-wash: oklch(93.2% 0.016 263);  /* #E3E9F4 info, selected */
  --on-pencil: oklch(98.6% 0.006 85);     /* #FCFAF6 text on pencil */
  --gold: oklch(72.2% 0.135 78);          /* #D3992F brand gold, graphics only */
  --gold-ink: oklch(50% 0.1 75);          /* #845A0F gold as text, edges */
  --gold-on-pencil: oklch(72.2% 0.135 78);/* #D3992F the "you are here" mark on pencil */
  --gold-wash: oklch(94.6% 0.04 85);      /* #FAECCF */
  --pass: oklch(45% 0.1 150);             /* #236436 */
  --pass-wash: oklch(94.6% 0.03 150);     /* #E0F3E3 */
  --query: oklch(50% 0.12 55);            /* #964D09 */
  --query-wash: oklch(94.8% 0.035 70);    /* #FEEAD5 */
  --stop: oklch(49% 0.175 27);            /* #AE2322 */
  --stop-wash: oklch(95% 0.025 25);       /* #FFE8E6 */
  --on-stop: oklch(98.6% 0.006 85);       /* #FCFAF6 */
  --paper: oklch(98.6% 0.018 90);         /* #FFFAED the book */
  --paper-ink: oklch(27% 0.012 75);       /* #2A2620 */
  --paper-ink-2: oklch(49% 0.02 75);      /* #675F54 */
  --paper-pencil: oklch(32% 0.08 263);    /* #1C315B */
  --paper-pass: oklch(45% 0.1 150);       /* #236436 */
  --mast: oklch(25% 0.08 263);            /* #0C1F47 the masthead band */
  --on-mast: oklch(98.6% 0.006 85);       /* #FCFAF6 */
  --on-mast-2: oklch(81% 0.03 262);       /* #B6C1D5 */
  --mast-line: oklch(36% 0.07 263);       /* #293C62 */
  --shade: oklch(25% 0.05 262 / 0.13);
}
[data-theme="dark"] {
  color-scheme: dark;
  --desk: oklch(18% 0.022 262);           /* #0C121B */
  --surface: oklch(21.5% 0.026 262);      /* #131926 */
  --raised: oklch(26.5% 0.03 262);        /* #1D2534 */
  --well: oklch(15% 0.02 262);            /* #070B14 */
  --field: oklch(15.5% 0.02 262);         /* #080C15 */
  --line: oklch(31% 0.03 262);            /* #283040 */
  --line-strong: oklch(58% 0.03 262);     /* #717B8D */
  --ink: oklch(94.5% 0.012 85);           /* #F0ECE4 */
  --ink-2: oklch(84% 0.012 85);           /* #CECAC2 */
  --ink-3: oklch(72% 0.016 262);          /* #9FA5AF */
  --pencil: oklch(93.5% 0.014 85);        /* #EEE9DF primary is still "ink": paper-light on navy */
  --pencil-hi: oklch(98.5% 0.008 85);     /* #FDFAF4 */
  --pencil-wash: oklch(28.5% 0.045 262);  /* #1E2A40 */
  --on-pencil: oklch(21% 0.05 262);       /* #0B172F */
  --gold: oklch(76% 0.13 78);             /* #DEA645 */
  --gold-ink: oklch(80% 0.12 80);         /* #E6B55D */
  --gold-on-pencil: oklch(52% 0.11 75);   /* #8D5E00 */
  --gold-wash: oklch(28.5% 0.05 78);      /* #382709 */
  --pass: oklch(80% 0.11 150);            /* #89D298 */
  --pass-wash: oklch(27% 0.04 150);       /* #172C1C */
  --query: oklch(82% 0.11 70);            /* #F2B772 */
  --query-wash: oklch(28.5% 0.045 65);    /* #392510 */
  --stop: oklch(76% 0.13 27);             /* #F98F84 */
  --stop-wash: oklch(28% 0.055 27);       /* #401D1A */
  --on-stop: oklch(21% 0.05 262);         /* #0B172F */
  --paper: oklch(97% 0.02 90);            /* #FAF5E6 */
  --paper-ink: oklch(27% 0.012 75);
  --paper-ink-2: oklch(49% 0.02 75);
  --paper-pencil: oklch(32% 0.08 263);
  --paper-pass: oklch(45% 0.1 150);
  --mast: oklch(13.5% 0.02 262);          /* #050810 */
  --on-mast: oklch(94.5% 0.012 85);       /* #F0ECE4 */
  --on-mast-2: oklch(78% 0.016 262);      /* #B2B8C2 */
  --mast-line: oklch(27% 0.03 262);       /* #1E2735 */
  --shade: oklch(5% 0.02 262 / 0.55);
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--desk); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; min-width: 320px; background: var(--desk); color: var(--ink); font: 400 var(--text-md)/1.5 var(--font-house); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }
a { color: var(--pencil); text-decoration-thickness: 1px; text-underline-offset: .2em; text-decoration-color: color-mix(in oklch, currentColor 45%, transparent); }
@media (hover:hover) and (pointer:fine) { a:hover { color: var(--pencil-hi); text-decoration-color: currentColor; } }
:focus-visible { outline: 2px solid var(--pencil-hi); outline-offset: 2px; border-radius: var(--radius-chip); }
::selection { background: var(--pencil); color: var(--on-pencil); }
code { font: 400 var(--text-xs)/1.4 var(--font-code); overflow-wrap: anywhere; color: var(--ink-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.i { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; }
.num, .money { font-variant-numeric: tabular-nums; }

/* The book's voice: titles and text that belong to the book. */
.page-title { font: 600 var(--text-3xl)/2.75rem var(--font-page); letter-spacing: -.012em; text-wrap: balance; }
.page-sub { margin-top: var(--space-1); max-width: 62ch; color: var(--ink-2); }
.aside-voice { font: italic 400 var(--text-sm)/1.25rem var(--font-page); color: var(--ink-3); }
.crumb { margin-bottom: var(--space-2); font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-3); }
.crumb a { color: var(--ink-2); }
.crumb span[aria-hidden] { margin: 0 var(--space-1); }

/* ---- Demo banner and masthead ---- */
.demo-banner { padding: var(--space-1) var(--space-5); background: var(--query-wash); color: var(--query); font-size: var(--text-xs); line-height: 1rem; font-weight: 600; }
.demo-banner code { font: 600 var(--text-xs)/1rem var(--font-code); color: inherit; }
.masthead { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--space-6); height: 56px; padding: 0 var(--space-5); background: var(--mast); color: var(--on-mast); border-bottom: 1px solid var(--mast-line); }
.masthead :focus-visible { outline-color: var(--on-mast); }
.imprint { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--on-mast); font: 600 var(--text-lg)/1 var(--font-page); letter-spacing: -.005em; text-decoration: none; white-space: nowrap; }
@media (hover:hover) and (pointer:fine) { .imprint:hover { color: var(--on-mast); } }
.imprint-mark { width: 38px; height: 28px; flex: none; --brand-navy: var(--on-mast); --brand-gold: var(--gold); }
.mast-nav { display: flex; align-self: stretch; gap: var(--space-1); }
.mast-nav a { display: inline-flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3); border-bottom: 2px solid transparent; color: var(--on-mast-2); font-size: var(--text-sm); font-weight: 600; text-decoration: none; }
@media (hover:hover) and (pointer:fine) { .mast-nav a:hover { color: var(--on-mast); } }
.mast-nav a[aria-current="page"] { border-bottom-color: var(--gold); color: var(--on-mast); }
.mast-tools { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.mast-tools .btn { border-color: var(--on-mast-2); color: var(--on-mast); }
@media (hover:hover) and (pointer:fine) { .mast-tools .btn:hover { background: var(--mast-line); color: var(--on-mast); } }
.count { display: inline-grid; min-width: 20px; height: 20px; padding: 0 6px; place-items: center; border-radius: 10px; background: var(--mast-line); color: var(--on-mast); font-size: var(--text-xs); font-weight: 700; }
.count.is-stop { background: var(--stop); color: var(--on-stop); border: 0; }

/* ---- Buttons: primary is set in ink. One per screen. ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: transparent; color: var(--ink); font: 650 var(--text-sm)/1.25rem var(--font-house); text-decoration: none; cursor: pointer; transition: background-color .15s var(--ease-out), border-color .15s var(--ease-out), transform .12s var(--ease-out); }
@media (hover:hover) and (pointer:fine) { .btn:hover { background: var(--raised); color: var(--ink); } }
.btn:active { background: var(--line); transform: scale(.97); }
.btn:disabled:active, .btn[aria-disabled="true"]:active { transform: none; }
.btn:focus-visible { border-radius: var(--radius-control); }
.btn-primary { border-color: var(--pencil); background: var(--pencil); color: var(--on-pencil); }
@media (hover:hover) and (pointer:fine) { .btn-primary:hover { border-color: var(--pencil-hi); background: var(--pencil-hi); color: var(--on-pencil); } }
.btn-primary:active { background: var(--pencil); }
.btn-keep { border-color: var(--pencil); color: var(--pencil); }
@media (hover:hover) and (pointer:fine) { .btn-keep:hover { background: var(--pencil-wash); color: var(--pencil); } }
.btn-danger { border-color: var(--stop); color: var(--stop); }
@media (hover:hover) and (pointer:fine) { .btn-danger:hover { background: var(--stop-wash); color: var(--stop); } }
.btn-lg { min-height: 48px; padding: 0 var(--space-5); font-size: var(--text-md); line-height: 1.5rem; }
.btn-sm { min-height: 32px; padding: 0 var(--space-3); }
.btn-icon { width: 32px; padding: 0; }
.btn-icon.has-count { width: auto; padding: 0 var(--space-2); gap: var(--space-1); }
.btn-icon .count { min-width: 16px; height: 16px; padding: 0 4px; font-size: var(--text-xs); line-height: 1; }
.btn .i { width: 16px; height: 16px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
/* A press shows at once (TASK-182): the pressed button says what it is doing and turns a small ring. */
button[data-pressed]::before { content: ""; display: inline-block; flex: none; box-sizing: border-box; width: 1em; height: 1em; margin-inline-end: .5em; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; vertical-align: -.15em; }
.btn[data-pressed]::before { margin-inline-end: 0; }
@media (prefers-reduced-motion: no-preference) { button[data-pressed]::before { animation: desk-spin .8s linear infinite; } }
@keyframes desk-spin { to { transform: rotate(360deg); } }
@media (hover:hover) and (pointer:fine) { .btn:disabled:hover { background: transparent; } }
@media (hover:hover) and (pointer:fine) { .btn-primary:disabled:hover { background: var(--pencil); border-color: var(--pencil); } }
/* The arrow on a forward action leans 3px into the hover. */
.btn .arrow { display: inline-block; transition: transform .2s var(--ease-out); }
.btn:focus-visible .arrow { transform: translateX(3px); }
@media (hover:hover) and (pointer:fine) { .btn:hover .arrow { transform: translateX(3px); } }
.btn-primary:focus-visible { outline-offset: 3px; }
.inline-form { display: inline-flex; gap: var(--space-2); margin: 0; }

/* ---- Fields ---- */
label { display: block; font-size: var(--text-sm); line-height: 1.25rem; font-weight: 600; color: var(--ink-2); }
input[type="text"], input[type="number"], input:not([type]), select, textarea { display: block; width: 100%; min-height: 40px; margin-top: var(--space-1); padding: var(--space-2) var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--field); color: var(--ink); font: 400 var(--text-md)/1.5rem var(--font-house); }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--pencil-hi); outline-offset: 1px; border-color: var(--pencil); border-radius: var(--radius-control); }
input[type="checkbox"] { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--pencil); flex: none; }
.fine { font-size: var(--text-xs); line-height: 1rem; color: var(--ink-3); }

/* ---- Status chips: the one status mark on every screen ---- */
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 var(--space-2); border: 1px solid transparent; border-radius: var(--radius-chip); background: var(--raised); color: var(--ink-2); font-size: var(--text-xs); font-weight: 650; line-height: 1rem; white-space: nowrap; }
.chip .i { width: 12px; height: 12px; stroke-width: 2.5; }
.chip-pencil { background: var(--pencil-wash); color: var(--pencil); }
.chip-pass { background: var(--pass-wash); color: var(--pass); }
.chip-query { background: var(--query-wash); color: var(--query); }
.chip-stop { background: var(--stop-wash); color: var(--stop); }
.chip-stale { background: transparent; border: 1px dashed var(--line-strong); color: var(--ink-2); }
/* "Your turn": the one chip set in ink, with the gold mark. */
.chip-turn { background: var(--pencil); color: var(--on-pencil); }
.chip-turn::before { content: ""; width: 6px; height: 6px; background: var(--gold-on-pencil); }
.chips, .cluster { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ---- Folds ---- */
.fold { border-top: 1px solid var(--line); }
.fold > summary { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; cursor: pointer; font-weight: 650; font-size: var(--text-sm); line-height: 1.25rem; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); transform: rotate(-45deg); transition: transform .15s var(--ease-out); }
.fold[open] > summary::before { transform: rotate(45deg); }
.fold > summary .fold-note { margin-left: auto; color: var(--ink-3); font-weight: 400; }
.fold-body { padding-bottom: var(--space-4); }
.more { font-size: var(--text-sm); line-height: 1.25rem; }
.more > summary { display: inline; cursor: pointer; color: var(--ink-2); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; text-decoration-color: var(--line-strong); list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more[open] > summary { color: var(--ink-2); }
@media (hover:hover) and (pointer:fine) { .more > summary:hover { color: var(--ink); } }
.more-body { margin-top: var(--space-2); color: var(--ink-2); }

/* ---- Callouts ---- */
.callout { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--raised); color: var(--ink); font-size: var(--text-sm); line-height: 1.25rem; }
.callout .i { margin-top: 2px; width: 16px; height: 16px; }
.callout-query { background: var(--query-wash); border-color: color-mix(in oklch, var(--query) 30%, transparent); } .callout-query .i { color: var(--query); }
.callout-stop { background: var(--stop-wash); border-color: color-mix(in oklch, var(--stop) 35%, transparent); } .callout-stop .i { color: var(--stop); }
.callout-pencil { background: var(--pencil-wash); } .callout-pencil .i { color: var(--pencil); }
.callout strong { font-weight: 700; }
/* The art step's refusal (a label and a sentence, not two columns): the label runs into the sentence, so a narrow screen never squeezes it to one word a line (TASK-105). */
#art-refused { display: block; }
.toast { position: fixed; left: var(--space-5); bottom: var(--space-5); z-index: 50; display: flex; align-items: center; gap: var(--space-3); max-width: 380px; padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); box-shadow: var(--shadow-overlay); font-size: var(--text-sm); font-weight: 600; }
.toast-icon { width: 18px; height: 18px; color: var(--pass); }
.toast.warn { border-color: var(--query); } .toast.warn .toast-icon { color: var(--query); }
.toast.error { border-color: var(--stop); } .toast.error .toast-icon { color: var(--stop); }
.toast-close { all: unset; display: grid; width: 28px; height: 28px; place-items: center; border-radius: var(--radius-control); color: var(--ink-3); cursor: pointer; }
@media (hover:hover) and (pointer:fine) { .toast-close:hover { background: var(--raised); color: var(--ink); } }
.toast-close:focus-visible { outline: 2px solid var(--pencil-hi); }
.toast.is-static { position: static; box-shadow: none; }

/* ---- Confirm: the desk's one question before a bulk or paid action (TASK-105) ----
   A native <dialog> made by app.js, in the desk's own type, buttons and tokens. The question is plain
   text; "Not yet" is the quiet button, the action is the primary one (red outline when the button
   that opened it was a danger button). Narrow screens stack the two, full width. */
.desk-confirm { width: min(30rem, calc(100% - var(--space-4) * 2)); max-width: none; margin: auto; padding: var(--space-5); border: 1px solid var(--line-strong); border-radius: var(--radius-panel); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-overlay); font: 400 var(--text-md)/1.5 var(--font-house); }
.desk-confirm::backdrop { background: color-mix(in oklch, var(--mast) 55%, transparent); }
.desk-confirm-text { margin: 0; max-width: 56ch; text-wrap: pretty; overflow-wrap: anywhere; }
.desk-confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-5); }
.desk-confirm-actions .btn { height: auto; padding-block: var(--space-2); text-align: center; }
@media (max-width: 560px) {
  .desk-confirm { padding: var(--space-4); }
  .desk-confirm-actions { flex-direction: column; }
  .desk-confirm-actions .btn { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .desk-confirm[open] { animation: desk-confirm-in .18s var(--ease-out); }
  .desk-confirm[open]::backdrop { animation: desk-confirm-fade .18s linear; }
}
@keyframes desk-confirm-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes desk-confirm-fade { from { opacity: 0; } }

/* ---- Shells ---- */
.shell { display: grid; min-height: calc(100vh - 56px); min-height: calc(100dvh - 56px); }
.shell-book { grid-template-columns: 256px minmax(0, 1fr) 352px; }
.shell-gate { grid-template-columns: minmax(0, 1fr) 368px; }
.work { padding: var(--space-6) var(--space-7) var(--space-8); min-width: 0; }
.work-in { max-width: 760px; margin: 0 auto; }
.shell-gate .work-in { max-width: 840px; }
.work-in > * + * { margin-top: var(--space-5); }
.work-in > .crumb + .page-title, .work-in > .page-title + .page-sub { margin-top: var(--space-1); }
.rail { background: var(--well); border-left: 1px solid var(--line); }
.rail-in { position: sticky; top: 56px; max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px); overflow-y: auto; padding: var(--space-5); display: grid; gap: var(--space-5); align-content: start; }
.rail h2, .rail h3, .rail-label { font: 650 var(--text-xs)/1rem var(--font-house); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

/* ---- Stepper: the book's contents page ---- */
.contents { padding: var(--space-6) var(--space-4) var(--space-6) var(--space-5); border-right: 1px solid var(--line); }
.contents-in { position: sticky; top: calc(56px + var(--space-6)); }
.contents-title { font: italic 400 var(--text-sm)/1.25rem var(--font-page); color: var(--ink-3); }
.toc-act { display: flex; justify-content: space-between; margin: var(--space-4) 0 var(--space-1); font: 650 var(--text-xs)/1rem var(--font-house); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.toc-act small { font-size: inherit; letter-spacing: 0; text-transform: none; font-weight: 500; }
.toc-step { display: grid; grid-template-columns: 14px 18px auto minmax(8px, 1fr) auto; align-items: baseline; column-gap: 6px; margin: 0 calc(var(--space-2) * -1); padding: 4px var(--space-2); border-radius: var(--radius-control); color: var(--ink-2); font-size: var(--text-sm); line-height: 1.25rem; text-decoration: none; }
@media (hover:hover) and (pointer:fine) { a.toc-step:hover { background: var(--raised); color: var(--ink); } }
.toc-mark { align-self: center; width: 14px; height: 14px; }
.toc-n { color: var(--ink-3); font-size: var(--text-xs); text-align: right; }
.toc-lead { border-bottom: 1px dotted var(--line-strong); transform: translateY(-4px); }
.toc-note { color: var(--ink-3); font-size: var(--text-xs); white-space: nowrap; }
.toc-step.is-done .toc-mark { color: var(--pass); }
.toc-step.is-wait { color: var(--ink-3); }
.toc-step.is-wait .toc-mark { color: var(--line-strong); }
/* You are here: the row is set in ink, the mark in gold. */
.toc-step.is-here { background: var(--pencil); color: var(--on-pencil); font-weight: 650; }
.toc-step.is-here .toc-mark { color: var(--gold-on-pencil); }
.toc-step.is-here .toc-n, .toc-step.is-here .toc-note { color: var(--on-pencil); }
.toc-step.is-here .toc-lead { border-color: transparent; }
@media (hover:hover) and (pointer:fine) { a.toc-step.is-here:hover { background: var(--pencil-hi); color: var(--on-pencil); } }
.toc-step.is-working .toc-mark, .toc-step.is-working .toc-note { color: var(--pencil); }
.toc-step.is-stop .toc-mark, .toc-step.is-stop .toc-note { color: var(--stop); }
.toc-step.is-stale .toc-mark, .toc-step.is-stale .toc-note { color: var(--query); }

/* ---- Next step: the one panel on the book desk ---- */
.next { margin-top: var(--space-6); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); box-shadow: 0 1px 0 var(--shade); }
.next-body { padding: var(--space-5) var(--space-5) var(--space-5); }
.next-where { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.next-where b { color: var(--ink); font-weight: 650; }
/* Twelve ticks, one per step, grouped by act. */
.next-track { display: flex; gap: 3px; margin-top: var(--space-3); }
.next-track li { flex: 1; height: 4px; background: var(--line); }
.next-track li.is-done { background: var(--ink-3); }
.next-track li.is-here { background: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-ink); }
.next-track li.act-start { margin-left: var(--space-2); }
/* The strip fills left to right once, in about a third of a second, when the panel arrives. */
.next .next-track li.is-done, .next .next-track li.is-here { transform-origin: left center; animation: tick-fill .32s var(--ease-out) both; }
.next .next-track li:nth-child(2) { animation-delay: 20ms; } .next .next-track li:nth-child(3) { animation-delay: 40ms; }
.next .next-track li:nth-child(4) { animation-delay: 60ms; } .next .next-track li:nth-child(5) { animation-delay: 80ms; }
.next .next-track li:nth-child(6) { animation-delay: 100ms; } .next .next-track li:nth-child(7) { animation-delay: 120ms; }
.next .next-track li:nth-child(8) { animation-delay: 140ms; } .next .next-track li:nth-child(9) { animation-delay: 160ms; }
.next .next-track li:nth-child(10) { animation-delay: 180ms; } .next .next-track li:nth-child(11) { animation-delay: 200ms; }
.next .next-track li:nth-child(12) { animation-delay: 220ms; }
@keyframes tick-fill { from { transform: scaleX(0); } }
/* Every step done: the whole strip turns gold. */
.next-track.is-complete li { background: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-ink); }
.next h2 { margin-top: var(--space-4); font: 600 var(--text-2xl)/2.25rem var(--font-page); letter-spacing: -.008em; text-wrap: balance; }
.next-why { margin-top: var(--space-1); max-width: 58ch; color: var(--ink-2); }
.next-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); margin-top: var(--space-5); }
.next-actions .aside-voice { max-width: 30ch; }
.next .specs { margin-top: var(--space-4); }
.specs dd.wrap-any { overflow-wrap: anywhere; }

/* ---- Cost: the panel's footer, always in dollars and cents ---- */
.cost { padding: var(--space-4) var(--space-5) var(--space-4); border-top: 1px solid var(--line); background: var(--desk); border-radius: 0 0 var(--radius-panel) var(--radius-panel); }
.cost-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
/* What this click will take is the loudest figure; the rest is context. */
.cost-line strong { font-size: var(--text-2xl); line-height: 2.25rem; color: var(--ink); font-weight: 650; letter-spacing: -.012em; }
.cost-fit { margin-left: auto; }
.meter { display: flex; height: 8px; margin-top: var(--space-3); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.meter-spent { min-width: 3px; background: var(--ink-2); }
.meter-uncertain { min-width: 3px; background: repeating-linear-gradient(135deg, var(--stop) 0 3px, var(--stop-wash) 3px 6px); }
.meter-step { min-width: 3px; background: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-ink); }
.cost.is-over .meter-step { background: repeating-linear-gradient(135deg, var(--stop) 0 3px, var(--stop-wash) 3px 6px); box-shadow: none; }
/* Legend: the figure first, set larger; label after it. */
.cost-legend { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); margin-top: var(--space-3); font-size: var(--text-xs); line-height: 1rem; color: var(--ink-3); }
.cost-legend > span { min-width: 88px; padding-top: var(--space-2); border-top: 3px solid var(--line); }
.cost-legend b { display: block; color: var(--ink-2); font-size: var(--text-sm); line-height: 1.25rem; font-weight: 600; }
.cost-legend .k-left b { color: var(--ink); }
.cost-legend .k-spent { border-top-color: var(--ink-2); }
.cost-legend .k-step { border-top-color: var(--gold); }
.cost-legend .k-step b { color: var(--gold-ink); }
.cost-legend .k-uncertain { border-top-color: var(--stop); }
.cost.is-over .cost-legend .k-step { border-top-color: var(--stop); }
.cost.is-over .cost-legend .k-step b { color: var(--stop); }
.cost-legend .k-limit { margin-left: auto; text-align: right; border-top-color: transparent; }
.cost .more { margin-top: var(--space-3); }

/* ---- Activity (run panel) ---- */
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); margin-top: var(--space-7); padding-bottom: var(--space-2); border-bottom: 1px solid var(--ink); }
.section-head h2 { font: 650 var(--text-md)/1.5rem var(--font-house); }
.section-head .aside-voice { margin-left: auto; }
.run-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-3) 0 0; font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.run-money, .run-tally { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); margin-top: var(--space-2); padding-bottom: var(--space-3); font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-3); }
.run-money strong { color: var(--ink); font-weight: 650; }
.run-controls { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-3); }
/* The book's record: Activity, Setup and Spend in one panel, one separator, one row rhythm. */
.records { margin-top: var(--space-6); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
.records > section { padding: 0 var(--space-5) var(--space-1); }
.records > section .section-head { margin-top: 0; padding: var(--space-4) 0 0; border-bottom: 0; }
.records > section .fold { margin-inline: calc(var(--space-5) * -1); padding-inline: var(--space-5); background: var(--desk); }
.records > section .fold > summary { font-weight: 600; color: var(--ink-2); }
.records > .fold { border-top: 1px solid var(--line); }
.records > .fold > summary { padding: var(--space-3) var(--space-5); }
.records > .fold > .fold-body { padding: 0 var(--space-5) var(--space-4); }
.records > .fold:last-child > summary { border-radius: 0 0 var(--radius-panel) var(--radius-panel); }
@media (hover:hover) and (pointer:fine) { .records .fold > summary:hover { color: var(--ink); } }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: 1.25rem; }
table.data th { padding: var(--space-2) var(--space-3) var(--space-2) 0; border-bottom: 1px solid var(--line-strong); color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; text-align: left; white-space: nowrap; }
table.data td { padding: var(--space-3) var(--space-3) var(--space-3) 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data .num { text-align: right; }
table.data tr > :last-child { padding-right: 0; }
table.kv th { width: 40%; color: var(--ink-3); font-size: var(--text-sm); font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ---- Paper: everything that is the book ---- */
.paper { position: relative; border-radius: var(--radius-paper); background: var(--paper); color: var(--paper-ink); box-shadow: var(--shadow-paper); overflow: hidden; }
.paper img { width: 100%; height: 100%; object-fit: cover; }
/* Crop marks at the trim corners, 12px out, 1px ink. */
.trimmed { position: relative; padding: 16px; --crop: var(--ink-2); }
.trimmed::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-repeat: no-repeat;
  background-image: linear-gradient(var(--crop), var(--crop)), linear-gradient(var(--crop), var(--crop)), linear-gradient(var(--crop), var(--crop)), linear-gradient(var(--crop), var(--crop)), linear-gradient(var(--crop), var(--crop)), linear-gradient(var(--crop), var(--crop)), linear-gradient(var(--crop), var(--crop)), linear-gradient(var(--crop), var(--crop));
  background-size: 1px 11px, 11px 1px, 1px 11px, 11px 1px, 1px 11px, 11px 1px, 1px 11px, 11px 1px;
  background-position: left 16px top 0, left 0 top 16px, right 16px top 0, right 0 top 16px, left 16px bottom 0, left 0 bottom 16px, right 16px bottom 0, right 0 bottom 16px; }
.rail-cover { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; row-gap: 2px; }
.rail-cover .trimmed { grid-column: 2; width: 216px; }
.rail-cover .paper { aspect-ratio: var(--cover-ratio, 6 / 9); }
.dim-h { grid-column: 2; display: flex; align-items: center; gap: var(--space-2); width: 184px; color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; }
.dim-h::before, .dim-h::after { content: ""; flex: 1; border-top: 1px solid var(--ink-3); }
.dim-v { grid-column: 3; grid-row: 1; justify-self: start; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); height: 84%; margin-left: -6px; color: var(--ink-3); font-size: var(--text-xs); }
.dim-v span { writing-mode: vertical-rl; }
.dim-v::before, .dim-v::after { content: ""; flex: 1; border-left: 1px solid var(--ink-3); }
.rail-cover figcaption { grid-column: 1 / -1; margin-top: var(--space-2); color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; text-align: center; }

/* The dummy: an unprinted book at the right size, set in the book's own type. */
.dummy { display: grid; grid-template-rows: 1fr auto; padding: 14% 10% 8%; text-align: center; }
.dummy-title { font: 700 21px/1.15 var(--font-book-display); text-wrap: balance; }
.dummy-sub { margin-top: 8px; font: 400 11px/1.4 var(--font-book-text); color: var(--paper-ink-2); }
.dummy-press { font: 700 10px/1 var(--font-book-text); }
/* Before cover art exists the dummy is typeset, never a placeholder: the press mark, as on the rail book's cover. */
.dummy-mark { display: block; width: 22%; max-width: 40px; height: auto; margin: 14% auto 0; --brand-navy: var(--paper-pencil); --brand-gold: var(--gold); }

/* A leaf: one page of the dummy, typeset in HTML before any PDF exists, fitted to the live review content's reading rhythm. */
.leaf { width: 100%; max-width: 300px; min-height: 0; aspect-ratio: var(--leaf-ratio, 6 / 9); padding: 9% 9% 7%; overflow-y: auto; font: 400 9.5px/1.45 var(--font-book-text); }
.leaf-head { font: 700 15px/1.2 var(--font-book-display); margin-bottom: 8px; }
.leaf-part { display: flex; gap: 6px; margin-top: 9px; font: 700 10.5px/1.3 var(--font-book-display); }
.leaf-row { display: flex; align-items: baseline; gap: 4px; padding-left: 12px; color: var(--paper-ink); text-decoration: none; }
.leaf-row .dots { flex: 1; min-width: 8px; border-bottom: 1px dotted currentColor; opacity: .45; transform: translateY(-2px); }
.leaf-row.is-open { color: var(--paper-ink-2); }
.leaf-row.is-open .t { font-style: italic; }
.leaf-row.is-marked .t { box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--paper-pencil) 55%, transparent); }
@media (hover:hover) and (pointer:fine) { .leaf-row:hover { color: var(--paper-pencil); text-decoration: underline; } }
.leaf-row:focus-visible { outline-color: var(--paper-pencil); }
.leaf-blank { padding-left: 12px; color: var(--paper-ink-2); font-style: italic; }
.leaf-slot { height: 14px; margin-left: 12px; border-bottom: 1px dotted color-mix(in srgb, var(--paper-ink-2) 60%, transparent); }
.leaf-q { font: 700 13px/1.25 var(--font-book-display); margin-top: 8px; }
.leaf-art { aspect-ratio: 4 / 3; border: 1px dashed var(--paper-ink-2); border-radius: 6px; display: grid; place-items: center; color: var(--paper-ink-2); }

.specs { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--space-4); font-size: var(--text-sm); line-height: 1.25rem; }
.specs dt { color: var(--ink-3); }
.specs dd { color: var(--ink); font-weight: 600; }
.specs dd small { display: block; color: var(--ink-3); font-size: var(--text-xs); font-weight: 400; }

.rail-block { display: grid; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.rail-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.rail-block-head a { font-size: var(--text-sm); }
.rail-block-head span { font-size: var(--text-xs); color: var(--ink-3); }
.rail-block > .muted { margin-top: calc(var(--space-2) * -1); }
.spreads { display: grid; gap: var(--space-4); }
.spread { position: relative; display: grid; grid-template-columns: 1fr 1fr; box-shadow: var(--shadow-paper); }
.spread::after { content: ""; position: absolute; inset: 0 calc(50% - 7px); pointer-events: none; background: linear-gradient(90deg, transparent, oklch(20% 0.02 75 / .16) 48%, oklch(20% 0.02 75 / .16) 52%, transparent); }
.page { position: relative; display: block; aspect-ratio: var(--page-ratio, 6 / 9); background: var(--paper); overflow: hidden; }
.page img { width: 100%; height: 100%; object-fit: contain; }
.page.is-blank { background: transparent; }
.spread.has-blank { box-shadow: none; } .spread.has-blank::after { display: none; }
.spread.has-blank .page:not(.is-blank) { box-shadow: var(--shadow-paper); }
.spread-cap { display: flex; justify-content: space-between; gap: var(--space-2); margin-top: 6px; color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; }
.spread-cap .mark { color: var(--pencil); font-weight: 700; }
.page:first-child { border-radius: var(--radius-paper) 0 0 var(--radius-paper); } .page:last-child { border-radius: 0 var(--radius-paper) var(--radius-paper) 0; }
.page.is-changed::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 22px 22px 0; border-color: transparent var(--paper-pencil) transparent transparent; }
.page.is-changed::before { content: ""; position: absolute; inset: 0; z-index: 1; border: 2px solid var(--paper-pencil); border-radius: inherit; pointer-events: none; }

/* The book's proofs, in step order, as one list in the rail. */
.rail-group { display: grid; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.proof-list { display: grid; }
.proof-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; column-gap: var(--space-2); align-items: baseline; padding: var(--space-3) 0; border-top: 1px solid var(--line); font-size: var(--text-sm); line-height: 1.25rem; }
.proof-row:first-child { border-top: 0; }
.proof-row > .i { align-self: center; width: 14px; height: 14px; }
.proof-row b { font-weight: 650; color: var(--ink); }
.proof-row .note { grid-column: 2; color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; }
.proof-row > a { grid-column: 3; grid-row: 1; font-size: var(--text-sm); }
.proof-row > .spreads { grid-column: 2 / -1; margin-top: var(--space-3); }
.proof-row.is-done > .i { color: var(--pass); }
.proof-row.is-here > .i { color: var(--gold-ink); }
.proof-row.is-here b { color: var(--ink); }
.proof-row.is-wait { color: var(--ink-3); }
.proof-row.is-wait > .i { color: var(--line-strong); }
.proof-row.is-wait b { color: var(--ink-3); font-weight: 600; }
/* A strip of pages at one height: singles and spreads keep their shape, the stamp lands on them. */
.spreads.is-strip { position: relative; display: flex; align-items: flex-start; gap: var(--space-2); padding-bottom: var(--space-1); }
.spreads.is-strip figure { flex: none; }
.spreads.is-strip .spread { display: flex; height: 72px; }
.spreads.is-strip .page { flex: none; height: 100%; width: auto; }
.spreads.is-strip .page.is-blank { display: none; }
.spreads.is-strip .spread.has-blank { box-shadow: var(--shadow-paper); }
.spreads.is-strip .spread-cap { margin-top: var(--space-1); }
.spreads.is-strip > .stamp { right: 6px; top: 30px; padding: 4px 7px 3px; font-size: 10px; }
.spreads.is-strip > .stamp small { font-size: 10px; }

.changes { display: grid; gap: var(--space-2); font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.changes li { display: grid; grid-template-columns: 14px 1fr; gap: var(--space-2); align-items: baseline; }
.changes li::before { content: ""; width: 7px; height: 7px; margin-top: 6px; background: var(--pencil); align-self: start; }
.changes li.is-same::before { background: transparent; border: 1px solid var(--line-strong); }
.changes strong { color: var(--ink); font-weight: 700; }

/* Approval stamp: the one loud moment. Square, double rule, no bounce. */
.stamp { display: inline-grid; gap: 2px; padding: 6px 10px 5px; border: 2px solid currentColor; outline: 1px solid currentColor; outline-offset: 2px; color: var(--pass); font: 800 12px/1.1 var(--font-house); letter-spacing: .1em; text-transform: uppercase; transform: rotate(-2deg); }
.stamp small { font-size: 11px; font-weight: 600; letter-spacing: .01em; text-transform: none; }
.stamp.is-fresh { animation: stamp .24s var(--ease-out) both; }
/* On paper the stamp takes the paper's own green and a little of the page behind it. */
.stamp-on-paper { position: absolute; z-index: 2; color: var(--paper-pass); background: color-mix(in oklch, var(--paper) 88%, transparent); font-size: 11px; }
.paper > .stamp-on-paper { right: 8%; bottom: 7%; }
@keyframes stamp { from { opacity: 0; transform: rotate(-2deg) scale(1.35); } }

/* ---- Review bar, groups, item review card (G1 / G2) ---- */
.review-bar { position: sticky; top: 56px; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); margin: var(--space-5) calc(var(--space-4) * -1) 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); box-shadow: var(--shadow-overlay); }
.review-count { font-weight: 700; white-space: nowrap; }
.track { flex: 1 1 120px; height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--pass); }
.group-head { display: flex; align-items: baseline; gap: var(--space-3); margin: var(--space-7) 0 var(--space-3); }
.group-head h2 { font: 700 var(--text-md)/1.3 var(--font-house); }
.group-head p { color: var(--ink-3); font-size: var(--text-sm); }
.item { margin-top: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
.item.is-flagged { border-color: var(--query); }
.item.is-pending { border-color: var(--pencil); }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-4) var(--space-5) 0; font-size: var(--text-sm); color: var(--ink-3); }
.item-head .chips { margin-left: auto; }
.item-read { padding: var(--space-2) var(--space-5) var(--space-4); }
.item-q { font: 600 var(--text-xl)/1.3 var(--font-page); text-wrap: balance; }
.item-a { margin-top: var(--space-2); max-width: 62ch; font: 400 var(--text-lg)/1.6 var(--font-page); }
.item-why { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--ink-2); }
.item-why strong { color: var(--query); font-weight: 700; }
.claims { border-top: 1px solid var(--line); }
.claim { display: grid; grid-template-columns: 20px 1fr auto; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.claim > .i { width: 18px; height: 18px; margin-top: 2px; }
.claim-text { color: var(--ink); font-weight: 600; }
.claim-note { margin-top: 2px; color: var(--ink-2); }
.claim-note b { font-weight: 700; }
.claim.is-verified > .i, .claim.is-verified .claim-note b { color: var(--pass); }
.claim.is-fix > .i, .claim.is-fix .claim-note b { color: var(--query); }
.claim.is-false > .i, .claim.is-false .claim-note b { color: var(--stop); }
.item-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); }
.item-foot select { width: 210px; margin: 0; font-size: var(--text-sm); }
.item-edit[open] { flex-basis: 100%; order: 9; }
.item-edit > summary { list-style: none; display: inline-flex; }
.item-edit > summary::-webkit-details-marker { display: none; }
.item-edit[open] > summary { background: var(--raised); }
.item-edit form { display: grid; gap: var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.item-edit .fine { font-size: var(--text-xs); color: var(--ink-3); }
/* Kept items fold to one line. */
.item-kept > summary { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); cursor: pointer; list-style: none; }
.item-kept > summary::-webkit-details-marker { display: none; }
.item-kept > summary > .i { color: var(--pass); }
.item-kept[open] > summary { border-bottom: 1px solid var(--line); }
.kept-q { font: 500 var(--text-md)/1.35 var(--font-page); }
.kept-by { color: var(--ink-3); font-size: var(--text-xs); }
.more-cards { margin-top: var(--space-4); padding: var(--space-3) var(--space-5); border: 1px dashed var(--line-strong); border-radius: var(--radius-panel); color: var(--ink-3); font-size: var(--text-sm); }

/* ---- Print checks ---- */
.proof-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.proof-bar .btn { margin-left: auto; }
.proof-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6) var(--space-5); margin: var(--space-5) calc(var(--space-5) * -1) 0; padding: var(--space-5); border-radius: var(--radius-panel); background: var(--well); }
.checks { margin-top: 0; }
.check-group { padding: var(--space-4) 0; border-bottom: 1px solid var(--line); }
.check-group > h3 { display: flex; align-items: center; gap: var(--space-2); font: 650 var(--text-sm)/1.25rem var(--font-house); }
.check-group > h3 .i { width: 16px; height: 16px; }
.check-group > p { margin-top: var(--space-1); color: var(--ink-2); font-size: var(--text-sm); }
.check-rows { margin-top: var(--space-2); display: grid; gap: var(--space-2); font-size: var(--text-sm); line-height: 1.25rem; }
.check-rows li { display: grid; grid-template-columns: 16px 1fr; gap: var(--space-2); align-items: baseline; color: var(--ink-2); }
.check-rows li b { color: var(--ink); font-weight: 600; }
.check-rows .i { width: 14px; height: 14px; transform: translateY(2px); }
.check-rows.two { grid-template-columns: 1fr 1fr; column-gap: var(--space-5); }
.is-query-ink { color: var(--query); } .is-pass-ink { color: var(--pass); } .is-muted-ink { color: var(--ink-3); } .is-stop-ink { color: var(--stop); }

/* ---- Cover proof stage: the wrap on a light table, trimmed, with its zones measured ---- */
.cover-proof-stage { padding: var(--space-6) var(--space-5) var(--space-4); background: var(--well); border: 1px solid var(--line); }
.cover-proof-stage .trimmed { padding: 20px; }
.cover-proof-stage .trimmed::before { background-position: left 20px top 0, left 0 top 20px, right 20px top 0, right 0 top 20px, left 20px bottom 0, left 0 bottom 20px, right 20px bottom 0, right 0 bottom 20px; }
.cover-proof-stage .paper { display: block; }
.cover-proof-stage img { height: auto; object-fit: contain; }
.cover-proof-stage .fold-line { position: absolute; top: 20px; bottom: 20px; left: 50%; width: 0; border-left: 1px dashed oklch(98% 0.01 85 / .7); }
.cover-zone-labels { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--space-2); margin: var(--space-2) 20px 0; color: var(--ink-2); text-align: center; font-size: var(--text-xs); line-height: 1rem; }
.cover-zone-labels span { display: flex; align-items: center; gap: var(--space-2); }
.cover-zone-labels span::before, .cover-zone-labels span::after { content: ""; flex: 1; border-top: 1px solid var(--ink-3); }
.cover-zone-labels .z-spine::before, .cover-zone-labels .z-spine::after { flex: 0 0 6px; }
.cover-zone-labels b { color: var(--ink); font-weight: 650; }

/* ---- Listing for the KDP upload ---- */
.listing-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-3); font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
/* Read first: the listing as the shopper meets it. Edit second, in a fold, as the HTML KDP takes. */
.listing-read { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-5); margin-top: var(--space-4); }
.listing-copy { display: grid; gap: var(--space-2); align-content: start; }
.listing-page { padding: var(--space-4) var(--space-5); border: 1px solid var(--line); background: var(--surface); font-size: var(--text-md); line-height: 1.5rem; max-width: 62ch; }
.listing-page p + p { margin-top: var(--space-3); }
.listing-facts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); align-content: start; }
.listing-facts > div { grid-column: 1 / -1; }
.listing-facts > .listing-half { grid-column: auto; }
.listing-facts dt { display: flex; justify-content: space-between; gap: var(--space-2); font: 650 var(--text-xs)/1rem var(--font-house); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.listing-facts dt small { font-size: inherit; letter-spacing: 0; text-transform: none; font-weight: 500; }
.listing-facts dd { margin-top: var(--space-2); font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink); }
.listing-keys { counter-reset: kw; display: grid; gap: 2px; }
.listing-keys li { counter-increment: kw; display: grid; grid-template-columns: 20px 1fr; padding: 2px 0; border-bottom: 1px dotted var(--line); }
.listing-keys li::before { content: counter(kw); color: var(--ink-3); font-size: var(--text-xs); }
.listing-cats { display: grid; gap: var(--space-2); }
.listing-cats li span + span::before { content: "›"; margin: 0 6px; color: var(--ink-3); }
.listing-cats li span:last-child { font-weight: 650; }
.listing-edit { margin-top: var(--space-5); }
.listing-edit > summary .fold-note { font-weight: 400; }
.listing-form { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4) var(--space-5); margin-top: var(--space-4); }
.listing-form > label:first-of-type, .listing-form > .fine, .listing-form > button { grid-column: 1 / -1; }
.listing-form > .fine { margin-top: calc(var(--space-3) * -1); }
.listing-form > button { justify-self: start; }
.listing-form textarea[name="description"] { font: 400 var(--text-sm)/1.25rem var(--font-code); }
.listing-form textarea[name="keywords"], .listing-form textarea[name="categories"] { white-space: pre; overflow-x: auto; font-size: var(--text-sm); line-height: 1.5rem; background-image: repeating-linear-gradient(transparent 0 calc(1.5rem - 1px), var(--line) calc(1.5rem - 1px) 1.5rem); background-attachment: local; background-position: 0 var(--space-2); }

/* ---- Decision panel ---- */
.gate { display: grid; gap: var(--space-4); padding: var(--space-5) var(--space-4) var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-panel); background: var(--surface); box-shadow: 0 1px 0 var(--shade); }
.gate > h2 { font: 600 var(--text-xl)/1.75rem var(--font-page); color: var(--ink); text-transform: none; letter-spacing: -.005em; }
.gate-file { font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-3); }
.gate-file b { display: block; color: var(--ink); font-weight: 650; }
.gate-sum { display: grid; gap: 6px; padding: var(--space-3) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: var(--text-sm); line-height: 1.25rem; }
.gate-sum li { display: grid; grid-template-columns: 16px 1fr; gap: var(--space-2); align-items: center; }
.gate-sum .i { width: 16px; height: 16px; }
.proof-decision-form, .gate form { display: grid; gap: var(--space-4); }
.acks { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid color-mix(in oklch, var(--query) 30%, transparent); border-radius: var(--radius-control); background: var(--query-wash); }
.acks legend { float: left; width: 100%; margin-bottom: var(--space-2); font-size: var(--text-xs); line-height: 1rem; font-weight: 700; color: var(--query); }
.acks label { display: grid; grid-template-columns: 18px 1fr; gap: var(--space-2); clear: both; color: var(--ink); font-weight: 400; cursor: pointer; }
.gate-actions { display: grid; gap: var(--space-2); }
.gate .fine { font-size: var(--text-xs); color: var(--ink-3); }
.gate-stamped { display: grid; justify-items: start; gap: var(--space-4); padding: var(--space-3) var(--space-2); }
.book-mini { display: grid; grid-template-columns: 52px 1fr; gap: var(--space-3); align-items: center; }
.book-mini .paper { aspect-ratio: 6 / 9; display: grid; place-items: center; }
.book-mini b { display: block; font: 600 var(--text-md)/1.375rem var(--font-page); color: var(--ink); }
.book-mini span { display: block; margin-top: 2px; font-size: var(--text-xs); line-height: 1rem; color: var(--ink-3); }
.cover-crop img { position: absolute; width: var(--crop-width); height: var(--crop-height); max-width: none; left: calc(-1 * var(--crop-left)); top: calc(-1 * var(--crop-top)); object-fit: fill; }
.mini-mark { width: 70%; --brand-navy: var(--paper-pencil); --brand-gold: oklch(72.2% 0.135 78); opacity: .9; }
#gate-panel { scroll-margin-top: 68px; }

/* ---- Books ---- */
.shelf { margin-top: var(--space-5); border-top: 1px solid var(--ink); }
.shelf-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 200px 160px; gap: var(--space-5); align-items: center; padding: var(--space-4) var(--space-3); border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
@media (hover:hover) and (pointer:fine) { .shelf-row:hover { background: var(--surface); color: inherit; } }
@media (hover:hover) and (pointer:fine) { .shelf-row:hover .shelf-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; text-decoration-color: var(--line-strong); } }
.shelf-row:focus-visible { outline-offset: -2px; }
.shelf-row .paper { aspect-ratio: 6 / 9; display: grid; place-items: center; }
.shelf-title { display: block; font: 600 var(--text-xl)/1.75rem var(--font-page); color: var(--ink); }
.shelf-step { display: block; font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.shelf-row .next-track { margin-top: var(--space-2); max-width: 280px; }
.shelf-money, .shelf-act { font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-3); }
.shelf-money b, .shelf-act b { display: block; color: var(--ink); font-size: var(--text-md); line-height: 1.5rem; font-weight: 650; }
.shelf-money .meter { height: 4px; margin-top: var(--space-2); }
.shelf-state { justify-self: end; }

/* ---- Empty state ---- */
.empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-7) var(--space-5); border: 1px dashed var(--line-strong); text-align: center; }
.empty .trimmed { width: 92px; margin-bottom: var(--space-3); }
.empty .paper { display: grid; place-items: center; aspect-ratio: 6 / 9; box-shadow: none; background: transparent; border: 1px dashed var(--line-strong); }
.empty h2 { font: 600 var(--text-xl)/1.75rem var(--font-page); }
.empty p { max-width: 44ch; color: var(--ink-2); }
.empty .btn { margin-top: var(--space-3); }
.empty .mini-mark { width: 64%; opacity: .35; }
.empty .aside-voice { margin-top: var(--space-2); }

/* ---- Finished: the two files, in the next-step panel ---- */
.files { display: grid; margin-top: var(--space-5); border-top: 1px solid var(--line); }
.file-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.file-kind { display: grid; place-items: center; width: 40px; height: 48px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--paper-ink-2); font: 700 10px/1 var(--font-house); letter-spacing: .06em; }
.file-row b { display: block; font-weight: 650; }
.file-row small { display: block; color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; }
.next.is-ready .next-where .chip-pass { font-weight: 700; }

/* ---- Spend ---- */
.allowance { margin-top: var(--space-5); padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
.allowance header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.allowance h2 { font: 650 var(--text-md)/1.5rem var(--font-house); }
.allowance .meter { height: 12px; margin-top: var(--space-4); }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-4); }
.figures div { font-size: var(--text-xs); line-height: 1rem; color: var(--ink-3); }
.figures b { display: block; margin-bottom: 2px; font-size: var(--text-xl); line-height: 1.75rem; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.figures .is-stop b { color: var(--stop); }
.attention { margin-top: var(--space-6); border: 1px solid color-mix(in oklch, var(--stop) 45%, transparent); border-radius: var(--radius-panel); background: var(--surface); }
.attention-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-3) var(--space-4); background: var(--stop-wash); border-bottom: 1px solid color-mix(in oklch, var(--stop) 30%, transparent); border-radius: var(--radius-panel) var(--radius-panel) 0 0; }
.attention-head h2 { font: 650 var(--text-md)/1.5rem var(--font-house); color: var(--ink); }
.attention-head .i { width: 18px; height: 18px; color: var(--stop); }
.attention-head .chip { margin-left: auto; }
.attention-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--space-2) var(--space-5); align-items: center; padding: var(--space-4); }
.attention-row h3 { font: 600 var(--text-lg)/1.75rem var(--font-page); }
.attention-row p { font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.attention-row .amount { text-align: right; font-size: var(--text-xs); line-height: 1rem; color: var(--ink-3); }
.attention-row .amount b { display: block; font-size: var(--text-xl); line-height: 1.75rem; color: var(--stop); font-weight: 600; }
/* The allowance holds every other budget: they sit inside its panel, under a hairline. */
.allowance-budgets { margin: var(--space-5) calc(var(--space-5) * -1) calc(var(--space-5) * -1); padding: var(--space-4) var(--space-5) var(--space-2); border-top: 1px solid var(--line); background: var(--desk); border-radius: 0 0 var(--radius-panel) var(--radius-panel); }
.allowance-budgets > h3 { display: flex; justify-content: space-between; gap: var(--space-3); font: 650 var(--text-sm)/1.25rem var(--font-house); }
.allowance-budgets > h3 .aside-voice { font-weight: 400; }
.allowance-budgets .table-wrap { margin-top: var(--space-2); }
.budgets td .meter { width: 120px; height: 6px; margin-top: 7px; }
/* A matching ledger is the quiet default; only a mismatch gets a filled chip. */
.budgets .chip-pass { background: transparent; padding-inline: 0; }
.budgets .name code { font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink); font-weight: 500; }
.budgets .name { font-weight: 600; color: var(--ink); }
.budgets .name small { display: block; font-weight: 400; color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; }
.budgets .group td { padding-top: var(--space-5); border-bottom-color: var(--line-strong); color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.uncertain-ink { color: var(--stop); font-weight: 650; }
.muted { color: var(--ink-3); font-size: var(--text-sm); line-height: 1.25rem; }
.inline-details { font-size: var(--text-sm); }
.inline-details summary { color: var(--ink-3); cursor: pointer; }
.section-title-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); }

/* ---- Rules only the desk has today: headings, setup form, cards ---- */
hgroup { margin-bottom: var(--space-5); }
hgroup h1 { font: 600 var(--text-3xl)/1.15 var(--font-page); }
hgroup p { margin-top: var(--space-2); color: var(--ink-2); }
.eyebrow { display: block; color: var(--ink-3); font-size: var(--text-sm); margin-bottom: var(--space-2); }
.grid { display: grid; }
#press, #run, #setup { scroll-margin-top: 72px; }
.shortfall .table-wrap { margin-top: var(--space-3); }
.work-in > .fold + .fold { margin-top: 0; }
.item-tools, .action-swap-form fieldset { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.action-swap-form select { max-width: 100%; min-width: 0; }
.item-foot .sources[open] { flex-basis: 100%; }
.sources ul { margin-top: var(--space-2); overflow-wrap: anywhere; }
.section-card .section-scope, .section-card > .muted { margin-inline: var(--space-5); }
.section-number { color: var(--pencil); font: 500 var(--text-xl)/1 var(--font-page); }
.section-heading h2, .proof-section h2, .style-overview-grid h2 { font: 600 var(--text-xl)/1.25 var(--font-page); }
.section-status { margin-left: auto; }
.style-overview-grid, .illustration-grid, .sample-page-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.style-rules li { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.style-bible-card pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--text-xs); }
.illustration-grid, .sample-page-grid { margin-top: var(--space-4); }
.illustration-meta, .sample-page figcaption { margin-top: var(--space-2); }
.art-placeholder { padding: var(--space-4); border: 1px dashed var(--line-strong); color: var(--ink-2); }
@media (max-width: 560px) {
  .style-overview-grid { grid-template-columns: minmax(0, 1fr); }
}
.new-book .work-in { max-width: 640px; }
.setup-form, .setup-fieldset { display: grid; gap: var(--space-4); }
.setup-fieldset { padding-block: var(--space-3) var(--space-5); border-bottom: 1px solid var(--line); }
.setup-fieldset legend { font: 600 var(--text-xl)/1.25 var(--font-page); }
.setup-fieldset small { display: block; margin-top: var(--space-1); }
.setup-fieldset .grid, .task-decision .grid { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: var(--space-3); }
.setup-form > .btn, .task-decision form > .btn { justify-self: start; }
.section-title-row h2 { font: 600 var(--text-xl)/1.25 var(--font-page); }
.run-counts { margin-block: var(--space-3); }
.run-counts li { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); }
.restart-fields { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.restart-fields select { width: auto; max-width: 100%; margin: 0; }
.restart-form + p { margin-top: var(--space-2); }
.attention-list { display: grid; gap: var(--space-3); }
.attention-card { align-items: center; justify-content: space-between; flex-wrap: wrap; }
.attention-card h3 { font-size: var(--text-md); }
.attention-card .btn { flex: none; }
.task-callout { display: block; }
.technical-job { padding-block: var(--space-3); }
.technical-job > * + * { margin-top: var(--space-3); }
.technical-job h2 { font-size: var(--text-md); }
/* A cover with no crop data (no page plan, no page count): the whole wrap, full width, on the paper colour. */
.uncropped-wrap { background: var(--paper); }
.uncropped-wrap img { object-fit: contain; }
.item-extra { margin-top: var(--space-2); }
.item[id] { scroll-margin-top: 145px; }
.claim-table { display: block; width: 100%; min-width: 0; border-collapse: collapse; }
.claim-table tbody { display: block; }
.claim-table .claim { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); }
.claim-table .claim-text { grid-column: 1 / -1; display: flex; align-items: baseline; gap: var(--space-2); }
.claim-table .claim-text .i { align-self: start; margin-top: 3px; }
.claim-table .is-verified .i { color: var(--pass); }
.claim-table .is-fix .i { color: var(--query); }
.claim-table .is-false .i { color: var(--stop); }
.claim-table .claim-note { grid-column: 1; margin-left: calc(1em + var(--space-2)); }
.claim-table .claim-blind { grid-column: 2; grid-row: 2; }
.claim-table td { padding: 0; }
#book-spend { scroll-margin-top: 72px; }
@media (max-width: 560px) {
  .claim-table .claim { grid-template-columns: minmax(0, 1fr); }
  .claim-table .claim-blind { grid-column: 1; grid-row: auto; margin-left: calc(1em + var(--space-2)); }
}

/* ---- Responsive ---- */
@media (max-width: 1240px) {
  .shell-book { grid-template-columns: minmax(0, 1fr) 320px; }
  .contents { grid-column: 1 / -1; padding: var(--space-4) var(--space-5); border-right: 0; border-bottom: 1px solid var(--line); }
  .contents-in { position: static; }
  .toc { columns: 4; column-gap: var(--space-6); }
  .toc-act { margin-top: 0; break-after: avoid; }
  .toc-step { break-inside: avoid; }
  .work { padding: var(--space-5) var(--space-5) var(--space-7); }
  .shell-gate { grid-template-columns: minmax(0, 1fr) 336px; }
}
@media (max-width: 900px) {
  .shell-book, .shell-gate { grid-template-columns: minmax(0, 1fr); }
  .rail { border-left: 0; border-top: 1px solid var(--line); }
  .rail-in { position: static; max-height: none; }
  .spreads { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .toc { columns: 2; }
  .shelf-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .shelf-money, .shelf-act { grid-column: 2; }
  .shelf-state { grid-column: 3; grid-row: 1; }
  .listing-read { grid-template-columns: minmax(0, 1fr); }
  .proof-grid { margin-inline: 0; padding: var(--space-3); gap: var(--space-4) var(--space-3); }
  .review-bar { margin-inline: 0; }
}
@media (max-width: 640px) {
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  body.has-single-nav { padding-bottom: 0; }
  .mast-nav.is-single { display: none; }
  .masthead { gap: var(--space-3); padding: 0 var(--space-4); }
  .mast-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(56px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); justify-content: space-around; border-top: 1px solid var(--mast-line); background: var(--mast); }
  .mast-nav a { flex: 1; justify-content: center; border-bottom: 0; border-top: 2px solid transparent; font-size: var(--text-xs); white-space: nowrap; }
  .mast-nav a[aria-current="page"] { border-top-color: var(--gold); }
  .mast-tools .btn-sm { min-height: 40px; }
  .mast-tools .btn-icon { width: 40px; }
  .shell-book .work { order: 0; } .shell-book .contents { order: 1; border-top: 1px solid var(--line); border-bottom: 0; } .shell-book .rail { order: 2; }
  .toast { bottom: calc(56px + var(--space-3) + env(safe-area-inset-bottom, 0px)); }
  body.has-single-nav .toast { bottom: var(--space-3); }
}
@media (max-width: 560px) {
  .demo-banner { padding-inline: var(--space-4); }
  .work { padding: var(--space-4) var(--space-4) var(--space-7); }
  .contents { padding: var(--space-4); }
  .rail-in { padding: var(--space-4); }
  .page-title { font-size: var(--text-2xl); line-height: 2.25rem; }
  .imprint span { font-size: var(--text-md); }
  .toc { columns: 1; }
  .toc-act { margin-top: var(--space-4); }
  .next { margin-top: var(--space-4); margin-inline: calc(var(--space-4) * -1); border-inline: 0; border-radius: 0; }
  .next-body, .cost { padding-inline: var(--space-4); }
  .cost { border-radius: 0; }
  .next h2 { font-size: var(--text-xl); line-height: 1.75rem; }
  .next-actions .btn-lg { width: 100%; }
  .records { margin-inline: calc(var(--space-4) * -1); border-inline: 0; border-radius: 0; }
  .records > section { padding-inline: var(--space-4); }
  .records > section .fold { margin-inline: calc(var(--space-4) * -1); padding-inline: var(--space-4); }
  .records > .fold > summary { padding-inline: var(--space-4); }
  .records > .fold > .fold-body { padding-inline: var(--space-4); }
  .allowance { padding: var(--space-4); }
  .allowance-budgets { margin: var(--space-4) calc(var(--space-4) * -1) calc(var(--space-4) * -1); padding-inline: var(--space-4); }
  .listing-page { padding: var(--space-3) var(--space-4); }
  .file-row { grid-template-columns: 32px minmax(0, 1fr); }
  .file-kind { width: 32px; height: 40px; }
  .file-row .btn { grid-column: 2; justify-self: start; }
  .cost-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: var(--space-3); }
  .cost-legend .k-limit { margin-left: 0; text-align: left; }
  .check-rows.two { grid-template-columns: 1fr; }
  .listing-form { grid-template-columns: 1fr; }
  .cover-proof-stage { margin-inline: calc(var(--space-4) * -1); padding: var(--space-5) var(--space-2) var(--space-3); border-inline: 0; }
  .cover-proof-stage .trimmed { padding: 14px; }
  .cover-proof-stage .trimmed::before { background-position: left 14px top 0, left 0 top 14px, right 14px top 0, right 0 top 14px, left 14px bottom 0, left 0 bottom 14px, right 14px bottom 0, right 0 bottom 14px; }
  .cover-zone-labels { margin-inline: 14px; }
  .shelf-row { grid-template-columns: 40px minmax(0, 1fr); gap: var(--space-2) var(--space-3); padding-inline: 0; }
  .shelf-row .paper { grid-row: span 3; align-self: start; }
  .shelf-money, .shelf-act, .shelf-state { grid-column: 2; grid-row: auto; justify-self: start; }
  .shelf-money, .shelf-act { justify-self: stretch; max-width: 280px; }
  .shelf-money, .shelf-act { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
  .shelf-money b, .shelf-act b { display: inline; }
  .shelf-money .meter { flex-basis: 100%; }
  .figures { grid-template-columns: 1fr 1fr; }
  .attention-row { grid-template-columns: minmax(0, 1fr) auto; }
  .attention-row .btn { grid-column: 1 / -1; }
  /* Budgets table becomes stacked rows. */
  table.data.budgets thead { display: none; }
  table.data.budgets tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
  table.data.budgets td { padding: 0; border: 0; }
  table.data.budgets td.num { text-align: left; }
  table.data.budgets td[data-k]::before { content: attr(data-k); display: block; color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; }
  table.data.budgets td.name { grid-column: 1 / -1; }
  table.data.budgets .group { padding: var(--space-4) 0 var(--space-2); border-bottom-color: var(--line-strong); }
  table.data.budgets .group td { grid-column: 1 / -1; padding: 0; }
  .allowance-budgets > h3 { flex-wrap: wrap; }
  table.data.budgets td .meter { width: 100%; margin-top: var(--space-1); }
  table.data.budgets td.m { grid-column: 1 / -1; order: 9; }
  .proof-grid { grid-template-columns: 1fr; }
  .item-head, .item-read, .item-foot, .claim { padding-inline: var(--space-4); }
  .claim { grid-template-columns: 20px 1fr; }
  .toast { left: var(--space-3); right: var(--space-3); }
  hgroup h1 { font-size: var(--text-2xl); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Desk wording (TASK-038): classes that replace inline styles ---- */
.task-gap { margin-bottom: var(--space-4); }
.task-lead { margin-bottom: var(--space-2); }
.task-more { margin-top: var(--space-2); }
.details-inline { display: inline; border: 0; padding: 0; margin: 0; }
.details-inline > summary { display: inline; font-size: var(--text-xs); color: var(--ink-3); cursor: pointer; }
.gate-lead { font-size: var(--text-sm); margin-bottom: var(--space-3); }
.gate-list { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-3); }
.gate-check { display: inline-flex; align-items: center; gap: .4rem; margin-bottom: 0; }

/* ---- Costs setting (TASK-050): the limit note and the Settings page ---- */
.next-limit { padding: var(--space-3) var(--space-5) var(--space-4); border-top: 1px solid var(--line); }
.settings-form { display: grid; gap: var(--space-4); max-width: 62ch; margin-top: var(--space-5); }
.settings-fieldset { display: grid; gap: var(--space-3); padding-block: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.settings-fieldset legend { font: 600 var(--text-xl)/1.25 var(--font-page); }
.settings-choice { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: var(--space-2); align-items: center; color: var(--ink); font-weight: 400; cursor: pointer; }
.settings-choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--pencil); }
.settings-internal { max-width: 62ch; margin-top: var(--space-6); }
.settings-links { display: grid; gap: var(--space-2); margin-top: var(--space-3); list-style: none; }
.settings-links .count { margin-left: var(--space-1); vertical-align: 1px; }

/* ---- Press path (TASK-050): the four acts as sheets on a press bed ----
   Geometry: hairline `stack` figure, MIT (app/web/static/vendor/hairline-LICENSE.txt). Motion is
   a transform per sheet; reduced motion shows the pose (rule above). */
.press-path { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: var(--space-5); align-items: center; margin-top: var(--space-5); padding: var(--space-4) var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
.press-fig { display: block; width: 176px; aspect-ratio: 256 / 280; pointer-events: none; }
.press-fig path { fill: none; stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.press-fig .press-bed-edge { fill: var(--well); stroke: var(--line-strong); }
.press-fig .press-lo { stroke: var(--line); }
.press-sheet { transform: translateY(calc(var(--rise, 0) * -1px)); transition: transform .48s var(--ease-out) calc(var(--j, 0) * 40ms); animation: press-rise .48s var(--ease-out) calc(var(--j, 0) * 40ms) backwards; }
@keyframes press-rise { from { transform: none; } }
.press-fig .press-sheet-edge { fill: var(--paper); stroke: var(--paper-ink-2); }
.press-fig .press-rim { stroke: var(--paper-ink-2); stroke-opacity: .35; }
.press-fig .press-mark { stroke: var(--paper-ink-2); }
.press-fig .press-sheet.is-settled .press-mark { stroke: var(--paper-pass); }
.press-fig .press-sheet.is-lifted .press-sheet-edge { stroke: var(--gold-ink); stroke-width: 1.5; }
.press-fig .press-sheet.is-lifted .press-mark { stroke: var(--paper-ink); stroke-width: 1.5; }
.press-fig .press-sheet.is-waiting .press-sheet-edge { stroke: var(--line-strong); }
.press-fig .press-sheet.is-waiting .press-mark { stroke-opacity: .45; }
.press-fig .press-sheet.has-stop .press-sheet-edge { stroke: var(--stop); }
.press-path.is-complete .press-fig [data-sheet="3"] .press-sheet-edge { stroke: var(--pass); stroke-width: 1.5; }
.press-head { font: 650 var(--text-xs)/1rem var(--font-house); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.press-acts { margin-top: var(--space-2); list-style: none; }
.press-act { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; column-gap: var(--space-2); align-items: baseline; padding: var(--space-2) 0; border-top: 1px solid var(--line); }
.press-act:first-child { border-top: 0; }
.press-act b { font-weight: 600; color: var(--ink-2); }
.press-n, .press-word { font: 650 var(--text-xs)/1rem var(--font-house); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.press-figs { grid-column: 2 / -1; font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.press-act.is-settled .press-word { color: var(--pass); }
.press-act.is-lifted b { color: var(--ink); }
.press-act.is-lifted .press-word { color: var(--gold-ink); }
.press-act.has-working .press-word { color: var(--pencil); }
.press-act.has-stale .press-word { color: var(--query); }
.press-act.has-stop .press-word { color: var(--stop); }
.press-act.is-waiting b, .press-act.is-waiting .press-figs { color: var(--ink-3); }
.press-act.is-changed .press-figs { animation: press-figure .6s var(--ease-out); }
@keyframes press-figure { from { color: var(--gold-ink); } }
@media (max-width: 640px) {
  .mast-tools { gap: var(--space-1); }
  .mast-tools .btn { white-space: nowrap; }
  .mast-tools .btn-icon.has-count { width: auto; }
}
@media (max-width: 560px) {
  .next-limit { padding-inline: var(--space-4); }
  .press-word { max-width: 10ch; text-align: right; }
  .press-path { grid-template-columns: 112px minmax(0, 1fr); gap: var(--space-3); padding: var(--space-3) var(--space-4); }
  .press-fig { width: 112px; }
}
@media (max-width: 400px) {
  .masthead { gap: var(--space-2); padding-inline: var(--space-3); }
  .imprint span { font-size: var(--text-sm); }
  .mast-tools .btn-sm { padding-inline: var(--space-2); }
  .mast-tools .btn-icon.has-count { padding-inline: 6px; }
}

/* ---- Book page guidance (TASK-062) ---- */
/* What happens after the click: one quiet line under the reason. */
.next-after { margin-top: var(--space-2); max-width: 58ch; font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
/* The live progress line: a gold mark that breathes while the work runs. */
.run-progress { display: flex; align-items: baseline; gap: var(--space-2); }
.run-progress::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--gold); transform: translateY(-1px); animation: run-breathe 1.6s ease-in-out infinite; }
@keyframes run-breathe { 50% { opacity: .35; } }
.run-failed { margin-top: var(--space-2); }
/* Put it on KDP: four numbered steps under the finished files. */
.kdp-steps-head { margin-top: var(--space-5); font: 650 var(--text-xs)/1rem var(--font-house); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.kdp-steps { counter-reset: kdp; display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.kdp-steps li { counter-increment: kdp; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--space-2); align-items: baseline; font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.kdp-steps li::before { content: counter(kdp); display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line-strong); border-radius: var(--radius-chip); color: var(--ink-3); font-size: var(--text-xs); font-weight: 650; }
/* On a narrow screen the book is a long way down: this link jumps to it. */
.next-book-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; }
@media (min-width: 901px) { .next-book-link { display: none; } }
/* The stepper: the list on a wide screen, one folded line on a phone. */
.toc-sum { display: none; }
.toc-fold > summary::-webkit-details-marker { display: none; }
@media (max-width: 640px) {
  .toc-sum { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; margin-top: var(--space-1); cursor: pointer; list-style: none; font-size: var(--text-sm); font-weight: 650; line-height: 1.25rem; color: var(--ink); }
  .toc-sum::after { content: ""; flex: none; width: 7px; height: 7px; margin-left: var(--space-1); border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); transform: rotate(-45deg); transition: transform .15s var(--ease-out); }
  .toc-fold[open] > .toc-sum::after { transform: rotate(45deg); }
  .toc-sum span { margin-left: auto; color: var(--ink-3); font-weight: 400; }
  .toc-fold[open] > .toc { margin-top: var(--space-2); }
}
/* A 16 px field does not make iOS zoom the page. */
@media (pointer: coarse) {
  .item-foot select { font-size: 16px; }
}

/* ======================================================= rail book (TASK-060, was flipbook.css) */
/* The rail book (TASK-060): a hairline book you page through. Tokens only, none added. Markup:
   templates/rail_book.html; behaviour: flipbook.js. The same fine line art as the press path: one
   pixel lines, square corners, the paper roles of the book, and a single soft shadow. */

.fb { display: grid; justify-items: center; gap: var(--space-3); }
.fb-hint { color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; text-align: center; }

.fb-stage {
  --fb-left: 0; --fb-right: 2;
  position: relative; width: min(240px, 100%); margin-inline: auto; aspect-ratio: var(--fb-ratio, 6 / 9);
  outline-offset: 6px; border-radius: 0;
  -webkit-tap-highlight-color: transparent; user-select: none;
  touch-action: pan-y;
}
.fb-pages { margin: 0; padding: 0; list-style: none; }
.fb-stage:focus-visible { border-radius: 0; }

/* A page: paper, a hairline edge, square corners. */
.fb-page {
  position: relative; background: var(--paper); color: var(--paper-ink);
  border: 1px solid color-mix(in oklch, var(--paper-ink-2) 35%, transparent);
  border-radius: 0; overflow: hidden;
  transform-origin: left center; backface-visibility: hidden;
}
.fb-page > img { display: block; width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none; }
.fb-page img { -webkit-user-drag: none; }
.fb-page .paper { position: absolute; inset: 0; box-shadow: none; }
.fb-cover.is-proof .paper:not(.cover-crop) img { object-fit: contain; }

/* ---- Without JavaScript: a row of pages to scroll sideways ---- */
.fb:not(.is-live) .fb-stage { width: min(240px, 100%); aspect-ratio: auto; }
.fb:not(.is-live) .fb-pages {
  display: flex; gap: var(--space-3); overflow-x: auto; padding-bottom: var(--space-2);
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
}
.fb:not(.is-live) .fb-page { flex: 0 0 100%; aspect-ratio: var(--fb-ratio, 6 / 9); scroll-snap-align: center; }
.fb:not(.is-live) .fb-controls { display: none; }
/* A browser that runs scripts shows the cover and the next page until flipbook.js takes over, so
   the pages after them are not fetched first. */
@media (scripting: enabled) {
  .fb:not(.is-live) .fb-pages { overflow: hidden; scroll-snap-type: none; }
  .fb:not(.is-live) .fb-page:nth-child(n + 3) { display: none; }
}

/* ---- With JavaScript: one page at a time, its neighbours underneath ---- */
.fb.is-live .fb-pages { position: absolute; inset: 0; }
.fb.is-live .fb-page { position: absolute; inset: 0; display: none; }
.fb.is-live .fb-page.is-cur { display: block; z-index: 1; }
.fb.is-live .fb-page.is-near { display: block; visibility: hidden; z-index: 0; }
.fb.is-live .fb-page.is-under { visibility: visible; }
.fb.is-live .fb-page.is-leaf { visibility: visible; z-index: 3; will-change: transform, opacity; }

/* The page-edge stack: a hairline layer for every few pages behind, to the right for the pages
   still to read, to the left for those already turned. --fb-left and --fb-right are 0 to 2 and
   change with no transition. */
.fb.is-live .fb-stage {
  box-shadow:
    calc(min(var(--fb-right), 1) * 2px) calc(min(var(--fb-right), 1) * 2px) 0 -1px var(--paper),
    calc(min(var(--fb-right), 1) * 2px) calc(min(var(--fb-right), 1) * 2px) 0 0 var(--line-strong),
    calc(var(--fb-right) * 2px) calc(var(--fb-right) * 2px) 0 -1px var(--paper),
    calc(var(--fb-right) * 2px) calc(var(--fb-right) * 2px) 0 0 var(--line-strong),
    calc(min(var(--fb-left), 1) * -2px) calc(min(var(--fb-left), 1) * 2px) 0 -1px var(--paper),
    calc(min(var(--fb-left), 1) * -2px) calc(min(var(--fb-left), 1) * 2px) 0 0 var(--line-strong),
    calc(var(--fb-left) * -2px) calc(var(--fb-left) * 2px) 0 -1px var(--paper),
    calc(var(--fb-left) * -2px) calc(var(--fb-left) * 2px) 0 0 var(--line-strong),
    var(--shadow-paper);
}
/* The hinge: a groove just inside the spine edge of the cover. It is drawn on the cover leaf, so
   it turns with the cover. */
.fb-cover::before {
  content: ""; position: absolute; z-index: 2; top: 0; bottom: 0; left: 7%; width: 1px;
  background: var(--line-strong); pointer-events: none;
}

/* ---- The turn ----
   Forward, the leaf you are leaving swings away from its left edge (.is-out) and the page under
   it is already in place. Back, the page you return to swings in over the one you leave (.is-in).
   flipbook.js adds .is-go one frame after the leaf is set. No bounce: a single ease, 320 ms. */
.fb-page::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, color-mix(in oklch, var(--ink) 20%, transparent), transparent 70%);
}
.fb.is-live .fb-stage.is-turning .fb-page.is-under::after { opacity: 1; }
.fb.is-live .fb-stage.is-turning.is-go .fb-page.is-under::after { opacity: 0; transition: opacity 320ms ease-out; }
.fb.is-live .fb-stage.is-turning.is-back .fb-page.is-under::after { opacity: 0; }
.fb.is-live .fb-stage.is-turning.is-back.is-go .fb-page.is-under::after { opacity: 1; transition: opacity 320ms ease-in; }

.fb.is-live .fb-page.is-leaf.is-in { transform: perspective(1200px) rotateY(-100deg); opacity: 0; }
.fb.is-live .fb-page.is-leaf.is-out.is-go {
  transform: perspective(1200px) rotateY(-100deg); opacity: 0;
  transition: transform 320ms cubic-bezier(.77, 0, .175, 1), opacity 120ms linear 200ms;
}
.fb.is-live .fb-page.is-leaf.is-in.is-go {
  transform: none; opacity: 1;
  transition: transform 320ms cubic-bezier(.77, 0, .175, 1), opacity 120ms linear;
}
/* Reduced motion: nothing rotates; the leaf fades for 150 ms. These rules are !important to
   outrank the page-wide "no transitions" rule in app.css, because an opacity fade is the
   reduced form of the turn rather than motion. */
@media (prefers-reduced-motion: reduce) {
  .fb.is-live .fb-page.is-leaf.is-out.is-go { transform: none; transition: opacity 150ms linear !important; }
  .fb.is-live .fb-page.is-leaf.is-in { transform: none; }
  .fb.is-live .fb-page.is-leaf.is-in.is-go { transition: opacity 150ms linear !important; }
  .fb.is-live .fb-stage.is-turning .fb-page.is-under::after { opacity: 0 !important; transition: none !important; }
}

/* ---- Wide: a book that opens (TASK-072, TASK-075) ----
   flipbook.js adds .is-spread above 560 px and sets --fb-pw (one page's width, the stage's) and
   --fb-zoom (how far the open book zooms out to fit the rail), both before any motion. The stage
   keeps the closed cover's footprint, so the rail below it never moves. The book inside it is
   .fb-pages, a zero-width anchor on the spine: it slides and zooms out as it opens (data-pose:
   front, open, back). A right-hand page sits to the right of the spine; a left-hand page (.is-l)
   to its left; everything turns about the spine. A leaf has two faces (.is-fl-front, .is-fl-back):
   going forward, the right page you leave and the new left page.
   One clock: the zoom and the leaf start in the same frame and share one duration and one ease
   (--fb-ms, --fb-ease), chosen by data-move on the stage: open 400 ms, close 300 ms, a plain turn
   320 ms. An ease-out, no bounce, so the book answers at once and settles softly. The zoom is a
   single transform on one wrapper, never a width, height, margin or zoom. */
.fb.is-spread .fb-stage {
  --fb-ease: cubic-bezier(.25, .7, .25, 1); --fb-ms: 320ms;
  box-shadow: none;
}
.fb.is-spread .fb-stage[data-move="open"] { --fb-ms: 400ms; }
.fb.is-spread .fb-stage[data-move="close"] { --fb-ms: 300ms; }
.fb.is-spread .fb-pages {
  right: auto; width: 0; transform-origin: 0 50%;
  transform: translateX(0px) scale(1);
  transition: transform var(--fb-ms) var(--fb-ease);
}
.fb.is-spread .fb-page { right: auto; width: var(--fb-pw, 240px); }
.fb.is-spread .fb-stage[data-pose="open"] .fb-pages {
  transform: translateX(calc(var(--fb-pw, 240px) / 2)) scale(var(--fb-zoom, .62));
}
.fb.is-spread .fb-stage[data-pose="back"] .fb-pages { transform: translateX(var(--fb-pw, 240px)) scale(1); }
.fb.is-spread .fb-stage.is-snap .fb-pages,
.fb.is-spread .fb-stage.is-snap .fb-pages::before,
.fb.is-spread .fb-stage.is-snap .fb-pages::after { transition: none; }
.fb.is-spread .fb-of { display: none; }

/* The block of pages behind each side: paper, a hairline layer for every few pages (--fb-right
   and --fb-left, 0 to 2) and the one soft shadow. A closed cover has only its own side. */
.fb.is-spread .fb-pages::before, .fb.is-spread .fb-pages::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: var(--fb-pw, 240px); z-index: -1;
  background: var(--paper); pointer-events: none;
  transition: opacity 160ms ease-out calc(var(--fb-ms) * .2); /* fades in as the leaf crosses the spine */
}
.fb.is-spread .fb-pages::before {
  left: 0;
  box-shadow:
    calc(min(var(--fb-right), 1) * 2px) calc(min(var(--fb-right), 1) * 2px) 0 -1px var(--paper),
    calc(min(var(--fb-right), 1) * 2px) calc(min(var(--fb-right), 1) * 2px) 0 0 var(--line-strong),
    calc(var(--fb-right) * 2px) calc(var(--fb-right) * 2px) 0 -1px var(--paper),
    calc(var(--fb-right) * 2px) calc(var(--fb-right) * 2px) 0 0 var(--line-strong),
    var(--shadow-paper);
}
.fb.is-spread .fb-pages::after {
  left: calc(var(--fb-pw, 240px) * -1);
  box-shadow:
    calc(min(var(--fb-left), 1) * -2px) calc(min(var(--fb-left), 1) * 2px) 0 -1px var(--paper),
    calc(min(var(--fb-left), 1) * -2px) calc(min(var(--fb-left), 1) * 2px) 0 0 var(--line-strong),
    calc(var(--fb-left) * -2px) calc(var(--fb-left) * 2px) 0 -1px var(--paper),
    calc(var(--fb-left) * -2px) calc(var(--fb-left) * 2px) 0 0 var(--line-strong),
    var(--shadow-paper);
}
/* The side a closed cover does not have fades out once the leaf has left it, then collapses, so
   that a block sitting beyond the rail's edge never gives the rail a sideways scroll. */
.fb.is-spread .fb-pages::before { transform-origin: 0 50%; }
.fb.is-spread .fb-pages::after { transform-origin: 100% 50%; }
.fb.is-spread .fb-stage[data-pose="front"] .fb-pages::after,
.fb.is-spread .fb-stage[data-pose="back"] .fb-pages::before {
  opacity: 0; transform: scaleX(0);
  transition: opacity 120ms ease-in calc(var(--fb-ms) * .3), transform 0s linear calc(var(--fb-ms) * .3 + 120ms);
}
.fb.is-spread .fb-stage:focus-visible { outline: none; }
.fb.is-spread .fb-stage:focus-visible .fb-pages::before,
.fb.is-spread .fb-stage:focus-visible .fb-pages::after { outline: 2px solid var(--pencil-hi); outline-offset: 3px; }

.fb.is-spread .fb-page.is-l { transform: translateX(-100%); }
/* A page waiting under the next view is hidden, and kept on the left of the spine: where the closed
   back cover is, the right-hand side lies beyond the rail's edge. */
.fb.is-spread .fb-page.is-near:not(.is-held) { transform: translateX(-100%); }
.fb.is-spread .fb-page.is-held { display: block; visibility: visible; z-index: 1; }
/* The spine gutter: each page darkens toward the fold. The back cover has its own fold line. */
.fb.is-spread .fb-page::after { opacity: 1; background: none; }
.fb.is-spread .fb-page.is-l::after {
  background: linear-gradient(270deg, color-mix(in oklch, var(--paper-ink) 20%, transparent), transparent 16%);
}
.fb.is-spread .fb-page.is-r:not(.fb-cover)::after {
  background: linear-gradient(90deg, color-mix(in oklch, var(--paper-ink) 20%, transparent), transparent 16%);
}
.fb.is-spread .fb-page.is-back::before {
  content: ""; position: absolute; z-index: 2; top: 0; bottom: 0; right: 7%; width: 1px;
  background: var(--line-strong); pointer-events: none;
}
/* The leaf's shadow falls on the page it reveals (fading as the leaf lifts) and on the page it
   lands on (growing as it comes down). */
.fb.is-spread .fb-page:not(.fb-cover):not(.is-back)::before {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
}
.fb.is-spread .fb-page.is-l:not(.fb-cover):not(.is-back)::before {
  background: linear-gradient(270deg, color-mix(in oklch, var(--paper-ink) 34%, transparent), transparent 80%);
}
.fb.is-spread .fb-page.is-r:not(.fb-cover):not(.is-back)::before {
  background: linear-gradient(90deg, color-mix(in oklch, var(--paper-ink) 34%, transparent), transparent 80%);
}
.fb.is-spread .fb-stage.is-flipping .fb-page.is-fl-reveal::before { opacity: 1; }
.fb.is-spread .fb-stage.is-flip-go .fb-page.is-fl-reveal::before { opacity: 0; transition: opacity var(--fb-ms) var(--fb-ease); }
.fb.is-spread .fb-stage.is-flip-go .fb-page.is-fl-cover::before { opacity: 1; transition: opacity var(--fb-ms) var(--fb-ease); }

/* The leaf: first pose, then (.is-flip-go, one frame later) last pose. Forward it swings from 0
   to -180 degrees; back, from -180 to 0 (.is-flip-back). The back face is turned over about its
   own middle, so it reads the right way round once the leaf lies on the left. No bounce. The two
   rules for the last pose carry the transition, so toggling .is-flip-back in mid-air turns the leaf
   round from where it is. */
.fb.is-spread .fb-page.is-fl-front, .fb.is-spread .fb-page.is-fl-back {
  display: block; visibility: visible; z-index: 3; will-change: transform; box-shadow: 0 2px 10px var(--shade);
}
.fb.is-spread .fb-page.is-fl-front { transform: perspective(1600px) rotateY(0deg); }
.fb.is-spread .fb-page.is-fl-back {
  transform: perspective(1600px) rotateY(0deg) translateX(50%) rotateY(180deg) translateX(-50%);
}
.fb.is-spread .fb-stage.is-flip-back .fb-page.is-fl-front { transform: perspective(1600px) rotateY(-180deg); }
.fb.is-spread .fb-stage.is-flip-back .fb-page.is-fl-back {
  transform: perspective(1600px) rotateY(-180deg) translateX(50%) rotateY(180deg) translateX(-50%);
}
.fb.is-spread .fb-stage.is-flip-go .fb-page.is-fl-front {
  transform: perspective(1600px) rotateY(-180deg); transition: transform var(--fb-ms) var(--fb-ease);
}
.fb.is-spread .fb-stage.is-flip-go .fb-page.is-fl-back {
  transform: perspective(1600px) rotateY(-180deg) translateX(50%) rotateY(180deg) translateX(-50%);
  transition: transform var(--fb-ms) var(--fb-ease);
}
.fb.is-spread .fb-stage.is-flip-go.is-flip-back .fb-page.is-fl-front {
  transform: perspective(1600px) rotateY(0deg); transition: transform var(--fb-ms) var(--fb-ease);
}
.fb.is-spread .fb-stage.is-flip-go.is-flip-back .fb-page.is-fl-back {
  transform: perspective(1600px) rotateY(0deg) translateX(50%) rotateY(180deg) translateX(-50%);
  transition: transform var(--fb-ms) var(--fb-ease);
}
/* The blank inside of a cover is only ever a face of the open book. */
.fb-page.is-blank { display: none; }

/* ---- Pages ---- */
.fb-sheet {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; padding: 9% 10% 7%; overflow: hidden;
  font: 400 9px/12px var(--font-book-text); color: var(--paper-ink);
}
.fb-sheet p:empty { display: none; }
.fb-q { font: 700 12px/16px var(--font-book-display); text-wrap: balance; overflow-wrap: anywhere; }
.fb-a { font: 400 9px/12px var(--font-book-text); color: var(--paper-ink-2); overflow-wrap: anywhere; }
.fb-label { font: 400 9px/12px var(--font-book-text); color: var(--paper-ink-2); }

/* The typeset cover and the title page: the book's own type on a hairline frame, with the
   publisher's mark at the foot (the mark the desk already carries). */
.fb-typeset {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22% 13% 9%; text-align: center;
}
.fb-typeset::before {
  content: ""; position: absolute; inset: 6%; pointer-events: none;
  border: 1px solid color-mix(in oklch, var(--paper-ink-2) 40%, transparent);
}
.fb-t-title { font: 700 20px/24px var(--font-book-display); text-wrap: balance; overflow-wrap: anywhere; }
.fb-t-sub { font: 400 11px/16px var(--font-book-text); color: var(--paper-ink-2); text-wrap: balance; }
.fb-t-mark {
  width: 34px; height: auto; margin-top: auto; flex: none;
  --brand-navy: var(--paper-pencil); --brand-gold: var(--gold);
}
.fb-t-imprint { margin-top: 2px; font: 700 10px/12px var(--font-book-text); letter-spacing: .08em; text-transform: uppercase; }
/* The title page is a quieter leaf than the cover: no frame, a smaller title, set in the middle. */
.is-title .fb-sheet { align-items: center; justify-content: center; gap: 10px; padding: 9% 12% 22%; text-align: center; }
.is-title .fb-t-title { font-size: 15px; line-height: 20px; }
.is-title .fb-t-title::after { content: ""; display: block; width: 24px; margin: 10px auto 0; border-top: 1px solid var(--paper-ink-2); }
.is-title .fb-t-sub { font-size: 10px; line-height: 14px; }
.is-title .fb-t-mark { position: absolute; left: 50%; bottom: 15%; width: 26px; margin: 0 0 0 -13px; }
.is-title .fb-t-imprint { position: absolute; left: 0; right: 0; bottom: 7%; margin: 0; text-align: center; font-size: 9px; }

.fb-toc { display: grid; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.fb-toc li { display: flex; gap: 6px; font: 700 10px/14px var(--font-book-display); }
.fb-toc li span:first-child { color: var(--paper-ink-2); font-weight: 400; font-family: var(--font-book-text); }
.fb-slot { display: block; height: 1px; margin-top: 10px; background: color-mix(in oklch, var(--paper-ink-2) 30%, transparent); }

.is-opener .fb-sheet, .is-more .fb-sheet { align-items: center; justify-content: center; text-align: center; }
.fb-part { font: 700 10px/12px var(--font-book-text); letter-spacing: .08em; text-transform: uppercase; color: var(--paper-ink-2); }
.fb-part::after { content: ""; display: block; width: 24px; margin: 8px auto 0; border-top: 1px solid var(--paper-ink-2); }
.is-opener .fb-q { font-size: 16px; line-height: 20px; }

.fb-pic, .fb-pic-empty { width: 100%; aspect-ratio: 4 / 3; flex: none; }
.fb-pic { display: block; object-fit: cover; }
.fb-pic-empty {
  display: grid; place-items: center; padding: 8px; text-align: center;
  border: 1px dashed color-mix(in oklch, var(--paper-ink-2) 50%, transparent);
  font: 400 9px/12px var(--font-book-text); color: var(--paper-ink-2);
}

/* ---- Controls ---- */
.fb-controls { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; width: min(264px, 100%); }
.fb-controls .btn { width: 40px; min-height: 40px; padding: 0; font-size: var(--text-md); }
.fb-count { display: flex; justify-content: center; min-width: 0; padding-inline: var(--space-2); font: 650 var(--text-xs)/1rem var(--font-house); color: var(--ink-3); }
.fb-at { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-of { flex: none; white-space: pre; }
.fb-caption { max-width: 264px; font-size: var(--text-xs); line-height: 1rem; color: var(--ink-3); text-align: center; text-wrap: balance; }
/* The caption has two texts (the cover's, the book's); both sit in one grid cell and the one not on
   show is only hidden, so the caption keeps the taller one's height and nothing under the book
   moves when it opens (REVIEW-064). */
.fb.is-live .fb-caption { display: grid; }
.fb.is-live .fb-cap-cover, .fb.is-live .fb-cap-book { grid-area: 1 / 1; }
.fb.is-live[data-at="cover"] .fb-cap-book, .fb.is-live:not([data-at="cover"]) .fb-cap-cover { visibility: hidden; }

/* ================================================== review screens (TASK-064, was review.css) */
/* TASK-064: review screens in plain words. Tokens from app.css only; nothing new is defined. */

/* Section titles read in normal ink (they inherited the grey of the card header). */
.section-card .section-heading h2 { color: var(--ink); }
.review-note { margin-top: var(--space-2); max-width: 62ch; }

/* The style card: colours as swatches, fonts as one line, never raw data. */
.style-rules li { align-items: start; }
.style-value { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.style-notes { display: grid; gap: var(--space-1); }
.style-note { font-weight: 400; }
.style-reference-card h2 + .paper, .style-reference-card h2 + .art-placeholder { margin-top: var(--space-3); }
.swatches { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.swatch-item { display: inline-flex; align-items: center; gap: var(--space-1); }
.swatch { display: inline-block; flex: none; width: 16px; height: 16px; background: var(--sw); border: 1px solid var(--line-strong); }
.swatch + .swatch { margin-left: -2px; }
.swatch-item small { color: var(--ink-2); font-size: var(--text-xs); font-weight: 400; line-height: 1rem; }

/* Picture and cover cards: chips sit in one row, with room between them. */
.illustration-meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); min-height: 1.5rem; }

/* G2 card actions (TASK-108). The footer is a stack: the action row first, the same on every card
   (Keep, or what stands in for it, at the left; then Edit), the sources under it. Before, the
   Sources fold shared the row and its `margin-right: auto` pushed the Keep to the right edge of
   every card that had sources. */
.item-foot-stack { display: grid; gap: var(--space-3); justify-items: start; }
.item-foot-stack > * { min-width: 0; margin: 0; }
.item-foot-stack > .item-tools { width: 100%; }
.item-foot-stack .sources[open] { justify-self: stretch; }
.item-tools { align-items: center; gap: var(--space-3); }
.item-decide { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); min-height: 40px; }
.item-decide .keep-wait { margin-left: 0; }
.btn-take-back { border-color: var(--line-strong); color: var(--ink-2); }
.item-note { font-size: var(--text-sm); line-height: 1.25rem; color: var(--ink-2); }
.item-note:empty { display: none; }
.item-note.is-error { color: var(--stop); font-weight: 650; }
.item-note.is-warn { color: var(--query); font-weight: 650; }
.item-earlier { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--pencil); border-radius: var(--radius-control); background: var(--pencil-wash); font-size: var(--text-sm); line-height: 1.25rem; }
.item-where { margin-top: var(--space-3); font-size: var(--text-sm); line-height: 1.25rem; }
.item[tabindex="-1"]:focus { outline: 2px solid var(--pencil); outline-offset: 3px; }
.item.is-backup { border-style: dashed; border-color: var(--line-strong); background: transparent; }
.group-head-backups { margin-bottom: var(--space-2); }
.backups-section { margin: var(--space-5) 0 0; color: var(--ink-2); font: 650 var(--text-sm)/1.25rem var(--font-house); }
.backups-note { margin: 0 0 var(--space-2); font-size: var(--text-sm); line-height: 1.25rem; max-width: 62ch; }
.review-top { display: contents; }
.review-more { flex-basis: 100%; margin: 0; color: var(--ink-2); font-size: var(--text-sm); line-height: 1.25rem; }
.track > span { transition: width .3s var(--ease-out); }
.bulk-what { display: grid; gap: var(--space-2); justify-items: start; min-width: 0; }
@media (max-width: 560px) {
  .item-decide .keep-wait { flex-basis: 100%; }
  /* a kept card's one line: the longer "Kept as an extra" goes under the words, not across them */
  .item-kept > summary { grid-template-columns: 18px minmax(0, 1fr); }
  .item-kept .kept-by { grid-column: 2; }
}

/* Proof screens: the plain sentence under an acknowledgement. */
.ack-plain { display: block; margin-top: var(--space-1); color: var(--ink-3); font-size: var(--text-xs); line-height: 1rem; }

/* Empty screens: a short sentence and one way back. */
.empty .btn { margin-top: var(--space-3); }

/* After the last approval: what to press next, and the way back to it. */
.review-next { align-items: center; margin-top: var(--space-3); }
.review-next .i { color: var(--pass); }
.review-next p { flex: 1; }
.review-next .btn { flex: none; }

/* ======================================================= books list (TASK-063, was shelf.css) */
/* Books list (TASK-063). Loaded on /books only; it adds to app.css and restyles no shared class
   for another page. Colour and type come from app.css's tokens. A row is one book: its cover,
   its title and facts, where it stands in words, and one state. */

.shelf-row { grid-template-columns: 64px minmax(0, 1fr) 140px 150px; }
.shelf-main { display: grid; gap: 2px; min-width: 0; align-content: start; }
.shelf-meta { display: block; color: var(--ink-2); font-size: var(--text-sm); line-height: 1.25rem; }
.shelf-step { color: var(--ink-3); }

/* The "next" line: what happens to this book now, in the same words the book page uses. */
.shelf-next { display: inline-flex; align-items: center; justify-self: start; gap: 6px; margin-top: var(--space-2); color: var(--ink); font: 650 var(--text-sm)/1.25rem var(--font-house); }
.shelf-next::before { content: ""; flex: none; width: 6px; height: 6px; background: var(--ink-3); }
.shelf-next-turn::before { background: var(--gold); box-shadow: 0 0 0 1px var(--gold-ink); }
.shelf-next-working { color: var(--pencil); }
.shelf-next-working::before { background: var(--pencil); }
.shelf-next-ready { color: var(--pass); }
.shelf-next-ready::before { background: var(--pass); }
.shelf-next-stop, .shelf-next-unknown { color: var(--stop); }
.shelf-next-stop::before, .shelf-next-unknown::before { background: var(--stop); }
.shelf-next-stale, .shelf-next-paused { color: var(--ink-2); }

/* A book with no cover yet: its title typeset on a small paper cover with a hairline frame.
   No press mark, no dashed hole. */
.shelf-row .shelf-typeset { display: grid; place-items: center; padding: 12% 9%; }
.shelf-typeset::after { content: ""; position: absolute; inset: 4px; border: 1px solid color-mix(in oklch, var(--paper-ink) 28%, transparent); pointer-events: none; }
.shelf-typeset span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; overflow: hidden; color: var(--paper-ink); font: 700 9px/1.12 var(--font-book-display); overflow-wrap: anywhere; text-align: center; text-wrap: balance; }

/* First run: the four acts in plain words above the button. */
.shelf-empty { gap: var(--space-3); border-style: solid; border-color: var(--line); }
.shelf-empty .paper { border: 0; background: var(--paper); box-shadow: var(--shadow-paper); }
.shelf-empty .mini-mark { opacity: .9; }
.first-run-acts { counter-reset: act; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: var(--space-4); width: 100%; max-width: 880px; margin: var(--space-3) 0; padding: 0; text-align: left; }
.first-run-acts li { counter-increment: act; padding-top: var(--space-3); border-top: 1px solid var(--ink); color: var(--ink-2); font-size: var(--text-sm); line-height: 1.25rem; }
.first-run-acts li::before { content: counter(act); display: grid; place-items: center; width: 22px; height: 22px; margin-bottom: var(--space-2); border: 1px solid var(--pencil); border-radius: 50%; color: var(--pencil); font: 650 var(--text-xs)/1 var(--font-house); }
.first-run-acts b { display: block; margin-bottom: 2px; color: var(--ink); font: 600 var(--text-md)/1.5rem var(--font-page); }

@media (max-width: 900px) {
  .shelf-row { grid-template-columns: 56px minmax(0, 1fr) auto; }
}
@media (max-width: 560px) {
  .shelf-row { grid-template-columns: 52px minmax(0, 1fr); }
}

/* ======================================================= back to the book (TASK-074) */
/* Every screen below a book opens with the same link, and the long ones close with it. */
.book-nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-2); }
.book-nav .crumb { margin: 0; }
.back-link { gap: var(--space-1); text-decoration: none; }
.back-link [aria-hidden] { display: inline-block; transition: transform .2s var(--ease-out); }
@media (hover:hover) and (pointer:fine) { .back-link:hover [aria-hidden] { transform: translateX(-3px); } }
.back-foot { display: flex; justify-content: flex-start; padding-top: var(--space-5); border-top: 1px solid var(--line); }
.work-in > .book-nav + .page-title, .work-in > .book-nav + hgroup { margin-top: var(--space-1); }
.rail .review-next { flex-wrap: wrap; }
.rail .review-next p { min-width: 0; }
.rail .review-next .btn { flex: 1 1 100%; }

/* ======================================================= the look (TASK-076) */
/* G3: the AI's style guide for the book (named colours) and the "Change the look" chips. */
.look-colours { gap: var(--space-2) var(--space-4); }
.look-colours .swatch { width: 22px; height: 22px; }
.look-colours .swatch-item small { font-size: var(--text-sm); line-height: 1.25rem; }
.look-picker form { display: grid; gap: var(--space-3); }
.look-group { display: grid; gap: var(--space-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.look-group legend { padding: 0; margin-bottom: var(--space-1); color: var(--ink-2); font: 650 var(--text-sm)/1.25rem var(--font-house); }
.look-chip { position: relative; display: grid; gap: 4px; padding: var(--space-2) var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--field); color: var(--ink); font: 650 var(--text-sm)/1.25rem var(--font-house); cursor: pointer; transition: background-color .15s var(--ease-out), border-color .15s var(--ease-out); }
.look-chip > input[type="radio"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
@media (hover:hover) and (pointer:fine) { .look-chip:hover { border-color: var(--pencil); } }
.look-chip:has(> input:checked) { border-color: var(--pencil); background: var(--pencil-wash); box-shadow: inset 0 0 0 1px var(--pencil); }
.look-chip:has(> input:focus-visible) { outline: 2px solid var(--pencil-hi); outline-offset: 2px; }
.look-chip.is-off, .look-chip:has(> input:disabled) { border-style: dashed; background: transparent; color: var(--ink-3); cursor: not-allowed; }
.look-chip small { color: var(--ink-3); font: 400 var(--text-xs)/1rem var(--font-house); }
.look-swatches { display: flex; }
.look-swatches i { display: block; flex: 1 1 0; min-width: 0; height: 16px; background: var(--sw); border: 1px solid color-mix(in oklch, var(--ink) 25%, transparent); }
.look-swatches i + i { margin-left: -1px; }
.look-chip.is-off .look-swatches { opacity: .45; }
@media (prefers-reduced-motion: reduce) { .look-chip { transition: none; } }

/* ======================================================= front and back pages (TASK-080) */
/* The Front and back pages screen: the choices reuse the new-book form's chips (new_book.css),
   then the kept backups and what the AI wrote. */
.setup-more { margin-top: var(--space-3); }
.fb-sub { color: var(--ink-2); font: 650 var(--text-sm)/1.25rem var(--font-house); }
.fb-backups { display: grid; justify-items: start; gap: var(--space-2); padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--raised); }
.fb-backups p { margin: 0; }
.fb-list { display: grid; gap: 0; width: 100%; margin: 0; padding: 0; list-style: none; }
.fb-list li { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 var(--space-3); padding-block: var(--space-2); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.fb-list li:last-child { border-bottom: 0; }
.fb-list small { display: inline; margin: 0; }
.fb-written { display: grid; gap: var(--space-3); padding-top: var(--space-3); }
.fb-written h2 { font: 600 var(--text-xl)/1.25 var(--font-page); }
.fb-text { display: grid; gap: var(--space-4); }
.fb-text.is-old { opacity: .62; }
.fb-card { display: grid; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--raised); }
.fb-card h3 { font: 650 var(--text-md)/1.5rem var(--font-house); }
.fb-card p { max-width: 62ch; margin: 0; }
.fb-questions { display: grid; gap: var(--space-4); margin: 0; padding-left: var(--space-5); }
.fb-q { font: 600 var(--text-md)/1.5rem var(--font-house); }
.fb-options { display: grid; gap: var(--space-1); margin: var(--space-2) 0 0; padding-left: var(--space-5); list-style: upper-alpha; }
.fb-options li { padding-left: var(--space-1); }
.fb-options li.is-right { color: var(--pass); font-weight: 600; }
.fb-options .chip { margin-left: var(--space-2); font-weight: 600; vertical-align: baseline; }
@media (max-width: 560px) {
  .fb-card { padding: var(--space-3); }
  .fb-questions, .fb-options { padding-left: var(--space-4); }
}

/* ======================================================= AI-chosen colours (TASK-081) */
/* G3: the cover's own colours under the book's, and the colour note of "Change the look". */
.style-value .cover-line { display: block; margin-top: var(--space-1); color: var(--ink-2); font-size: var(--text-sm); line-height: 1.25rem; }
.look-note { display: grid; gap: var(--space-1); color: var(--ink-2); font: 650 var(--text-sm)/1.25rem var(--font-house); }
.look-note input { margin-top: 0; font-weight: 400; }
.look-note small { display: block; margin: 0; color: var(--ink-3); font: 400 var(--text-xs)/1rem var(--font-house); }
.look-grey { margin: 0; }

/* ======================================================= Sample pictures with their words (TASK-085) */
/* G3: each sample picture over the fact it goes with, the words on a small page-like card. */
.sample-page.has-words { display: grid; gap: var(--space-2); align-content: start; margin: 0; }
.sample-words { display: grid; gap: var(--space-1); padding: var(--space-3); border-radius: var(--radius-paper); background: var(--paper); color: var(--paper-ink); box-shadow: var(--shadow-paper); overflow-wrap: anywhere; }
.sample-words p { max-width: 62ch; margin: 0; }
.sample-q { font: 700 var(--text-md)/1.4 var(--font-page); }
.sample-a { font: 400 var(--text-sm)/1.45 var(--font-page); }

/* ======================================================= A step that failed for good (TASK-086) */
/* The book page's activity panel names the step and links to its own page, where the one retry is. */
.run-stuck { margin-block: var(--space-3); }
.run-stuck > div { display: grid; gap: var(--space-2); }
.run-stuck ul { display: grid; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.run-stuck p { margin: 0; }
.run-stuck a { font-weight: 700; }

/* ======================================================= Fewer rough edges (TASK-095) */
/* G2: a Keep that waits for the second check, and the backups under a fact, kept or not. */
.keep-wait { display: inline-block; max-width: 40ch; margin-left: var(--space-3); vertical-align: middle; font-size: var(--text-sm); line-height: 1.25rem; }
.item-backups .more-body { display: grid; gap: var(--space-3); margin-top: var(--space-3); }
.item-backups .backup-note { margin: 0; font-size: var(--text-sm); line-height: 1.25rem; }
.item-backup { display: grid; gap: var(--space-1); justify-items: start; padding-top: var(--space-3); border-top: 1px solid var(--line); }
.item-backup p { margin: 0; }
.item-backup .inline-form { margin-top: var(--space-2); }
@media (max-width: 560px) {
  .keep-wait { display: block; max-width: none; margin: var(--space-2) 0 0; }
}
/* Book page: the step that runs, and Activity as a fold under the next step. */
#run { display: grid; gap: var(--space-3); }
#run > * { margin-block: 0; }
#activity { scroll-margin-top: 72px; }
.run-clock { padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); color: var(--ink-2); font-size: var(--text-sm); line-height: 1.25rem; font-variant-numeric: tabular-nums; }
.run-clock b { color: var(--ink); font-weight: 650; }
.run-clock noscript { color: var(--ink-3); }
#run > .activity { border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
#run > .activity > summary { padding: var(--space-3) var(--space-4); color: var(--ink-2); }
#run > .activity > .fold-body { padding: 0 var(--space-4) var(--space-4); border-top: 1px solid var(--line); }
#run > .activity .fold { margin-top: var(--space-3); }
.run-number { margin: var(--space-3) 0 0; }
#run > .run-paused { padding: 0; }
@media (hover:hover) and (pointer:fine) { #run > .activity > summary:hover { color: var(--ink); } }
/* A long unbroken word in a title wraps instead of running out sideways. */
.page-title, .shelf-title { overflow-wrap: anywhere; }

/* ======================================================= A book's spending limit (TASK-097) */
/* The way out of a refused step: which limit is short (callout above), and the one form that raises the book's own. */
.book-limit { scroll-margin-top: 72px; }
.limit-facts { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); margin: 0 0 var(--space-3); color: var(--ink-3); font-size: var(--text-sm); line-height: 1.25rem; }
.limit-facts b { color: var(--ink); font: 650 var(--text-md)/1.5rem var(--font-house); }
.limit-form { display: grid; gap: var(--space-2); max-width: 46ch; margin: 0; }
.limit-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; }
.limit-row input[type="number"] { flex: 1 1 9rem; width: auto; max-width: 14rem; margin-top: 0; }
.limit-hint { color: var(--ink-3); font: 400 var(--text-xs)/1rem var(--font-house); }
section.book-limit.is-needed { margin-top: var(--space-4); padding: var(--space-4) var(--space-5); border: 1px solid color-mix(in oklch, var(--stop) 35%, transparent); border-radius: var(--radius-panel); background: var(--surface); }
section.book-limit.is-needed h2 { margin: 0 0 var(--space-2); font: 650 var(--text-md)/1.5rem var(--font-house); }
.callout > span { min-width: 0; }
.limit-head { display: block; margin-bottom: var(--space-1); }
@media (max-width: 560px) {
  section.book-limit.is-needed { padding-inline: var(--space-4); }
  .limit-row input[type="number"] { flex-basis: 100%; max-width: none; }
}

/* ---- TASK-098: the fact review. Keep in bulk, the claim rows in two columns. Self-contained: this block is the lane's own, at the very end. ---- */
.review-jump { font-size: var(--text-sm); font-weight: 650; color: var(--pencil); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; white-space: nowrap; }
@media (hover:hover) and (pointer:fine) { .review-jump:hover { color: var(--pencil-hi); } }
.bulk { margin: var(--space-4) calc(var(--space-4) * -1) 0; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); scroll-margin-top: 120px; }
.bulk-rows { margin: 0; padding: 0; list-style: none; }
.bulk-row { display: grid; grid-template-columns: minmax(0, 17rem) minmax(0, 1fr); align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-3) var(--space-4); }
.bulk-row + .bulk-row { border-top: 1px solid var(--line); }
.bulk-line { margin: 0; color: var(--ink); font-size: var(--text-sm); line-height: 1.25rem; font-weight: 650; }
.bulk-n { margin-right: var(--space-1); font: 700 var(--text-xl)/1.3 var(--font-house); font-variant-numeric: tabular-nums; }
.bulk-row.is-none .bulk-n { color: var(--ink-3); }
.bulk-why { margin: 0; font-size: var(--text-sm); line-height: 1.25rem; }
.bulk-row .inline-form { justify-self: start; }
.bulk-row .btn { padding-block: var(--space-2); text-align: left; }
.bulk-wait { margin: 0; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); font-size: var(--text-sm); line-height: 1.25rem; }
.claim-table .claim { grid-template-columns: minmax(0, 1fr); }
.claim-table .claim.has-second { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto 1fr; column-gap: var(--space-5); }
.claim-table .claim-note, .claim-table .claim-blind { min-width: 0; overflow-wrap: anywhere; }
.claim-table .claim.has-second .claim-blind { grid-column: 2; grid-row: 2 / span 2; }
.claim-table .claim:not(.has-second) .claim-blind { grid-column: 1; grid-row: auto; margin-left: calc(1em + var(--space-2)); }
@media (max-width: 900px) { .bulk { margin-inline: 0; } }
@media (max-width: 720px) {
  .bulk-row { grid-template-columns: minmax(0, 1fr); }
  .claim-table .claim, .claim-table .claim.has-second { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .claim-table .claim.has-second .claim-blind { grid-column: 1; grid-row: auto; margin-left: calc(1em + var(--space-2)); }
}

/* TASK-107: a drawn page whose text audit failed, on G5; the pages passed by hand, on G6. */
.hand-pass { display: grid; gap: var(--space-2); margin-block: var(--space-2); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--raised); }
.hand-pass p { margin: 0; }
.hand-pass-head { font-size: var(--text-xs); line-height: 1rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.hand-pass-words, .hand-pass-read { font-size: var(--text-sm); line-height: 1.25rem; overflow-wrap: anywhere; }
.hand-pass-read { color: var(--ink-3); }
.hand-pass-form .btn { white-space: normal; text-align: left; }
.hand-passed { margin-block: var(--space-4); }
.hand-passed ul { margin: var(--space-2) 0 0; padding-left: var(--space-5); }

/* A picture being made, and the proof's pages being drawn */
.illustration-card[data-making="1"] img.paper { opacity: 0.55; }
.making-note { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--ink-3); }
.making-note .btn { margin-inline-start: var(--space-2); }
.prepare-pages { margin-block: var(--space-3); }
.illustration-card[data-unseen] { outline: 3px solid var(--query, #c58a00); outline-offset: 2px; }
.decision-hold { margin-block: var(--space-2); }
.decision-hold .btn { margin-inline-start: var(--space-2); }
