  /* Two widths only: the text column (38rem) and the wide column (54rem) shared by code and drawings. Desktop only. */
  :root {
    --page: #f6eee7; --wash: #eeebe2; --paper: #ffffff; --ink: #17150f; --muted: #57544d; --line: #d6d2c6; --edge: #8f897c;
    --clay: #c96a4b; --clay-deep: #9e4a32; --clay-ink: #9a4428; --clay-tint: #f3dcd1; --data: #d8ecdc;
    --sucker: #e8a98e; --iris: #e6c98e;
    --imsg: #0a7aea; --bubble: #e9e9eb; --ok: #1f9d55; --alert: #cf4436; --meter: #efc244;
    --good: #2f7d4f; --good-tint: #d9eedf; --alert-tint: #f7d8d2;
    --cta: #9a4428; --on-cta: #ffffff;
    --text: 38rem; --wide: 54rem;
    --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
    --sans: "DM Sans", "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  /* No CSS smooth scrolling: ScrollTrigger measures scenes by jumping the scroll position, and smooth scrolling corrupts that measurement. Links scroll smoothly through script instead. */
  html { font-size: 18px; overflow-x: clip; }
  body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--serif); line-height: 1.65; -webkit-font-smoothing: antialiased; }
  ::selection { background: var(--meter); color: var(--ink); }
  .readbar { position: fixed; inset: 0 0 auto; height: 3px; z-index: 40; pointer-events: none; }
  .readbar i { display: block; height: 3px; background: var(--clay); transform-origin: 0 50%; transform: scaleX(0); }

  /* Top bar: course, the part you are in, and two on-demand panels. It slides away while a drawing fills the window. */
  .chapbar { position: fixed; inset: 0 0 auto; z-index: 30; height: 3.4rem; display: flex; align-items: center; gap: 1.2rem; padding: 0 1.5rem; font-family: var(--sans); font-size: 0.92rem; background: var(--page); transition: transform 400ms cubic-bezier(0.32, 0.72, 0, 1), background 600ms; }
  body.in-scene .chapbar { transform: translateY(-110%); }
  .chapbar .course { font-weight: 700; white-space: nowrap; color: var(--ink); text-decoration: none; }
  .chapbar .here { color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chapbar .btn { padding: 0.45rem 1rem; font-size: 0.9rem; }
  /* Chapters menu: domains in exam-weight order, each with its share drawn as a bar; this chapter's parts listed under it. */
  .chapmenu { position: absolute; right: 1.5rem; top: 3.3rem; width: 25rem; background: var(--paper); border-radius: 16px; padding: 1.1rem 1.1rem 0.9rem; box-shadow: 0 18px 48px rgb(23 21 15 / 0.18), 0 2px 6px rgb(23 21 15 / 0.06); transform-origin: 90% 0; max-height: calc(100vh - 4.5rem); overflow-y: auto; overscroll-behavior: contain; }
  .dom { padding: 0.55rem 0.5rem 0.7rem; }
  .dom + .dom { margin-top: 0.15rem; }
  .dom-head { display: flex; justify-content: space-between; gap: 1rem; font-weight: 700; font-size: 0.92rem; }
  .dom-w { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
  .wbar { display: block; height: 4px; margin-top: 0.45rem; border-radius: 2px; background: var(--wash); overflow: hidden; }
  .wbar i { display: block; height: 100%; background: var(--clay); border-radius: 2px; }
  .dom.none .dom-head { color: var(--muted); font-weight: 600; }
  .dom.none .wbar i { background: var(--edge); }
  .chaps { list-style: none; margin: 0.5rem 0 0; padding: 0; }
  .chap { display: block; padding: 0.4rem 0.7rem; border-radius: 10px; color: var(--ink); font-size: 0.9rem; font-weight: 600; text-decoration: none; }
  a.chap:hover { background: var(--wash); }
  .chap[aria-current="page"] { background: var(--clay-tint); font-weight: 700; }
  .chap.planned { color: var(--muted); font-weight: 500; }
  .parts { list-style: none; margin: 0.3rem 0 0; padding: 0; counter-reset: pt; }
  .parts li { counter-increment: pt; }
  .parts a { display: grid; grid-template-columns: 1.5rem 1fr; padding: 0.38rem 0.7rem; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 0.9rem; }
  .parts a::before { content: counter(pt); color: var(--clay-ink); font-weight: 700; }
  .parts a:hover { background: var(--wash); }
  .parts a[aria-current="location"] { background: var(--wash); font-weight: 700; }
  .menu-note { margin: 0.5rem 0.5rem 0; font-size: 0.8rem; color: var(--muted); }


  .page { padding: 7rem 16px 4rem; }
  .col { max-width: var(--text); margin-inline: auto; }

  /* Type: five sizes. Chapter title, part title, section title, figure title, body. */
  h1, h2, h3 { font-family: var(--serif); text-wrap: balance; font-weight: 500; }
  /* The chapter name is the title; the claim sits under it as a subline. */
  h1 { font-size: clamp(3.4rem, 6vw, 5.4rem); line-height: 1; letter-spacing: -0.035em; margin: 0 0 0.9rem; }
  .subline { font-family: var(--serif); font-size: clamp(1.6rem, 2.4vw, 2.1rem); line-height: 1.25; letter-spacing: -0.015em; margin: 0 -8rem 1.6rem 0; color: var(--ink); text-wrap: balance; }
  .lede { font-size: 1.35rem; line-height: 1.5; color: var(--muted); margin: 0 0 3.5rem; }
  .part-h { font-size: clamp(2.5rem, 4vw, 3.5rem); line-height: 1.05; letter-spacing: -0.03em; margin: 0 -8rem 2rem 0; padding-top: 2rem; }
  h3 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.02em; margin: 4.5rem 0 1rem; }
  .scene-title { font-family: var(--sans); font-size: 1.1rem; font-weight: 700; margin: 0; contain: inline-size; }
  p { font-size: 1.12rem; margin: 0 0 1.2rem; text-wrap: pretty; }
  .tieback { font-size: 1.28rem; line-height: 1.5; margin: 3rem 0 2rem; }
  q { quotes: "“" "”"; }

  /* Contents at the top */
  .toc-h { font-family: var(--sans); font-size: 1rem; font-weight: 700; margin: 0 0 0.8rem; }
  .toc { list-style: none; margin: 0; padding: 0; counter-reset: part; display: grid; gap: 0.35rem; }
  .toc li { counter-increment: part; }
  .toc a { display: grid; grid-template-columns: 2.4rem 1fr; padding: 0.7rem 0.9rem 0.7rem 0.4rem; border-radius: 12px; color: var(--ink); text-decoration: none; font-size: 1.06rem; line-height: 1.45; transition: background 160ms; }
  .toc a::before { content: counter(part); font-family: var(--sans); font-weight: 700; color: var(--clay-ink); font-size: 1.1rem; text-align: center; }
  .toc a:hover { background: var(--paper); }
  .toc b { font-weight: 600; }

  /* Code: wide column, no ligatures, so != and == read as typed. */
  code, pre { font-family: var(--mono); font-variant-ligatures: none; }
  code { font-size: 0.84em; background: var(--wash); padding: 0.1em 0.35em; border-radius: 5px; }
  pre { font-size: 0.8rem; line-height: 1.65; background: var(--paper); border-radius: 14px; padding: 1.2rem 1.5rem; margin: 2rem 0; width: min(var(--wide), calc(100vw - 32px)); position: relative; left: 50%; transform: translateX(-50%); white-space: pre; overflow-x: auto; }
  pre code { background: none; padding: 0; font-size: inherit; }
  /* Code with a plain-English column: each chunk of code sits beside one sentence saying what it does. English that Claude reads inside the code is highlighted like a prompt. */
  .coderead { width: min(var(--wide), calc(100vw - 32px)); position: relative; left: 50%; transform: translateX(-50%); margin: 2rem 0; background: var(--paper); border-radius: 14px; padding: 0.5rem; display: grid; gap: 2px; }
  .cr { display: grid; grid-template-columns: minmax(0, 1fr) 17.5rem; gap: 1.6rem; align-items: start; padding: 0.55rem 0.9rem; border-radius: 10px; transition: background 160ms; }
  .cr:not(.cr-head):hover { background: var(--wash); }
  .cr-head { padding-bottom: 0.1rem; font: 700 0.8rem/1.2 var(--sans); color: var(--clay-ink); }
  .coderead .cr-code { margin: 0; padding: 0; background: none; width: auto; left: 0; transform: none; border-radius: 0; font-size: 0.8rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
  .cr-say { margin: 0; font: 400 0.95rem/1.45 var(--sans); color: var(--ink); }
  .cr-say code { font-size: 0.85em; }
  mark.en { background: #f9e7a3; color: var(--ink); font-family: var(--sans); font-size: 1.04em; padding: 0.05em 0.3em; border-radius: 4px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .task .coderead { width: 100%; left: 0; transform: none; background: var(--wash); }
  .task .cr { grid-template-columns: minmax(0, 1fr) 13rem; }
  .task .cr:not(.cr-head):hover { background: var(--paper); }
  .c { color: var(--muted); }
  .k { color: var(--clay-ink); font-weight: 500; }

  /* Glossary terms: dotted underline, one click shows the definition beside the word. */
  .term { all: unset; cursor: pointer; text-decoration: underline dotted var(--clay-ink) 2px; text-underline-offset: 0.22em; border-radius: 4px; }
  .term:hover { background: var(--clay-tint); }
  .term:focus-visible { outline: 3px solid var(--clay-ink); outline-offset: 2px; }
  .term code { text-decoration: inherit; }
  .term[aria-expanded="true"] { background: var(--meter); }
  .pop { position: absolute; z-index: 35; width: 21rem; background: var(--ink); color: var(--page); border-radius: 12px; padding: 0.9rem 1.1rem 1rem; font-family: var(--sans); box-shadow: 0 12px 32px rgb(23 21 15 / 0.22); }
  .pop b { display: block; font-size: 1rem; margin-bottom: 0.3rem; color: var(--meter); }
  .pop p { font-size: 0.95rem; line-height: 1.5; margin: 0; color: #f4f1ea; }
  .pop code { background: rgb(255 255 255 / 0.12); color: inherit; }
  /* Terms panel: every term in the chapter, grouped by the part that introduces it. */
  .scrim { position: fixed; inset: 0; z-index: 44; background: rgb(23 21 15 / 0.18); }
  .terms { position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: 27rem; background: var(--paper); box-shadow: -18px 0 48px rgb(23 21 15 / 0.16); padding: 1.3rem 1.5rem 2rem; overflow-y: auto; font-family: var(--sans); overscroll-behavior: contain; }
  .terms-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
  .terms-head h2 { font-family: var(--sans); font-size: 1.15rem; font-weight: 700; margin: 0; }
  .terms-head h2 span { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
  .find { display: block; margin: 1rem 0 0.4rem; }
  .find input { width: 100%; font: 500 0.95rem/1.2 var(--sans); color: var(--ink); background: var(--wash); border: 2px solid transparent; border-radius: 10px; padding: 0.65rem 0.8rem; }
  .find input:focus { outline: none; border-color: var(--clay-ink); background: var(--paper); }
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tgroup h3 { font-family: var(--sans); font-size: 0.8rem; font-weight: 700; color: var(--clay-ink); margin: 1.3rem 0 0.2rem; letter-spacing: 0; }
  .tentry { padding: 0.55rem 0.6rem; margin: 0 -0.6rem; border-radius: 10px; }
  .tentry button { all: unset; cursor: pointer; font-weight: 700; font-size: 0.98rem; text-decoration: underline dotted var(--clay-ink) 2px; text-underline-offset: 0.22em; }
  .tentry button:focus-visible { outline: 3px solid var(--clay-ink); outline-offset: 2px; border-radius: 3px; }
  .tentry p { margin: 0.2rem 0 0; font-size: 0.92rem; line-height: 1.5; }
  .tentry code { font-size: 0.85em; }
  .tentry.read button { text-decoration-color: var(--edge); }
  .terms-none { color: var(--muted); font-size: 0.95rem; margin-top: 1rem; }
  .term.flash { animation: flash 1.6s ease-out; }
  @keyframes flash { 0%, 30% { background: var(--meter); } 100% { background: transparent; } }


  /* Scroll scenes. The figure opens out of the text column as the scene arrives. */
  .scrolly { position: relative; margin: 3rem auto; }
  .stage { position: sticky; top: 0; z-index: 2; height: 100vh; display: flex; align-items: center; justify-content: center; padding-block: 2vh; }
  .fig { display: flex; flex-direction: column; gap: 0.8rem; transform-origin: 50% 40%; }
  .stage .frame { height: calc(100vh - 4vh - 10.4rem); aspect-ratio: 1200 / 720; max-width: calc(100vw - 32px); background: var(--wash); border-radius: 22px; overflow: hidden; }
  .caption { contain: inline-size; min-height: 6.4rem; font-size: 1.28rem; line-height: 1.5; display: flex; flex-direction: column; gap: 0.6rem; }
  .caption .t { max-width: 46rem; }
  .caption .n { display: flex; gap: 6px; }
  .caption .n i { width: 2.2rem; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 18%, transparent); transition: background 200ms; }
  .caption .n i.on { background: var(--clay); }
  .caption code { font-size: 0.8em; }
  .steps { position: relative; z-index: 1; margin-top: -100vh; }
  .step { height: 140vh; }
  .step p { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stage svg { display: block; width: 100%; height: 100%; }
  .ink3 { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
  .paper { fill: var(--paper); stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }
  .sans { font-family: var(--sans); fill: var(--ink); }
  .mono { font-family: var(--mono); fill: var(--ink); }
  .mark { fill: none; stroke: var(--alert); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }

  /* Controls */
  .pause { background: var(--paper); border-radius: 16px; padding: 1.4rem 1.5rem 1.3rem; margin: 2rem 0; }
  .pause .q { font-size: 1.3rem; line-height: 1.35; font-weight: 500; margin: 0 0 1rem; }
  .choices { display: flex; flex-wrap: wrap; gap: 0.7rem; }
  .btn, .opt, .pick {
    font: 500 1rem/1.3 var(--sans); color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 999px;
    padding: 0.7rem 1.2rem; cursor: pointer;
    transition: box-shadow 200ms cubic-bezier(0.32, 0.72, 0, 1), background 160ms, border-color 160ms, transform 120ms cubic-bezier(0.32, 0.72, 0, 1);
  }
  .btn:hover:not(:disabled), .opt:hover:not(:disabled), .pick:hover:not(:disabled) { box-shadow: 0 0 0 4px rgb(154 68 40 / 0.22); }
  .btn:active:not(:disabled), .opt:active:not(:disabled), .pick:active:not(:disabled) { transform: scale(0.98); }
  .btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
  .btn.wrong { background: var(--alert-tint); border-color: var(--alert); color: var(--ink); }
  .btn.right { background: var(--good-tint); border-color: var(--good); color: var(--ink); }
  .btn:disabled, .opt:disabled, .pick:disabled { cursor: default; }
  .pause .answer { margin: 1rem 0 0; font-size: 1.08rem; }
  button:focus-visible, a:focus-visible { outline: 3px solid var(--clay-ink); outline-offset: 3px; }
  .task { background: var(--paper); border-radius: 18px; padding: 2rem 2rem 1.8rem; margin: 2rem 0 3rem; }
  .task h3 { margin-top: 0; }
  .task pre { width: 100%; left: 0; transform: none; background: var(--wash); font-size: 0.76rem; padding: 1rem 1.1rem; }
  .picks { display: grid; gap: 0.6rem; }
  .pick { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr); gap: 0.75rem; align-items: start; text-align: left; border-radius: 14px; border-color: var(--edge); padding: 0.85rem 1rem; font-weight: 400; }
  .pick .box { width: 1.3rem; height: 1.3rem; border: 2px solid var(--ink); border-radius: 5px; margin-top: 0.1rem; display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; line-height: 1; }
  .pick[aria-pressed="true"] { border-color: var(--ink); }
  .pick[aria-pressed="true"] .box { background: var(--ink); color: var(--paper); }
  .pick[aria-pressed="true"] .box::after { content: "✓"; }
  .pick.ok { border-color: var(--good); background: var(--good-tint); }
  .pick.bad { border-color: var(--alert); background: var(--alert-tint); }
  .pick .why { display: block; margin-top: 0.35rem; font-size: 0.95rem; color: var(--muted); }
  .actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: 1.3rem; font-family: var(--sans); }
  .cta { font: 600 1.02rem/1 var(--sans); color: var(--on-cta); background: var(--cta); border: 0; border-radius: 999px; padding: 0.95rem 1.5rem; cursor: pointer; transition: box-shadow 200ms cubic-bezier(0.32, 0.72, 0, 1), opacity 160ms; }
  .cta:hover:not(:disabled) { box-shadow: 0 0 0 4px rgb(154 68 40 / 0.22); }
  .cta:disabled { opacity: 0.35; cursor: default; }
  .hint { color: var(--muted); margin: 0; font-size: 1rem; }
  .opts { display: grid; gap: 0.7rem; margin-top: 1.25rem; }
  .opt { text-align: left; border-radius: 16px; padding: 0.95rem 1.15rem; font-weight: 400; border-color: var(--edge); }
  .opt.correct { border-color: var(--good); background: var(--good-tint); }
  .opt.chosen-wrong { border-color: var(--alert); background: var(--alert-tint); }
  .feedback { margin: 1.2rem 0 0; }
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

  /* Byline under the subline, and links to the previous and next chapters after the last part. */
  .byline { font: 500 0.9rem/1.4 var(--sans); color: var(--muted); margin: -0.6rem 0 1.8rem; }
  .chapnav { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 5rem; padding-top: 2rem; border-top: 1.5px solid var(--line); font-family: var(--sans); }
  .company-note { margin-top: 2.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--sans); font-size: 0.82rem; font-style: italic; line-height: 1.55; }
  .chapnav-link { display: block; padding: 1rem 1.1rem; border-radius: 14px; background: var(--paper); color: var(--ink); text-decoration: none; transition: box-shadow 200ms cubic-bezier(0.32, 0.72, 0, 1); }
  .chapnav-link:hover { box-shadow: 0 0 0 4px rgb(154 68 40 / 0.22); }
  .chapnav-next { grid-column: 2; text-align: right; }
  .chapnav-k { display: block; font-size: 0.85rem; font-weight: 600; color: var(--clay-ink); }
  .chapnav-t { display: block; margin-top: 0.2rem; font-size: 1.05rem; font-weight: 700; }
  .chapnav-all { grid-column: 1 / -1; justify-self: center; margin-top: 0.6rem; padding: 0.4rem 0.6rem; color: var(--ink); font-size: 0.95rem; font-weight: 600; text-decoration: underline; text-underline-offset: 0.2em; }

  /* Narrow screens get the chapter text at full width and no scroll scenes; one line at the top says where the scenes show. */
  .phone-note { display: none; }
  @media (max-width: 860px) {
    html { font-size: 16px; }
    .phone-note { display: block; max-width: var(--text); margin: 0 auto 1.6rem; font: 500 0.95rem/1.5 var(--sans); color: var(--muted); }
    .page { padding: 5rem 16px 3rem; }
    .chapbar .here, .readbar { display: none; }
    /* Scenes keep their layout, because scene code measures SVG text while it builds them, but take no height and are not shown. */
    .scrolly { height: 0; margin: 0; overflow: hidden; visibility: hidden; }
    .page table { display: block; max-width: 100%; overflow-x: auto; }
    body.in-scene .chapbar { transform: none; }
    .chapbar { gap: 0.6rem; padding: 0 16px; height: 3.2rem; font-size: 0.88rem; }
    .chapbar .course { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .chapbar .btn { padding: 0.4rem 0.8rem; font-size: 0.88rem; flex: 0 0 auto; }
    .chapmenu { left: 16px; right: 16px; width: auto; top: 3.1rem; max-height: calc(100vh - 4rem); }
    .terms { width: 100%; padding: 1.1rem 16px 2rem; }
    .pop { width: auto; max-width: calc(100vw - 32px); left: 16px !important; right: 16px; }
    h1 { font-size: clamp(2.2rem, 10vw, 3.4rem); overflow-wrap: anywhere; }
    .subline, .part-h { margin-right: 0; }
    .subline { font-size: 1.4rem; }
    .part-h { font-size: 2rem; }
    h3 { font-size: 1.4rem; margin-top: 3rem; }
    .lede { margin-bottom: 2.5rem; }
    p, li, td, th { overflow-wrap: anywhere; }
    code { overflow-wrap: anywhere; }
    .cr, .task .cr { grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
    .task { padding: 1.3rem 1rem 1.2rem; }
    .pause { padding: 1.2rem 1rem 1.1rem; }
    .wall-card { padding: 1.4rem 1rem 1.3rem; }
    .chapnav { grid-template-columns: minmax(0, 1fr); margin-top: 3rem; }
    .chapnav-next { grid-column: 1; }
  }
  /* Disclaimer: the last thing on every page, below the chapter. */
  .disclaim { max-width: var(--wide); margin: 0 auto; padding: 2.5rem 16px 3rem; }
  .disclaim p { font-family: var(--sans); font-size: 0.78rem; line-height: 1.55; color: var(--muted); margin: 0; }
