/* ==========================================================================
   stay add. — the standard lesson form, any subject
   The chapter's topics on the left (its tile, then each topic with what it
   covers, and how many you have opened); one topic at a time on the right.
   Each topic opens with its title, lede and contents, then numbered steps —
   1 Understand · 2 Experiment / Look closely · 3 Interpret · 4 Flashcards.
   A 64px number column (--gut) holds step and section numbers; text keeps a
   reading width (--measure), figures and labs use the full width.
   ========================================================================== */

:root { --side-w: 288px; --gutter: clamp(20px, 3.6vw, 64px); --measure: 720px; --gut: 64px; }
:root, .on-dark { --paper: var(--surface); --focus: var(--accent); --mark: var(--amber); }   /* re-resolved inside dark labs */

/* ---------- Page ---------- */
.l-app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); }
.l-app b, .l-app strong { color: var(--ink); font-weight: 600; }
.l-app p, .l-app li { text-wrap: pretty; }

/* ---------- Sidebar: the chapter tile, its topics, progress ---------- */
.side { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; display: flex; flex-direction: column; padding: 28px 20px 20px 24px; border-right: 1px solid var(--line); scrollbar-width: thin; }
.tabs { display: flex; flex-direction: column; gap: 2px; counter-reset: lab; }
/* the chapter: its syllabus number on a tile in the subject's ink, then its name */
.nav-group { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center; margin-bottom: 20px; font: 500 18px/1.15 var(--font-display); letter-spacing: -0.025em; color: var(--ink); }
.nav-group span { display: grid; align-content: space-between; width: 48px; height: 48px; padding: 5px 6px; border-radius: var(--radius-xs); background: var(--subj); color: var(--tile-ink); font: 600 17px/1 var(--font-display); letter-spacing: -0.03em; }
.nav-group span::before { content: "topic"; font: 500 9px/1 var(--font-mono); letter-spacing: 0; opacity: .7; }
.tabs a { counter-increment: lab; display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 14.5px; line-height: 1.3; color: var(--ink-2); transition: color var(--t-fast), background-color var(--t-fast); }
.tabs a::before { content: counter(lab); grid-row: span 2; display: grid; place-items: center; width: 22px; height: 22px; margin-top: -2px; border-radius: 6px; font: 500 11px/1 var(--font-mono); color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line-2); transition: background-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.tabs a::after { content: attr(data-full); grid-column: 2; margin-top: 2px; font-size: 12.5px; line-height: 1.4; color: var(--ink-3); }
.tabs a:hover { color: var(--ink); background: var(--bg-2); }
.tabs a[aria-current="page"] { background: var(--raised); color: var(--ink); font-weight: 500; box-shadow: 0 0 0 1px var(--line), var(--shadow); }
.tabs a[aria-current="page"]::before { background: var(--subj); color: var(--tile-ink); box-shadow: none; }
.tabs a[aria-current="page"]::after { font-weight: 400; color: var(--ink-2); }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.55; color: var(--ink-3); }
.side-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 13px; color: var(--ink-2); }
.side-count { font: 500 12px var(--font-mono); color: var(--ink); }
.side-steps { display: flex; gap: 3px; margin-bottom: 12px; }
.side-steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); transition: background-color var(--t-med); }
.side-steps i.done { background: color-mix(in srgb, var(--subj) 70%, var(--ink-3)); }
.side-steps i.now { background: var(--ink); }
.side-foot b { font: 500 12px var(--font-mono); color: var(--ink-2); }

/* ---------- Topic ---------- */
.l-main { width: 100%; max-width: 1180px; margin: 0; padding: 56px var(--gutter) 112px; min-width: 0; }
.topic { scroll-margin-top: var(--header-h); animation: topic-in .32s var(--ease); }
@keyframes topic-in { from { opacity: 0; transform: translateY(6px); } }

/* title, lede and (for long topics) the contents */
.t-head { display: grid; gap: 20px; max-width: calc(var(--gut) + var(--measure)); }
.t-head > .t-art { display: none; }
.t-head .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.t-head .eyebrow span { display: inline-grid; place-items: center; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--subj); color: var(--tile-ink); font-weight: 500; }
.t-head h1 { font: 500 clamp(40px, 2.6vw + 22px, 64px)/1.02 var(--font-display); letter-spacing: -0.03em; color: var(--ink); text-wrap: balance; }
.lede { max-width: var(--measure); font-size: 19px; line-height: 1.55; color: var(--ink-2); }
.t-art .ax { fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.t-art .el { fill: var(--ink-3); }
.t-art .cu { fill: #b5683a; }
.t-art .sg { font: 500 12px var(--font-mono); fill: var(--ink); }
.t-art .p-cat { fill: var(--c-cation); }
.t-art .p-an { fill: var(--c-anion); }
.t-art .p-h { fill: none; stroke: var(--c-cation); stroke-width: 1.5; }
.t-art .p-oh { fill: none; stroke: var(--c-anion); stroke-width: 1.5; }
.t-art .bub { fill: none; stroke: var(--ink-3); stroke-width: 1.25; }
.t-art .arr { fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 3 3; }

/* the steps: a hairline, the step number on a small ink tile in the number column, its name and what it holds */
.step { display: grid; gap: 28px; margin-top: 96px; }
.t-head + .step { margin-top: 64px; }
.step-h { display: grid; grid-template-columns: var(--gut) minmax(0, 1fr); align-items: center; padding-top: 20px; border-top: 1px solid var(--line-2); }
.step-n { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--ink); color: var(--bg); font: 500 13px/1 var(--font-mono); }
.step-n::before { content: "0"; }
.step-h > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.step-h h2 { font: 500 32px/1.1 var(--font-display); letter-spacing: -0.025em; color: var(--ink); }
.step-h p { font-size: 15px; color: var(--ink-3); }
.step > :not(.step-h):not(.secs) { margin-left: var(--gut); }

/* Understand (lab lessons): the notes side by side when there is room, each at a reading width */
.notes { display: grid; gap: 40px 48px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); align-items: start; }
.note { display: grid; gap: 14px; min-width: 0; max-width: var(--measure); font-size: 16.5px; color: var(--text); }
.note h3 { font: 500 22px/1.2 var(--font-display); letter-spacing: -0.025em; color: var(--ink); }
.note p, .note li { line-height: 1.7; }
.note ul { list-style: none; display: grid; gap: 6px; }
.note li { position: relative; padding-left: 22px; }
.note li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 7px; height: 7px; border-radius: 2px; background: var(--subj); }
/* the definition that opens a topic: a card in the subject's ink */
.notes .note:first-child > p:first-of-type { padding: 16px 20px; border-radius: 12px; background: color-mix(in srgb, var(--subj) 18%, var(--surface)); font-size: 18px; line-height: 1.6; color: var(--ink); }
.kC { color: var(--c-cation); font-weight: 600; }
.kA { color: var(--c-anion); font-weight: 600; }
.note .formula { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--bg-2); font: 400 14.5px/1.65 var(--font-mono); color: var(--ink); }

/* ---------- The lab: the one object lifted off the page ---------- */
.lab { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); container-type: inline-size; scroll-margin-top: calc(var(--header-h) + 20px); min-width: 0; overflow: hidden; }
.lab-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--line); }
.lab-title { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; color: var(--ink); }
.lab-title::before { content: "Fig. " attr(data-fig); flex: none; padding: 3px 7px; border-radius: 5px; background: var(--bg-2); font: 500 11.5px/1.2 var(--font-mono); color: var(--ink-2); }

.lab-body { display: grid; gap: 16px; padding: 16px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "graph" "dock" "explain"; }
.lab-body > .graph { grid-area: graph; }
.lab-body > .dock { grid-area: dock; }
.lab-body > .explain { grid-area: explain; }
@container (min-width: 720px) {
  .lab-body { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "graph dock" "explain dock"; gap: 16px 0; padding: 0; align-items: stretch; }
  .lab-body > .graph { margin: 16px 16px 0; }
  .lab-body > .explain { margin: 0 16px 16px; align-self: start; }
  .lab-body > .dock { border-left: 1px solid var(--line); background: var(--bg); }
  .dock .block { padding: 16px 20px 18px; }
}
.graph { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-width: 0; }
.graph svg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.key { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 6px 6px 2px; font: 12px/1.45 var(--font-mono); color: var(--ink-3); }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }

.dock { display: grid; align-content: start; min-width: 0; }
.block { display: grid; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); min-width: 0; }
.block:first-child { padding-top: 0; border-top: 0; }
.block-h { font: 500 12px/1.4 var(--font-mono); color: var(--ink-3); }
.group { display: grid; gap: 8px; }
.group > p { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.group > p .hint { margin-left: 6px; font-size: 12.5px; font-weight: 400; color: var(--ink-3); }

/* one button style; selected = filled with ink */
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.sc, .ghost { border-radius: var(--radius-sm); font-size: 13px; line-height: 1.3; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform .1s var(--ease); }
.sc { padding: 7px 11px; background: var(--raised); border: 1px solid var(--line-2); color: var(--ink); text-align: left; }
.sc:hover { border-color: var(--ink-3); }
.sc[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.ghost { height: 32px; padding: 0 12px; border: 1px solid var(--line-2); background: var(--raised); color: var(--ink); }
.ghost:hover { border-color: var(--ink-3); }
.sc:active, .ghost:active, .seg button:active, .chain:active { transform: scale(.98); }

/* results */
.rows { display: grid; font-variant-numeric: tabular-nums; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.row:first-child { padding-top: 0; }
.row:last-child { border-bottom: 0; }
.row .k { font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.row .v { font: 500 14px var(--font-mono); color: var(--ink); text-align: right; white-space: nowrap; }
.rows .row:first-child { padding-bottom: 10px; }
.rows .row:first-child .k { align-self: center; }
.rows .row:first-child .v { font-size: 22px; letter-spacing: -0.02em; }

/* what just happened */
.explain { display: grid; gap: 10px; min-width: 0; background: var(--bg-2); border-radius: 12px; padding: 16px 18px 18px; }
.result { display: grid; gap: 10px; min-width: 0; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 2px 7px; border-radius: 5px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); font: 500 11.5px/1.5 var(--font-mono); color: var(--ink-2); }
.chip.up, .chip.down, .chip.warn { --cc: var(--ok); color: var(--cc); background: color-mix(in srgb, var(--cc) 10%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cc) 40%, transparent); }
.chip.down { --cc: var(--red); }
.chip.warn { --cc: var(--mark); }
.result h3 { font: 500 22px/1.2 var(--font-display); letter-spacing: -0.025em; color: var(--ink); text-wrap: balance; }
.result p { line-height: 1.7; max-width: 68ch; }
.result .follow { padding-top: 10px; border-top: 1px dashed var(--line-2); font-size: 14px; }
.result .num { font-size: .92em; }
.flow, .chain { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.flow { padding-top: 12px; border-top: 1px dashed var(--line-2); }
.flow span + span::before, .chain span + span::before { content: "→"; margin: 0 8px; font-family: var(--font-mono); color: var(--ink-4); }
.flow span:first-child, .chain span:first-child { color: var(--ink); font-weight: 500; }
.flow span:last-child, .chain span:nth-last-child(2) { color: var(--ink); font-weight: 600; }
.c-cat { color: var(--c-cation); }
.c-an { color: var(--c-anion); }

/* ---------- Interpret: chains to remember, one tip, the checklist ---------- */
.interpret { display: grid; gap: 32px; max-width: var(--measure); }
.chains { display: grid; border-top: 1px solid var(--line-2); counter-reset: chain; }
/* the number hangs in its own 40px column, so a chain that wraps stays aligned */
.chain { position: relative; width: 100%; padding: 16px 12px 16px 44px; border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.55; color: var(--text); text-align: left; transition: background-color var(--t-fast); }
.chain::before { counter-increment: chain; content: counter(chain, decimal-leading-zero); position: absolute; left: 4px; top: 16px; font: 500 12px/1.95 var(--font-mono); color: var(--subj-ink); }
.chain em { margin-left: auto; padding-left: 16px; font-style: normal; font: 500 12px var(--font-mono); color: var(--ink-3); white-space: nowrap; transition: color var(--t-fast); }
.chain em::after { content: "\00a0→"; }
button.chain:hover { background: var(--surface); }
button.chain:hover em { color: var(--accent-ink); }
.interpret .tip, .sec-b .note-k { padding: 16px 20px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: 16px; line-height: 1.7; color: var(--text); }
.interpret .tip b:first-child, .sec-b .note-k b:first-child { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font: 500 12.5px var(--font-mono); color: var(--accent-ink); }
.interpret .tip b:first-child::before, .sec-b .note-k b:first-child::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }

/* ---------- Long topics: contents, numbered sections, key terms, checklist ---------- */
/* "In this topic": the sections, each a jump link */
.toc { display: grid; max-width: var(--measure); margin-top: 4px; border-top: 1px solid var(--line-2); }
.toc button { display: flex; gap: 16px; align-items: baseline; padding: 11px 8px 11px 0; border-bottom: 1px solid var(--line); font-size: 15.5px; color: var(--ink); text-align: left; transition: color var(--t-fast); }
.toc button span { min-width: 44px; font: 500 12px var(--font-mono); color: var(--ink-3); transition: color var(--t-fast); }
.toc button::after { content: "↓"; margin-left: auto; color: var(--ink-4); transition: color var(--t-fast), transform var(--t-med) var(--ease); }
.toc button:hover span { color: var(--subj-ink); }
.toc button:hover::after { color: var(--ink); transform: translateY(2px); }
.secs { display: grid; max-width: calc(var(--gut) + var(--measure)); }
.sec { display: grid; grid-template-columns: var(--gut) minmax(0, 1fr); padding: 36px 0; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--header-h) + 24px); }
.sec:first-child { padding-top: 8px; border-top: 0; }
.sec-n { font: 500 12px/2.6 var(--font-mono); color: var(--subj-ink); }
.sec-b { display: grid; gap: 14px; min-width: 0; font-size: 16.5px; color: var(--text); }
.sec-b h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font: 500 26px/1.18 var(--font-display); letter-spacing: -0.03em; color: var(--ink); }
.sec-b h4 { font-size: 17px; font-weight: 600; color: var(--ink); margin-top: 6px; }
.sec-b p, .sec-b li { line-height: 1.7; }
.sec-b ul, .sec-b ol { display: grid; gap: 6px; }
.sec-b ul { list-style: none; }
.sec-b ul li { position: relative; padding-left: 22px; }
.sec-b ul li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 7px; height: 7px; border-radius: 2px; background: var(--subj); }
.sec-b ol { padding-left: 24px; }
.sec-b ol li::marker { font: 500 13px var(--font-mono); color: var(--ink-3); }
.sec-b .formula { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--bg-2); font: 400 14.5px/1.65 var(--font-mono); color: var(--ink); }
.sec-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.sec-table th { font: 500 12px var(--font-mono); color: var(--ink-3); text-align: left; padding: 8px 14px 8px 0; border-bottom: 1px solid var(--line-2); vertical-align: bottom; }
.sec-table td { padding: 10px 14px 10px 0; border-bottom: 1px solid var(--line); color: var(--text); vertical-align: top; line-height: 1.55; }
.sec-table td:first-child { color: var(--ink); font-weight: 500; }
.sec-table tbody tr:hover td { background: color-mix(in srgb, var(--subj) 8%, transparent); }
.table-wrap { overflow-x: auto; }
.practical { display: grid; gap: 10px; padding: 18px 20px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.practical h4 { margin: 0; font: 600 15px var(--font-sans); color: var(--ink); }
.punnett { border-collapse: separate; border-spacing: 4px; font: 500 14px var(--font-mono); }
.punnett th, .punnett td { width: 60px; height: 40px; text-align: center; border-radius: 6px; }
.punnett th { color: var(--ink-3); font-weight: 500; background: var(--bg-2); }
.punnett td { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); }
.punnett td.hl { background: color-mix(in srgb, var(--subj) 40%, var(--surface)); box-shadow: none; }
.punnett-row { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; }
.punnett-row p { font-size: 14px; }
.terms { display: grid; grid-template-columns: minmax(130px, max-content) minmax(0, 1fr); border-top: 1px solid var(--line-2); }
.terms dt, .terms dd { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.55; }
.terms dt { padding-right: 20px; color: var(--ink); font-weight: 600; }
.terms dd { color: var(--text); }
.summary { list-style: none; display: grid; gap: 6px; }
.checklist { display: grid; }
.checklist-h { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.checklist-h p { font: 500 20px var(--font-display); letter-spacing: -0.025em; color: var(--ink); }
.checklist-h .num { font-size: 13px; color: var(--ink-3); }
.checklist label { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.5; color: var(--text); cursor: pointer; }
.checklist input { appearance: none; -webkit-appearance: none; display: grid; place-items: center; margin-top: 2px; width: 20px; height: 20px; border-radius: 6px; background: var(--raised); box-shadow: inset 0 0 0 1.5px var(--line-2); cursor: pointer; transition: background-color var(--t-fast), box-shadow var(--t-fast); }
.checklist input::after { content: ""; width: 10px; height: 6px; margin-top: -2px; border: solid var(--bg); border-width: 0 0 2px 2px; transform: rotate(-45deg) scale(0); transition: transform var(--t-fast) var(--ease); }
.checklist input:hover { box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.checklist input:checked { background: var(--ink); box-shadow: none; }
.checklist input:checked::after { transform: rotate(-45deg) scale(1); }
.checklist input:checked + span { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-4); }
.step > .plate + .plate, .step > .lab + .plate { margin-top: 4px; }

/* a topic without a lab: chains are lines to remember, not buttons */
p.chain { cursor: default; }
p.chain span:nth-last-child(2) { color: var(--ink-2); font-weight: 400; }
p.chain span:last-child { color: var(--ink); font-weight: 600; }

/* step 2 without a lab: one framed figure ("Look closely"), optionally with a table */
.plate { min-width: 0; }
.plate-h { padding: 0 0 10px; }
.plate-fig { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.plate-fig svg { display: block; width: 100%; height: auto; }
.plate figcaption { max-width: var(--measure); padding: 14px 0 0; font-size: 15.5px; line-height: 1.65; color: var(--text); }
.plate figcaption b { color: var(--ink); }
.plate-table { width: 100%; margin: 16px 0 0; border-collapse: collapse; font-size: 13.5px; }
.plate-table th { font: 500 12px var(--font-mono); color: var(--ink-3); text-align: left; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line-2); }
.plate-table td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: top; }
.plate-table td:first-child { color: var(--ink); font-weight: 500; white-space: nowrap; }

/* Previous / Next: the next topic is the obvious way on */
.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 112px; }
.pager a { display: grid; gap: 8px; padding: 22px 24px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); font: 500 22px/1.2 var(--font-display); letter-spacing: -0.03em; transition: box-shadow var(--t-fast), background-color var(--t-fast), transform .1s var(--ease); }
.pager a:hover { box-shadow: inset 0 0 0 1px var(--ink-3); background: var(--raised); }
.pager a:active { transform: scale(.99); }
.pager small { font: 500 12px var(--font-mono); letter-spacing: 0; color: var(--ink-3); }
.pager [data-next] { grid-column: 2; text-align: right; background: var(--ink); box-shadow: none; color: var(--bg); }
.pager [data-next] small { color: color-mix(in srgb, var(--bg) 62%, var(--ink)); }
.pager [data-next]:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); box-shadow: none; }

/* ---------- Cell figure parts ---------- */
.graph .wire { fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.graph .psu { fill: var(--raised); stroke: var(--ink-3); }
.graph .beaker { fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.graph .liquid { fill: var(--liq, color-mix(in srgb, var(--ink) 4%, transparent)); transition: fill .4s; }
.graph .electrode { fill: var(--ink-3); }
.graph text { font: 10px var(--font-mono); fill: var(--ink-3); }
.graph .lbl-ink { fill: var(--ink-2); }
.graph .sign { font: 500 13px var(--font-mono); fill: var(--ink); }
.graph .p-cat { fill: var(--c-cation); }
.graph .p-an { fill: var(--c-anion); }
.graph .p-h { fill: var(--surface); stroke: var(--c-cation); stroke-width: 1.5; }
.graph .p-oh { fill: var(--surface); stroke: var(--c-anion); stroke-width: 1.5; }
.graph .ion-t { font: 500 8.5px var(--font-mono); fill: var(--surface); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.graph .ion-t.dark { fill: var(--ink); }
.graph .electron { fill: var(--c-electron); }
.graph .track { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; }
.graph .solid-l { font: italic 400 15px var(--font-serif); fill: var(--ink-3); }

/* ---------- Displayed formulae (organic lessons) ---------- */
.fig .bd { stroke: var(--ink-3); stroke-width: 1.6; stroke-linecap: round; }
.fig .bd.g { stroke: var(--c-group); }
.fig .at { font: 500 20px var(--font-sans); fill: var(--ink-2); text-anchor: middle; dominant-baseline: central; }
.fig .at.c { fill: var(--c-chain); }
.fig .at.h { font-weight: 400; fill: var(--ink-3); }
.fig .at.g { fill: var(--c-group); }
.fig .at.a { fill: var(--c-alcohol); }
.fig .cn { font: 500 11px var(--font-mono); fill: var(--c-chain); text-anchor: middle; }
.fig .brk { fill: none; stroke-width: 1.25; }
.fig .brk.c { stroke: var(--c-chain); }
.fig .brk.a { stroke: var(--c-alcohol); }
.fig .brk-t { font: 500 12px var(--font-mono); text-anchor: middle; }
.fig .brk-t.c { fill: var(--c-chain); }
.fig .brk-t.a { fill: var(--c-alcohol); }
.mol .mol-in { animation: mol-in .35s var(--ease); }
@keyframes mol-in { from { opacity: 0; transform-box: fill-box; } }
.t-art .at { font-size: 24px; }
.nm-pre { color: var(--c-chain); font-weight: 600; }
.nm-suf { color: var(--c-group); font-weight: 600; }
.nm-pos { color: var(--ink-3); }
.nm-alc { color: var(--c-alcohol); font-weight: 600; }
.result h3 .nm-pre, .result h3 .nm-suf, .result h3 .nm-alc { font-weight: 500; }
.seg button small { display: block; font: 10.5px var(--font-mono); color: var(--ink-3); }
.fig .bd.s { stroke: var(--c-sub); }
.fig .at.s { fill: var(--c-sub); }
.fig .at.lbl { font-size: 15px; }
.fig .hit-c { fill: transparent; cursor: pointer; }
.fig .hit-c:hover { fill: color-mix(in srgb, var(--c-sub) 12%, transparent); stroke: var(--c-sub); stroke-dasharray: 3 3; }
.nm-sub { color: var(--c-sub); font-weight: 600; }
.result h3 .nm-sub { font-weight: 500; }
.seg-6 button { padding-left: 2px; padding-right: 2px; }
.steps7 { list-style: none; display: grid; gap: 6px; padding-top: 12px; border-top: 1px dashed var(--line-2); font-size: 14px; color: var(--ink-2); }
.steps7 li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.steps7 .s7 { font-size: 11px; color: var(--ink-3); }
.steps7 b { color: var(--ink); font-weight: 600; }
.opts { display: grid; gap: 6px; margin-bottom: 12px; }
.opt { text-align: left; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--raised); font-size: 14px; color: var(--ink); transition: border-color var(--t-fast), background-color var(--t-fast); }
.opt:hover:not(:disabled) { border-color: var(--ink-3); }
.opt.is-right { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--raised)); }
.opt.is-wrong { border-color: var(--red); color: var(--red); text-decoration: line-through; }
.opt.is-dim { opacity: .5; }
.opt:disabled { cursor: default; }

/* ---------- Flashcards: the last step of every topic (assets/js/flashcards.js) ---------- */
.deck { display: grid; gap: 16px; max-width: var(--measure); outline: none; }
.deck:focus-visible { outline: 2px solid var(--accent); outline-offset: 8px; border-radius: 4px; }
.deck [hidden] { display: none !important; }
.deck-modes { display: inline-grid; grid-auto-flow: column; gap: 3px; padding: 3px; width: max-content; max-width: 100%; border-radius: 10px; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); }
.deck-mode { display: inline-flex; align-items: baseline; justify-content: center; gap: 8px; padding: 7px 14px; border-radius: 7px; font: 500 14px var(--font-sans); color: var(--ink-2); transition: background-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.deck-mode .num { font-size: 12px; color: var(--ink-3); }
.deck-mode:hover { color: var(--ink); }
.deck-mode[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, .08); }
.deck-nav { display: flex; align-items: center; gap: 12px; }
.deck-nav .btn { gap: 8px; }
.deck-nav .btn:disabled { opacity: .35; cursor: default; }
.deck-nav .btn:disabled:hover { border-color: var(--line-2); background: var(--surface); }
.deck-next { margin-left: auto; }
.deck-mark { font-size: 12px; color: var(--ink-3); }
.deck-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; font-size: 13px; color: var(--ink-3); }
.deck-count { color: var(--ink); }
.deck-link { margin-left: auto; font: 500 13px var(--font-mono); color: var(--ink-3); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-2); transition: color var(--t-fast), text-decoration-color var(--t-fast); }
.deck-link:hover { color: var(--ink); text-decoration-color: var(--ink); }
.deck-meter { display: flex; gap: 3px; }
.deck-meter i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); transition: background-color var(--t-med); }
.deck-meter i.now { background: var(--ink-3); }
.deck-meter i.ok { background: var(--green); }
.deck-meter i.miss { background: var(--amber); }

.fcard { display: block; width: 100%; padding: 0; perspective: 1400px; text-align: left; cursor: pointer; border-radius: 16px; }
.fcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.fcard-in { display: grid; min-height: 260px; transform-style: preserve-3d; transition: transform .5s var(--ease); }
.fcard.flipped .fcard-in { transform: rotateY(180deg); }
.fcard.instant .fcard-in { transition: none; }
.fcard-face { grid-area: 1 / 1; display: flex; flex-direction: column; gap: 14px; padding: 24px 28px; border-radius: 16px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: box-shadow var(--t-fast); }
.fcard-back { transform: rotateY(180deg); background: color-mix(in srgb, var(--subj) 20%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--subj) 60%, var(--line)); }
.fcard:hover .fcard-front { box-shadow: inset 0 0 0 1px var(--ink-3), var(--shadow); }
.fcard-k { display: flex; align-items: center; gap: 8px; font: 500 12px var(--font-mono); color: var(--ink-3); }
.fcard-k::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--subj); }
.fcard-t { flex: 1; display: flex; align-items: center; font: 500 23px/1.35 var(--font-display); letter-spacing: -0.02em; color: var(--ink); white-space: pre-line; }
.fcard-back .fcard-t { font: 400 18.5px/1.6 var(--font-sans); letter-spacing: 0; color: var(--ink); }
.fcard-hint { font: 12px var(--font-mono); color: var(--ink-3); }
.fcard.enter .fcard-in { animation: fcard-in .28s var(--ease); }
@keyframes fcard-in { from { opacity: 0; translate: 0 6px; } }

.deck-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.deck-actions .btn { flex: 1 1 180px; }
.deck-actions kbd { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; box-shadow: inset 0 0 0 1px currentColor; font: 11px/1 var(--font-mono); opacity: .6; }

.deck-done { display: grid; gap: 14px; padding: 24px 28px; border-radius: 16px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); }
.deck-score { font: 500 18px var(--font-display); color: var(--ink-3); }
.deck-score b { margin-right: 4px; font: 500 44px/1 var(--font-display); letter-spacing: -0.03em; color: var(--ink); }
.deck-msg { font-size: 16px; color: var(--text); }
.deck-missed { display: grid; gap: 6px; padding-left: 22px; font-size: 15.5px; line-height: 1.5; color: var(--text); }
.deck-missed li::marker { font: 12px var(--font-mono); color: var(--ink-3); }
.deck-done .deck-actions { margin-top: 6px; }

/* ---------- Jump links: to the experiment and the flashcards of the open topic (lesson.js) ---------- */
.step { scroll-margin-top: calc(var(--header-h) + 24px); }
.jumps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.jumps-h { margin-right: 4px; font: 500 12px var(--font-mono); color: var(--ink-3); }
.jump { display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); font: 500 14px var(--font-sans); color: var(--ink); transition: box-shadow var(--t-fast), background-color var(--t-fast), transform .1s var(--ease); }
.jump .num { font-size: 11.5px; color: var(--ink-3); }
.jump::after { content: "↓"; color: var(--ink-3); transition: transform var(--t-med) var(--ease); }
.jump:hover { box-shadow: inset 0 0 0 1px var(--ink-3); background: var(--raised); }
.jump:hover::after { transform: translateY(2px); }
.jump:active { transform: scale(.98); }
.jump-cards { background: var(--ink); box-shadow: none; color: var(--bg); }
.jump-cards .num, .jump-cards::after { color: var(--bg); opacity: .6; }
.jump-cards:hover { background: color-mix(in srgb, var(--ink) 84%, var(--bg)); box-shadow: none; }
.side-jump { display: grid; gap: 6px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.side-jump p { margin-bottom: 2px; font: 500 12px var(--font-mono); color: var(--ink-3); }
.side-jump .jump { width: 100%; }
.side-jump .jump::after { margin-left: auto; }

/* ---------- Small screens ---------- */
@media (max-width: 1100px) { :root { --side-w: 248px; } }
@media (max-width: 900px) {
  .l-app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: var(--header-h); z-index: 20; height: auto; padding: 0 16px; border-right: 0; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); overflow: visible; }
  .tabs { flex-direction: row; gap: 4px; padding: 8px 0; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .tabs::-webkit-scrollbar { display: none; }
  .nav-group, .side-foot, .tabs a::after { display: none; }
  .tabs a, .tabs a[aria-current="page"] { display: flex; align-items: center; gap: 8px; flex: none; padding: 6px 12px 6px 6px; white-space: nowrap; font-size: 14px; }
  .tabs a::before { grid-row: auto; margin: 0; }
  .l-main { padding: 36px var(--gutter) 72px; }
  .lab, .step { scroll-margin-top: calc(var(--header-h) + 64px); }
  .side-jump { display: none; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; --gut: 0px; }
  .t-head { gap: 16px; }
  .t-head h1 { font-size: 36px; }
  .lede { font-size: 17.5px; }
  .step, .t-head + .step { margin-top: 64px; }
  .step-h { grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; }
  .step-n { width: 30px; height: 30px; font-size: 12px; }
  .step-h h2 { font-size: 26px; }
  .sec { grid-template-columns: minmax(0, 1fr); padding: 28px 0; }
  .sec-n { line-height: 1.6; margin-bottom: 4px; }
  .note, .sec-b { font-size: 16.5px; }
  .sec-b h3 { font-size: 23px; }
  .terms { grid-template-columns: 1fr; }
  .terms dt { border-bottom: 0; padding-bottom: 0; }
  .sec-table { font-size: 13.5px; }
  .punnett th, .punnett td { width: 52px; height: 36px; font-size: 13px; }
  .lab { border-radius: 14px; }
  .lab-h { padding: 8px 10px 8px 12px; }
  .lab-body { padding: 10px; gap: 14px; }
  .graph { padding: 4px; }
  .graph text { font-size: 15px; }
  .graph .ion-t { font-size: 10px; }
  .explain { padding: 14px 14px 16px; }
  .plate-fig { padding: 4px; }
  .plate-table { font-size: 12.5px; }
  .chain { padding-left: 36px; padding-right: 4px; }
  .chain::before { left: 0; }
  .chain em { flex-basis: 100%; margin-left: 0; padding-left: 0; margin-top: 4px; }
  .pager { grid-template-columns: 1fr; margin-top: 80px; }
  .pager [data-next] { grid-column: 1; grid-row: 1; }
  .pager a { font-size: 19px; }
  .fcard-in { min-height: 220px; }
  .fcard-face, .deck-done { padding: 20px 18px; }
  .fcard-t { font-size: 20px; }
  .fcard-back .fcard-t { font-size: 17px; }
  .deck-modes { width: 100%; grid-auto-columns: 1fr; }
  .deck-mode { padding: 7px 6px; }
  .deck-mark { display: none; }
}
