/* ==========================================================================
   DFT course (dft/). Builds on the tokens in ../style.css.
   A lecture is a column of 16:9 slide frames, each followed by its notes.
   Everything inside a frame is sized in em from a font size tied to the
   frame's width (container query units), so a slide looks the same in the
   page, full screen and on a projector, and never scrolls. On narrow
   columns the frame drops the fixed ratio and reflows.
   ========================================================================== */

.dft {
  --top-h: 56px;
  --fig-bg: #f8f9fb;
  --code-bg: #f6f7f9;
  --hl: #fdecc2;
  --hl-line: #d39a14;
  --ok: #1f7a4d;
  --warm: #c8651f;
  --red: #b3261e;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #fff;
}
html:has(body.lecture) { scroll-padding-top: calc(var(--top-h, 56px) + 16px); }
.dft sub, .dft sup { line-height: 0; }
kbd { font: 500 .78em var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--ink); background: #fff; }
code { font: .9em var(--mono); color: var(--ink); }

/* ---------- top bar ---------- */
.dft-top { position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.dft-top-in { max-width: 1440px; margin: 0 auto; padding: 0 24px; height: var(--top-h); display: flex; align-items: center; gap: 18px; }
.dft-top .brand { font-size: 1.02rem; white-space: nowrap; }
.crumbs { display: flex; gap: 10px; min-width: 0; font-size: .9rem; color: var(--muted); }
.crumbs > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs > * + *::before { content: "/"; margin-right: 10px; color: var(--line-strong); }
.crumbs a { color: var(--ink-2); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.top-actions button { font: 500 .84rem var(--sans); padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--ink); cursor: pointer; }
.top-actions button:hover { border-color: var(--ink); background: var(--ink); color: #fff; }
.progress { height: 2px; margin-bottom: -1px; }
.progress span { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- lecture layout ---------- */
.lec { max-width: 1440px; margin: 0 auto; padding: 0 24px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 40px; }
.lec-main { min-width: 0; container: main / inline-size; padding-bottom: 24px; }

.rail { position: sticky; top: var(--top-h); align-self: start; max-height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 32px 0 24px; font-size: .82rem; scrollbar-width: thin; }
.rail ol { list-style: none; margin: 0; padding: 0; counter-reset: s 1; }
.rail li { counter-increment: s; }
.rail li.back { counter-increment: none; }
.rail a { display: grid; grid-template-columns: 1.9em 1fr; padding: 4px 0; line-height: 1.35; color: var(--muted); }
.rail a::before { content: counter(s); font-variant-numeric: tabular-nums; }
.rail li.back a::before { content: "·"; }
.rail a:hover { color: var(--ink); text-decoration: none; }
.rail a.on { color: var(--ink); font-weight: 600; }
.rail a.on::before { color: var(--accent); }

/* a slide: the frame, then its notes. The frame never gets taller than the screen. */
.deck-slide { max-width: calc((100vh - var(--top-h) - 40px) * 16 / 9); padding: 28px 0 36px; scroll-margin-top: calc(var(--top-h) + 4px); }
.deck-slide + .deck-slide { border-top: 1px solid var(--line); }

.frame { position: relative; aspect-ratio: 16 / 9; container-type: size; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 10px 28px rgba(17, 24, 39, .07); overflow: hidden; }
.frame-in { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 3.6cqw 4.6cqw 4.4cqw; font-size: 1.72cqw; line-height: 1.42; color: var(--ink-2); }
.frame-foot { position: absolute; left: 4.6cqw; right: 4.6cqw; bottom: 1.3cqw; margin: 0; display: flex; justify-content: space-between; font: 1.02cqw/1 var(--sans); color: #9aa1ab; pointer-events: none; }

.frame-in > h2 { margin: 0 0 .45em; font: 600 .74em/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.claim { margin: 0 0 .7em; max-width: 30em; font: 600 1.52em/1.22 var(--serif); color: var(--ink); text-wrap: balance; }
.ev { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: .7em; }
.ev > * { margin: 0; }
.frame p, .frame li { line-height: 1.42; }
.frame p { margin: 0 0 .5em; }
.frame ul, .frame ol { margin: 0; padding-left: 1.2em; }
.frame li { margin: 0 0 .3em; }
.frame li:last-child, .frame p:last-child { margin-bottom: 0; }
.frame b, .frame strong { color: var(--ink); font-weight: 600; }
.frame h3 { margin: 0 0 .3em; font: 600 1em/1.3 var(--sans); color: var(--ink); }
.frame .small { font-size: .82em; }
.frame .muted { color: var(--muted); }
.frame code { font-size: .88em; }

/* layouts inside a frame */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4em; align-items: center; min-height: 0; }
.cols.wl { grid-template-columns: 3fr 2fr; }
.cols.wr { grid-template-columns: 2fr 3fr; }
.cols.top { align-items: start; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1em; align-items: start; }
.ev > .cols, .ev > .cols-3 { flex: 1; }
.ev > .cols.fit, .ev > .cols-3.fit { flex: 0 1 auto; }

/* tiles: a grid of small labelled boxes */
.tiles { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: .7em; list-style: none; margin: 0; padding: 0 !important; }
.tile { margin: 0 !important; padding: .65em .85em .7em; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.tile h3 { font-size: .96em; }
.tile p, .tile li { font-size: .84em; }
.tile .k { display: block; margin-bottom: .2em; font: 600 .66em/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.k .katex { text-transform: none; letter-spacing: 0; }   /* uppercase labels must not change the math */
.tile.acc { border-color: #c9d7ec; background: #f6f9fd; }
.tile.warn { border-color: #ecd6a6; background: #fdf8ec; }
.tile.key { border-color: var(--ink); }
.tile code.file { font: 600 1em var(--mono); color: var(--ink); }

/* a big number with a caption */
.big { margin: 0; font: 600 2.7em/1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.big small { font: 500 .36em var(--sans); color: var(--muted); letter-spacing: 0; }
.big-cap { margin: .35em 0 0 !important; font-size: .86em; color: var(--muted); }
.tile .big, .tile .big-cap { display: block; }
.tile .big { font-size: 2.1em; margin-top: .15em; }

/* quotation */
.quote { margin: 0; padding: .2em 0 .2em 1em; border-left: 3px solid var(--accent); font: italic 1.08em/1.45 var(--serif); color: var(--ink); }
.quote cite { display: block; margin-top: .4em; font: normal .72em var(--sans); color: var(--muted); }

/* flow of ideas, as a row of pills */
/* the site's style.css also defines .flow (a centred column); the course's is a row */
.dft .flow { list-style: none; display: flex; flex-direction: row; align-items: center; gap: .45em 0; flex-wrap: wrap; margin: 0 !important; padding: 0 !important; }
.flow li { display: flex; align-items: center; margin: 0 !important; font-size: .82em; }
.flow li + li::before { content: "→"; margin: 0 .5em; color: var(--muted); }
.flow span { padding: .2em .7em; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; color: var(--ink); white-space: nowrap; }
.dft .flow.v { flex-direction: column; align-items: flex-start; row-gap: .4em; counter-reset: f; }
.flow.v li { counter-increment: f; font-size: .9em; }
.flow.v li + li::before { content: none; }
.flow.v span::before { content: counter(f); display: inline-block; width: 1.4em; color: var(--accent); font-weight: 600; }
.flow .on span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

/* flip cards: a statement or question on the front, the answer behind it */
.flips { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: .65em; }
.flip { display: grid; padding: .7em .9em; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; cursor: pointer; text-align: left; }
.flip > * { grid-area: 1 / 1; margin: 0; }
.flip .q { font-size: .9em; font-weight: 500; color: var(--ink); }
.flip .a { font-size: .8em; line-height: 1.4; }
.flip .q::before, .flip .a::before { display: block; margin-bottom: .25em; font: 600 .74em/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; }
.flips.myths .q::before { content: "Misconception"; color: #a1402b; }
.flips.myths .a::before { content: "What is true"; color: var(--ok); }
.flips.checks .q::before { content: attr(data-k); color: var(--accent); }
.flips.checks .a::before { content: "Answer"; color: var(--ok); }
.js .flip .a { visibility: hidden; }
.js .flip.on .q { visibility: hidden; }
.js .flip.on .a { visibility: visible; }
.js .flip.on { border-color: #b8dcc8; background: #f5fbf7; }
.flip:hover { border-color: var(--ink-2); }
.flip-hint { font-size: .72em !important; color: var(--muted); }
html:not(.js) .flip { display: block; }
html:not(.js) .flip .a { display: block; margin-top: .4em; }

/* inputs and code */
pre.code { margin: 0; padding: .55em .8em; overflow: hidden; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; font: .74em/1.5 var(--mono); color: var(--ink); }
pre.code .c { color: var(--muted); }
pre.code a.vtag { font-size: 1em; padding: 0 2px; }
.file-k { margin: 0 0 .25em !important; font: 600 .74em var(--mono); color: var(--ink); letter-spacing: .02em; }
.notes pre.code { margin: 12px 0 16px; padding: 12px 16px; overflow-x: auto; font-size: .88rem; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .8em; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink); border-bottom: 1.5px solid var(--ink); padding: .3em .8em .3em 0; }
.tbl td { border-bottom: 1px solid var(--line); padding: .36em .8em .36em 0; vertical-align: top; }
.tbl td:first-child { color: var(--ink); }
.notes .tbl { font-size: .94rem; margin: 10px 0 18px; }

/* callouts */
.callout { padding: .55em .85em; border: 1px solid var(--line); border-radius: 8px; font-size: .88em; }
.callout > :last-child { margin-bottom: 0; }
.callout-k { margin: 0 0 .2em !important; font: 600 .74em/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.callout.vasp { border-color: #c9d7ec; background: #f6f9fd; }
.callout.vasp .callout-k { color: var(--accent); }
.callout.caution { border-color: #ecd6a6; background: #fdf8ec; }
.callout.caution .callout-k { color: #8a5a00; }
.callout.key { border-color: var(--ink); }
.notes .callout { margin: 16px 0; padding: 12px 16px; font-size: 1rem; }

/* builds: revealed one at a time while presenting */
.presenting .deck-slide.current .step:not(.shown) { visibility: hidden; }

/* ---------- title slide ---------- */
.deck-title .frame-in { justify-content: center; }
.eyebrow { margin: 0 0 .7em; font: 600 .74em/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.deck-title h1 { margin: 0 0 .3em; font-size: 2.35em; letter-spacing: -.015em; line-height: 1.1; }
.question { margin: 0 0 1.1em !important; max-width: 30em; font: italic 1.22em/1.4 var(--serif); color: var(--ink); }
.fits { display: grid; grid-template-columns: 1.8fr 1fr; border: 1px solid var(--line); border-radius: 8px; font-size: .84em; }
.fits > div { padding: .7em 1em; }
.fits > div + div { border-left: 1px solid var(--line); }
.fits p { margin: 0 0 .5em; }
.fits ul { padding-left: 1.1em; }
.fits li { margin-bottom: .15em; }
.fits-k { margin: 0 0 .25em !important; font: 600 .78em/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.byline { margin: 1em 0 0 !important; font-size: .74em; color: var(--muted); }
.byline a { color: var(--ink-2); }
.present-hint { margin: 14px 0 0; font-size: .86rem; color: var(--muted); }
@media (hover: none) { .present-hint { display: none; } }

/* ---------- notes under each slide ---------- */
.notes { max-width: 46rem; margin: 22px 0 0; font-size: 1.02rem; line-height: 1.72; }
.notes p { margin: 0 0 .85em; }
.notes > :last-child { margin-bottom: 0; }
.notes ul, .notes ol { padding-left: 1.3em; margin: 0 0 .9em; }
.notes li { margin-bottom: .3em; }
.notes b, .notes strong { color: var(--ink); font-weight: 600; }
.notes h3 { font-size: 1.06rem; margin: 18px 0 6px; }

/* ---------- math ---------- */
.dft .katex { font-size: 1.08em; }
.frame .katex-display { margin: .35em 0; padding: .15em 0; overflow: visible; }
.notes .katex-display { margin: 14px 0; overflow-x: auto; overflow-y: hidden; }
.eqbox { padding: .25em .9em .6em; border: 1px solid var(--line); border-radius: 8px; }
.eqbox [data-eq] { cursor: pointer; border-radius: 3px; transition: background-color .15s; }
.eqbox .katex [data-eq].on { background: var(--hl); box-shadow: 0 0 0 3px var(--hl); }
.eq-legend { list-style: none; margin: .2em 0 0 !important; padding: 0 !important; display: grid; gap: .2em; }
.eq-legend li { margin: 0 !important; padding: .25em .6em; font-size: .8em; line-height: 1.4 !important; border-left: 3px solid var(--line-strong); border-radius: 0 4px 4px 0; }
.eq-legend li:hover, .eq-legend li:focus-visible { background: var(--fig-bg); }
.eq-legend li.on { border-left-color: var(--hl-line); background: #fdf7e6; }
.eq-hint { margin: .35em 0 0 !important; font-size: .7em; color: var(--muted); }
.eqbox.eq-split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: .3em 1.2em; align-items: center; }
.eq-split > .eq-hint { grid-column: 1 / -1; }

/* ---------- inline links that open popovers ---------- */
a.term { color: inherit; text-decoration: underline dotted; text-decoration-color: var(--muted); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a.term:hover { color: var(--accent); text-decoration-color: var(--accent); }
a.vtag { font: 500 .86em var(--mono); color: var(--accent-ink); background: var(--accent-soft); border: 1px solid #c9d7ec; border-radius: 4px; padding: 0 .3em; white-space: nowrap; }
a.vtag:hover { border-color: var(--accent); text-decoration: none; }
a.ref { display: inline-block; font-size: .76em; line-height: 1.5; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 .5em; white-space: nowrap; vertical-align: .1em; }
a.ref:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.lec-ref { color: inherit; border-bottom: 1px dashed var(--line-strong); }

.pop { position: fixed; z-index: 80; max-height: 60vh; overflow-y: auto; padding: 12px 14px; background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 12px 32px rgba(17, 24, 39, .14); font-size: .9rem; line-height: 1.55; color: var(--ink-2); }
.pop:focus { outline: none; }
.pop p { margin: 0 0 6px; }
.pop-k { font-size: .68rem !important; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px !important; }
.pop-title { font-weight: 600; color: var(--ink); }
.pop-body .tag-meta { margin-top: 6px; }
.pop-more { display: inline-block; margin-top: 6px; font-size: .8rem; }

/* ---------- collapsible panels (in the notes) ---------- */
details { margin: 14px 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; float: right; margin-left: 12px; font: 400 1.1rem/1.4 var(--sans); color: var(--muted); }
details[open] > summary::after { content: "−"; }
details.deeper { border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
details.deeper > summary { padding: 10px 16px; font-weight: 600; color: var(--ink); }
details.deeper > summary::before { content: "Going deeper · "; font-weight: 500; color: var(--accent); }
details.deeper > :not(summary) { padding-left: 16px; padding-right: 16px; }
details.deeper > ol, details.deeper > ul { padding-left: calc(16px + 1.3em); }
details.deeper > :last-child { padding-bottom: 12px; }

/* ---------- figures ---------- */
.fig { margin: 0; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.ev > .fig { flex: 1; }
.fig-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--fig-bg); }
.dft .fig-body svg { display: block; width: 100%; height: 100%; max-height: 100%; stroke: none; fill: var(--ink); stroke-width: 1; }
.fig figcaption { padding: .35em .8em .45em; border-top: 1px solid var(--line); font-size: .7em; line-height: 1.4; color: var(--muted); }
.fig figcaption b { color: var(--ink); font-weight: 600; }
.model-label { display: inline-block; margin-right: .5em; padding: 0 .45em; border: 1px solid #ecd6a6; border-radius: 3px; background: #fdf8ec; font-size: .9em; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #8a5a00; }
.data-label { display: inline-block; margin-right: .5em; padding: 0 .45em; border: 1px solid #c9d7ec; border-radius: 3px; background: #f6f9fd; font-size: .9em; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }

/* a figure with a control panel beside it */
.fig.side { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.fig.side > .fig-body { grid-row: 1; grid-column: 1; }
.fig.side > .fig-panel { grid-row: 1; grid-column: 2; border-left: 1px solid var(--line); }
.fig.side > figcaption { grid-row: 2; grid-column: 1 / -1; }
.fig-panel { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: .55em; padding: .7em .85em; font-size: .78em; }
.fig-panel p { margin: 0; }
.fig-panel label { display: flex; align-items: center; gap: .5em; }
.fig-panel input[type=range] { flex: 1; min-width: 0; accent-color: var(--ink); }
.fig-panel .row { display: flex; flex-wrap: wrap; gap: .4em; }
.fig-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4em .9em; padding: .4em .8em; border-top: 1px solid var(--line); font-size: .76em; }
.readout { font-variant-numeric: tabular-nums; color: var(--ink-2); line-height: 1.45; }
.readout b { color: var(--ink); }
.seg { display: inline-flex; flex-wrap: wrap; }
.seg button { border: 1px solid var(--line-strong); background: #fff; color: var(--ink-2); cursor: pointer; font: 500 1em/1 var(--sans); padding: .42em .7em; margin-right: -1px; }
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; margin-right: 0; }
.seg button.on { background: var(--ink); border-color: var(--ink); color: #fff; position: relative; }
.btn-step { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); border-radius: 4px; padding: .42em .7em; font: 500 1em/1 var(--sans); cursor: pointer; }
.btn-step:hover { border-color: var(--ink); }
.btn-step.play { min-width: 6.5em; }

/* Lecture 0: carbon frameworks, energy above graphite */
.dots-svg .row-l { font: 12.5px var(--sans); fill: var(--ink-2); }
.dots-svg .row-l.new { font-weight: 600; fill: var(--ink); }
.dots-svg .grid { stroke: var(--line); stroke-width: 1; }
.dots-svg .tick { font: 11px var(--sans); fill: var(--muted); }
.dots-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.dots-svg .stem { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 2 3; }
.dots-svg .dot { fill: #fff; stroke: var(--ink-2); stroke-width: 2; }
.dots-svg .dot.new { fill: var(--warm); stroke: #fff; stroke-width: 2; }
.dots-svg .val { font: 600 11.5px var(--sans); fill: var(--ink); }
.dots-svg .gap { stroke: var(--ink); stroke-width: 1.2; }
.dots-svg .gap-l { font: 600 11.5px var(--sans); fill: var(--ink); }
.dots-svg .leg { font: 11.5px var(--sans); fill: var(--ink-2); }

/* Lecture 0: the exponential wall */
.wall-svg .grid { stroke: var(--line); stroke-width: 1; }
.wall-svg .tick { font: 12px var(--sans); fill: var(--muted); }
.wall-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.wall-svg .ax { stroke: var(--ink-2); stroke-width: 1.2; }
.wall-svg .psi { fill: none; stroke: var(--accent); stroke-width: 2.4; }
.wall-svg .rho { fill: none; stroke: var(--warm); stroke-width: 2.4; }
.wall-svg .lim { stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 5 4; }
.wall-svg .lim-l { font: 11.5px var(--sans); fill: var(--ink-2); }
.wall-svg .lab { font: 600 13px var(--sans); }
.wall-svg .lab.psi-l { fill: var(--accent); }
.wall-svg .lab.rho-l { fill: #9a4a12; }
.wall-svg .mk { stroke: #fff; stroke-width: 2.5; }
.wall-svg .mk.psi-m { fill: var(--accent); }
.wall-svg .mk.rho-m { fill: var(--warm); }
.wall-svg .vline { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; }

/* Lecture 0: the life of a VASP run */
.run-fig .fig-body { background: #fff; }
.run-svg .box { cursor: pointer; outline: none; }
.run-svg .box rect { fill: #fff; stroke: var(--line-strong); stroke-width: 1.2; transition: fill .2s, stroke .2s; }
.run-svg .box:hover rect, .run-svg .box:focus-visible rect { stroke: var(--accent); }
.run-svg .box.on rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.run-svg .t1 { font: 600 13px var(--sans); fill: var(--ink); }
.run-svg .t2 { font: 11.5px var(--sans); fill: var(--muted); }
.run-svg .arrow { fill: none; stroke: var(--ink-2); stroke-width: 1.4; marker-end: url(#run-arrow); }
.run-svg .head { fill: var(--ink-2); }
.run-svg .lbl { font: 11.5px var(--sans); fill: var(--ink-2); }
.run-svg .loop-e { fill: #f1f5fb; }
.run-svg .loop-i { fill: none; stroke: var(--line-strong); stroke-dasharray: 5 4; }
.run-svg .loop-lbl { font: 600 10.5px var(--sans); fill: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.run-detail { min-height: 4.4em; padding: .45em .8em; border-top: 1px solid var(--line); font-size: .8em; }
.run-detail h3 { margin: 0 0 .15em; font-size: 1em; }
.run-detail p { margin: 0; line-height: 1.4; }
.run-status { color: var(--muted); }
.run-steps { padding-left: 1.3em; }
.run-steps h3 { display: inline; font: 600 1em var(--sans); }
.run-steps h3::after { content: " "; }
.run-steps p { display: inline; margin: 0; }

/* Lecture 0: energy units */
.units-fig .fig-body { display: block; padding: .3em .8em; background: #fff; }
.units-table td:nth-child(2) { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.conv { display: flex; flex-direction: column; gap: .5em; padding: .7em .9em; border-left: 1px solid var(--line); background: var(--fig-bg); font-size: .8em; height: 100%; }
.conv .row { display: flex; gap: .5em; }
.conv input, .conv select { font: 1em var(--sans); padding: .3em .45em; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; color: var(--ink); min-width: 0; }
.conv input { width: 7em; }
.conv-out { list-style: none; margin: 0 !important; padding: 0 !important; display: grid; gap: .15em; }
.conv-out li { margin: 0 !important; font-variant-numeric: tabular-nums; }
.conv-out b { color: var(--ink); font-weight: 600; }
.units-fig .cols { gap: 0; align-items: stretch; height: 100%; }

/* Lecture 0: course map */
.parts { counter-reset: p; }
.parts { gap: .5em; }
.parts .tile { position: relative; padding: .5em .8em .5em 2.2em; font-size: .92em; }
.parts .tile::before { counter-increment: p; content: counter(p, upper-roman); position: absolute; left: .7em; top: .5em; font: 600 .8em var(--serif); color: var(--accent); }

/* Lecture 2: one particle in a box */
.qm-svg .psi { fill: none; stroke: var(--accent); stroke-width: 2.4; }
.qm-svg .rho { fill: none; stroke: var(--warm); stroke-width: 2.4; }
.qm-svg .area { fill: rgba(200, 101, 31, .2); }
.qm-svg .wall { stroke: var(--ink); stroke-width: 3; }
.qm-svg .ax { stroke: var(--ink-2); stroke-width: 1.2; }
.qm-svg .zero, .qm-svg .lvl { stroke: var(--line-strong); stroke-width: 1.2; stroke-dasharray: 4 4; }
.qm-svg .edge { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.qm-svg .lbl { font: 600 13px var(--sans); fill: var(--ink); }
.qm-svg .lbl.psi-t { fill: var(--accent); }
.qm-svg .lbl.rho-t { fill: #9a4a12; }
.qm-svg .pval { font: 600 13px var(--sans); fill: var(--ink); }
.qm-svg .eval { font: 12.5px var(--sans); fill: var(--ink-2); }
.qm-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.qm-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.qm-svg .bar { fill: var(--accent); opacity: .85; }
.qm-svg .expect { stroke: var(--warm); stroke-width: 3; }

/* Lecture 2: crystal translation phases, reciprocal-space sampling and band gaps */
.crystal-svg .ax { stroke: var(--ink-2); stroke-width: 1.2; }
.crystal-svg .grid { stroke: var(--line); stroke-width: 1; }
.crystal-svg .lbl { font: 600 13px var(--sans); fill: var(--ink); }
.crystal-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.crystal-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.crystal-svg .cell { fill: none; stroke: var(--line-strong); stroke-width: 1; }
.crystal-svg .phase-ring { fill: none; stroke: var(--line-strong); stroke-width: 1; }
.crystal-svg .phase-hand { stroke: var(--accent); stroke-width: 2.5; }
.crystal-svg .phase-tip { fill: var(--accent); }
.crystal-svg .atom, .crystal-svg .lattice-point { fill: var(--ink); }
.crystal-svg .wave, .crystal-svg .valence { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.crystal-svg .conduction { fill: none; stroke: var(--warm); stroke-width: 2.5; }
.crystal-svg .dimension { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.crystal-svg .zone-fill, .crystal-svg .gap-fill { fill: var(--accent); opacity: .08; }
.crystal-svg .zone-box { fill: none; stroke: var(--ink-2); stroke-width: 1.2; }
.crystal-svg .edge { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.crystal-svg .sample { fill: var(--warm); stroke: #fff; stroke-width: 1.3; }
.crystal-svg .mesh-point { fill: var(--accent); }
.crystal-svg .band-path { fill: none; stroke: var(--accent); stroke-width: 2; }
.crystal-svg .selection { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.crystal-svg .edge-dot { fill: var(--ink); }
.crystal-svg .band-value { stroke: #fff; stroke-width: 1.5; }
.crystal-svg .val-dot { fill: var(--accent); }
.crystal-svg .cond-dot { fill: var(--warm); }
.crystal-svg .fermi { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 3; }
.crystal-svg .cube-face { fill: var(--accent); opacity: .035; }
.crystal-svg .cube-edge { stroke: var(--line-strong); stroke-width: 1.2; }
.crystal-svg .basis-axis { stroke: var(--ink-2); stroke-width: 1.7; }
.crystal-svg .phase-label { font-weight: 400; fill: var(--accent); }
.crystal-svg .component { stroke: var(--warm); stroke-width: 1; stroke-dasharray: 3 3; }
.crystal-svg .k-vector { stroke: var(--warm); stroke-width: 2.5; }
.crystal-3d .fig-body { cursor: grab; touch-action: none; user-select: none; }
.crystal-3d .fig-body:active { cursor: grabbing; }
.fig-panel [hidden] { display: none; }

/* Prerequisite explorers shared by Lectures 2–6. */
.teach-svg .axis { stroke: var(--ink-2); stroke-width: 1.2; }
.teach-svg .label { fill: var(--ink); font: 600 14px var(--sans); }
.teach-svg .tick { fill: var(--muted); font: 12px var(--sans); }
.teach-svg .axis-label { fill: var(--ink-2); font: 13px var(--sans); }
.teach-svg .ring { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.teach-svg .guide { fill: none; stroke: var(--line-strong); stroke-width: 1.2; stroke-dasharray: 4 3; }
.teach-svg .curve { fill: none; stroke: var(--accent); stroke-width: 3; }
.teach-svg .point, .teach-svg .included, .teach-svg .energy-bar { fill: var(--accent); }
.teach-svg .excluded { fill: var(--line-strong); }
.teach-svg .cut-disk { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.2; }
.teach-svg .warm-line { fill: none; stroke: var(--warm); stroke-width: 2; }
.teach-svg .orbital-box, .teach-svg .number-cell { fill: #fff; stroke: var(--line-strong); stroke-width: 1.5; }
.teach-svg .spin-arrow { fill: var(--ink); font: 400 36px var(--sans); }
.teach-svg .big { fill: var(--ink); font: 600 36px var(--serif); }
.teach-svg .number { fill: var(--ink); font: 600 24px var(--sans); }
.teach-svg .angular-face { stroke: #fff; stroke-width: .35; fill-opacity: .92; stroke-opacity: .25; }
.teach-svg .angular-face.positive { fill: var(--accent); }
.teach-svg .angular-face.negative, .teach-svg .energy-bar.exchange { fill: var(--warm); }
.teach-svg .det-line { fill: none; stroke-width: 2.5; }
.teach-svg .det-line.first { stroke: var(--accent); }
.teach-svg .det-line.second { stroke: var(--warm); }
.teach-svg .det-bracket { fill: none; stroke: var(--ink); stroke-width: 2; }
.angular-3d .fig-body { cursor: grab; touch-action: none; user-select: none; }
.angular-3d .fig-body:active { cursor: grabbing; }

/* Lecture 3: trial energies, level repulsion, basis convergence */
.vp-svg .grid { stroke: var(--line); stroke-width: 1; }
.vp-svg .ax { stroke: var(--ink-2); stroke-width: 1.2; }
.vp-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.vp-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.vp-svg .lbl { font: 600 12.5px var(--sans); fill: var(--ink); }
.vp-svg .lbl.ex { fill: var(--ink-2); }
.vp-svg .lbl.tr { fill: var(--warm); }
.vp-svg .curve { fill: none; stroke: var(--accent); stroke-width: 2.4; }
.vp-svg .curve.hi { stroke: #6b8fc4; }
.vp-svg .exact { stroke: var(--ink-2); stroke-width: 1.3; stroke-dasharray: 5 4; }
.vp-svg .mk { fill: var(--warm); stroke: #fff; stroke-width: 2.5; }
.vp-svg .mk.hi { fill: #6b8fc4; }
.vp-svg .pt { fill: var(--accent); opacity: .55; }
.vp-svg .vline { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; }
.vp-svg .exact-psi { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 6 4; }
.vp-svg .trial-psi { fill: none; stroke: var(--warm); stroke-width: 2.4; }
.vp-svg .pot { fill: none; stroke: #b9c0ca; stroke-width: 2; }
.vp-svg .wall { stroke: var(--ink); stroke-width: 3; }

/* Lecture 4: hydrogen orbitals and titanium's shells */
.orb-svg .ax { stroke: var(--ink-2); stroke-width: 1.2; }
.orb-svg .rad { fill: none; stroke: var(--accent); stroke-width: 2.4; }
.orb-svg .node-l { stroke: var(--red); stroke-width: 1; stroke-dasharray: 3 3; }
.orb-svg .mean { stroke: var(--ink); stroke-width: 2; }
.orb-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.orb-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.orb-svg .lbl { font: 12px var(--sans); fill: var(--ink-2); }
.orb-svg .axis-z { stroke: var(--line-strong); stroke-width: 1; }
.orb-svg .lobe { stroke-width: 1.4; }
.orb-svg .lobe.pos { fill: rgba(29, 79, 145, .28); stroke: var(--accent); }
.orb-svg .lobe.neg { fill: rgba(200, 101, 31, .28); stroke: var(--warm); }
.shell-svg .lbl { font: 600 13px var(--sans); fill: var(--ink); }
.shell-svg .shell rect { stroke-width: 1.5; }
.shell-svg .shell.core rect { fill: #eef0f3; stroke: #c3c8d0; }
.shell-svg .shell.val rect { fill: var(--accent-soft); stroke: var(--accent); }
.shell-svg .sh { font: 600 17px var(--sans); fill: var(--ink); }
.shell-svg .ne { font: 13px var(--sans); fill: var(--ink-2); }
.shell-svg .split { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 4; }
.shell-svg .cap { font: 600 13px var(--sans); }
.shell-svg .core-t { fill: var(--muted); }
.shell-svg .val-t { fill: var(--accent); }

/* Lecture 5: helium energies, two electrons in a box, storage */
.he-svg .grid { stroke: var(--line); stroke-width: 1; }
.he-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.he-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.he-svg .row-l { font: 600 13px var(--sans); fill: var(--ink); }
.he-svg .row-n { font: 11.5px var(--sans); fill: var(--muted); }
.he-svg .stem { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 2 3; }
.he-svg .dot { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.he-svg .dot.exp { fill: var(--warm); }
.he-svg .val { font: 600 12px var(--sans); fill: var(--ink); }
.he-svg .gap { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.he-svg .gap-l { font: 600 12px var(--sans); fill: var(--ink); }
.pair-svg .frame-r { fill: none; stroke: var(--ink-2); stroke-width: 1.2; }
.pair-svg .diag { stroke: var(--warm); stroke-width: 2; stroke-dasharray: 6 4; }
.pair-svg .diag-l { font: 600 12px var(--sans); fill: #9a4a12; }
.pair-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.pair-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.pair-svg .lbl { font: 600 13px var(--sans); fill: var(--ink); }
.store-svg .lbl { font: 600 13px var(--sans); fill: var(--ink); }
.store-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.store-svg .b-psi { fill: var(--accent); }
.store-svg .b-rho { fill: var(--warm); }
.store-svg .big-v { font: 600 14px var(--sans); fill: #fff; }

/* Lecture 6: Hartree–Fock SCF for helium */
.hf-svg .grid { stroke: var(--line); stroke-width: 1; }
.hf-svg .ax { stroke: var(--ink-2); stroke-width: 1.2; }
.hf-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.hf-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.hf-svg .ref { stroke: var(--ink-2); stroke-width: 1.4; stroke-dasharray: 6 4; }
.hf-svg .ref.ex { stroke: var(--warm); }
.hf-svg .cur { stroke: var(--accent); stroke-width: 3; }
.hf-svg .trace { fill: none; stroke: var(--accent); stroke-width: 1.6; opacity: .6; }
.hf-svg .pt { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.hf-svg .lv { font: 600 12px var(--sans); fill: var(--ink); }
.hf-svg .lv2 { font: 11.5px var(--sans); fill: var(--muted); }

/* Lecture 1: the particles of the full Hamiltonian; groups light up with their term */
.ham-svg { display: block; width: 100%; height: auto; max-height: 100%; margin: 0 auto; fill: none; stroke: none; }
.ham-svg [data-eq] { cursor: pointer; }
.ham-svg line, .ham-svg .mv { stroke: #d5dae1; stroke-width: 1.5; fill: none; transition: stroke .15s, stroke-width .15s; }
.ham-svg .mv { marker-end: url(#ham-arrow); }
.ham-svg .ham-head { fill: #d5dae1; }
.ham-svg [data-eq].on line, .ham-svg [data-eq].on .mv { stroke: var(--hl-line); stroke-width: 3; }
.ham-svg .nuc { fill: var(--ink); }
.ham-svg .ele { fill: var(--accent); }
.ham-svg text { fill: #fff; font: 600 14px var(--sans); stroke: none; }
.ham-svg text.cap { fill: var(--muted); font: 11px var(--sans); }

/* Lecture 1: diagrams drawn inline (displaced atom, relaxation loop) */
.diag { display: block; width: 100%; height: 100%; max-height: 100%; fill: none; stroke: none; }
.diag .atom { fill: var(--ink); }
.diag .atom.off { fill: var(--warm); }
.diag .ghost { fill: none; stroke: var(--warm); stroke-width: 1.5; stroke-dasharray: 3 3; }
.diag .bond { stroke: var(--line-strong); stroke-width: 3; }
.diag .force { stroke: var(--red); stroke-width: 3; marker-end: url(#diag-force); }
.diag .head-f { fill: var(--red); }
.diag .t { font: 13px var(--sans); fill: var(--ink-2); }
.diag .t.b { font-weight: 600; fill: var(--ink); }
.diag .t.m { fill: var(--muted); font-size: 12px; }
.diag .node rect { fill: #fff; stroke: var(--line-strong); stroke-width: 1.3; }
.diag .node.acc rect { fill: var(--accent-soft); stroke: var(--accent); }
.diag .node.ok rect { fill: #eef7f1; stroke: #8cc5a3; }
.diag .arr { stroke: var(--ink-2); stroke-width: 1.4; fill: none; marker-end: url(#diag-arrow); }
.diag .head { fill: var(--ink-2); }
.diag .tag { font: 600 12px var(--mono); fill: var(--accent-ink); }

/* Lecture 1: potential-energy curve */
.pes-svg { display: block; touch-action: none; cursor: crosshair; background: #fff; }
.pes-svg .curve { fill: none; stroke: var(--accent); stroke-width: 2.4; }
.pes-svg .grid { stroke: var(--line); stroke-width: 1; }
.pes-svg .ax { stroke: var(--ink-2); stroke-width: 1.2; }
.pes-svg .zero { stroke: var(--line-strong); stroke-width: 1.2; stroke-dasharray: 5 4; }
.pes-svg .tick { font: 11px var(--sans); fill: var(--muted); }
.pes-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.pes-svg .lbl { font: 600 12.5px var(--sans); fill: var(--ink); }
.pes-svg .marker { fill: var(--warm); stroke: #fff; stroke-width: 2.5; }
.pes-svg .atom { fill: var(--ink); }
.pes-svg .atom.b { fill: var(--warm); }
.pes-svg .bond, .pes-svg .track { stroke: var(--line-strong); stroke-width: 3; }
.pes-svg .track { stroke-width: 1.5; stroke-dasharray: 3 4; }
.pes-svg .farrow { stroke: var(--red); stroke-width: 3; }
.pes-svg .head { fill: var(--red); }
.pes-log { margin: 0; font-size: .92em; font-variant-numeric: tabular-nums; }
.pes-log th, .pes-log td { padding: .12em .7em .12em 0; }
.pes-log .more td { color: var(--muted); border-bottom: 0; }
.pes-status { font-weight: 600; color: var(--ink); }
.pes-status.done { color: var(--ok); }

/* ---------- key terms and references (page sections after the slides) ---------- */
.backmatter { max-width: 52rem; padding: 40px 0 8px; border-top: 1px solid var(--line); }
.backmatter h2 { font-size: 1.5rem; margin: 0 0 14px; }
.backmatter h3 { font-size: 1.1rem; margin: 26px 0 8px; }
.terms dt { margin-top: 16px; font-weight: 600; color: var(--ink); scroll-margin-top: calc(var(--top-h) + 16px); }
.terms dt:first-child { margin-top: 4px; }
.terms dd { margin: 4px 0 0; font-size: .97rem; }
.terms dt:target, .refs li:target { background: var(--hl); }
.tag-meta { display: block; margin-top: 4px; font-size: .84rem; color: var(--muted); }
.refs { padding-left: 1.4em; }
.refs li { font-size: .94rem; margin-bottom: 9px; scroll-margin-top: calc(var(--top-h) + 16px); }
.refs .read { color: var(--muted); font-size: .9em; }
.next { font-family: var(--serif); color: var(--ink); }

/* ---------- lecture footer ---------- */
.lec-foot { max-width: 52rem; padding: 40px 0 8px; }
.author-box { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: .95rem; }
.author-box p { margin-bottom: 6px; }
.author-name { font-family: var(--serif); font-size: 1.1rem; margin-bottom: 4px !important; }
.author-name a { color: var(--ink); }
.lec-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 22px 0 10px; }
.lec-nav a, .lec-nav .soon { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); font: 1.04rem/1.35 var(--serif); color: var(--ink); }
.lec-nav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.lec-nav .soon { color: var(--muted); border-style: dashed; }
.lec-nav-next { text-align: right; }
.nav-k { display: block; margin: 2px 0; font: .76rem var(--sans); color: var(--muted); }
.back { font-size: .92rem; }

/* ---------- presentation mode: one frame, letterboxed to fill the screen ---------- */
.presenting { overflow: hidden; }
.presenting .dft-top, .presenting .rail, .presenting .site-copy, .presenting .lec-foot, .presenting .skip-link, .presenting .backmatter, .presenting .notes, .presenting .present-hint { display: none; }
.presenting .lec { display: block; max-width: none; padding: 0; }
.presenting .deck-slide { display: none; }
.presenting .deck-slide.current { display: grid; place-items: center; position: fixed; inset: 0; z-index: 30; max-width: none; padding: 0; border: 0; background: #0d1117; }
.presenting .deck-slide.current .frame { width: min(100vw, calc(100vh * 16 / 9)); border: 0; border-radius: 0; box-shadow: none; }
.present-help { position: fixed; right: 16px; bottom: 12px; z-index: 50; margin: 0; padding: 6px 10px; border-radius: 6px; background: rgba(17, 24, 39, .82); color: #fff; font: .78rem var(--sans); opacity: 0; transition: opacity .4s; pointer-events: none; }
.present-help.show { opacity: 1; }
.present-help kbd { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }

/* Lecture 31: phonon figures (plots, chains, matrices) */
.ph-svg { --c0: var(--accent); --c1: var(--ok); --c2: var(--warm); --c3: #9aa3af; }
.ph-svg .sb { font-size: 80%; }
.ph-svg .grid { stroke: var(--line); stroke-width: 1; }
.ph-svg .ax { stroke: var(--ink-2); stroke-width: 1.2; }
.ph-svg .zero { stroke: var(--ink-2); stroke-width: 1; }
.ph-svg .tick { font: 11.5px var(--sans); fill: var(--muted); }
.ph-svg .axl { font: 12px var(--sans); fill: var(--ink-2); }
.ph-svg .lbl { font: 600 12px var(--sans); fill: var(--ink); }
.ph-svg .lbl.m { font-weight: 400; fill: var(--muted); }
.ph-svg .lbl.big { font-size: 15px; }
.ph-svg .lbl.c0, .ph-svg .lbl.ac { fill: var(--accent-ink); }
.ph-svg .lbl.c1 { fill: #17603c; }
.ph-svg .lbl.c2, .ph-svg .lbl.op { fill: #9a4a12; }
.ph-svg .lbl.c3 { fill: #6b7280; }
.ph-svg path.c0, .ph-svg path.c1, .ph-svg path.c2, .ph-svg path.c3, .ph-svg line.c2, .ph-svg .band { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ph-svg path.c0, .ph-svg .band.ac { stroke: var(--c0); }
.ph-svg path.c1 { stroke: var(--c1); }
.ph-svg path.c2, .ph-svg line.c2, .ph-svg .band.op { stroke: var(--c2); }
.ph-svg path.c3 { stroke: var(--c3); stroke-width: 1.4; }
.ph-svg .dash { stroke-dasharray: 7 5; }
.ph-svg .dot { stroke-dasharray: 2 4; }
.ph-svg .ref { stroke: var(--ink-2); stroke-width: 1.1; stroke-dasharray: 5 4; }
.ph-svg .qline { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: .55; }
.ph-svg .pt { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.ph-svg .scan { fill: #fff; stroke: var(--warm); stroke-width: 1.6; }
.ph-svg .ball { fill: var(--ink); stroke: #fff; stroke-width: 2; }
.ph-svg .hit { fill: transparent; cursor: crosshair; }
.ph-svg .mat { font: 13px var(--mono); fill: var(--ink); white-space: pre; }
.ph-svg .rest { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 4; }
.ph-svg .bond { stroke: var(--line-strong); stroke-width: 1.4; }
.ph-svg .atom.a { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.ph-svg .atom.b { fill: var(--warm); stroke: #fff; stroke-width: 1.5; }
.ph-svg .spring { fill: none; stroke: var(--ink-2); stroke-width: 1.4; }
.ph-svg .spring2 { fill: none; stroke: var(--warm); stroke-width: 1.4; stroke-dasharray: 4 3; }
.ph-svg .ghost { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.ph-svg circle.atom { fill: #e8edf5; stroke: var(--ink-2); stroke-width: 1.4; }
.ph-svg circle.atom.on { fill: var(--accent); stroke: var(--accent-ink); }
.ph-svg .an { font: 600 12px var(--sans); fill: var(--ink); pointer-events: none; }
.ph-svg circle.atom.on + .an { fill: #fff; }
.ph-svg .force { stroke: var(--red); stroke-width: 2.4; }
.ph-svg .head { fill: var(--red); }
.ph-svg .fv { font: 11.5px var(--sans); fill: var(--red); font-variant-numeric: tabular-nums; }
.ph-svg .cell.pos { fill: #fbe3d3; }
.ph-svg .cell.neg { fill: #dde7f4; }
.ph-svg .cell.nil { fill: #f3f4f6; }
.ph-svg .cv { font: 11px var(--sans); fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.ph-svg .cv.col { font-weight: 700; fill: var(--ink); }
.ph-svg .cv.sum { font-weight: 600; fill: var(--ok); }
.ph-svg .colbox { fill: none; stroke: var(--accent); stroke-width: 2; }
.ph-svg .band-b { fill: var(--accent-soft); opacity: .7; }
.ph-svg .dist { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.2; }
.diag .ph-curve { fill: none; stroke: var(--ink-2); stroke-width: 2.6; }
.diag .ph-curve.warm { stroke: var(--warm); }
.diag .ph-cell { fill: none; stroke: var(--line-strong); stroke-width: 1.3; stroke-dasharray: 6 4; }
.fig-body:has(> .bd) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
.fig-body > .bd, .fig-body > .md { min-width: 0; min-height: 0; display: flex; }
.fig-body > .md { border-left: 1px solid var(--line); background: #fff; }
.ph-svg.rot { cursor: grab; touch-action: none; user-select: none; }
.ph-svg.rot:active { cursor: grabbing; }
.ph-svg .edge { stroke: #c3cad6; stroke-width: 1; }
.ph-svg .atA { fill: var(--accent); stroke: #fff; stroke-width: 1.2; }
.ph-svg .atB { fill: var(--warm); stroke: #fff; stroke-width: 1.2; }
.ph-svg .dos-fill { fill: #e5e7eb; stroke: #9aa3af; stroke-width: 1; }
.ph-svg .dosA { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.ph-svg .dosB { fill: none; stroke: var(--warm); stroke-width: 1.8; }
.ph-svg .qarrow { stroke: var(--ink); stroke-width: 2; }
.ph-svg .qhead { fill: var(--ink); }
.ph-svg .atAc { fill: #7c8aa5; stroke: #fff; stroke-width: 1.2; }
.ph-svg .atBc { fill: var(--accent); stroke: #fff; stroke-width: 1.2; }
.ph-svg .atO { fill: var(--red); stroke: #fff; stroke-width: 1; }
.ph-svg .bo { stroke: var(--accent); stroke-width: 1.6; opacity: .7; }
.ph-svg .oct { stroke: #efc6c1; stroke-width: 1; }
.fig-panel .warn { color: #9a4a12; font-weight: 600; }
.fig-panel .seg { font-size: .95em; }

/* ---------- narrow columns: the frame reflows instead of shrinking ---------- */
@container main (max-width: 640px) {
  .deck-slide { max-width: none; padding: 22px 0 28px; }
  .frame { aspect-ratio: auto; container-type: normal; }
  .frame-in { position: static; padding: 20px 18px 34px; font-size: 15.5px; }
  .frame-foot { bottom: 10px; left: 18px; right: 18px; font-size: 11px; }
  .claim { font-size: 1.35em; }
  .ev { justify-content: flex-start; }
  .cols, .cols.wl, .cols.wr, .cols-3, .eqbox.eq-split, .fits, .fig.side { grid-template-columns: minmax(0, 1fr); }
  .fig.side > .fig-body, .fig.side > .fig-panel, .fig.side > figcaption { grid-column: 1; grid-row: auto; }
  .fig.side > .fig-panel { border-left: 0; border-top: 1px solid var(--line); }
  .tiles, .flips { grid-template-columns: minmax(0, 1fr); }
  .tiles.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fits > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .deck-title h1 { font-size: 2em; }
  .fig-body { overflow-x: auto; justify-content: flex-start; }
  .fig-body:has(> .bd) { grid-template-columns: minmax(0, 1fr); }
  .fig-body > .md { border-left: 0; border-top: 1px solid var(--line); }
  .run-fig .run-svg { min-width: 600px; }
  .dft .fig-body svg { height: auto; }
  .conv { border-left: 0; border-top: 1px solid var(--line); }
  .ham-svg { max-width: 320px; }
  .diag { height: auto; }
}

/* ---------- course home ---------- */
.home-in { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.home-hero { padding: 64px 0 44px; border-bottom: 1px solid var(--line); }
.home-hero h1 { font-size: clamp(2.4rem, 5vw, 3.4rem); letter-spacing: -.02em; margin-bottom: 12px; }
.tagline { font-family: var(--serif); font-size: clamp(1.2rem, 2.2vw, 1.5rem); line-height: 1.4; color: var(--ink); max-width: 34em; margin-bottom: 18px; }
.home-lede { font-size: 1.04rem; max-width: 46em; }
.home-cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 0; }
.home-cta [hidden] { display: none; }
.soon-note { color: var(--muted); font-style: italic; }
.home-block { padding: 48px 0; border-bottom: 1px solid var(--line); }
.home-block h2, .part h2 { font-size: clamp(1.4rem, 2.4vw, 1.75rem); letter-spacing: -.01em; margin-bottom: 10px; }
.thread { list-style: none; display: flex; flex-wrap: wrap; row-gap: 10px; margin: 22px 0 0; padding: 0; }
.thread li { display: flex; align-items: center; }
.thread li + li::before { content: "→"; margin: 0 9px; color: var(--muted); }
.thread .pill { display: inline-block; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-size: .9rem; color: var(--ink); white-space: nowrap; }
.thread span.pill { color: var(--ink-2); border-style: dashed; }
.thread a.pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-top: 18px; }
.how-grid h3 { font-size: 1.06rem; margin-bottom: 6px; }
.how-grid p { font-size: .95rem; margin: 0; }
.syllabus { padding-top: 12px; padding-bottom: 36px; }
.part { padding: 36px 0 8px; }
.part + .part { border-top: 1px solid var(--line); }
.part-no { color: var(--muted); font-weight: 400; }
.cards { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card > a, .card.soon { display: flex; flex-direction: column; height: 100%; padding: 16px 18px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink-2); }
.card > a:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(17, 24, 39, .06); text-decoration: none; }
.card.soon { background: var(--bg-soft); }
.card-no { font-size: .72rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.card h3 { font-size: 1.08rem; margin: 6px 0; }
.card.soon h3 { color: var(--ink-2); }
.card-q { flex: 1; margin: 0 0 12px; font-size: .9rem; }
.card-meta { margin: 0; font-size: .8rem; color: var(--muted); }
.card-done { display: none; }
.card.done .card-done { display: inline; color: var(--ok); }
.card.done > a { border-color: #b8dcc8; }
.milestone { margin: 18px 0 0; padding: 12px 16px; border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--accent-soft); font-size: .93rem; }
.milestone b { color: var(--accent-ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.checked { padding-left: 1.2em; font-size: .95rem; }
.checked li { margin-bottom: 6px; }
.errata { padding-left: 1.2em; font-size: .92rem; }
.about p { max-width: 50em; }


/* ---------- small screens ---------- */
@media (max-width: 1080px) {
  .lec { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .rail { display: none; }
}
@media (max-width: 880px) {
  .how-grid, .two { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 720px) {
  .dft-top-in, .lec, .home-in { padding-left: 16px; padding-right: 16px; }
  .dft-top .brand { display: none; }
  .crumbs > :first-child::before { content: none; }
  .lec-nav { grid-template-columns: 1fr; }
  .home-hero { padding: 44px 0 32px; }
}

/* ---------- print: each slide on its own with its notes, as a handout ---------- */
@media print {
  .dft-top, .rail, .present-help, .present-hint, .pop, .lec-nav, .back, .skip-link { display: none !important; }
  .lec { display: block; padding: 0; }
  .deck-slide { max-width: none; padding: 12px 0 18px; border: 0 !important; break-inside: avoid-page; }
  .frame { box-shadow: none; break-inside: avoid; }
  .notes details { break-inside: avoid; }
  a.ref, a.vtag { border: 0; background: none; padding: 0; }
}
