/* Layout: one centred working column on a faint graph-paper ground; cards only for the question
   bench and topic tiles. Ink-blue accent, amber "signal" trace for hints and highlights. */
/* The web build of JetBrains Mono lacks most Unicode sub/superscript digits (f₀, 10⁻⁹): take only those
   code points from a system monospace font that has them. */
@font-face {
  font-family: "MonoScripts";
  src: local("Consolas"), local("Cascadia Mono"), local("Menlo"), local("SF Mono"), local("DejaVu Sans Mono"), local("Noto Sans Mono"), local("Roboto Mono");
  unicode-range: U+00B2-00B3, U+00B9, U+2070-209F;
}
:root {
  --bg: #f3f5f8;
  --grid: rgba(40, 70, 120, 0.06);
  --surface: #ffffff;
  --surface-2: #e9edf3;
  --fg: #17202c;
  --muted: #5a6779;
  --line: #d3dae4;
  --accent: #2348b8;
  --accent-fg: #ffffff;
  --accent-soft: #e2e9fb;
  --tab-bg: #4a5260; /* the contents tab: visible, quieter than the accent */
  --tab-fg: #eef1f5;
  --sig: #c27c00;
  --sig-soft: #fbf0d9;
  --ok: #18794e;
  --ok-soft: #dcf2e6;
  --bad: #b42318;
  --bad-soft: #fbe3e0;
  --plot-1: #2348b8;
  --plot-2: #c27c00;
  --plot-3: #18794e;
  --plot-4: #8a3ab9;
  --plot-5: #c0392b;
  /* cross-section materials */
  --m-metal: #a9b4c2; --m-ox: #d9ecd9; --m-hk: #b7dcc0; --m-hydro: #f3e3a1; --m-glass: #e4eef6;
  --m-semi: #e8c9a8; --m-liq: #b9d6f5; --m-oil: #f6efd8; --m-air: #ffffff; --m-poly: #d7c3e6; --m-lm: #8792a3; --m-sub: #cfd6df;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.06), 0 4px 16px rgba(20, 30, 50, 0.05);
  --f-display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "MonoScripts", "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131b; --grid: rgba(140, 170, 220, 0.05); --surface: #161d28; --surface-2: #1e2734;
    --fg: #dfe6ef; --muted: #93a1b4; --line: #2b3646; --accent: #86a6ff; --accent-fg: #0b1220;
    --accent-soft: #1d2a48; --tab-bg: #3a4250; --tab-fg: #d5dce6; --sig: #f0b13c; --sig-soft: #3a2c10; --ok: #4cc38a; --ok-soft: #12301f;
    --bad: #ff7b6e; --bad-soft: #3a1714; --plot-1: #86a6ff; --plot-2: #f0b13c; --plot-3: #4cc38a;
    --plot-4: #cf9bff; --plot-5: #ff7b6e;
    --m-metal: #6d7a8c; --m-ox: #2c4a35; --m-hk: #2f5c3c; --m-hydro: #5b4f20; --m-glass: #24384c;
    --m-semi: #6b4e33; --m-liq: #24486e; --m-oil: #3d3622; --m-air: #161d28; --m-poly: #4a3a5c; --m-lm: #9aa6b8; --m-sub: #343f4d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e131b; --grid: rgba(140, 170, 220, 0.05); --surface: #161d28; --surface-2: #1e2734;
  --fg: #dfe6ef; --muted: #93a1b4; --line: #2b3646; --accent: #86a6ff; --accent-fg: #0b1220;
  --accent-soft: #1d2a48; --tab-bg: #3a4250; --tab-fg: #d5dce6; --sig: #f0b13c; --sig-soft: #3a2c10; --ok: #4cc38a; --ok-soft: #12301f;
  --bad: #ff7b6e; --bad-soft: #3a1714; --plot-1: #86a6ff; --plot-2: #f0b13c; --plot-3: #4cc38a;
    --plot-4: #cf9bff; --plot-5: #ff7b6e;
    --m-metal: #6d7a8c; --m-ox: #2c4a35; --m-hk: #2f5c3c; --m-hydro: #5b4f20; --m-glass: #24384c;
    --m-semi: #6b4e33; --m-liq: #24486e; --m-oil: #3d3622; --m-air: #161d28; --m-poly: #4a3a5c; --m-lm: #9aa6b8; --m-sub: #343f4d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--fg);
  font: 400 17px/1.55 var(--f-body);
  min-height: 100%;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--f-display); font-stretch: 85%; line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0; }
sub, sup { font-size: 0.72em; line-height: 0; }
code, .mono { font-family: var(--f-mono); font-size: 0.9em; }
.f { font-family: var(--f-mono); font-size: 0.88em; background: var(--surface-2); padding: 0.05em 0.35em; border-radius: 4px; white-space: nowrap; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
/* the page is as wide as a lesson: its 86ch text column (+ the 12px room for the contents tab),
   plus the 230px contents sidebar and its 28px gap once there is room for two columns */
.wrap { max-width: calc(86ch + 68px); margin: 0 auto; padding-inline: 16px; }
@media (min-width: 700px) { .wrap { padding-inline: 28px; } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: calc(86ch + 68px); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (min-width: 700px) { .topbar-in { padding-inline: 28px; } }
@media (min-width: 1020px) { .wrap, .topbar-in { max-width: calc(86ch + 314px); } }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--fg); margin-right: auto; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); flex: none; }
.brand-name { font-family: var(--f-display); font-weight: 800; font-stretch: 80%; font-size: 1.2rem; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; display: none; }
@media (min-width: 560px) { .brand-sub { display: inline; } }
.nav { display: flex; gap: 2px; flex-wrap: wrap; order: 3; width: 100%; }
@media (min-width: 1020px) { .nav { order: 0; width: auto; } }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.95rem; padding: 6px 10px; border-radius: 7px; display: inline-flex; align-items: center; gap: 6px; }
.nav a:hover { color: var(--fg); background: var(--surface-2); }
.nav a.on { color: var(--accent); background: var(--accent-soft); }
.badge { background: var(--sig); color: var(--accent-fg); font-size: 0.72rem; font-weight: 700; border-radius: 99px; padding: 0 7px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--fg); width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }

main { padding-block: 28px 40px; display: flex; flex-direction: column; gap: 28px; outline: none; }
.foot { color: var(--muted); font-size: 0.85rem; padding-block: 0 32px; }

/* ---------- generic ---------- */
.eyebrow { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
.lede { color: var(--muted); max-width: 62ch; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.note { color: var(--muted); font-size: 0.93rem; border-left: 3px solid var(--sig); padding-left: 10px; }
span.note { display: block; margin-top: 6px; }

.btn {
  font: 600 0.98rem/1 var(--f-body); border-radius: 8px; padding: 11px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 11px; min-height: 34px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.kbd { font-family: var(--f-mono); font-size: 0.72rem; border: 1px solid currentColor; border-radius: 4px; padding: 1px 4px; opacity: 0.65; }

.chip { font-size: 0.78rem; font-weight: 700; border-radius: 99px; padding: 2px 9px; background: var(--surface-2); color: var(--muted); white-space: nowrap; letter-spacing: 0.02em; }
.chip.l1 { background: var(--ok-soft); color: var(--ok); }
.chip.l2 { background: var(--accent-soft); color: var(--accent); }
.chip.l3 { background: var(--sig-soft); color: var(--sig); }
.toggle-chip { cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 600 0.88rem var(--f-body); border-radius: 99px; padding: 6px 12px; }
.toggle-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }

/* ---------- dashboard ---------- */
.hero { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .hero { grid-template-columns: 1.4fr 1fr; align-items: end; } }
.hero h1 em { font-style: normal; color: var(--accent); }
.countdown { display: flex; gap: 18px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; min-width: 84px; }
.stat b { font-family: var(--f-display); font-stretch: 80%; font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 4px; }

.plan { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .plan { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1020px) { .plan { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.plan-day { padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.plan-day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan-day header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.plan-item { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: start; padding: 7px 0; border-top: 1px dashed var(--line); }
.plan-item input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); }
.plan-item .pi-label { font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.plan-item .pi-label small { display: block; font-weight: 400; color: var(--muted); font-size: 0.84rem; margin-top: 2px; }
.plan-item.done .pi-label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.plan-item .btn { padding: 5px 10px; min-height: 30px; font-size: 0.84rem; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.tile { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--fg); transition: border-color 0.15s, transform 0.15s; }
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tile-num { font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); }
.tile p { color: var(--muted); font-size: 0.92rem; line-height: 1.4; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.meter i { display: block; height: 100%; }
.meter .m-solid { background: var(--ok); }
.meter .m-learn { background: var(--sig); }
.tile-foot { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.roles { display: flex; gap: 4px; }

/* ---------- topic page ---------- */
.primer { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; max-width: 100%; }
.primer ul, .primer ol { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.primer table, .sol table, .qtext table, .formula table { border-collapse: collapse; font-size: 0.92rem; }
.primer td, .primer th, .sol td, .sol th, .qtext td, .qtext th, .formula td, .formula th { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.tablewrap { overflow-x: auto; max-width: 100%; }
.qlist { display: flex; flex-direction: column; }
.qrow { display: grid; grid-template-columns: 14px auto 1fr auto auto; gap: 10px; align-items: center; padding: 9px 4px; border-top: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; font: inherit; color: inherit; width: 100%; }
.qrow:hover { background: var(--surface-2); }
.qrow .qprev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: 0.94rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dot.solid { background: var(--ok); }
.dot.learn { background: var(--sig); }
.dot.wrong { background: var(--bad); }
.type-tag { font-family: var(--f-mono); font-size: 0.75rem; color: var(--muted); }

/* ---------- bench (question card) ---------- */
.bench { padding: 0; overflow: hidden; }
.bench-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.bench-head .grow { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.progress { font-family: var(--f-mono); font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer { font-family: var(--f-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); }
.pbar { height: 3px; background: var(--line); }
.pbar i { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }
.bench-body { padding: 20px 18px 22px; display: flex; flex-direction: column; gap: 18px; }
@media (min-width: 700px) { .bench-body { padding: 26px 28px 28px; } }
.qtext { font-size: 1.08rem; line-height: 1.6; max-width: 70ch; }
.qtext p + p { margin-top: 8px; }
.parts { display: grid; grid-template-columns: max-content minmax(0, 260px) minmax(0, 1fr); gap: 10px 12px; align-items: center; }
.part { display: contents; }
@media (max-width: 520px) { .parts { grid-template-columns: minmax(0, 1fr); gap: 4px; } .part .unit { margin-bottom: 8px; } }
.part label { font-weight: 600; font-family: var(--f-mono); font-size: 0.92rem; }
.part input {
  font: 500 1.05rem var(--f-mono); padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--line);
  background: var(--bg); color: var(--fg); width: 100%; min-width: 0;
}
.part input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.part input.ok { border-color: var(--ok); background: var(--ok-soft); }
.part input.bad { border-color: var(--bad); background: var(--bad-soft); }
.part .unit { font-size: 0.86rem; color: var(--muted); }
.part .verdict { font-family: var(--f-mono); font-size: 0.9rem; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.input-help { font-size: 0.84rem; color: var(--muted); }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  text-align: left; font: inherit; color: var(--fg); background: var(--bg); border: 1.5px solid var(--line);
  border-radius: 8px; padding: 11px 14px; cursor: pointer; display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: start; line-height: 1.45;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice .key { font-family: var(--f-mono); font-size: 0.82rem; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; text-align: center; line-height: 1.6; }
.choice.ok { border-color: var(--ok); background: var(--ok-soft); }
.choice.bad { border-color: var(--bad); background: var(--bad-soft); }
.choice:disabled { cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1; }
.reveal { border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; line-height: 1.55; }
.reveal.hint { background: var(--sig-soft); border: 1px solid color-mix(in srgb, var(--sig) 35%, transparent); }
.reveal.sol { background: var(--surface-2); border: 1px solid var(--line); }
.reveal.result-ok { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.reveal.result-bad { background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.reveal h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-family: var(--f-body); }
.points { display: flex; flex-direction: column; gap: 6px; }
.points label { display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: start; cursor: pointer; }
.points input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ok); }
textarea.notes { font: 400 0.98rem/1.5 var(--f-body); width: 100%; min-height: 96px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); resize: vertical; }

/* ---------- summary ---------- */
.score-big { font-family: var(--f-display); font-stretch: 80%; font-weight: 800; font-size: 3.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.result-list { display: flex; flex-direction: column; }
.result-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); align-items: center; }
.result-row .qprev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 0.94rem; }
.mark-ok { color: var(--ok); font-weight: 700; }
.mark-bad { color: var(--bad); font-weight: 700; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr 52px; gap: 10px; align-items: center; font-size: 0.92rem; }
.bar-row .meter { height: 10px; }
.bar-row b { font-family: var(--f-mono); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- lab ---------- */
.sims { display: grid; gap: 16px; grid-template-columns: 1fr; }
.sim { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sim canvas { width: 100%; height: 240px; display: block; background: var(--bg); border-radius: 8px; border: 1px solid var(--line); }
.controls { display: grid; gap: 10px 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.ctl { display: flex; flex-direction: column; gap: 2px; font-size: 0.88rem; }
.ctl .ctl-top { display: flex; justify-content: space-between; gap: 6px; }
.ctl output { font-family: var(--f-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.ctl input[type="range"] { width: 100%; accent-color: var(--accent); }
.readouts { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 0.9rem; }
.readouts div { display: flex; flex-direction: column; }
.readouts span { color: var(--muted); font-size: 0.8rem; }
.readouts b { font-family: var(--f-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 5px; border-radius: 2px; }

/* ---------- formulas ---------- */
.formulas { columns: 1; column-gap: 16px; }
@media (min-width: 820px) { .formulas { columns: 2; } }
.formula { break-inside: avoid; padding: 14px 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.formula ul { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 5px; font-size: 0.95rem; }
.formula .f { white-space: normal; }

.settings { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 600; }
.settings input[type="date"], .settings select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); max-width: 240px; }
.confirm-box { background: var(--bad-soft); border: 1px solid var(--bad); border-radius: 8px; padding: 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
textarea.export { width: 100%; min-height: 90px; font: 0.78rem var(--f-mono); background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

.empty { padding: 26px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* ================================================================ course */
.part { gap: 12px; }
.part-head { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }
.part-n { font-family: var(--f-display); font-stretch: 80%; font-weight: 800; font-size: 2.1rem; line-height: 1; color: var(--accent); }
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; text-decoration: none; color: var(--fg); transition: border-color 0.15s; }
.lesson-row:hover { border-color: var(--accent); }
.lesson-row.read { background: color-mix(in srgb, var(--ok-soft) 45%, var(--surface)); }
.lesson-num { font-family: var(--f-mono); color: var(--muted); font-size: 0.9rem; }
.lesson-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lesson-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.read-mark { color: var(--ok); font-weight: 800; }
@media (max-width: 560px) { .lesson-row { grid-template-columns: 36px minmax(0, 1fr); } .lesson-meta { grid-column: 2; flex-direction: row; align-items: center; justify-content: flex-start; } }

.lesson-head { display: flex; flex-direction: column; gap: 10px; }
.lesson-head h1 { font-size: clamp(1.8rem, 4.4vw, 2.7rem); }
.lesson-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
@media (min-width: 1020px) { .lesson-grid { grid-template-columns: 230px minmax(0, 1fr); } }
.toc { display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; }
.toc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.toc-x { border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); width: 32px; height: 32px; border-radius: 8px; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.toc-tab, .toc-scrim { display: none; }
@media (min-width: 1020px) {
  .toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); max-height: calc(100vh - 96px); overflow-y: auto; }
  .toc-x { display: none; }
}
/* below the two-column layout the contents become a drawer, opened by a tab on the left edge */
@media (max-width: 1019px) {
  .toc {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); overflow-y: auto; overscroll-behavior: contain;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px calc(env(safe-area-inset-bottom, 0px) + 20px) calc(env(safe-area-inset-left, 0px) + 14px);
    background: var(--surface); border-right: 1px solid var(--line); box-shadow: 0 14px 44px rgba(10, 20, 40, 0.28);
    transform: translateX(-105%); visibility: hidden; transition: transform 0.22s ease, visibility 0s 0.22s;
  }
  .toc.open { transform: none; visibility: visible; transition: transform 0.22s ease; }
  .toc a { padding-block: 7px; }
  .lesson-grid { padding-left: 12px; } /* room for the tab */
  .toc-scrim { display: block; position: fixed; inset: 0; z-index: 49; background: rgba(5, 10, 20, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .toc-scrim.on { opacity: 1; pointer-events: auto; }
  .toc-tab {
    display: inline-flex; align-items: center; gap: 6px; position: fixed; z-index: 30; left: 0; top: 50%; transform: translateY(-50%);
    writing-mode: vertical-rl; padding: 12px 5px 12px calc(env(safe-area-inset-left, 0px) + 5px); border-radius: 0 10px 10px 0;
    border: 1px solid var(--tab-bg); border-left: 0; background: var(--tab-bg); color: var(--tab-fg);
    font: 700 0.82rem/1 var(--f-body); letter-spacing: 0.04em; cursor: pointer; box-shadow: 0 4px 12px rgba(10, 15, 25, 0.18);
  }
  .toc-tab svg { width: 14px; height: 14px; }
}
.toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.toc a { display: grid; grid-template-columns: 22px 1fr; gap: 4px; text-decoration: none; color: var(--muted); padding: 4px 6px; border-radius: 6px; line-height: 1.3; }
.toc a:hover { color: var(--fg); background: var(--surface-2); }
.toc a.on { color: var(--accent); background: var(--accent-soft); }
.lsec-n { font-family: var(--f-mono); font-size: 0.8em; color: var(--muted); font-weight: 600; }
h2 .lsec-n { margin-right: 6px; color: var(--accent); }

.lesson { display: flex; flex-direction: column; gap: 44px; min-width: 0; max-width: 86ch; } /* one right edge for text, figures and quizzes */
.lsec { display: flex; flex-direction: column; gap: 16px; scroll-margin-top: 84px; min-width: 0; }
.lsec h2 { font-size: 1.55rem; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.lsec h3 { font-size: 1.12rem; margin-top: 8px; }
.lsec > p, .lsec > ul, .lsec > ol, .lsec > .tablewrap { max-width: 86ch; }
.lsec ul, .lsec ol { margin: 0; padding-left: 1.25em; display: flex; flex-direction: column; gap: 6px; }
.lsec li::marker { color: var(--muted); }

.eq { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 6px 18px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; max-width: 86ch; }
.eq-m { font-family: var(--f-mono); font-size: 1.05rem; font-weight: 600; text-align: center; white-space: pre-wrap; }
.eq-n { font-size: 0.88rem; color: var(--muted); }

.callout { border-radius: 8px; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; max-width: 86ch; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.callout-t { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); }
.callout > div { display: flex; flex-direction: column; gap: 6px; }
.callout ul { gap: 4px; }
.callout.itera { border-left-color: var(--sig); background: var(--sig-soft); }
.callout.itera .callout-t { color: var(--sig); }
.callout.pitfall { border-left-color: var(--bad); background: var(--bad-soft); }
.callout.pitfall .callout-t { color: var(--bad); }
.callout.interview { border-left-color: var(--plot-4); background: color-mix(in srgb, var(--plot-4) 12%, var(--surface)); }
.callout.interview .callout-t { color: var(--plot-4); }
.callout.try, .callout.rule { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.try .callout-t, .callout.rule .callout-t { color: var(--ok); }
.callout.deep { border-left-color: var(--muted); background: var(--surface-2); }
.callout.deep .callout-t { color: var(--muted); }

.ltable { border-collapse: collapse; font-size: 0.93rem; }
.ltable th, .ltable td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.ltable th { background: var(--surface-2); font-weight: 700; }
.ltable td { background: var(--surface); }

.example { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; max-width: 90ch; }
.example-h { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 700; color: var(--accent); }
.example summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.example-s { padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }

.takeaways { gap: 8px !important; }
.iq-list { display: flex; flex-direction: column; gap: 8px; }
.iq { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.iq summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
.iq-a { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.lesson-end { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.read-toggle { display: flex; gap: 8px; align-items: center; font-weight: 600; cursor: pointer; }
.read-toggle input { width: 18px; height: 18px; accent-color: var(--ok); }
.lesson-nav .btn { max-width: 100%; white-space: normal; line-height: 1.25; }

/* ---------- glossary ---------- */
.gl-search { font: inherit; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); max-width: 360px; }
.glossary { display: flex; flex-direction: column; gap: 18px; }
.gl-group { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: baseline; }
.gl-group h2 { color: var(--accent); }
.gl-terms { display: flex; flex-wrap: wrap; gap: 6px 16px; }

/* ---------- terms and their explanation panel ---------- */
button.term {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: help; display: inline;
  text-decoration: underline dotted color-mix(in srgb, var(--accent) 70%, transparent); text-decoration-thickness: 1.5px; text-underline-offset: 3px;
}
button.term:hover, button.term[aria-expanded="true"] { color: var(--accent); text-decoration-style: solid; }
button.term.missing { text-decoration-color: var(--bad); }
.tip {
  position: fixed; z-index: 60; width: min(30rem, calc(100vw - 24px)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 40px rgba(10, 20, 40, 0.22); padding: 14px 16px 16px; font-size: 0.93rem; line-height: 1.5;
}
.tip.sheet { left: 8px !important; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); top: auto !important; width: auto; max-height: 72vh !important; }
.tip-body { display: flex; flex-direction: column; gap: 10px; }
.tip-body ul { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 4px; }
.tip-t { font-family: var(--f-display); font-stretch: 85%; font-weight: 700; font-size: 1.08rem; padding-right: 28px; }
.tip-see { font-size: 0.85rem; color: var(--muted); }
.tip-see .term { margin-right: 8px; }
.tip-x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); font-size: 1.1rem; line-height: 1; cursor: pointer; display: none; }
.tip.pinned .tip-x, .tip.sheet .tip-x { display: block; }
.tip .fig-svg { max-width: 100%; }

/* ---------- live figures and embedded drills ---------- */
.live { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.live select { font: inherit; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.ctl-check { flex-direction: row; align-items: center; gap: 6px; }
.live-cap { font-size: 0.88rem; color: var(--muted); }
.quiz { border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: var(--r); background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.quiz-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quiz .qtext { font-size: 1rem; }
.quiz-out { display: flex; flex-direction: column; gap: 8px; }
.quiz-out:empty { display: none; }

/* ================================================================ figures */
.fig { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; min-width: 0; }
.fig-art { width: 100%; display: flex; justify-content: center; overflow-x: auto; }
.fig-svg { width: 100%; max-width: var(--fig-max, 480px); height: auto; overflow: visible; font-family: var(--f-body); font-size: 11px; --c: var(--fg); }
.fig figcaption { font-size: 0.86rem; color: var(--muted); text-align: center; max-width: 60ch; line-height: 1.4; }
.fig-row { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: start; }
.fig-row .fig-svg { max-width: var(--fig-max, 340px); }
.lsec > .fig, .lsec > .fig-row, .lsec > .live, .lsec > .quiz { max-width: 920px; width: 100%; }

.fig-svg .k { --c: var(--fg); }
.fig-svg .mu { --c: var(--muted); }
.fig-svg .c1, .fig-svg .f1 { --c: var(--plot-1); }
.fig-svg .c2, .fig-svg .f2 { --c: var(--plot-2); }
.fig-svg .c3, .fig-svg .f3 { --c: var(--plot-3); }
.fig-svg .c4, .fig-svg .f4 { --c: var(--plot-4); }
.fig-svg .c5, .fig-svg .f5 { --c: var(--plot-5); }
.fig-svg .st { fill: none; stroke: var(--c); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fig-svg .st.thin { stroke-width: 1; }
.fig-svg .st.thick { stroke-width: 3; }
.fig-svg .plate { stroke-width: 2.6; stroke-linecap: butt; }
.fig-svg .dash { stroke-dasharray: 4 3; }
.fig-svg .fl, .fig-svg .ah { fill: var(--c); stroke: none; }
.fig-svg .fl-bg { fill: var(--surface); }
.fig-svg .fs1 { fill: color-mix(in srgb, var(--plot-1) 14%, var(--surface)); }
.fig-svg .fs2 { fill: color-mix(in srgb, var(--plot-2) 16%, var(--surface)); }
.fig-svg .fs3 { fill: color-mix(in srgb, var(--plot-3) 14%, var(--surface)); }
.fig-svg .fs4 { fill: color-mix(in srgb, var(--plot-4) 14%, var(--surface)); }
.fig-svg .fs5 { fill: color-mix(in srgb, var(--plot-5) 14%, var(--surface)); }
.fig-svg .fs0 { fill: var(--surface-2); }
.fig-svg .port { fill: var(--surface); }
.fig-svg .wire { fill: none; }
.fig-svg .lbl { fill: var(--c); stroke: none; font-size: 12px; }
.fig-svg .lbl.small { font-size: 10.5px; }
.fig-svg .lbl.big { font-size: 13px; font-weight: 700; }
.fig-svg .lbl.b { font-weight: 700; }
.fig-svg .lbl.pm { font-size: 12px; font-weight: 700; }
.fig-svg .lbl.tick { font-family: var(--f-mono); font-size: 9.5px; fill: var(--muted); }
.fig-svg .lbl.axl { font-size: 11px; fill: var(--muted); }
.fig-svg .lbl .sub, .fig-svg .lbl .sup { font-size: 0.72em; }
.fig-svg .grid { stroke: var(--line); stroke-width: 0.7; }
.fig-svg .axis { fill: none; stroke: var(--muted); stroke-width: 0.9; }
.fig-svg .curve { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.fig-svg .area { fill: var(--c); fill-opacity: 0.16; stroke: none; }
.fig-svg .legend-bg { fill: var(--surface); fill-opacity: 0.88; stroke: var(--line); stroke-width: 0.6; }
.fig-svg .mat { stroke: color-mix(in srgb, var(--fg) 35%, transparent); stroke-width: 0.7; }
.fig-svg .mat.metal { fill: var(--m-metal); }
.fig-svg .mat.ox { fill: var(--m-ox); }
.fig-svg .mat.hk { fill: var(--m-hk); }
.fig-svg .mat.hydro { fill: var(--m-hydro); }
.fig-svg .mat.glass { fill: var(--m-glass); }
.fig-svg .mat.semi { fill: var(--m-semi); }
.fig-svg .mat.liq { fill: var(--m-liq); }
.fig-svg .mat.oil { fill: var(--m-oil); }
.fig-svg .mat.air { fill: var(--m-air); }
.fig-svg .mat.poly { fill: var(--m-poly); }
.fig-svg .mat.lm { fill: var(--m-lm); }
.fig-svg .mat.sub { fill: var(--m-sub); }

/* ---------- figures inside questions, hints and solutions; tip callout; picture cards ---------- */
.qfig { display: flex; flex-direction: column; gap: 10px; align-items: center; max-width: 640px; }
.qfig > .fig, .qfig > .fig-row, .reveal .fig, .reveal .fig-row, .qtext .fig, .qtext .fig-row, .callout .fig, .tip-body .fig, .tip-body .fig-row, .icard-art .fig { width: 100%; }
.qfig .fig-svg, .reveal .fig-svg { max-width: var(--fig-max, 420px); }
.reveal .fig, .qtext .fig { margin-block: 6px; }
.callout.tipline { flex-direction: row; align-items: flex-start; gap: 10px; border-left: 0; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); color: var(--accent); }
.callout.tipline > div { color: var(--fg); }
.callout.tipline .bulb { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--accent); }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); max-width: 920px; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); } }
.icard { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.icard.on { border-color: var(--sig); background: color-mix(in srgb, var(--sig) 7%, var(--surface)); }
.icard-art { display: flex; justify-content: center; }
.icard-art .fig-svg { max-width: 220px; }
.icard p { font-size: 0.9rem; color: var(--muted); line-height: 1.45; }
.fig-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.86rem; color: var(--muted); justify-content: center; }
.fig-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--fg); }
.fig-legend .sw-c1 { background: var(--plot-1); } .fig-legend .sw-c2 { background: var(--plot-2); } .fig-legend .sw-c3 { background: var(--plot-3); }
.fig-legend .sw-c4 { background: var(--plot-4); } .fig-legend .sw-c5 { background: var(--plot-5); } .fig-legend .sw-mu { background: var(--muted); }

/* ---------- calculator ---------- */
.calc-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg);
  font: 700 0.92rem var(--f-body); cursor: pointer; box-shadow: 0 6px 20px rgba(20, 40, 90, 0.25);
}
.calc-fab svg { width: 20px; height: 20px; }
.calc-fab.on { background: var(--surface); color: var(--accent); }
.calc {
  position: fixed; right: 16px; bottom: calc(68px + env(safe-area-inset-bottom, 0px)); z-index: 45;
  width: min(340px, calc(100vw - 32px)); max-height: calc(100vh - 140px); overflow-y: auto;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 44px rgba(10, 20, 40, 0.28); padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
@media (max-width: 520px) { .calc { right: 8px; left: 8px; width: auto; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); max-height: 70vh; } }
.calc-head { display: flex; align-items: center; gap: 6px; }
.calc-head b { margin-right: auto; font-family: var(--f-display); font-stretch: 85%; font-size: 1.05rem; }
.calc-head button { font: 600 0.78rem var(--f-mono); border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); border-radius: 6px; min-width: 30px; height: 28px; cursor: pointer; }
.calc-help { font-size: 0.85rem; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.calc-help code { font-size: 0.85em; }
.calc-hist { display: flex; flex-direction: column; gap: 2px; max-height: 130px; overflow-y: auto; }
.calc-hist:empty { display: none; }
.calc-h { display: flex; justify-content: space-between; gap: 10px; font: 0.82rem var(--f-mono); border: 0; background: none; color: var(--muted); text-align: left; padding: 3px 4px; border-radius: 5px; cursor: pointer; }
.calc-h:hover { background: var(--surface-2); }
.calc-h span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.calc-h b { color: var(--fg); white-space: nowrap; }
.calc-in { width: 100%; font: 500 1.05rem var(--f-mono); padding: 9px 10px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg); color: var(--fg); }
.calc-in:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.calc-out { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.calc-res { font: 700 1.3rem var(--f-mono); font-variant-numeric: tabular-nums; }
.calc-res.err { font-size: 0.9rem; color: var(--bad); font-family: var(--f-body); }
.calc-plain { font: 0.82rem var(--f-mono); color: var(--muted); margin-right: auto; }
.calc-keys { display: grid; gap: 4px; }
.calc-fns { grid-template-columns: repeat(5, 1fr); }
.calc-pfx { grid-template-columns: repeat(8, 1fr); }
.calc-pad { grid-template-columns: repeat(6, 1fr); }
.calc-keys button { font: 600 0.9rem var(--f-mono); padding: 8px 0; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; min-width: 0; }
.calc-keys button:hover { border-color: var(--accent); }
.calc-fns button, .calc-pfx button { font-size: 0.8rem; padding: 6px 0; background: var(--surface-2); }
.calc-pad .op { color: var(--accent); }
.calc-pad .eq { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.calc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
main { padding-bottom: 80px; }

/* ---------- wide figures on phones: keep text readable, scroll inside the figure ---------- */
@media (max-width: 560px) {
  .fig-art .fig-svg.wide { min-width: calc(var(--w) * 0.8px); }
  .fig-art:has(.fig-svg.wide) { justify-content: flex-start; }
}

.formula-fig { display: flex; justify-content: center; }
.formula-fig .fig-svg { max-width: 320px; }
/* phones: give question figures the full card width so their labels stay legible */
@media (max-width: 520px) {
  .bench-body { padding-inline: 12px; }
  .qfig .fig-svg, .reveal .fig-svg { max-width: 100%; }
  .reveal { padding-inline: 10px; }
}
@media (max-width: 520px) { .calc-fab { padding: 10px; right: 10px; } .calc-fab span { display: none; } }

/* ================================================================ 30h course & workshop features */
/* 1. Deeper sections */
.lsec.deep { border-left: 3px solid var(--accent, currentColor); padding-left: 14px; }
.chip.deep-chip { vertical-align: middle; font-size: 0.7rem; background: var(--accent-soft); color: var(--accent); }

/* 2. Recall cards & flashcard deck */
.recall { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
details.rcard { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-width: 0; }
details.rcard > summary { cursor: pointer; padding: 10px 14px; display: flex; gap: 10px; align-items: baseline; list-style: none; }
details.rcard > summary::-webkit-details-marker { display: none; }
details.rcard > summary .rnum { flex: none; min-width: 1.6em; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
details.rcard > summary > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: break-word; }
details.rcard > summary .rfrom { flex: none; }
details.rcard[open] > summary { border-bottom: 1px solid var(--line); }
details.rcard .ra { padding: 10px 14px 12px 3.2em; min-width: 0; overflow-wrap: break-word; }
details.rcard .ra > * + * { margin-top: 8px; }
@media (max-width: 600px) {
  details.rcard > summary { flex-wrap: wrap; }
  details.rcard .ra { padding-left: 14px; }
}

/* 3. Interview method cards */
.method { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 10px; margin: 10px 0; }
.mstep { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 0.92rem; min-width: 0; overflow-wrap: break-word; }
.mstep-n { font-family: var(--f-mono); color: var(--accent); font-weight: 700; }

/* 4. Workshop / clinic inline exercise groups and the 5-part plan */
.wgroup { display: flex; flex-direction: column; gap: 14px; scroll-margin-top: 84px; min-width: 0; }
.wgroup-list { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.wgroup-list .quiz { max-width: 920px; width: 100%; min-width: 0; }
.plan-day header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.plan-day, .plan-item, .plan-item .pi-label { min-width: 0; }
.plan-item { grid-template-columns: 22px minmax(0, 1fr) auto; }
.plan-item .pi-label { overflow-wrap: break-word; }
.plan-item .btn { flex: none; white-space: nowrap; }


/* 5. References, explainers and the update bar (js/refs.js, js/pwa.js) */
.refs { display: inline-flex; gap: 4px; align-items: center; vertical-align: baseline; white-space: nowrap; }
.refs-after { display: flex; justify-content: flex-end; margin-top: -12px; max-width: 920px; width: 100%; }
.ref { border: 0; background: none; padding: 0 2px; font: 600 0.7rem/1.4 var(--f-mono); color: var(--muted); opacity: 0.55; cursor: pointer; border-radius: 4px; }
.ref:hover, .ref:focus-visible { opacity: 1; color: var(--accent); background: var(--accent-soft); }
.xpl { border: 1px solid var(--sig); background: var(--sig-soft); border-radius: 99px; padding: 0 6px; font-size: 0.8rem; line-height: 1.5; cursor: pointer; }
.xpl:hover, .xpl[aria-expanded="true"] { background: var(--sig); }
summary .refs, .quiz-head .refs { margin-left: auto; }
.qref { font: 600 0.72rem var(--f-mono); color: var(--muted); }
[data-ref] { scroll-margin-top: 90px; }
.ref-flash { outline: 2px solid var(--sig); outline-offset: 4px; border-radius: 4px; }
.tip.wide { width: min(42rem, calc(100vw - 24px)); }
.xpl-asked { font-size: 0.88rem; color: var(--muted); font-style: italic; }
.xpl-list { gap: 10px; }
.xpl-card { padding: 0; }
.xpl-card > summary { cursor: pointer; padding: 12px 16px; display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.xpl-card .xpl-t { font-weight: 700; }
.xpl-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.toast, .update-bar { position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); width: max-content; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 24px); background: var(--fg); color: var(--bg); border-radius: 10px; padding: 10px 14px; font-size: 0.9rem; box-shadow: var(--shadow); }
.update-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
.update-bar .btn.ghost { color: var(--bg); border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
.foot .ver { white-space: nowrap; }
