/*
 * mathuser.com: a shelf of course books.
 * One ink, one paper, one colour per course. Hierarchy comes from type, rules and space:
 * no gradients, shadows, pills or striped boxes.
 */
:root {
    --serif: "STIX Two Text", "STIXGeneral", Georgia, serif;
    --sans: Archivo, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", Consolas, monospace;
    --ink: #17171a;
    --ink-2: #53535c;
    --rule: #dcdce0;
    --wash: #f3f3f1;
    --paper: #fff;
    --course: #17171a;
    --gutter: 28px;
}
.course-discrete { --course: #2a3a9e; }
.course-linear { --course: #0b6149; }
.course-calculus { --course: #a62b1f; }
.course-numerical { --course: #7d4700; }

/* ---------- Frame ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 20px; }
html body { margin: 0; padding: 0; max-width: none; overflow-x: clip; background: var(--paper); color: var(--ink); font-family: var(--serif); font-size: 18px; line-height: 1.65; }
body #content { display: block; margin: 0; padding: 0; max-width: none; }
html body { display: flex; flex-direction: column; min-height: 100vh; }
body > * { flex-shrink: 0; }
body #content { flex-grow: 1; }
.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 20; background: var(--paper); color: var(--ink); padding: 8px 14px; font-family: var(--sans); }
.skip-link:focus { left: 8px; }
:where(a) { color: var(--course); text-decoration-thickness: 1px; text-underline-offset: .18em; }
:where(img, svg, canvas, iframe, video) { max-width: 100%; }
:focus-visible { outline: 3px solid var(--course); outline-offset: 2px; }
.site-header :focus-visible, .opener :focus-visible { outline-color: #fff; }

.button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border: 0; border-radius: 2px; background: var(--ink); color: #fff; font: 650 16px/1 var(--sans); text-decoration: none; cursor: pointer; }
.button:hover { background: #000; text-decoration: underline; }

/* ---------- Header ---------- */
.site-header { background: var(--ink); color: #fff; font-family: var(--sans); font-size: 15px; line-height: 1.4; }
.site-header__inner { display: flex; align-items: stretch; gap: 28px; min-height: 60px; }
.site-header__logo, .site-footer__logo { align-self: center; color: inherit; font: 800 23px/1 var(--sans); font-stretch: 118%; letter-spacing: -.02em; text-decoration: none; }
.site-header__logo b, .site-footer__logo b { font-weight: 400; }
.site-header__menu-button { display: none; }
.site-nav { display: flex; flex: 1; align-items: stretch; justify-content: space-between; gap: 20px; }
.site-nav__list { display: flex; margin: 0; padding: 0; list-style: none; }
.site-nav__list li { display: flex; }
.site-nav__list a { display: flex; align-items: center; padding: 0 14px; color: #d9d9de; font-weight: 550; text-decoration: none; }
.site-nav__list a:hover { color: #fff; text-decoration: underline; }
.site-nav__list li:where([class^="course-"]) a { box-shadow: inset 0 -4px 0 var(--course); }
.site-nav__list a[aria-current="page"] { background: #fff; color: var(--ink); }
.site-nav__list li:where([class^="course-"]) a[aria-current="page"] { background: var(--course); color: #fff; box-shadow: none; }
.site-search { display: flex; align-items: center; }
.site-search input { width: 210px; min-height: 36px; padding: 0 2px; border: 0; border-bottom: 1px solid #77777f; border-radius: 0; background: transparent; color: #fff; font: 400 16px var(--sans); }
.site-search input::placeholder { color: #b4b4bb; }

/* ---------- Chapter and course openers: a solid block in the course colour ---------- */
.opener { background: var(--course); color: #fff; padding: 40px 0 38px; }
.opener a:not(.button) { color: #fff; }
.opener__row { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 52px; align-items: start; }
#content .opener__number { margin: 0; font: 800 150px/.86 var(--sans); font-stretch: 64%; text-align: right; font-variant-numeric: lining-nums; }
#content .opener p { color: #fff; }
#content .opener__course { margin: 0 0 8px; font: 550 15px/1.5 var(--sans); }
#content .opener__course a { font-weight: 750; }
#content .opener__course span { margin-left: 10px; opacity: .82; }
#content .opener h1 { max-width: 21ch; margin: 0; color: #fff; font: 750 clamp(34px, 4.6vw, 54px)/1.06 var(--sans); font-stretch: 92%; letter-spacing: -.015em; text-wrap: balance; }
#content .opener h1 em { color: inherit; font-style: normal; }
#content .opener__summary { max-width: 68ch; margin: 14px 0 0; font: 400 19px/1.55 var(--serif); }
#content .opener__source { margin: 14px 0 0; font: 500 14px/1.5 var(--sans); opacity: .82; }
#content .opener--course h1 { font-size: clamp(44px, 7vw, 88px); font-stretch: 80%; }
#content .opener--course .button { margin-top: 22px; background: #fff; color: var(--ink); }
#content .opener--course p:last-child { margin: 0; }

/* ---------- The reader: chapters, page, contents ---------- */
.book { display: grid; grid-template-columns: 230px minmax(0, 1fr) 210px; grid-template-areas: "chapters page toc"; gap: 52px; align-items: start; padding-top: 40px; }
.book__chapters { grid-area: chapters; }
.book__page { grid-area: page; min-width: 0; }
.book__toc { grid-area: toc; }
.book > details { position: sticky; top: 20px; min-width: 0; font: 400 14.5px/1.4 var(--sans); }
.book > details > summary { display: none; }
.book > details > nav { max-height: calc(100vh - 40px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
#content .book__side-title { margin: 0 0 10px; padding-bottom: 9px; border-bottom: 2px solid var(--ink); font: 750 14.5px/1.3 var(--sans); }
#content .book > details .book__side-title a { padding: 0; color: var(--ink); font-weight: 750; }
#content .book > details :is(ol, ul) { margin: 0; padding: 0; list-style: none; }
#content .book > details li { margin: 0; padding: 0; }
#content .book > details a { display: block; padding: 6px 8px; color: var(--ink-2); font-weight: 450; text-decoration: none; }
#content .book > details a:hover { color: var(--ink); text-decoration: underline; }
#content .book > .book__chapters ol a { display: flex; gap: 9px; }
#content .book__chapters a span { flex: none; width: 18px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
#content .book__chapters a[aria-current="page"] { background: var(--course); color: #fff; font-weight: 650; }
#content .book__chapters a[aria-current="page"] span { color: #fff; }
#content .book__toc ul ul { padding-left: 14px; }
#content .book__toc ul ul a { font-size: 13.5px; }
#content .book__toc a[aria-current="location"] { color: var(--course); font-weight: 700; }

/* ---------- Running text (chapters and articles) ---------- */
#content :is(.book__page, .prose) { font: 400 19px/1.66 var(--serif); color: var(--ink); overflow-wrap: break-word; }
/* The widgets' own colour names, pointed at this design. */
#content .book__page, #content .book__page > * { --txt: var(--ink); --muted: var(--ink-2); --text-muted: var(--ink-2); --text-dim: var(--ink-2); --border: var(--rule); --bg: #fff; --bg2: var(--wash); --r: 2px; }
#content .book__page [class$="-content"], #content .book__page .mu-calc, #content .book__page .page-wrap, #content .book__page .page-wrap > main { display: block; margin: 0; padding: 0; max-width: none; background: none; font: inherit; color: inherit; }
#content :is(.book__page, .prose) p { margin: 0 0 1.05em; padding: 0; color: inherit; font-size: inherit; line-height: inherit; }
#content :is(.book__page, .prose) :is(ul, ol):not([class*="steps"]) { margin: 0 0 1.05em; padding-left: 1.35em; }
#content :is(.book__page, .prose) :is(ul):not([class*="steps"]) { list-style: disc; }
#content :is(.book__page, .prose) ol:not([class*="steps"]) { list-style: decimal; }
#content :is(.book__page, .prose) li { margin: 0 0 .35em; }
#content :is(.book__page, .prose) li::marker { color: var(--course); }
#content :is(.book__page, .prose) :is(strong, b) { color: inherit; font-weight: 700; }
#content :is(.book__page, .prose) em { color: inherit; }
#content :is(.book__page, .prose) :is(h2, h3, h4) { color: var(--ink); font-family: var(--sans); letter-spacing: -.005em; text-transform: none; text-wrap: balance; }
#content :is(.book__page, .prose) h2 { margin: 2.4em 0 .7em; padding: 18px 0 0; border: 0; border-top: 2px solid var(--ink); font-size: 29px; font-weight: 750; line-height: 1.18; }
#content :is(.book__page, .prose) h3 { margin: 1.9em 0 .55em; font-size: 21px; font-weight: 700; line-height: 1.28; }
#content :is(.book__page, .prose) h4 { margin: 1.5em 0 .4em; font-size: 17px; font-weight: 700; line-height: 1.35; }
#content .book__page .sh { margin: 62px 0 20px; padding: 18px 0 0; border: 0; border-top: 2px solid var(--ink); }
#content .book__page .sh h2 { margin: 0; padding: 0; border: 0; }
#content .book__page .sn { display: block; margin-bottom: 2px; color: var(--course); font: 650 15px/1.5 var(--sans); }
#content .book__page .section { margin: 0; padding: 0; }
#content .book__page > :first-child, #content .book__page .section:first-of-type > h2:first-child { margin-top: 0; }
#content :is(.book__page, .prose) code { padding: .08em .3em; border: 0; border-radius: 2px; background: var(--wash); color: var(--ink); font: 400 .82em var(--mono); }
#content :is(.book__page, .prose) pre { overflow-x: auto; padding: 18px 20px; background: var(--wash); font: 400 14.5px/1.6 var(--mono); }
#content .katex { font-size: 1.08em; }
/* KaTeX has a "vbox" of its own; the figure styles below must not reach it. */
#content .book__page .katex .vbox, #content .katex .vbox { margin: 0; padding: 0; overflow: visible; border: 0; background: none; text-align: left; font: inherit; }
#content .katex-display { max-width: 100%; margin: 1.1em 0; padding: 2px 0; overflow-x: auto; overflow-y: hidden; }

/* ---------- Definitions, theorems, notes: set as in a printed textbook ---------- */
#content .book__page .box { position: static; margin: 30px 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; font-size: 18.5px; }
#content .book__page .box > :last-child { margin-bottom: 0; }
#content .book__page :is(.lbl, .box-label) { position: static; display: block; margin: 0 0 8px; padding: 0; background: none; color: var(--ink); font: 750 15.5px/1.4 var(--sans); letter-spacing: 0; text-transform: none; }
/* Definition: ruled above and below, label in the course colour. */
#content .book__page .box:is(.def, .definition) { padding: 14px 0 16px; border-top: 3px solid var(--course); border-bottom: 1px solid var(--rule); }
#content .book__page .box:is(.def, .definition) :is(.lbl, .box-label) { color: var(--course); }
/* Theorem: a flat tint of the course colour. */
#content .book__page .box:is(.thm, .theorem), #content .book__page .callout { padding: 20px 24px; background: color-mix(in srgb, var(--course) 8%, #fff); }
/* Key idea: a thin ink frame. */
#content .book__page .box:is(.key, .note) { padding: 20px 24px; border: 1px solid var(--ink); }
#content .book__page .box:is(.warn, .warning) { padding: 20px 24px; background: #fbf0d6; }
#content .book__page .box:is(.warn, .warning) :is(.lbl, .box-label) { color: #6d4300; }
#content .book__page .box.proof { padding: 0 0 14px; border-bottom: 1px solid var(--rule); }
#content .book__page .box.example { padding: 20px 24px; background: var(--wash); }
#content .book__page .callout { margin: 30px 0; border: 0; border-radius: 0; color: var(--ink); font-size: 18.5px; }
#content .book__page .math-block { margin: 24px 0; padding: 16px 20px; overflow-x: auto; border: 0; border-radius: 0; background: var(--wash); color: var(--ink); font: 400 18px/1.7 var(--serif); letter-spacing: 0; text-align: center; }

/* Worked examples open in place. */
#content .book__page details.eg { margin: 22px 0; overflow: visible; border: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); border-radius: 0; }
#content .book__page details.eg + details.eg { margin-top: -23px; }
#content .book__page details.eg summary { position: relative; display: block; min-height: 52px; padding: 13px 130px 13px 0; border: 0; background: none; color: var(--ink); font: 650 17px/1.45 var(--sans); list-style: none; cursor: pointer; }
#content .book__page details.eg summary::-webkit-details-marker { display: none; }
#content .book__page details.eg summary::before { content: none; }
#content .book__page details.eg summary::after { content: "Show solution"; position: absolute; top: 14px; right: 0; color: var(--course); font-size: 14px; font-weight: 650; }
#content .book__page details.eg[open] summary::after { content: "Hide"; }
#content .book__page details.eg summary:hover::after { text-decoration: underline; }
#content .book__page .eb { padding: 4px 0 20px; font-size: 18.5px; line-height: 1.66; }
#content .book__page .eb > :last-child { margin-bottom: 0; }
#content .book__page .sl { display: block; margin: 16px 0 4px; color: var(--course); font: 750 14.5px/1.5 var(--sans); letter-spacing: 0; text-transform: none; }
#content .book__page .ans { display: inline-block; margin-top: 8px; padding: 5px 12px; border-radius: 0; background: color-mix(in srgb, var(--course) 10%, #fff); font-weight: 600; }

/* Numbered steps. */
#content .book__page .steps { margin: 20px 0 26px; padding: 0; list-style: none; counter-reset: step; }
#content .book__page .steps li { position: relative; display: block; margin: 0; padding: 10px 0 10px 44px; border-top: 1px solid var(--rule); counter-increment: step; }
#content .book__page .steps li::before { content: counter(step); position: absolute; top: 10px; left: 0; width: auto; height: auto; background: none; color: var(--course); font: 800 18px/1.65 var(--sans); }
#content .book__page .proof-steps { margin: 18px 0 26px; padding: 0; list-style: none; }
#content .book__page .proof-steps li { position: relative; margin: 0; padding: 10px 0 10px 96px; border: 0; border-top: 1px solid var(--rule); }
#content .book__page .proof-steps li::before { content: attr(data-step); position: absolute; top: 12px; left: 0; padding: 0; background: none; color: var(--course); font: 750 14px/1.7 var(--sans); }
#content .book__page .concept-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 0 28px; margin: 26px 0; overflow: visible; border-radius: 0; background: none; }
#content .book__page .concept-card { padding: 12px 0; border: 0; border-top: 2px solid var(--ink); background: none; }
#content .book__page .concept-card h4 { margin: 0 0 4px; color: var(--ink); }
#content .book__page .concept-card :is(p, li) { font-size: 16.5px; line-height: 1.55; }

/* Tables: ruled, as in print. */
#content :is(.book__page, .prose, .contents) table { width: 100%; margin: 28px 0; border: 0; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); border-collapse: collapse; font: 400 16px/1.5 var(--sans); }
#content :is(.book__page, .prose, .contents) th { padding: 9px 12px; border: 0; border-bottom: 1px solid var(--ink); background: none; color: var(--ink); font-weight: 700; letter-spacing: 0; text-align: left; text-transform: none; vertical-align: bottom; }
#content :is(.book__page, .prose, .contents) td { padding: 8px 12px; border: 0; border-bottom: 1px solid var(--rule); background: none; color: var(--ink); text-align: left; vertical-align: top; }
#content :is(.book__page, .prose) tr:nth-child(even) td { background: none; }
#content .book__page .true-val { color: #0b6b3a; font-weight: 700; }
#content .book__page .false-val { color: #a62b1f; font-weight: 700; }

/* ---------- Figures and their controls ---------- */
#content .book__page .vbox { margin: 32px 0; padding: 18px; overflow: hidden; border: 1px solid var(--rule); border-radius: 2px; background: var(--paper); text-align: center; font-family: var(--sans); font-size: 15px; line-height: 1.5; }
#content .book__page .vbox canvas { display: block; margin: 0 auto; max-width: 100%; }
#content .book__page .vcap { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rule); color: var(--ink-2); font: italic 400 16px/1.5 var(--serif); text-align: left; }
#content .book__page .ctrl { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; color: var(--ink); font: 500 14.5px/1.4 var(--sans); }
#content .book__page button { min-height: 36px; padding: 6px 14px; border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink); font: 600 14px/1.2 var(--sans); cursor: pointer; }
#content .book__page button:hover { background: var(--wash); }
#content .book__page button:is(.on, .pri, .active) { background: var(--ink); color: #fff; }
#content .book__page button:disabled { opacity: .45; cursor: default; }
#content .book__page input[type="range"] { width: min(240px, 100%); accent-color: var(--course); }
#content .book__page :is(input[type="number"], input[type="text"], select) { min-height: 36px; padding: 4px 8px; border: 1px solid var(--ink-2); border-radius: 2px; font: 400 16px var(--sans); }
#content .book__page .mb { margin: .9em 0; padding: 4px 0; overflow-x: auto; text-align: center; }
#content .book__page .fi { opacity: 1; transform: none; transition: none; }
#content .adwrap { clear: both; }
#content .adwrap a, #content .adwrap a > div { border-radius: 2px !important; box-shadow: none !important; transform: none !important; }
#content .adwrap h2 { margin: 0; padding: 0; border: 0; }

/* Previous and next chapter. */
.turn { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 64px; border-top: 2px solid var(--ink); }
#content .turn a { padding: 16px 0; color: var(--ink); font: 700 20px/1.3 var(--sans); text-decoration: none; }
#content .turn a:hover { color: var(--course); }
.turn span { display: block; margin-bottom: 4px; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.turn__next { grid-column: 2; text-align: right; }

/* ---------- A course's contents page ---------- */
.contents { max-width: 1040px; padding-top: 44px; }
#content .contents__intro { max-width: 68ch; font-size: 20px; line-height: 1.65; }
#content .contents__intro p { margin: 0 0 1em; }
#content .contents__unit h2 { margin: 44px 0 0; padding-bottom: 10px; border-bottom: 3px solid var(--ink); font: 750 20px/1.3 var(--sans); }
#content .contents__unit ol { margin: 0; padding: 0; list-style: none; }
#content .contents__unit li { margin: 0; border-bottom: 1px solid var(--rule); }
#content .contents__unit a { display: grid; grid-template-columns: 74px minmax(0, 5fr) minmax(0, 7fr); gap: 0 22px; align-items: baseline; padding: 20px 0; color: var(--ink); text-decoration: none; }
#content .contents__unit a:hover { background: color-mix(in srgb, var(--course) 6%, #fff); }
#content .contents__unit a:hover .contents__title { text-decoration: underline; text-decoration-thickness: 2px; }
.contents__number { color: var(--course); font: 800 46px/1 var(--sans); font-stretch: 70%; font-variant-numeric: lining-nums tabular-nums; }
.contents__title { font: 700 23px/1.22 var(--sans); }
.contents__about { color: var(--ink); font-size: 17px; line-height: 1.55; }
.contents__topics { display: block; margin-top: 6px; color: var(--ink-2); font: 400 14px/1.55 var(--sans); }
#content .contents__extras { margin-top: 48px; }
#content .contents__extras .eqbox { margin: 0 0 28px; padding: 24px; background: color-mix(in srgb, var(--course) 7%, #fff); }
#content .contents__extras .eqbox-h, #content .contents__extras .info-box .lbl { margin: 0 0 14px; font: 750 17px/1.4 var(--sans); }
#content .contents__extras .eq-grid, #content .contents__extras .info-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 22px 32px; }
#content .contents__extras .eq-label { font: 600 14px/1.4 var(--sans); color: var(--ink-2); }
#content .contents__extras .eq-math { overflow-x: auto; }
#content .contents__extras .info-box { padding: 14px 0 0; border-top: 2px solid var(--ink); font-size: 17px; }

/* ---------- Home ---------- */
.lead { border-bottom: 2px solid var(--ink); }
.lead__row { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 56px; align-items: center; padding-top: 56px; padding-bottom: 48px; }
#content .lead h1 { margin: 0; font: 850 clamp(42px, 5.6vw, 72px)/1 var(--sans); font-stretch: 78%; letter-spacing: -.015em; text-wrap: balance; }
#content .lead__text p { max-width: 36ch; margin: 22px 0 0; font-size: 22px; line-height: 1.5; }
#content .lead__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; max-width: none !important; }
#content .lead__actions a:not(.button) { font: 600 16px var(--sans); color: var(--ink); }
#content .lead__actions .button { color: #fff; }
.lead__figure { margin: 0; --course: #a62b1f; }
.lead__figure svg { display: block; width: 100%; height: auto; border: 1px solid var(--ink); cursor: ew-resize; touch-action: pan-y; }
.lead__figure .grid { stroke: #e6e6e9; }
.lead__figure .axis { stroke: #9a9aa2; }
.lead__figure .curve { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.lead__figure .tangent { stroke: var(--course); stroke-width: 3; }
.lead__figure .point { fill: var(--course); stroke: #fff; stroke-width: 2; }
.lead__figure input { display: block; width: 100%; min-height: 36px; margin: 8px 0 0; accent-color: var(--course); }
.lead__figure figcaption { margin-top: 4px; font: italic 400 16.5px/1.55 var(--serif); color: var(--ink-2); }
.lead__figure figcaption span { display: block; color: var(--ink); font: 650 16px var(--sans); font-variant-numeric: tabular-nums; }

.shelf { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; align-items: stretch; padding-top: 48px; }
.shelf__book { display: flex; flex-direction: column; min-width: 0; border-bottom: 4px solid var(--course); }
.shelf__book header { display: flex; flex-direction: column; justify-content: space-between; min-height: 150px; padding: 18px 18px 16px; background: var(--course); color: #fff; }
#content .shelf__book h2 { margin: 0; font: 800 36px/1 var(--sans); font-stretch: 72%; }
#content .shelf__book h2 a { color: #fff; text-decoration: none; }
#content .shelf__book h2 a:hover { text-decoration: underline; }
#content .shelf__book header p { margin: 0; font: 550 14px var(--sans); }
#content .shelf__about { margin: 14px 0; min-height: 5.2em; font-size: 16px; line-height: 1.5; }
#content .shelf__book ol { margin: 0 0 12px; padding: 0; list-style: none; border-top: 1px solid var(--ink); }
#content .shelf__book li { margin: 0; border-bottom: 1px solid var(--rule); }
#content .shelf__book li a { display: flex; gap: 9px; padding: 7px 0; color: var(--ink); font: 450 14.5px/1.35 var(--sans); text-decoration: none; }
#content .shelf__book li a:hover { color: var(--course); text-decoration: underline; }
.shelf__book li span { flex: none; width: 20px; color: var(--course); font-weight: 750; font-variant-numeric: tabular-nums; }

.about { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 56px; margin-top: 72px; }
#content .about h2 { margin: 0 0 16px; padding-top: 16px; border-top: 3px solid var(--ink); font: 750 26px/1.2 var(--sans); text-wrap: balance; }
#content .about p { margin: 0 0 18px; }
#content .about dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin: 28px 0 0; }
.about dt { grid-row: auto; padding-top: 12px; border-top: 1px solid var(--rule); font: 700 16px var(--sans); }
#content .about dd { margin: 4px 0 20px; font-size: 16px; line-height: 1.5; }
.about dl { grid-auto-flow: column; grid-template-rows: auto auto auto auto; }

/* ---------- Articles, lists, search, 404 ---------- */
.article, .page-head, .listing, .post-footer { max-width: calc(760px + 2 * var(--gutter)); }
#content .page-head { padding-top: 52px; }
#content .article .page-head { padding: 52px 0 0; }
#content .page-head .eyebrow { margin: 0 0 12px; font: 700 15px var(--sans); }
#content .page-head h1 { margin: 0; font: 800 clamp(36px, 5.4vw, 60px)/1.04 var(--sans); font-stretch: 82%; letter-spacing: -.01em; text-wrap: balance; }
#content .page-head p:not(.eyebrow) { margin: 16px 0 0; color: var(--ink-2); font: 450 15px/1.6 var(--sans); }
#content .page-head { margin-bottom: 32px; }
#content .page-head::after { content: ""; display: block; margin-top: 20px; border-bottom: 3px solid var(--ink); }
#content .page-head form { display: flex; gap: 10px; margin-top: 20px; }
#content .page-head input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--ink); border-radius: 2px; font: 400 16px var(--sans); }
#content .prose img:not(.emoji) { display: block; width: 100%; max-height: 440px; margin: 30px 0 10px; object-fit: cover; }
#content .prose figure { margin: 0 0 24px; }
#content .prose :is(figcaption, .image-caption) { margin: 0 0 30px; color: var(--ink-2); font: 400 14px/1.55 var(--sans); }
#content .prose figure table { margin-top: 0; }
#content .prose figure:has(table) { overflow-x: auto; }
#content .prose .toc { margin: 32px 0 40px; padding: 18px 0 14px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); }
#content .prose .toc :is(.toc-h, h3) { margin: 0 0 10px; padding: 0; border: 0; font: 750 16px/1.4 var(--sans); }
#content .prose .toc ul { columns: 2 260px; column-gap: 32px; margin: 0; padding: 0; list-style: none; }
#content .prose .toc li { margin: 0; padding: 3px 0; break-inside: avoid; }
#content .prose .toc a { color: var(--ink); font: 450 15.5px/1.45 var(--sans); }
#content .prose :is(.highlight-box, .pro-tip, .visual-example, blockquote) { margin: 30px 0; padding: 20px 24px; border: 0; background: var(--wash); }
#content .prose .pro-tip { border: 1px solid var(--ink); background: none; }
#content .prose .visual-example { overflow-x: auto; font: 400 14.5px/1.7 var(--mono); white-space: pre-wrap; }
#content .prose :is(.highlight-box, .pro-tip, blockquote) > :last-child { margin-bottom: 0; }
#content .prose :is(.career-card, .method-card) { margin: 36px 0; padding-top: 4px; border-top: 1px solid var(--ink); }
#content .prose .salary-badge { display: inline-block; margin: 0 0 12px; padding: 0; font: 700 15px var(--sans); color: #0b6149; }
#content .prose hr { margin: 44px 0; border: 0; border-top: 1px solid var(--rule); }
#content .prose .video-embed iframe { width: 100%; height: auto; aspect-ratio: 16 / 9; border: 0; }

.post-rows { margin: 0; padding: 0; list-style: none; }
#content .post-rows li { margin: 0; padding: 0; border-bottom: 1px solid var(--rule); }
#content .post-row { display: block; padding: 18px 0; color: var(--ink); text-decoration: none; }
.post-row__title { display: block; font: 700 21px/1.3 var(--sans); }
#content .post-row:hover .post-row__title { text-decoration: underline; }
.post-row__text { display: block; margin-top: 4px; font-size: 16.5px; line-height: 1.5; }
.post-row time { display: block; margin-top: 6px; color: var(--ink-2); font: 450 14px var(--sans); }
#content .listing h2 { font: 750 24px var(--sans); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 32px; font: 500 15px var(--sans); }
#content .pagination .button { color: #fff; }
#content .post-footer { margin-top: 64px; }
.post-footer__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-bottom: 40px; font: 500 15px var(--sans); }
#content .post-tag { display: inline-flex; align-items: center; min-height: 36px; color: var(--ink); font-weight: 650; }
#content .post-footer h2 { margin: 0; padding-top: 16px; border-top: 3px solid var(--ink); font: 750 26px var(--sans); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 88px; padding: 44px 0 28px; background: var(--ink); color: #d9d9de; font: 400 15px/1.6 var(--sans); }
.site-footer__row { display: grid; grid-template-columns: 5fr 3fr 3fr 3fr; gap: 36px; }
.site-footer__logo { color: #fff; }
.site-footer p { max-width: 40ch; margin: 14px 0 0; }
.site-footer h2 { margin: 0 0 10px; color: #fff; font: 750 15px var(--sans); }
.site-footer ul { margin: 0; padding: 0; list-style: none; }
.site-footer li a { display: inline-flex; align-items: center; min-height: 32px; color: #d9d9de; text-decoration: none; }
.site-footer li a:hover { color: #fff; text-decoration: underline; }
.site-footer li:where([class^="course-"]) a::before { content: ""; width: 10px; height: 10px; margin-right: 10px; background: var(--course); outline: 1px solid #ffffff55; }
.site-footer .site-footer__small { max-width: 1240px; margin: 32px auto 0; font-size: 14px; color: #a9a9b1; }
body.is-course .site-footer { margin-top: 88px; }
#content .post-footer:empty { display: none; }

/* ---------- Narrower screens ---------- */
@media (max-width: 1179px) {
    .book { grid-template-columns: 220px minmax(0, 1fr); grid-template-areas: "chapters toc" "chapters page"; grid-template-rows: auto 1fr; gap: 0 40px; }
    .book > .book__toc { position: static; margin-bottom: 36px; }
    .book > .book__toc > summary { display: flex; }
    .book > .book__toc .book__side-title { display: none; }
    .opener__row { grid-template-columns: 220px minmax(0, 1fr); gap: 40px; }
    .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 36px; }
}

.book > details > summary { align-items: center; justify-content: space-between; min-height: 48px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); font: 700 15px var(--sans); list-style: none; cursor: pointer; }
.book > details > summary::-webkit-details-marker { display: none; }
.book > details > summary::after { content: "+"; font-size: 22px; font-weight: 500; }
.book > details[open] > summary::after { content: "\2212"; }

@media (max-width: 899px) {
    :root { --gutter: 20px; }
    html body { font-size: 17px; }
    .site-header__inner { flex-wrap: wrap; gap: 0; min-height: 56px; justify-content: space-between; }
    .site-header__logo { min-height: 56px; display: flex; align-items: center; }
    .site-header__menu-button { display: block; align-self: center; min-height: 40px; padding: 0 16px; border: 1px solid #77777f; border-radius: 2px; background: none; color: #fff; font: 650 15px var(--sans); }
    .site-nav { display: none; flex-basis: 100%; flex-direction: column; gap: 0; padding-bottom: 16px; }
    body.nav-open .site-nav { display: flex; }
    .site-nav__list { flex-direction: column; }
    .site-nav__list li { display: block; }
    .site-nav__list a { min-height: 48px; }
    .site-nav__list li:where([class^="course-"]) a { box-shadow: inset 4px 0 0 var(--course); }
    .site-search { margin-top: 12px; }
    .site-search input { width: 100%; min-height: 44px; }

    .opener { padding: 24px 0 26px; }
    .opener__row { display: block; }
    #content .opener__number { float: right; margin: 0 0 6px 14px; font-size: 76px; }
    #content .opener__summary { font-size: 17px; }

    .book { display: block; padding-top: 16px; }
    .book > details { position: static; }
    .book > details > summary { display: flex; }
    .book > details > nav { max-height: none; padding: 8px 0 14px; }
    .book > .book__chapters { margin-bottom: 0; }
    .book > .book__chapters[open] { margin-bottom: 8px; }
    .book > .book__toc { margin: -1px 0 28px; }
    .book__side-title { display: none; }
    #content .book > details a { min-height: 40px; align-content: center; }
    #content .book > .book__chapters ol a { align-items: center; }

    #content :is(.book__page, .prose) { font-size: 18px; }
    #content :is(.book__page, .prose) h2 { font-size: 24px; }
    #content .book__page .sh { margin-top: 48px; }
    #content .book__page .box, #content .book__page .eb { font-size: 17.5px; }
    #content .book__page .box:is(.thm, .theorem, .key, .note, .warn, .warning, .example), #content .book__page .callout { padding: 16px; }
    #content .book__page details.eg summary { padding-right: 0; }
    #content .book__page details.eg summary::after { position: static; display: block; margin-top: 2px; }
    #content .book__page .vbox { margin-inline: calc(var(--gutter) * -1); padding: 14px var(--gutter); border-width: 1px 0; }
    #content .book__page button, #content .post-tag { min-height: 42px; }
    #content .book__page .proof-steps li { padding-left: 0; }
    #content .book__page .proof-steps li::before { position: static; display: block; }
    /* The wide sponsor strip wraps instead of being cut off. */
    #content .adwrap a[style*="height:90px"] { height: auto !important; flex-wrap: wrap; gap: 10px !important; padding: 16px !important; }
    #content .adwrap a[style*="height:90px"] h2 { flex: 1 1 100% !important; font-size: 20px !important; line-height: 1.25 !important; }

    /* Formulas and tables scroll inside their own space. */
    #content .katex { position: relative; }
    #content :not(.katex-display) > .katex { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; }
    #content table { display: block; max-width: 100%; overflow-x: auto; }

    .lead__row, .about { grid-template-columns: minmax(0, 1fr); gap: 32px; }
    .lead__row { padding-top: 32px; padding-bottom: 32px; }
    #content .lead__text p { font-size: 19px; }
    .shelf { padding-top: 32px; }
    .about { margin-top: 48px; }
    #content .contents__unit a { grid-template-columns: 52px minmax(0, 1fr); }
    .contents__number { font-size: 34px; }
    .contents__title { font-size: 20px; }
    .contents__about { grid-column: 2; margin-top: 4px; }
    .site-footer__row { grid-template-columns: 1fr 1fr; }
    .site-footer__row > div { grid-column: 1 / -1; }
    .site-footer li a { min-height: 40px; }
    .turn { grid-template-columns: 1fr; gap: 0; }
    .turn__next { grid-column: 1; text-align: left; border-top: 1px solid var(--rule); }
}

@media (max-width: 599px) {
    .shelf { grid-template-columns: minmax(0, 1fr); }
    .shelf__book header { min-height: 110px; }
    #content .shelf__about { min-height: 0; }
    #content .about dl { display: block; }
}

@media print {
    .site-header, .site-footer, .book > details, .turn { display: none; }
    .book { display: block; }
    .opener { background: none; color: #000; }
    #content .opener * { color: #000; }
}

/* The pill-less, widget-level text should never drop below a readable size. */
@media (max-width: 899px) {
    #content .book__page :is(.step-label, .day-label, .section-label, .name, .badge, .beyond-badge, .algo-title, .pill) { font-size: 12.5px; }
}
