/* Shared reading and interaction styles: desktop and tablet layouts. */
:root {
  color-scheme: light;
  --page: #f1f4f8;
  --paper: #fff;
  --ink: #263140;
  --muted: #5f6f81;
  --line: #d5dfea;
  --accent: #2c5f99;
  --accent-dark: #1e426d;
  --accent-light: #edf3fa;
  --focus: #1e70b7;
  --code-paper: #fffbf2;
  --code-edge: #e7ddc8;
  --demo-paper: #fdfcff;
  --demo-heading: #f1edf8;
  --demo-edge: #d4cbe4;
  --demo-ink: #594572;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --reading: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body { min-width: 720px; margin: 0; background: var(--page); color: var(--ink); font-family: var(--ui); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-dark); }
button, select, input { font: inherit; }
button, select, input[type="checkbox"], input[type="range"], summary { cursor: pointer; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, .demo-explanation:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; top: -90px; left: 20px; padding: 9px 15px; z-index: 99; background: var(--accent); color: white; }
.skip-link:focus { top: 8px; }
/* A running head, like the identification line of printed lecture notes. */
.running-head { max-width: 1120px; min-height: 38px; margin: 0 auto; display: flex; align-items: center; gap: 20px; border-bottom: 1px solid #9ea3aa; font-size: 13px; }
.course-signature { color: var(--ink); font-family: var(--reading); font-size: 15px; text-decoration: none; letter-spacing: .005em; }
.course-signature span { font-family: Consolas, "Liberation Mono", monospace; font-size: 14px; color: var(--accent); }
.running-reference { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.running-reference > span { padding: 0 8px; color: #9aa0a7; }
.header-source { color: var(--muted); text-decoration: none; font-size: 12px; }
.page-layout { max-width: 1120px; margin: 0 auto; }
main { min-width: 0; background: var(--paper); padding: 24px 36px 0; }
.last-modified { flex-basis: 100%; margin: 0; text-align: right; color: var(--muted); font: 12px/1.5 var(--ui); }
.chapter-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 17px; }
.chapter-heading { display: flex; align-items: center; gap: 16px; }
.chapter-number { font-family: var(--reading); color: #7c828a; font-size: 42px; line-height: 1; letter-spacing: -.06em; padding-right: 18px; border-right: 1px solid #b4bac2; }
.eyebrow { color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .12em; font-weight: 600; margin: 0 0 4px; }
h1 { font: 400 31px/1.2 var(--reading); letter-spacing: -.025em; margin: 0; }
.source-links { display: flex; flex-wrap: wrap; gap: 5px 10px; align-items: baseline; justify-content: flex-end; font-size: 12px; max-width: 250px; }
.source-links > span { color: var(--muted); }
.source-links a { text-decoration-color: #b6bcc5; }
.chapter-contents { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 0 20px; }
.chapter-contents h2 { padding: 8px 0; margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.chapter-nav { display: flex; flex-wrap: wrap; gap: 7px 25px; margin: 0; padding: 2px 0 11px 18px; font-size: 13px; line-height: 1.5; }
.chapter-nav a { text-decoration-color: #b9c0c9; }
.when-open { display: none; }
details[open] > summary .when-open { display: inline; }
details[open] > summary .when-closed { display: none; }
/* Lecture prose and reusable semantic treatments. No inline export colors. */
.prose { font-family: var(--reading); font-size: 17px; line-height: 1.63; }
.prose h2, .prose h3 { font-family: var(--ui); font-weight: 600; letter-spacing: -.02em; line-height: 1.35; }
.prose h2 { font-size: 24px; margin: 0 0 12px; }
.prose h3 { font-size: 20px; margin: 0 0 12px; }
.reading-section { scroll-margin-top: 22px; margin: 0 0 25px; }
.prose :is(h2, h3)[id] { scroll-margin-top: 22px; }
#wstep { margin-bottom: 16px; }
.prose p { margin: 0 0 11px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 13px; }
.prose li { padding-left: 3px; margin-bottom: 9px; }
.prose strong { font-weight: 700; }
.prose ins { text-decoration-color: #a0a8b3; text-underline-offset: 3px; }
.prose code { font: .81em/1.5 Consolas, "Liberation Mono", monospace; padding: 1px 3px; background: #edeff2; color: #353b44; overflow-wrap: anywhere; }
.prose sup { font-size: .65em; color: var(--accent); }
.formula-line { display: block; white-space: nowrap; overflow-x: auto; padding: 6px 0 3px; overscroll-behavior-x: contain; }
.math-punctuation { display: inline-block; white-space: nowrap; max-width: 100%; }
.katex { font-size: 1.04em; }
.footnotes { font: 14px/1.55 var(--ui); color: var(--muted); background: #f0f2f5; border-top: 1px solid var(--line); padding: 10px 13px; margin-top: 17px; }
.footnotes p { margin: 0; }
.prose .figure-credit { display: block; color: var(--muted); font: 12px/1.6 var(--ui); text-align: center; margin: 6px 0 0; }
.criteria-list { list-style: none; padding-left: 0 !important; }
.criteria-list li { margin-bottom: 9px; }
.callout { --callout-bg: var(--accent-light); --callout-edge: var(--accent); background: var(--callout-bg); border-left: 3px solid var(--callout-edge); padding: 12px 16px 2px; margin: 16px 0; }
.callout blockquote { margin: 0; }
.callout p > strong:first-child, .callout b:first-child { color: var(--accent-dark); font-family: var(--ui); font-size: .83em; }
.callout--definition { --callout-bg: #edf0f3; }
.callout--consequence { --callout-bg: #f4f6f8; --callout-edge: #9ba5b3; }
.callout--note { --callout-bg: #ecf1f7; --callout-edge: #8c9eb5; font-size: 15px; padding-bottom: 12px; }
.example-table { margin: 16px 0 19px; }
.table-scroll { overflow-x: auto; }
.example-table table { border-collapse: collapse; width: 100%; min-width: 500px; font: 14px/1.45 var(--ui); text-align: left; }
.example-table th { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #eef1f4; font-weight: 600; color: #4e5661; padding: 8px 11px; }
.example-table td { padding: 4px 11px; border-bottom: 1px solid #e4e8ed; white-space: nowrap; }
.example-table th + th, .example-table td + td { border-left: 1px solid #e0e4ea; }
/* Disclosure and controls: controls precede every changing piece of content. */
.demonstration { border: 1px solid var(--demo-edge); margin: 25px 0 23px; scroll-margin-top: 22px; }
.demonstration > summary { display: flex; align-items: center; gap: 12px; padding: 11px 16px; background: var(--demo-heading); list-style: none; user-select: none; }
.demonstration > summary::-webkit-details-marker { display: none; }
.demonstration > summary:hover { background: #e9e2f3; }
.demo-symbol { width: 25px; flex: 0 0 auto; color: var(--demo-ink); font-size: 24px; }
.disclosure-title { flex: 1; }
.disclosure-eyebrow { display: block; color: #5f6a78; font-size: 12px; margin-bottom: 2px; }
.disclosure-title strong { font-size: 14px; color: var(--demo-ink); font-weight: 600; }
.disclosure-action { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--demo-ink); }
.disclosure-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.demonstration[open] > summary { border-bottom: 1px solid var(--demo-edge); }
.demonstration[open] .disclosure-action svg { transform: rotate(180deg); }
.demo-body { padding: 12px 16px 10px; background: var(--demo-paper); font-size: 14px; }
select { color: var(--ink); background: white; border: 1px solid #c0c6cf; border-radius: 2px; padding: 6px 24px 6px 8px; font-size: 13px; }
[hidden] { display: none !important; }
.demo-controls { display: flex; gap: 12px; align-items: center; min-height: 46px; border-bottom: 1px solid var(--line); padding: 5px 0 9px; white-space: nowrap; }
.step-buttons { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.demo-controls button { border: 1px solid #bec5ce; border-radius: 2px; color: #384352; background: white; padding: 6px 11px; font-size: 13px; min-height: 31px; }
.demo-controls button:hover:not(:disabled) { background: #ebeff4; }
.demo-controls .primary-button { background: var(--accent); border-color: var(--accent); color: white; }
.demo-controls .primary-button:hover:not(:disabled) { background: var(--accent-dark); }
.demo-controls button:disabled { opacity: .4; cursor: default; }
.playback-controls { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; font: 13px/1.5 var(--ui); }
.playback-controls button { width: 76px; min-width: 76px; padding: 6px 7px; border: 1px solid var(--demo-edge); border-radius: 2px; background: #fff; color: var(--demo-ink); }
.playback-controls button:hover { background: var(--demo-heading); }
.playback-controls button[aria-pressed="true"] { background: var(--demo-heading); border-color: #9a85b5; }
.playback-controls select { appearance: none; width: 44px; min-width: 44px; height: 31px; padding: 4px 12px 4px 4px; font-size: 13px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='4'%3E%3Cpath d='m1 1 2 2 2-2' fill='none' stroke='%235f6f81'/%3E%3C/svg%3E") right 4px center / 6px 4px no-repeat; }
.timeline { display: flex; flex: 1 1 0; min-width: 0; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.timeline input { flex: 1; width: 0; min-width: 30px; accent-color: var(--accent); }
.timeline output { flex: 0 0 60px; font-variant-numeric: tabular-nums; text-align: right; }
.demo-stage-heading { display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 15px; block-size: 72px; margin: 8px 0 0; }
.small-label { color: var(--muted); font-size: 12px; margin: 0 0 4px; }
.demo-stage-heading h3 { font-size: 17px; line-height: 1.3; font-weight: 600; margin: 0; }
.status-pill { display: block; border-left: 2px solid #99a6b7; color: var(--accent); font-size: 13px; line-height: 1.5; padding: 4px 8px; background: #ecf0f5; }
.status-pill[data-kind="warning"] { color: #81521e; border-color: #c4a67e; background: #faf5e9; }
.status-pill[data-kind="neutral"] { color: var(--muted); border-color: var(--line); background: #f0f2f5; }
.key-caption { color: var(--muted); font-size: 13px; margin: 0; height: 26px; line-height: 1.6; }
.demo-table-wrap { margin-bottom: 13px; }
.people-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; line-height: 1.45; text-align: left; }
.people-table .col-position { width: 10%; }
.people-table .col-first { width: 20%; }
.people-table .col-last { width: 22%; }
.people-table .col-origin { width: 17%; }
.people-table .col-key { width: 31%; }
.people-table thead th { background: #e5e9ef; color: #4e5968; font-size: 12px; font-weight: 600; padding: 7px 10px; border-top: 1px solid #c0c8d2; border-bottom: 1px solid #c0c8d2; }
.people-table tbody th, .people-table tbody td { height: 29px; padding: 5px 10px; white-space: nowrap; border-bottom: 1px solid #dce1e8; }
.people-table tbody th { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.people-table tbody tr:nth-child(even) { background: #f0f3f7; }
.people-table .person-origin { font-family: Consolas, "Liberation Mono", monospace; color: #5b6878; }
.people-table .compared-value { font-weight: 650; }
.people-table .person-key { font: 13px Consolas, "Liberation Mono", monospace; color: #47576d; }
.demo-explanation { box-sizing: border-box; block-size: 160px; overflow-y: auto; padding: 10px 12px; border-left: 2px solid #9aa7b8; background: #edf0f5; }
.demo-explanation p { margin: 0; font-size: 14px; line-height: 1.6; }
.demo-explanation p + p { color: #555f6c; font-size: 13px; margin-top: 5px; }
.demonstration .demo-inline-code { font-family: Consolas, "Liberation Mono", monospace; font-size: max(12px, .95em); line-height: inherit; padding: 0 2px; background: #edf0f4; color: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.identity-note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 9px 0 0; }
.chapter-footer { border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; padding: 14px 0 19px; }
.chapter-footer a { text-decoration: none; }
.callout--invariant { --callout-bg: #f3f6fa; --callout-edge: #8ca7c6; }
.callout--algorithm { --callout-bg: #f7f9fc; --callout-edge: #a9bbd0; }
.callout--invariant ul, .callout--algorithm ol { margin-bottom: 10px; }
.highlight pre, .trace-code, .example-code { margin: 12px 0 17px; border: 1px solid var(--code-edge); background: var(--code-paper); padding: 12px 15px; overflow-x: auto; white-space: pre; overflow-wrap: normal; font: 14px/1.55 Consolas, "Liberation Mono", monospace; tab-size: 4; }
.prose pre > code { display: block; padding: 0; background: none; color: inherit; font: inherit; white-space: inherit; overflow-wrap: normal; }
.example-code { line-height: 1.6; }
/* Shared Python token palette, also used inside the step-by-step traces. */
.python-code { color: #263649; }
.python-code :is(.k, .kc, .kd, .kn, .kp, .kr, .kt, .ow) { color: #7937a5; font-weight: 650; }
.python-code :is(.nf, .fm) { color: #165ba8; }
.python-code :is(.nb, .bp) { color: #087775; }
.python-code :is(.nc, .ne, .nn, .nd) { color: #875518; }
.python-code :is(.m, .mi, .mf, .mh, .mo, .mb, .il) { color: #a64b14; }
.python-code :is(.s, .sa, .sb, .sc, .dl, .sd, .s1, .s2, .se, .sh, .si, .sr, .ss, .sx) { color: #337339; }
.python-code :is(.c, .ch, .cm, .cp, .cpf, .c1, .cs) { color: #647182; font-style: italic; }
.python-code .o { color: #a12e50; }
.python-code .p { color: #58677a; }
.code-block { margin: 12px 0 17px; border: 1px solid var(--code-edge); background: var(--code-paper); }
.code-toolbar { display: flex; align-items: center; gap: 12px; padding: 4px 8px 4px 14px; border-bottom: 1px solid var(--code-edge); background: #faf4e7; font: 12px/1.5 var(--ui); }
.code-language { color: var(--muted); }
.copy-status { margin-left: auto; color: var(--muted); }
.copy-code { flex: 0 0 auto; padding: 3px 8px; border: 1px solid #bdcadd; border-radius: 2px; background: #fff; color: var(--accent-dark); font: 13px/1.5 var(--ui); }
.copy-code:hover:not(:disabled) { background: var(--accent-light); }
.copy-code:disabled { opacity: .6; cursor: default; }
.code-block pre { border: 0; margin: 0; background: none; }
.clipboard-buffer { position: fixed; left: -10000px; top: 0; width: 1px; height: 1px; opacity: 0; }
.trace-code-wrap .code-block { margin: 0; }
.prose .partition-guide { padding-left: 23px; margin: 8px 0; font: 13px/1.6 var(--ui); }
.partition-guide li { padding: 4px 6px; margin-bottom: 4px; }
.partition-guide .is-active-step { background: #dbe9fb; box-shadow: -3px 0 0 #457bb8; }
.code-block + .trace-code-label { margin-top: 14px; }
.demonstration { font-family: var(--ui); line-height: 1.5; }
.demonstration p { margin-bottom: 0; }
.demo-input { display: flex; align-items: center; gap: 9px; min-height: 34px; margin: 0; }
.demo-input label { color: var(--muted); font-size: 14px; }
.demo-input input { border: 1px solid #b4c6dc; background: white; color: var(--ink); padding: 6px 9px; font: 14px Consolas, monospace; width: 235px; }
.demo-input input[type="number"] { width: 74px; }
.demo-input input[aria-invalid="true"] { border-color: #a83939; }
.demo-input button { border: 1px solid #b4c6dc; background: #f1f5fb; color: var(--accent-dark); padding: 6px 10px; font-size: 13px; border-radius: 2px; }
.input-hint { color: var(--muted); font-size: 12px; }
.prose .input-error { min-height: 21px; color: #963333; font-size: 12px; line-height: 1.5; margin: 0; }
.trace-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; margin-bottom: 12px; }
.trace-layout > div { min-width: 0; }
.trace-layout .demo-explanation { block-size: 112px; margin-top: 10px; }
.trace-board .demo-explanation { block-size: 96px; margin-top: 10px; }
.trace-code-wrap { border-left: 1px solid var(--line); padding-left: 14px; }
.prose .trace-code-label { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0 0 4px; }
.trace-code { border: 0; margin: 0; padding: 6px 8px; font-size: 13px; }
.prose .trace-code code { padding: 0; background: none; color: inherit; font: inherit; overflow-wrap: normal; }
.code-line.is-active { color: #123f73; background: #dbe9fb; box-shadow: -3px 0 0 #457bb8; }
.prose .trace-metrics { display: flex; gap: 25px; border-bottom: 1px solid var(--line); margin: 0 0 10px; padding: 0 0 9px; font-size: 13px; }
.trace-metrics > div { display: flex; gap: 7px; align-items: baseline; }
.trace-metrics dt { color: var(--muted); }
.trace-metrics dd { margin: 0; color: #1b4e85; font: 14px Consolas, monospace; min-width: 20px; }
.sort-chart { display: block; width: 100%; height: auto; }
.chart-axis { stroke: #afbed0; stroke-width: 1; }
.sort-bar { fill: #fff; stroke: #879fbf; stroke-width: 1; }
.sort-bar.is-sorted { fill: #a8c4e5; stroke: #4a77ae; }
.sort-bar.is-focus { stroke: #ad5815; stroke-width: 3; }
.sort-bar.is-pivot { stroke: #95324f; stroke-width: 3; stroke-dasharray: 5 3; }
.active-segment { fill: #e4e7eb; }
.sort-chart text { text-anchor: middle; font-family: Consolas, monospace; fill: #3c5470; }
.bar-value { font-size: 20px; }
.bar-origin, .bar-index { font-size: 18px; }
.bar-pointer { font-size: 17px; font-weight: 700; fill: #174c88 !important; }
.prose .chart-legend { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 4px 0 10px; }
.prose .invariant-state { border-left: 2px solid #9bb8d8; background: #edf3fb; padding: 9px 10px; min-height: 57px; margin: 12px 0 0; font-size: 14px; line-height: 1.6; }
.invariant-state:empty { display: none; }
.state-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
.state-table caption { text-align: left; color: var(--muted); font-size: 13px; padding: 0 0 9px; }
.state-table th { font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); padding: 8px; }
.state-table td { background: #edf3fa; padding: 12px 8px; font: 17px Consolas, monospace; border-bottom: 1px solid var(--line); }
/* Later lecture sections and recursive algorithms share the original controls. */
.source-illustration { display: block; max-width: 100%; height: auto; margin: 12px auto; }
.comparison-table { border-collapse: collapse; width: 100%; min-width: 620px; font: 14px/1.5 var(--ui); margin: 14px 0; }
.comparison-table th { background: #e9f0f8; text-align: center; }
.comparison-table th, .comparison-table td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: center; }
.comparison-table th:first-child, .comparison-table td:first-child { text-align: left; }
.comparison-table tr:nth-child(2n+1) td { background: #f6f8fb; }
.advanced-input { flex-wrap: wrap; }
.advanced-input input { width: 205px; }
.advanced-metrics { flex-wrap: wrap; gap: 7px 16px !important; }
.list-board { margin: 6px 0 12px; }
.list-board:empty { display: none; }
.list-row { display: flex; gap: 9px; align-items: center; margin-bottom: 8px; min-height: 57px; }
.list-label { flex: 0 0 90px; font: 13px/1.4 Consolas, monospace; color: #365374; }
.list-strip { display: flex; gap: 4px; overflow-x: auto; padding: 3px 2px 5px; min-width: 0; flex: 1; position: relative; }
.list-item { display: flex; flex-direction: column; align-items: center; flex: 0 0 40px; padding: 4px; background: white; border: 1px solid #9aafc9; font: 15px/1.3 Consolas, monospace; }
.list-item small { font-size: 12px; color: #586b80; }
.list-item.is-used { background: #edf0f3; border-style: dashed; color: #68717e; }
.list-item.is-current { outline: 2px solid #ad5815; outline-offset: -1px; }
.empty-list, .list-end { font: 13px/1.5 Consolas, monospace; color: var(--muted); align-self: center; padding: 5px; }
.recursion-view { margin: 13px 0; border-top: 1px solid var(--line); padding-top: 8px; }
.prose .stack-line { min-height: 27px; font: 13px/1.6 var(--ui); color: var(--muted); }
.stack-line span { font-family: Consolas, monospace; color: var(--accent-dark); }
.prose .tree-caption { font: 12px/1.5 var(--ui); color: var(--muted); margin-bottom: 6px; }
.tree-scroll { max-height: 280px; min-height: 70px; overflow: auto; border: 1px solid var(--line); position: relative; }
.tree-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.call-tree { border-collapse: separate; border-spacing: 0; min-width: 100%; font: 12px/1.5 Consolas, monospace; white-space: nowrap; }
.call-tree td, .call-tree th { padding: 5px 9px; border-bottom: 1px solid #dfe6ef; text-align: left; }
.call-tree thead th { background: #e8eef6; position: sticky; top: 0; z-index: 1; font: 12px/1.5 var(--ui); }
.call-tree .call-name { color: #4a6380; font-weight: 500; }
.call-tree .is-active-call > * { background: #dce9f8; box-shadow: inset 0 1px #94b1d4, inset 0 -1px #94b1d4; }
.call-name[data-depth]:not([data-depth="0"])::before { content: "└ "; color: #9aacc1; }
.call-name[data-depth="1"] { padding-left: 19px; }
.call-name[data-depth="2"] { padding-left: 29px; }
.call-name[data-depth="3"] { padding-left: 39px; }
.call-name[data-depth="4"] { padding-left: 49px; }
.call-name[data-depth="5"] { padding-left: 59px; }
.call-name[data-depth="6"] { padding-left: 69px; }
.call-name[data-depth="7"] { padding-left: 79px; }
.call-name[data-depth="8"] { padding-left: 89px; }
.call-name[data-depth="9"] { padding-left: 99px; }
.call-name[data-depth="10"] { padding-left: 109px; }
.call-name[data-depth="11"] { padding-left: 119px; }
.call-name[data-depth="12"] { padding-left: 129px; }
@media (max-width: 1180px) {
  .running-head, .page-layout { margin-left: 24px; margin-right: 24px; }
}
@media (max-width: 900px) {
  .running-head, .page-layout { margin-left: 16px; margin-right: 16px; }
  main { padding: 20px 24px 0; }
  .chapter-header { gap: 15px; }
  h1 { font-size: 28px; }
  .source-links { max-width: 170px; gap: 4px 8px; }
  .source-links > span { flex-basis: 100%; text-align: right; }
  .demo-body { padding-left: 12px; padding-right: 12px; }
  .demo-controls { gap: 8px; }
  .step-buttons { gap: 5px; }
  .demo-controls button { padding-left: 6px; padding-right: 6px; }
  .demo-controls:has(.playback-controls:not([hidden])) .timeline label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .trace-layout { grid-template-columns: 1fr; }
  .trace-code-wrap { border-left: 0; padding-left: 0; }
  .demo-input .input-hint { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  body { min-width: 0; background: white; }
  .running-head, .chapter-contents, .skip-link, .chapter-footer { display: none; }
  .page-layout { max-width: none; margin: 0; }
  main { padding: 0; }
  .prose { font-size: 11pt; }
  .demonstration { break-inside: avoid; }
  .code-toolbar { display: none; }
}
