/* ---------- numbers ---------- */
/* Prologue numbers: the band right after the hero. Four figures in one row on desktop, about one screen tall. */
#prologue-numbers { padding-block: clamp(88px, 9vw, 128px); }
#prologue-numbers .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 36px; }
#prologue-numbers .stat b { font-size: clamp(46px, 4.2vw, 60px); white-space: nowrap; }
#prologue-numbers .stat span { max-width: 17em; }
#prologue-numbers .np-method { margin: 56px 0 0; font-size: 15px; line-height: 1.45; color: var(--muted); }

@media (max-width: 1060px) {
  #prologue-numbers .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px 40px; }
  #prologue-numbers .stat span { max-width: 22em; }
}
@media (max-width: 560px) {
  #prologue-numbers .stats { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  #prologue-numbers .np-method { margin-top: 48px; }
}

/* ---------- ch1 ---------- */
/* Chapter 1, glossary: three core terms as cards (term, English term, one definition, link),
   eight working terms as a compact index, then the vibe coding / agentic engineering distinction. */
/* Cards share three rows through subgrid, so definitions and links line up even when a term wraps. */
#ch1 .ch1-core { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 20px; row-gap: 0; }
#ch1 .ch1-term { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; border-radius: 30px; padding: 34px 34px 30px; }
#ch1 .ch1-term h3 { font-size: clamp(28px, 2.6vw, 32px); line-height: 1.08; letter-spacing: -.03em; }
#ch1 .ch1-term h3 span,
#ch1 .ch1-list dt span { display: block; font-size: 15px; line-height: 1.3; font-weight: 500; letter-spacing: -.005em; color: var(--muted); margin-top: 6px; }
#ch1 .ch1-term p { margin-top: 18px; }
#ch1 .ch1-def { color: var(--strong); }
#ch1 .ch1-term .more { align-self: end; justify-self: start; padding-top: 22px; font-size: 17px; }

#ch1 .ch1-list { margin: 44px 0 0; display: grid; gap: 30px; }
#ch1 .ch1-list > div { display: grid; grid-template-columns: 230px minmax(0, 1fr) 170px; column-gap: 40px; align-items: baseline; }
#ch1 .ch1-list dt { font-size: 21px; line-height: 1.2; font-weight: 650; letter-spacing: -.02em; color: var(--strong); }
#ch1 .ch1-list dd { margin: 0; font-size: 17px; line-height: 1.47; color: var(--muted); max-width: 40em; }
#ch1 .ch1-list .ch1-go { font-size: 17px; }

#ch1-vibe .card { border-radius: 30px; padding: 34px 34px 32px; }
#ch1-vibe .card h3 { font-size: clamp(24px, 2.4vw, 32px); line-height: 1.12; letter-spacing: -.028em; color: var(--strong); }
#ch1-vibe .card p { margin-top: 14px; }

html.sf #ch1 .ch1-term h3, html.sf #ch1-vibe .card h3 { letter-spacing: -.014em; }

@media (max-width: 960px) {
  #ch1 .ch1-core { grid-template-columns: minmax(0, 1fr); row-gap: 16px; }
  #ch1 .ch1-term { display: flex; flex-direction: column; grid-row: auto; }
  #ch1 .ch1-term .more { align-self: flex-start; }
  #ch1 .ch1-list > div { grid-template-columns: 200px minmax(0, 1fr); }
  #ch1 .ch1-list .ch1-go { grid-column: 2; margin-top: 6px; }
}
@media (max-width: 680px) {
  #ch1 .ch1-core { gap: 16px; }
  #ch1 .ch1-term { padding: 28px 26px 26px; border-radius: 26px; }
  #ch1 .ch1-term h3 { font-size: 24px; }
  #ch1 .ch1-list { gap: 26px; }
  #ch1 .ch1-list > div { display: block; }
  #ch1 .ch1-list dt span { display: inline; margin: 0 0 0 6px; }
  #ch1 .ch1-list dd { margin-top: 6px; }
  #ch1-vibe .card { padding: 28px 26px 26px; border-radius: 26px; }
}

/* Phone: line breaking tuned in review; desktop follows the shared balance rule. */
@media (max-width: 680px) {
  #ch1 .ch1-list dd { text-wrap: pretty; }
}

/* ---------- ch2 ---------- */
/* Chapter 2, the canon: 18 milestones in one column (six per era, one line each),
   two verbatim voices, three paraphrased positions and a note on where the canon is written. */
#ch2 .ch2-era + .ch2-era { margin-top: clamp(40px, 4.4vw, 56px); }
#ch2 .ch2-year { margin: 0 0 8px; font-size: clamp(30px, 3vw, 40px); line-height: 1.1; letter-spacing: -.03em; font-weight: 650; font-variant-numeric: tabular-nums; background: none; color: #f5f5f7; }
#ch2 .ch2-year span { margin-left: .35em; font-size: clamp(19px, 1.6vw, 22px); font-weight: 500; letter-spacing: -.016em; color: var(--muted); }
#ch2 .ch2-era ol { list-style: none; margin: 0; padding: 0; }
#ch2 .ch2-era li { display: grid; grid-template-columns: 120px minmax(0, 1fr); column-gap: 24px; align-items: baseline; padding: 10px 0; }
#ch2 .ch2-d { font-size: 15px; line-height: 24px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#ch2 .ch2-era p { margin: 0; font-size: 17px; line-height: 24px; letter-spacing: -.012em; color: var(--strong); }
#ch2 .ch2-era p a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: rgba(255, 255, 255, .3); text-underline-offset: 3px; }
#ch2 .ch2-era p a:hover { text-decoration-color: currentColor; }
#ch2 .ch2-who { margin-left: 6px; font-size: 15px; letter-spacing: -.006em; color: var(--muted); }
#ch2 .ch2-nw { white-space: nowrap; }

#ch2 .ch2-voices { grid-template-columns: repeat(6, minmax(0, 1fr)); }
#ch2 .ch2-q:first-child { grid-column: span 4; }
#ch2 .ch2-q:nth-child(2) { grid-column: span 2; }
#ch2 .ch2-q blockquote { font-size: clamp(24px, 2.4vw, 30px); line-height: 1.22; letter-spacing: -.024em; font-weight: 600; }
#ch2 .ch2-para { grid-column: span 2; }
#ch2 .ch2-para blockquote { font-size: clamp(18px, 1.5vw, 20px); color: var(--muted); }
#ch2 .ch2-aside { margin-top: clamp(56px, 6vw, 80px); }
#ch2 .ch2-links { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-top: 16px; }

html.sf #ch2 .ch2-year { letter-spacing: -.016em; }
html.sf #ch2 .ch2-q blockquote { letter-spacing: -.012em; }

@media (max-width: 1060px) {
  #ch2 .ch2-who { margin-left: 0; }
  #ch2 .ch2-voices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #ch2 .ch2-q:first-child, #ch2 .ch2-q:nth-child(2), #ch2 .ch2-para { grid-column: auto; }
  #ch2 .ch2-para:last-child { grid-column: span 2; }
}
@media (max-width: 680px) {
  #ch2 .ch2-year { font-size: 24px; }
  #ch2 .ch2-year span { display: block; margin: 6px 0 0; }
  #ch2 .ch2-era li { display: block; padding: 9px 0; }
  #ch2 .ch2-d { display: block; line-height: 20px; margin-bottom: 2px; }
  #ch2 .ch2-voices { grid-template-columns: minmax(0, 1fr); }
  #ch2 .ch2-para:last-child { grid-column: auto; }
  #ch2 .ch2-q blockquote { font-size: 23px; }
}

/* Phone: line breaking tuned in review; desktop follows the shared balance rule. */
@media (max-width: 680px) {
  #ch2 .ch2-era p { text-wrap: pretty; }
}

/* ---------- ch3 ---------- */
/* Chapter 3, «Рынок в цифрах». Shared blocks carry the layout. This file adds smaller units inside
   big numbers (like «п. п.» in chapter 4), reading paragraphs inside .wrap, the quote on a light
   surface and the marks of three charts drawn to scale. */

/* Units after a figure: «млрд», «дней». */
#ch3 .stat b small, #ch3-adoption .stat b small, #ch3-models .stat b small { font-size: .5em; font-weight: 650; letter-spacing: -.025em; }

/* Reading paragraphs between blocks: the .prose type at reading width. */
#ch3 .ch3-text, #ch3-adoption .ch3-text, #ch3-speed .ch3-text, #ch3-models .ch3-text { max-width: 700px; margin-top: 48px; }
#ch3 .ch3-text > :last-child, #ch3-adoption .ch3-text > :last-child, #ch3-speed .ch3-text > :last-child, #ch3-models .ch3-text > :last-child { margin-bottom: 0; }
#ch3-adoption .ch3-links, #ch3-speed .ch3-links, #ch3-models .ch3-links { display: flex; flex-wrap: wrap; gap: 8px 28px; }
/* Figures set inside a sentence instead of a second row of big numbers. */
#ch3-adoption .ch3-text b { font-weight: 650; color: var(--strong); }
#ch3-models .aside .ch3-links { margin-top: 16px; }

/* Four survey answers in one row on desktop, as in the prologue numbers. */
#ch3-adoption .ch3-four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 36px; }
#ch3-adoption .ch3-four .stat b { font-size: clamp(46px, 4.5vw, 66px); white-space: nowrap; }
#ch3-adoption .ch3-four .stat span { max-width: 17em; }

/* A single figure: its caption carries the two other doubling times, so give it reading width. */
#ch3-models .stat span { max-width: 34em; }

/* Two figures that are one comparison: keep them on the three-column grid of the other rows. */
#ch3-speed .ch3-pair { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* The quote sits on a light surface here; the shared footer colour is set for dark sections. */
#ch3-speed .quote { margin-top: 88px; }
#ch3-speed .quote footer { color: var(--muted); }

/* Chart marks. Text sizes are in viewBox units: the wide charts render at about 1.08×,
   the narrow ones at about 0.89× on a 390 px phone, so nothing drops below 12 px. */
#ch3-adoption .chart .ax, #ch3-speed .chart .ax { fill: var(--muted); font-size: 14px; }
#ch3-adoption .ch3-track { fill: currentColor; fill-opacity: .07; }
#ch3-adoption .ch3-cat, #ch3-speed .ch3-cat { fill: currentColor; font-size: 17px; font-weight: 500; }
#ch3-adoption .ch3-val, #ch3-speed .ch3-val { fill: currentColor; font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
#ch3-speed .ch3-num { fill: currentColor; font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
#ch3-speed .ch3-grp { fill: var(--muted); font-size: 15px; font-weight: 600; }
#ch3-speed .ch3-zero { stroke: var(--axis); stroke-width: 1.5; }
/* Interval whiskers: 1.5 px at any scale, 8 px caps (drawn in viewBox units per version). */
#ch3-speed .ch3-ci { fill: none; stroke: var(--strong); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
#ch3-speed .ch3-arr { font-size: 1.35em; }

#ch3-adoption .chart .narrow .ax, #ch3-speed .chart .narrow .ax { font-size: 14.5px; }
#ch3-adoption .narrow .ch3-cat, #ch3-speed .narrow .ch3-cat { font-size: 15px; }
#ch3-adoption .narrow .ch3-val, #ch3-speed .narrow .ch3-val { font-size: 24px; }
#ch3-speed .narrow .ch3-num { font-size: 17px; }
#ch3-speed .narrow .ch3-val { font-size: 22px; }
#ch3-speed .narrow .ch3-grp { font-size: 14.5px; }

@media (max-width: 1060px) {
  #ch3-adoption .ch3-four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px 40px; }
  #ch3-adoption .ch3-four .stat span { max-width: 22em; }
}
@media (max-width: 680px) {
  #ch3-speed .ch3-pair { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  #ch3-adoption .ch3-four { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  #ch3-speed .quote { margin-top: 64px; }
}

/* ---------- ch4 ---------- */
/* Chapter 4 continuation, «Что такое харнесс»: what ages, three patterns, long tasks, harness engineering.
   The opener (#ch4) and the reading section (#ch4-read) use shared styles only. Solid surfaces, no glass. */

/* ---------- Was → became ---------- */
#ch4-aging .ch4-was th:first-child { width: 24%; }
#ch4-aging .ch4-was th:nth-child(2) { width: 34%; }
#ch4-aging .ch4-was td:nth-child(2) { color: var(--muted); }
/* The chapter keeps one pull quote (the opener); this line closes the table as plain text. */
#ch4-aging .ch4-coda { margin-top: 36px; }
@media (max-width: 680px) { #ch4-aging .ch4-coda { margin-top: 48px; } }

/* ---------- Three patterns ---------- */
#ch4-patterns .card, #ch4-practice .card { display: flex; flex-direction: column; }
#ch4-patterns .card p b { font-weight: 600; color: var(--strong); }
#ch4-patterns .card .more, #ch4-practice .card .more { margin-top: auto; padding-top: 20px; font-size: 17px; }

/* ---------- Long tasks ---------- */
/* A reading column inside the wide section, aligned with the heading. */
#ch4-long .ch4-text { max-width: 700px; }
#ch4-long .ch4-text > p:last-child { margin-bottom: 0; }

/* Runs: one time scale for all three bars; labels sit on the data. */
#ch4-long .ch4-runs .r-name text { font-size: 17px; font-weight: 600; fill: var(--strong); }
#ch4-long .ch4-runs .r-sub text { font-size: 15px; fill: var(--muted); }
#ch4-long .ch4-runs .r-val text { font-size: 17px; font-weight: 600; fill: var(--strong); font-variant-numeric: tabular-nums; }
#ch4-long .ch4-runs .r-val .r-in { fill: #fff; }
#ch4-long .ch4-runs .r-gray { fill: var(--c-gray); }
#ch4-long .ch4-runs .r-blue { fill: var(--c-blue); }
#ch4-long .ch4-runs .narrow .r-name text, #ch4-long .ch4-runs .narrow .r-val text { font-size: 16px; }
#ch4-long .ch4-runs .narrow .r-sub text { font-size: 14px; }

/* Managed Agents: session, brain, hands. One card stands for many interchangeable sandboxes. */
#ch4-long .ch4-ma { margin-top: 48px; }
#ch4-long .ch4-ma .d-card { fill: var(--card); }
/* Illustrative log lines; the newest, just appended, in blue. */
#ch4-long .ch4-ma .d-log text { font: 13px var(--mono); fill: var(--muted); }
#ch4-long .ch4-ma .d-log .d-new, #ch4-long .ch4-ma .d-core { fill: var(--c-blue); }
#ch4-long .ch4-ma .d-title { font-size: 26px; font-weight: 650; letter-spacing: -.02em; fill: var(--strong); }
#ch4-long .ch4-ma .d-sub { font-size: 15px; fill: var(--muted); }
#ch4-long .ch4-ma .d-note { font-size: 14px; fill: var(--muted); }
#ch4-long .ch4-ma .d-core-title { font-size: 32px; font-weight: 650; letter-spacing: -.02em; fill: #fff; }
#ch4-long .ch4-ma .d-core-sub { font-size: 17px; fill: #fff; fill-opacity: .86; }
#ch4-long .ch4-ma .d-link { fill: none; stroke: var(--axis); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#ch4-long .ch4-ma .narrow .d-title { font-size: 22px; }
#ch4-long .ch4-ma .narrow .d-sub { font-size: 14px; }
#ch4-long .ch4-ma .narrow .d-note { font-size: 13px; }
#ch4-long .ch4-ma .narrow .d-core-title { font-size: 26px; }
#ch4-long .ch4-ma .narrow .d-core-sub { font-size: 15px; }

/* ---------- Harness engineering ---------- */
#ch4-practice .ch4-oa { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 36px; }
#ch4-practice .ch4-oa .stat b { font-size: clamp(46px, 4.5vw, 66px); white-space: nowrap; }
#ch4-practice .ch4-oa + .grid-2 { margin-top: 56px; }

@media (max-width: 960px) {
  #ch4-practice .ch4-oa { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; }
}
@media (max-width: 680px) {
  #ch4-long .ch4-ma { margin-top: 36px; }
  #ch4-practice .ch4-oa { gap: 32px 20px; }
  #ch4-practice .ch4-oa + .grid-2 { margin-top: 44px; }
}

/* ---------- ch5 ---------- */
/* Chapter 5: verification. Light versions of the display blocks drawn for dark sections,
   the tests bento, the rules grid, the risk table and the advice layout. No glass, no animation. */

/* Opener: the statement and the quote come from chapter 4, where they sit on black */
#ch5 .statement .big { background: none; color: var(--c-blue); }
#ch5 .statement-note { color: var(--muted); }
#ch5 .statement-note strong { color: var(--strong); }

/* Inline commands must not break at their hyphen (/code-review) */
#ch5-rules code, #ch5-advice .checks code { white-space: nowrap; }

/* Evidence line under the strictness rungs */
#ch5-levels .ch5-evidence { margin-top: 40px; grid-template-columns: minmax(0, 1fr); background: var(--card); }

/* Three kinds of tests: running the app gets the big card */
#ch5-levels .ch5-bento { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; margin-top: 40px; }
#ch5-levels .ch5-main { grid-row: span 2; display: flex; flex-direction: column; }
#ch5-levels .ch5-main p.ch5-punch { margin: 16px 0 0; padding-top: 0; font-size: clamp(24px, 2.5vw, 34px); line-height: 1.14; letter-spacing: -.028em; font-weight: 600; color: var(--strong); text-wrap: balance; }

/* Team rules: heading and the checklist number on the left, the rules on the right;
   on phones the number follows the rules */
#ch5-rules .ch5-rules { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "head list" "side list"; grid-template-rows: auto 1fr; column-gap: 64px; align-items: start; }
#ch5-rules .ch5-rules-head { grid-area: head; }
#ch5-rules .ch5-rules > .checks { grid-area: list; margin-top: 4px; }
#ch5-rules .ch5-rules-side { grid-area: side; }
#ch5-rules .ch5-rules-side .stats { margin-top: 48px; }

/* Who approves, with the accountability line as its caption */
#ch5-review .ch5-risk { max-width: 620px; margin-top: clamp(56px, 7vw, 96px); }
#ch5-review .ch5-risk .table-wrap { margin-top: 0; }
#ch5-levels .ch5-note, #ch5-review .ch5-note { margin: 28px 0 0; font-size: 15px; line-height: 1.45; color: var(--muted); max-width: 44em; }

/* Reading section: reading width, left edge shared with the other sub-sections */
#ch5-who .ch5-read { max-width: 700px; margin-top: 36px; }

/* Working advice next to the example skill */
#ch5-advice .ch5-advice { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 64px; align-items: start; margin-top: 40px; }
#ch5-advice .checks { margin-top: 0; }
#ch5-advice .code-card { margin: 0 0 14px; }
#ch5-advice .ch5-caption { margin: 0; font-size: 15px; line-height: 1.45; color: var(--muted); }

[id^="ch5"] .ch5-more { margin: 28px 0 0; font-size: 17px; }

@media (max-width: 960px) {
  #ch5-advice .ch5-advice { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  #ch5-rules .ch5-rules { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "list" "side"; grid-template-rows: auto; }
  #ch5-rules .ch5-rules > .checks { margin-top: 40px; }
}
@media (max-width: 680px) {
  #ch5-levels .ch5-bento { grid-template-columns: minmax(0, 1fr); }
  #ch5-levels .ch5-main { grid-row: auto; }
  #ch5-levels .ch5-main p.ch5-punch { padding-top: 26px; }
}

/* ---------- ch6 ---------- */
/* Chapter 6: the project's knowledge base. Sizes follow the shared classes, colours come from the section theme. */

/* Monospace labels inside the diagrams (SVG tspans, not code elements) */
#ch6-memory .ch6-mono { font-family: var(--mono); letter-spacing: 0; }

/* What the agent cannot find in the code: a two-tone list at heading size */
#ch6 .ch6-unseen { list-style: none; margin: 36px 0 0; padding: 0; display: grid; gap: 12px; }
#ch6 .ch6-unseen li { font-size: clamp(26px, 3vw, 40px); line-height: 1.12; letter-spacing: -.03em; font-weight: 650; color: var(--muted); max-width: 24em; text-wrap: balance; }
#ch6 .ch6-unseen b { font-weight: 650; color: var(--strong); }
html.sf #ch6 .ch6-unseen li { letter-spacing: -.016em; }

/* Two questions before writing anything down */
#ch6 .ch6-decide { --ch6-in: #fff; margin-top: clamp(48px, 6vw, 72px); background: var(--card); border-radius: 30px; padding: clamp(24px, 3vw, 40px); }
#ch6[data-theme=light] .ch6-decide { --ch6-in: var(--paper); }
#ch6 .ch6-decide h3 { font-size: clamp(21px, 1.8vw, 24px); line-height: 1.18; letter-spacing: -.022em; font-weight: 650; margin: 0; text-wrap: balance; }
#ch6 .ch6-flow { display: grid; grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr) 44px minmax(0, 1.6fr); align-items: center; margin-top: 24px; }
#ch6 .ch6-q { align-self: stretch; display: flex; align-items: center; margin: 0; background: var(--ch6-in); border-radius: 20px; padding: 22px 24px; font-size: clamp(19px, 1.6vw, 22px); line-height: 1.24; letter-spacing: -.018em; font-weight: 600; color: var(--strong); text-wrap: balance; }
#ch6 .ch6-to { height: 24px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4.5 12h14m-5.5-5.5 5.5 5.5-5.5 5.5' fill='none' stroke='%2386868b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 22px no-repeat; }
#ch6 .ch6-outs { display: grid; gap: 10px; }
#ch6 .ch6-out { margin: 0; background: var(--ch6-in); border-radius: 20px; padding: 15px 18px; font-size: 17px; line-height: 1.38; color: var(--strong); }
#ch6 .ch6-out.is-write { background: var(--c-blue); color: #fff; }

/* Memory: failure modes are a risk list, so the marker is an orange cross instead of a blue tick */
#ch6-memory .ch6-listhead { margin-top: clamp(48px, 6vw, 64px); }
#ch6-memory .ch6-fails { margin-top: 24px; }
#ch6-memory .ch6-fails li::before { background: var(--c-orange) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7.5 7.5 9 9m0-9-9 9' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / 14px no-repeat; }

/* Files: the tree beside the heading, then the table */
#ch6-files .ch6-split { grid-template-columns: 7fr 5fr; }
#ch6-files .ch6-tree { margin: 0; }
#ch6-files .ch6-tree .code-card { margin: 0; }
#ch6-files .ch6-tree .code { font-size: 16px; line-height: 1.7; padding: 30px 34px; }
#ch6-files .code .ch6-g { color: #6e6e73; }
#ch6-files .ch6-tree figcaption { margin-top: 14px; font-size: 15px; line-height: 1.45; color: var(--muted); }
#ch6-files .table-wrap { margin-top: clamp(64px, 8vw, 112px); }
#ch6-files .dt th:nth-child(1) { width: 27%; }
#ch6-files .dt th:nth-child(3) { width: 30%; }

/* Skills: nine types as a three-column text list; verification takes the first column with its reason */
#ch6-skills .ch6-types { list-style: none; margin: 36px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, auto); grid-auto-flow: column; column-gap: 40px; font-size: 24px; line-height: 1.5; letter-spacing: -.02em; font-weight: 600; color: var(--strong); }
#ch6-skills .ch6-types .is-key { grid-row: 1 / span 4; color: var(--strong); }
#ch6-skills .ch6-types .is-key span { display: block; margin-top: 8px; max-width: 20em; font-size: 17px; line-height: 1.47; letter-spacing: -.01em; font-weight: 400; color: var(--muted); text-wrap: balance; }
#ch6-cycle .diagram .steps-row { margin-top: 0; }

@media (max-width: 960px) {
  #ch6-files .ch6-split { grid-template-columns: 1fr; }
  #ch6-files .ch6-tree { margin-top: 40px; }
}
@media (max-width: 680px) {
  #ch6 .ch6-unseen { gap: 14px; }
  #ch6 .ch6-decide { border-radius: 26px; }
  #ch6 .ch6-flow { grid-template-columns: minmax(0, 1fr); margin-top: 20px; }
  #ch6 .ch6-q { padding: 18px 20px; border-radius: 18px; }
  #ch6 .ch6-to { height: 36px; transform: rotate(90deg); }
  #ch6 .ch6-out { border-radius: 18px; }
  #ch6-files .ch6-tree .code { font-size: 14px; padding: 24px 24px; }
  #ch6-skills .ch6-types { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-auto-flow: row; font-size: 21px; }
  #ch6-skills .ch6-types .is-key { grid-row: auto; margin-bottom: 14px; }
}

#ch6-files td:first-child code { white-space: nowrap; }

/* Phone: line breaking tuned in review; desktop follows the shared balance rule. */
@media (max-width: 680px) {
  #ch6 .ch6-out { text-wrap: pretty; }
  #ch6-skills .ch6-types .is-key span { text-wrap: pretty; }
}

/* ---------- ch7 ---------- */
/* Chapter 7, «Свой агент». Every selector starts from one of the chapter's sections (#ch7, #ch7-…);
   colours come from the section theme (--card, --muted, --strong, --axis, --c-blue). */

/* ---------- Opener: the agent loop ---------- */
#ch7 .ch7-loop .ring { fill: none; stroke: var(--axis); stroke-opacity: .55; stroke-width: 2.5; }
#ch7 .ch7-loop .arrow { fill: var(--axis); }
#ch7 .ch7-loop .node { fill: var(--card); }
#ch7 .ch7-loop .node-t { fill: var(--strong); font-weight: 600; letter-spacing: -.01em; }
#ch7 .ch7-loop .core-t { fill: #fff; font-weight: 650; letter-spacing: -.01em; }
#ch7 .ch7-loop .lbl { fill: var(--muted); font-weight: 500; }
#ch7 .ch7-loop .exit { fill: none; stroke: var(--c-blue); stroke-width: 2.5; }
#ch7 .ch7-loop .arrow-ok, #ch7 .ch7-loop .ok { fill: var(--c-blue); }
#ch7 .ch7-loop .ok-tick { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
#ch7 .ch7-nw, #ch7-paths .ch7-nw { white-space: nowrap; }
#ch7 .ch7-loopnote { margin-top: 40px; }
@media (max-width: 680px) { #ch7 .ch7-loopnote { margin-top: 48px; } }

/* ---------- Do you need an agent: verdict and workflow patterns ---------- */
#ch7-need .ch7-patterns { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-top: 40px; }
#ch7-need .ch7-pattern { display: flex; flex-direction: column; padding: 26px 22px 26px; }
#ch7-need .ch7-pattern h3 { font-size: 21px; }
#ch7-need .ch7-pattern .ch7-en { margin: 4px 0 0; font-size: 15px; line-height: 1.35; }
#ch7-need .ch7-pattern p:last-child { margin-top: 12px; font-size: 16px; line-height: 1.45; }
#ch7-need .ch7-g { display: block; width: 100%; max-width: 168px; height: auto; margin: 0 0 24px; overflow: visible; }
#ch7-need .ch7-g .ln { fill: none; stroke: var(--axis); stroke-width: 1.75; stroke-linecap: round; }
#ch7-need .ch7-g .ln.on { stroke: var(--c-blue); }
#ch7-need .ch7-g .ln.dash { stroke-dasharray: 2.5 4; }
#ch7-need .ch7-g .io, #ch7-need .ch7-g .off { fill: none; stroke: var(--axis); stroke-width: 1.75; }
#ch7-need .ch7-g .llm { fill: var(--c-blue); }
#ch7-need .ch7-g .agg, #ch7-need .ch7-g .tip { fill: var(--axis); }

/* ---------- Typographic rule grid: tools, cache, evals ---------- */
#ch7-tools .ch7-rules, #ch7-cache .ch7-rules, #ch7-auto .ch7-rules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 44px 40px; margin-top: 56px; }
#ch7-tools .ch7-rules { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#ch7-auto .ch7-rules { grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: 28px; }
#ch7-cache .ch7-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 860px; }
#ch7-tools .ch7-rules h3, #ch7-cache .ch7-rules h3, #ch7-auto .ch7-rules h3 { margin: 0; font-size: clamp(20px, 1.7vw, 23px); line-height: 1.2; letter-spacing: -.022em; font-weight: 650; color: var(--strong); text-wrap: balance; }
#ch7-tools .ch7-rules p, #ch7-cache .ch7-rules p, #ch7-auto .ch7-rules p { margin: 8px 0 0; max-width: 24em; font-size: 17px; line-height: 1.47; color: var(--muted); }
#ch7-tools .ch7-rules .more { display: inline-block; margin-top: 10px; font-size: 17px; }

/* ---------- Context for Claude 5: six shifts ---------- */
#ch7-context .ch7-shifts { list-style: none; margin-bottom: 0; padding: 0; display: grid; gap: 12px; }
#ch7-context .ch7-shifts li { max-width: 28em; font-size: clamp(28px, 3vw, 40px); line-height: 1.12; letter-spacing: -.03em; font-weight: 650; color: var(--muted); text-wrap: balance; }
#ch7-context .ch7-shifts b { font-weight: 650; color: var(--strong); }
#ch7-context .ch7-ref { margin-top: 28px; }

/* ---------- Cache: the prompt prefix ---------- */
#ch7-cache .ch7-prefix .t { fill: var(--strong); font-weight: 600; letter-spacing: -.01em; }
#ch7-cache .ch7-prefix .hit { fill: var(--c-blue); }
#ch7-cache .ch7-prefix .miss { fill: var(--c-gray); fill-opacity: .2; }
#ch7-cache .ch7-prefix .in { fill: #fff; font-weight: 600; }
#ch7-cache .ch7-prefix .in-d { fill: var(--strong); font-weight: 600; }
#ch7-cache .ch7-prefix .n-hit { fill: var(--strong); font-weight: 600; }
#ch7-cache .ch7-prefix .n { fill: var(--muted); font-weight: 500; }
#ch7-cache .ch7-prefix figcaption { margin-top: 24px; }

/* ---------- Links to other chapters ---------- */
#ch7-context .ch7-next, #ch7-cache .ch7-next, #ch7-subagent .ch7-next { margin: 40px 0 0; font-size: 17px; }


/* ---------- Model line-up ---------- */
#ch7-models .ch7-lineup { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 56px; }
#ch7-models .ch7-lineup .card { min-height: 200px; }
#ch7-models .ch7-lineup h3 { font-size: clamp(24px, 2.3vw, 30px); line-height: 1.1; letter-spacing: -.03em; }
#ch7-models .ch7-lineup p { margin-top: 12px; }
#ch7-models .stats { margin-top: 48px; }
#ch7-models .ch7-tb { display: none; }

/* ---------- Subagent file and its fields ---------- */
#ch7-subagent .ch7-anatomy { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 56px; align-items: center; }
#ch7-subagent .code-card { margin: 0; }
#ch7-subagent .ch7-file { margin: 0; padding: 24px 30px 0; font: 500 15px/1.3 var(--mono); color: #98989d; }
#ch7-subagent .code { padding-top: 14px; }
#ch7-subagent .ch7-fields { margin: 0; display: grid; gap: 24px; }
#ch7-subagent .ch7-fields dt { font: 600 16px/1.3 var(--mono); color: var(--strong); }
#ch7-subagent .ch7-fields dd { margin: 6px 0 0; max-width: 26em; font-size: 17px; line-height: 1.45; color: var(--muted); }

html.sf #ch7-context .ch7-shifts li { letter-spacing: -.016em; }
html.sf #ch7-models .ch7-lineup h3 { letter-spacing: -.012em; }

@media (max-width: 1080px) {
  #ch7-need .ch7-patterns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #ch7-tools .ch7-rules, #ch7-auto .ch7-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  #ch7-auto .ch7-rules, #ch7-models .ch7-lineup { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #ch7-subagent .ch7-anatomy { grid-template-columns: minmax(0, 1fr); gap: 40px; }
}
@media (max-width: 680px) {
  #ch7-need .ch7-patterns { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  #ch7-need .ch7-pattern { display: grid; grid-template-columns: 92px minmax(0, 1fr); column-gap: 18px; align-items: start; padding: 22px 20px; }
  #ch7-need .ch7-pattern .ch7-g { grid-row: 1 / span 3; margin: 4px 0 0; }
  #ch7-tools .ch7-rules, #ch7-cache .ch7-rules, #ch7-auto .ch7-rules { grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 44px; }
  #ch7-context .ch7-shifts { gap: 14px; }
  #ch7-models .ch7-lineup { gap: 12px; margin-top: 44px; }
  #ch7-models .ch7-lineup .card { min-height: 0; padding: 22px 20px; }
  #ch7-models .ch7-lineup h3 { font-size: 22px; }
  #ch7-models .ch7-lineup p { font-size: 16px; }
  #ch7-subagent .ch7-file { padding: 20px 22px 0; }
  #ch7-subagent .code { padding-top: 12px; }
}
@media (max-width: 480px) {
  #ch7-need .ch7-pattern { display: flex; flex-direction: column; }
  #ch7-need .ch7-pattern .ch7-g { width: 120px; margin: 0 0 12px; }
  #ch7-models .ch7-lineup { grid-template-columns: minmax(0, 1fr); }
  #ch7-models .ch7-lineup .card { display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: 16px; align-items: baseline; }
  #ch7-models .ch7-lineup h3 { font-size: 20px; }
  #ch7-models .ch7-lineup p { margin-top: 0; }
  #ch7-models .ch7-lr { display: none; }
  #ch7-models .ch7-tb { display: inline; }
}

/* Phone: step texts rag naturally instead of balancing into steps. */
@media (max-width: 680px) { #ch7-steps .step-text { text-wrap: pretty; } }

/* Phone: line breaking tuned in review; desktop follows the shared balance rule. */
@media (max-width: 680px) {
  #ch7-tools .ch7-rules p, #ch7-cache .ch7-rules p, #ch7-auto .ch7-rules p { text-wrap: pretty; }
  #ch7-subagent .ch7-fields dd { text-wrap: pretty; }
}

/* ---------- ch8 ---------- */
/* Chapter 8, «Подписки и деньги»: the 2026 rule, API prices, task cost with the
   subscription-or-API calculator, competitors and the choice. Solid surfaces only, no glass. */

/* API prices: four short columns that fit a phone without stacking */
#ch8-api .ch8-prices th:first-child { width: 40%; }
#ch8-api .ch8-prices th.n { white-space: normal; }
#ch8-api .ch8-prices td.n { font-size: 19px; font-weight: 500; }

/* ---------- Calculator «Подписка или API» ---------- */
#ch8-calc .ch8-calc {
  margin-top: 40px; background: var(--card); border-radius: 30px; padding: clamp(28px, 3.6vw, 48px);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: 44px 64px; align-items: start;
}
#ch8-calc .ch8-out { grid-column: 1; grid-row: 1; min-width: 0; }
#ch8-calc .ch8-total { margin: 0; }
#ch8-calc .ch8-total b {
  display: block; font-size: clamp(64px, 8vw, 112px); font-weight: 650; letter-spacing: -.055em; line-height: .92;
  font-variant-numeric: tabular-nums; color: var(--strong);
}
#ch8-calc .ch8-total span { display: block; margin-top: 14px; font-size: clamp(19px, 1.7vw, 23px); line-height: 1.3; font-weight: 500; letter-spacing: -.018em; color: var(--strong); }
#ch8-calc .ch8-per { margin: 6px 0 0; font-size: 17px; line-height: 1.45; color: var(--muted); font-variant-numeric: tabular-nums; }

#ch8-calc .ch8-controls { grid-column: 2; grid-row: 1; display: grid; gap: 34px; padding-top: 6px; }

/* Segmented control: solid, like iOS; the white thumb slides to the chosen model */
#ch8-calc .ch8-seg { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 3px; border-radius: 999px; background: rgba(118, 118, 128, .12); }
#ch8-calc .ch8-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 3); border-radius: 999px; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04);
  transform: translateX(calc(var(--i, 1) * 100%)); transition: transform .45s var(--ease);
}
#ch8-calc .ch8-seg button {
  position: relative; z-index: 1; height: 40px; min-width: 0; padding: 0 6px; border: 0; border-radius: 999px; background: none;
  font: 500 16px/1 var(--font); letter-spacing: -.012em; color: var(--ink); cursor: pointer; white-space: nowrap;
  transition: color .3s var(--ease);
}
#ch8-calc .ch8-seg button[aria-pressed=true] { font-weight: 600; }
#ch8-calc .ch8-seg button:disabled { cursor: default; }
#ch8-calc .ch8-seg button:focus-visible { outline: 3px solid rgba(0, 113, 227, .65); outline-offset: 1px; }

/* Tasks per day: a real range input with an Apple-style track and white knob */
#ch8-calc .ch8-range { display: grid; grid-template-columns: 1fr auto; align-items: baseline; row-gap: 12px; }
#ch8-calc .ch8-range label { font-size: 17px; font-weight: 500; color: var(--strong); }
#ch8-calc .ch8-count { font-size: 30px; line-height: 1; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--strong); }
#ch8-calc input[type=range] {
  grid-column: 1 / -1; -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 0; padding: 0;
  background: none; cursor: pointer; --fill: calc(14px + (100% - 28px) * var(--f, .4737));
}
#ch8-calc input[type=range]:disabled { cursor: default; }
#ch8-calc input[type=range]:focus-visible { outline: none; }
#ch8-calc input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--c-blue) var(--fill), rgba(118, 118, 128, .2) var(--fill));
}
#ch8-calc input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -11px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .06), 0 3px 8px rgba(0, 0, 0, .16), 0 3px 1px rgba(0, 0, 0, .05);
  transition: transform .2s var(--ease);
}
#ch8-calc input[type=range]:active::-webkit-slider-thumb { transform: scale(1.08); }
#ch8-calc input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(0, 113, 227, .65), 0 3px 8px rgba(0, 0, 0, .16); }
#ch8-calc input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(118, 118, 128, .2); }
#ch8-calc input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--c-blue); }
#ch8-calc input[type=range]::-moz-range-thumb {
  width: 28px; height: 28px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .06), 0 3px 8px rgba(0, 0, 0, .16), 0 3px 1px rgba(0, 0, 0, .05);
}
#ch8-calc input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(0, 113, 227, .65), 0 3px 8px rgba(0, 0, 0, .16); }

/* Monthly cost on one scale with the three subscriptions; labels sit at the end of each bar.
   The note on limits sits beside the bars, under the controls. */
#ch8-calc .ch8-bars { grid-column: 1; grid-row: 2; display: grid; gap: 12px; }
#ch8-calc .ch8-note { grid-column: 2; grid-row: 2; align-self: end; margin: 0; font-size: 17px; line-height: 1.47; color: var(--muted); }
#ch8-calc .ch8-bar { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; column-gap: 14px; }
#ch8-calc .ch8-bar-name { font-size: 15px; font-weight: 600; color: var(--muted); }
#ch8-calc .ch8-bar-track { display: flex; align-items: center; gap: 12px; min-width: 0; }
#ch8-calc .ch8-bar-track i {
  flex: none; display: block; height: 12px; width: calc((100% - 84px) * var(--w, 0)); min-width: 12px; border-radius: 6px;
  background: var(--c-gray); transition: width .55s var(--ease);
}
#ch8-calc .ch8-bar.is-api .ch8-bar-track i { background: var(--c-blue); }
#ch8-calc .ch8-bar-track b { font-size: 17px; font-weight: 600; letter-spacing: -.012em; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
#ch8-calc .ch8-bar.is-api .ch8-bar-name, #ch8-calc .ch8-bar.is-api .ch8-bar-track b { color: var(--strong); }
#ch8-calc .ch8-assume { grid-column: 1 / -1; grid-row: 3; margin: -12px 0 0; font-size: 15px; line-height: 1.45; color: var(--muted); }

/* The quote closes the section on white: the shared style was written for black */
#ch8-cost .quote footer { color: var(--muted); }

/* ---------- Competitors ---------- */
#ch8-market .ch8-rivals th:nth-child(1) { width: 27%; }
#ch8-market .ch8-rivals th:nth-child(2) { width: 33%; }
#ch8-market .ch8-tiers { list-style: none; margin: 0; padding: 0; font-variant-numeric: tabular-nums; }
#ch8-market .ch8-tiers li + li { margin-top: 4px; }
#ch8-market .ch8-rivals td:last-child { color: var(--muted); }

/* ---------- How to choose: five scenarios on one grid, the second row left-aligned ---------- */
#ch8-choose .ch8-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
#ch8-choose .card { display: flex; flex-direction: column; }
#ch8-choose .card p b { font-weight: 600; color: var(--strong); }
#ch8-choose .card .more { margin-top: auto; padding-top: 20px; font-size: 17px; }
#ch8-choose .stamp { margin-top: 40px; }

html.sf #ch8-calc .ch8-total b { letter-spacing: -.03em; }

@media (max-width: 960px) {
  #ch8-calc .ch8-calc { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  #ch8-calc .ch8-out, #ch8-calc .ch8-controls, #ch8-calc .ch8-bars, #ch8-calc .ch8-note, #ch8-calc .ch8-assume { grid-column: 1; grid-row: auto; }
  #ch8-calc .ch8-note { margin-top: -10px; }
  #ch8-calc .ch8-controls { max-width: 460px; padding-top: 0; }
  #ch8-choose .ch8-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  #ch8-api .ch8-prices th, #ch8-api .ch8-prices td { padding-inline: 10px; }
  #ch8-api .ch8-prices th:first-child { width: auto; }
  #ch8-api .ch8-prices td.n { font-size: 17px; }
  #ch8-calc .ch8-calc { margin-top: 32px; border-radius: 26px; padding: 26px 20px 24px; gap: 30px; }
  #ch8-calc .ch8-total span { margin-top: 10px; }
  #ch8-calc .ch8-controls { gap: 28px; max-width: none; }
  #ch8-calc .ch8-seg button { font-size: 15px; height: 38px; }
  #ch8-calc .ch8-bar { grid-template-columns: 44px minmax(0, 1fr); column-gap: 10px; }
  #ch8-calc .ch8-bar-track i { width: calc((100% - 72px) * var(--w, 0)); }
  #ch8-calc .ch8-bar-track b { font-size: 16px; }
  #ch8-calc .ch8-assume { margin-top: -6px; }
  #ch8-market .ch8-rivals th { width: auto; }
  #ch8-market .ch8-rivals td:first-child { font-size: 17px; }
  #ch8-market .ch8-tiers { margin-top: 2px; }
  #ch8-choose .ch8-choices { grid-template-columns: minmax(0, 1fr); }
}

/* Phone: line breaking tuned in review; desktop follows the shared balance rule. */
@media (max-width: 680px) {
  #ch8-calc .ch8-per { text-wrap: pretty; }
  #ch8-calc .ch8-note { text-wrap: pretty; }
  #ch8-calc .ch8-assume { text-wrap: pretty; }
}

/* ---------- ch9 ---------- */
/* Chapter 9, boundaries: body text under a short lead, the incidents table, before → after numbers, the questions beside the automation rules, the deny rules. */

/* Body text under a lead, set like .prose p but aligned to the wrap. */
#ch9-auto .ch9-body { margin-bottom: 0; max-width: 34em; font-size: clamp(18px, 1.42vw, 21px); line-height: 1.6; letter-spacing: -.012em; }

#ch9-layers .ch9-nw { white-space: nowrap; }
#ch9-layers .dt code { overflow-wrap: anywhere; }

/* Before → after: two values in one figure, so a smaller size than a single number; the arrow stays quiet. */
#ch9-autonomy .ch9-shift .stat b { font-size: clamp(40px, 3.6vw, 52px); white-space: nowrap; }
#ch9-autonomy .ch9-to { color: var(--muted); font-weight: 400; margin: 0 .16em; }
#ch9-autonomy .ch9-next { margin: 32px 0 0; font-size: clamp(17px, 1.4vw, 19px); line-height: 1.45; }

#ch9-checks .ch9-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 56px 64px; align-items: start; }
#ch9-checks .ch9-col-h { font-size: clamp(21px, 1.8vw, 24px); line-height: 1.2; letter-spacing: -.022em; font-weight: 650; margin: 0; }
#ch9-checks .ch9-col .checks { margin-top: 24px; }
#ch9-checks .ch9-col > .checks:first-child { margin-top: 0; }
#ch9-checks .ch9-deny { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 32px 64px; align-items: center; margin-top: clamp(64px, 8vw, 104px); }
#ch9-checks .ch9-deny .code-card { margin: 0; }
#ch9-checks .ch9-deny .verdict { margin: 0; }
#ch9-checks .ch9-deny-note { margin: 16px 0 0; font-size: 17px; line-height: 1.47; color: var(--muted); max-width: 30em; }

@media (max-width: 960px) {
  #ch9-checks .ch9-pair, #ch9-checks .ch9-deny { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 961px) {
  #ch9-checks .ch9-pair { grid-template-rows: auto auto; row-gap: 0; }
  #ch9-checks .ch9-col { display: grid; grid-row: span 2; grid-template-rows: subgrid; }
}

#ch9-checks .ch9-col-h + .checks { margin-top: 16px; }

/* Phone: line breaking tuned in review; desktop follows the shared balance rule. */
@media (max-width: 680px) {
  #ch9-checks .ch9-deny-note { text-wrap: pretty; }
}

/* ---------- ch10 ---------- */
/* Chapter 10: many agents. Four topology panels on black, the lesson line, two voices side by side,
   the sessions pictogram. Colours come from the section theme. */

/* Topologies: graphite panels on black, agents in blue, shared media (git, tmux, tables) in faint white */
#ch10 .ch10-topo .pn { fill: var(--card); }
#ch10 .ch10-topo .tt { fill: var(--strong); font-weight: 650; letter-spacing: -.012em; }
#ch10 .ch10-topo .ts { fill: var(--muted); }
#ch10 .ch10-topo .tf { fill: var(--strong); fill-opacity: .8; }
#ch10 .ch10-topo .tl { fill: var(--strong); fill-opacity: .86; font-weight: 600; }
#ch10 .ch10-topo .tm { fill: var(--muted); }
#ch10 .ch10-topo .ag { fill: var(--c-blue); }
#ch10 .ch10-topo .ag2 { fill: var(--c-blue); fill-opacity: .55; }
#ch10 .ch10-topo .jd { fill: var(--strong); }
#ch10 .ch10-topo .hub { fill: var(--strong); fill-opacity: .1; }
#ch10 .ch10-topo .tb { fill: var(--strong); fill-opacity: .2; }
#ch10 .ch10-topo .pane { fill: var(--card); }
#ch10 .ch10-topo .tx { fill: var(--strong); fill-opacity: .22; }
#ch10 .ch10-topo .ln { stroke: var(--strong); stroke-opacity: .22; stroke-width: 1.5; fill: none; }

/* The lesson under the figure reuses the chapter-4 statement note */
#ch10 .ch10-lesson { margin-top: clamp(44px, 5.5vw, 72px); }
@media (max-width: 680px) { #ch10 .ch10-lesson { margin-top: 48px; } }

/* Two principles from one post: a two-tone list at heading size, as in the chapter-6 opener */
#ch10-against .ch10-principles { list-style: none; margin-bottom: 0; padding: 0; display: grid; gap: 14px; }
#ch10-against .ch10-principles li { font-size: clamp(26px, 3vw, 40px); line-height: 1.12; letter-spacing: -.03em; font-weight: 650; color: var(--muted); max-width: 24em; text-wrap: balance; }
#ch10-against .ch10-principles b { font-weight: 650; color: var(--strong); }
#ch10-against .ch10-by { margin: 22px 0 0; font-size: 17px; color: var(--muted); }
html.sf #ch10-against .ch10-principles li { letter-spacing: -.016em; }

/* Sessions pictogram: Cherny in blue (the uncertain part of his web range pale), Hashimoto in grey */
#ch10-solo .ch10-people .nm { fill: var(--strong); font-weight: 650; }
#ch10-solo .ch10-people .sb { fill: var(--muted); }
#ch10-solo .ch10-people .lb { fill: var(--strong); }
#ch10-solo .ch10-people .sa { fill: var(--c-blue); }
#ch10-solo .ch10-people .sg { fill: var(--c-gray); }
#ch10-solo .ch10-people .sg2 { fill: none; stroke: var(--c-blue); stroke-width: 1.5; }

/* Table: the first column names the sign, the other two split evenly */
#ch10-when .ch10-table th:first-child { width: 16%; }
#ch10-when .ch10-table th:not(:first-child) { width: 42%; }

/* ---------- ch11 ---------- */
/* Chapter 11: the team after agents. The cycle before and after and the rescue bars; the six steps use
   the shared .steps-row, the rollout order is one line. Colours come from the section theme. */

/* Cycle: blue is the person's work; the agent's step and the states sit on the quiet card fill */
#ch11 .ch11-cycle .rl { fill: var(--strong); font-weight: 650; }
#ch11 .ch11-cycle .nh { fill: var(--c-blue); }
#ch11 .ch11-cycle .na { fill: var(--card); }
#ch11 .ch11-cycle .nn { fill: var(--card); }
#ch11 .ch11-cycle .nht { fill: #fff; font-weight: 600; }
#ch11 .ch11-cycle .nhs { fill: #fff; fill-opacity: .82; }
#ch11 .ch11-cycle .nat { fill: var(--strong); font-weight: 600; }
#ch11 .ch11-cycle .nas { fill: var(--muted); }
#ch11 .ch11-cycle .nnt { fill: var(--muted); font-weight: 600; }
#ch11 .ch11-cycle .ar { stroke: var(--axis); stroke-opacity: .7; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#ch11 .ch11-cycle .lp { stroke: var(--c-blue); stroke-width: 2.25; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#ch11 .ch11-cycle .lpt { fill: var(--c-blue); font-weight: 650; }
#ch11 .ch11-cycle { max-width: 1000px; }

/* Rollout order: one line at heading size, the arrows quieter than the steps */
#ch11-rollout .ch11-order { margin-bottom: 0; font-size: clamp(24px, 2.6vw, 34px); line-height: 1.3; letter-spacing: -.024em; font-weight: 650; color: var(--strong); max-width: 30em; text-wrap: balance; }
#ch11-rollout .ch11-arr { color: var(--c-blue); font-weight: 500; }
#ch11-rollout .ch11-owner { margin-top: 26px; }
html.sf #ch11-rollout .ch11-order { letter-spacing: -.012em; }

/* Rescue bars */
#ch11-risks .ch11-rescue .rn { fill: var(--strong); font-weight: 600; }
#ch11-risks .ch11-rescue .rv { fill: var(--strong); font-weight: 650; }
#ch11-risks .ch11-rescue .rb { fill: var(--c-blue); }
#ch11-risks .ch11-rescue .rg { fill: var(--c-gray); }

/* ---------- ch12 ---------- */
/* ch12: seven disputes in one table — the question, one side, the other, the verdict with its chapter. */
#ch12 .ch12-table td b { font-weight: 600; color: var(--strong); }
#ch12 .ch12-table .more { white-space: nowrap; }
@media (min-width: 681px) {
  #ch12 .ch12-table th:nth-child(1) { width: 17%; } /* the questions set on two lines */
  #ch12 .ch12-table th:nth-child(2), #ch12 .ch12-table th:nth-child(3) { width: 27%; }
  #ch12 .ch12-table th:nth-child(4) { width: 29%; }
}
@media (max-width: 680px) {
  #ch12 .ch12-table tbody td:first-child { font-size: 18px; line-height: 1.3; padding-bottom: 8px; }
  #ch12 .ch12-table tbody td + td { padding-bottom: 8px; }
}

/* ---------- ch13 ---------- */
/* ch13: old advice → what now. Two columns on black; the old advice is quieter, the new one carries the row.
   On a phone every row stacks: old advice above, the replacement under it. */
#ch13 .ch13-table { width: 100%; border-collapse: separate; border-spacing: 0; }
#ch13 .ch13-table th { text-align: left; padding: 0 24px 14px; font-size: 15px; line-height: 1.3; font-weight: 600; color: var(--muted); }
#ch13 .ch13-table th + th { padding-left: 76px; }
#ch13 .ch13-table td { padding: 20px 24px 21px; vertical-align: top; font-size: clamp(19px, 1.7vw, 23px); line-height: 1.34; letter-spacing: -.018em; }
#ch13 .ch13-table td:first-child { width: 44%; color: var(--muted); border-radius: 18px 0 0 18px; }
#ch13 .ch13-table td + td { position: relative; padding-left: 76px; color: var(--strong); font-weight: 500; border-radius: 0 18px 18px 0; }
#ch13 .ch13-table td + td::before {
  content: ""; position: absolute; left: 22px; top: calc(21px + .67em - 12px); width: 24px; height: 24px; background: var(--muted); opacity: .7;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12h15M13.5 6.5 19 12l-5.5 5.5' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12h15M13.5 6.5 19 12l-5.5 5.5' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
#ch13 .ch13-table tbody tr:nth-child(odd) td { background: var(--zebra); }
#ch13 .ch13-note { margin-top: 22px; max-width: 52em; }
html.sf #ch13 .ch13-table td { letter-spacing: -.01em; }

@media (max-width: 680px) {
  #ch13 .ch13-table, #ch13 .ch13-table tbody, #ch13 .ch13-table tr, #ch13 .ch13-table td { display: block; width: 100%; }
  #ch13 .ch13-table thead { display: none; }
  #ch13 .ch13-table tbody tr { padding: 16px 18px 17px; border-radius: 18px; }
  #ch13 .ch13-table tbody tr:nth-child(odd) { background: var(--zebra); }
  #ch13 .ch13-table tbody tr td { border-radius: 0; padding: 0; }
  #ch13 .ch13-table tbody tr:nth-child(odd) td { background: none; }
  #ch13 .ch13-table tbody td:first-child { width: 100%; border-radius: 0; font-size: 16px; line-height: 1.4; letter-spacing: -.01em; }
  #ch13 .ch13-table tbody tr td + td { margin-top: 6px; padding-left: 28px; font-size: 18px; line-height: 1.38; }
  #ch13 .ch13-table tbody tr td + td::before { left: 0; top: calc(.69em - 9px); width: 18px; height: 18px; }
}

/* Phone: line breaking tuned in review; desktop follows the shared balance rule. */
@media (max-width: 680px) {
  #ch13 .ch13-table td { text-wrap: pretty; }
}

/* ---------- ch14 ---------- */
/* ch14: the plan. The light stepper from ch7 carries three checklists. Every step stays open: a checklist
   shows all its items. ch14.js sets the step states from the ticks (page.js leaves this stepper alone). */
#ch14 .step-more { grid-template-rows: 1fr; opacity: 1; }
#ch14 .ch14-wrap { overflow: hidden; min-height: 0; margin: 0 -8px; padding: 0 8px; }

/* Checklist: a real checkbox under a round mark, as in Reminders. */
#ch14 .ch14-list { list-style: none; margin: 0; padding: 14px 0 6px; display: grid; gap: 12px; }
#ch14 .ch14-list li { position: relative; padding-left: 38px; font-size: 17px; line-height: 1.45; color: var(--ink); }
#ch14 .ch14-list input { position: absolute; left: 0; top: 0; z-index: 1; width: 26px; height: 26px; margin: 0; opacity: 0; cursor: pointer; }
#ch14 .ch14-list label { cursor: pointer; transition: color .25s var(--ease); }
#ch14 .ch14-list label::before {
  content: ""; position: absolute; left: 1px; top: 1px; width: 24px; height: 24px; border-radius: 50%;
  box-shadow: inset 0 0 0 2px #c7c7cc; transition: background-color .2s var(--ease), box-shadow .2s var(--ease);
}
#ch14 .ch14-list input:hover + label::before { box-shadow: inset 0 0 0 2px #8e8e93; }
#ch14 .ch14-list input:checked + label::before {
  box-shadow: none;
  background: var(--c-blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m5.5 12.5 4 4 9-9.5' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
}
#ch14 .ch14-list input:checked + label { color: var(--ink-2); }
#ch14 .ch14-list input:focus-visible + label::before { outline: 3px solid rgba(0, 113, 227, .65); outline-offset: 2px; }
#ch14 .ch14-list .more { font-size: 15px; white-space: nowrap; }
#ch14 .ch14-nw { white-space: nowrap; }

/* The checklists get more room than the ch7 stepper text. */
@media (min-width: 961px) {
  #ch14 .split { grid-template-columns: 5fr 7fr; }
}

/* Status under the heading, written by ch14.js only. */
#ch14 .ch14-status { margin: 32px 0 0; /* same as text after a lead (.lead-cont); the script puts it in .split-text */ font-size: 15px; line-height: 1.5; color: var(--ink-2); max-width: 26em; }
#ch14 .ch14-status b { display: block; margin-bottom: 2px; font-size: 17px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
#ch14 .ch14-reset { font: inherit; font-weight: 500; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; border-radius: 4px; }
#ch14 .ch14-reset:hover { text-decoration: underline; }

@media (max-width: 680px) {
  #ch14 .ch14-status { margin-top: 28px; }
  /* A denser stepper than ch7: the checklists need the width. */
  #ch14 .stepper { padding: 24px 18px 26px; }
  #ch14 .step { grid-template-columns: 52px 1fr; column-gap: 14px; }
  #ch14 .step-dot { width: 52px; height: 52px; }
  #ch14 .step-dot svg { width: 26px; height: 26px; }
  #ch14 .step-line { left: 24px; top: 52px; }
  #ch14 .step-title { padding-top: 9px; }
  #ch14 .ch14-list { gap: 10px; padding-top: 12px; }
  #ch14 .ch14-list li { padding-left: 34px; font-size: 16px; }
  #ch14 .ch14-list input { width: 24px; height: 24px; }
  #ch14 .ch14-list label::before { left: 0; top: 1px; width: 22px; height: 22px; }
  #ch14 .ch14-list input:checked + label::before { background-size: 13px; }
}
@media (max-width: 480px) {
  /* Phone: a thin rail, so the items get the width. */
  #ch14 .step { grid-template-columns: 44px 1fr; column-gap: 12px; }
  #ch14 .step-dot { width: 44px; height: 44px; }
  #ch14 .step-dot svg { width: 22px; height: 22px; }
  #ch14 .step-line { left: 20px; top: 44px; }
  #ch14 .step-title { padding-top: 6px; }
}

/* Phone: line breaking tuned in review; desktop follows the shared balance rule. */
@media (max-width: 680px) {
  #ch14 .ch14-list li { text-wrap: pretty; }
}

