/* BioActive · GCSE Biology. Dark "lab" theme by default, light theme via the toggle. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #060913;
  --bg-glow-a: rgba(56, 189, 248, .10);
  --bg-glow-b: rgba(255, 77, 125, .08);
  --surface: #0e1530;
  --surface-2: #151f40;
  --ink: #e9eeff;
  --muted: #9facc9;
  --line: #222d52;
  --line-2: #33426f;
  --link: #7cbcff;
  --cta: linear-gradient(135deg, #2563eb, #6d4aff);
  --accent-ink: #ffffff;
  --teal: #38e1d0;
  --good: #4ade80;
  --good-bg: #0f2f22;
  --bad: #ff8a80;
  --bad-bg: #3a1620;
  --key: #2b2410;
  --key-line: #f5b82e;
  --note: #101c3a;
  --note-line: #4f7fd6;
  --maths: #0e2a2c;
  --sel: #ffd166;
  /* blood colours: oxygenated = pink-red, deoxygenated = blue */
  --oxy: #ff4d7d;
  --oxy-line: #ff8fb0;
  --oxy-hi: #d8466f; --oxy-mid: #8f1f45; --oxy-lo: #4a0d25;
  --deoxy: #22d3ee;
  --deoxy-line: #5ce1ff;
  --deoxy-hi: #3f8fe3; --deoxy-mid: #1c4f9c; --deoxy-lo: #0d2552;
  --flow-o: #ffe3ec;
  --flow-d: #e0fbff;
  --ecg: #2be4ff;
  --ecg-bg: #050810;
  --ray-i: #38e1d0;
  --ray-r: #ffc247;
  --glow: 1;
  --radius: 16px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .35);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f3ec;
  --bg-glow-a: rgba(111, 152, 209, .12);
  --bg-glow-b: rgba(200, 55, 74, .06);
  --surface: #ffffff;
  --surface-2: #f4efe6;
  --ink: #1d2733;
  --muted: #566475;
  --line: #e4ddcf;
  --line-2: #cfc6b4;
  --link: #a4263a;
  --cta: #c8374a;
  --accent-ink: #ffffff;
  --teal: #12736c;
  --good: #1c7c4a;
  --good-bg: #e0f3e8;
  --bad: #b3261e;
  --bad-bg: #fbe4e1;
  --key: #fff1c9;
  --key-line: #9a6f00;
  --note: #eaf1fb;
  --note-line: #6f98d1;
  --maths: #e4f4f1;
  --sel: #e0a800;
  --oxy: #e5675f;
  --oxy-line: #a8302b;
  --oxy-hi: #f08a82; --oxy-mid: #e5675f; --oxy-lo: #c24840;
  --deoxy: #6f98d1;
  --deoxy-line: #2f5b92;
  --deoxy-hi: #9bbbe8; --deoxy-mid: #6f98d1; --deoxy-lo: #5282bd;
  --flow-o: #ffffff;
  --flow-d: #ffffff;
  --ecg: #0b8aa0;
  --ecg-bg: #f1f6f8;
  --ray-i: #0b8aa0;
  --ray-r: #b35f00;
  --glow: 0;
  --shadow: 0 1px 2px rgba(29, 39, 51, .06), 0 6px 18px rgba(29, 39, 51, .06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--bg-glow-a), transparent 60%),
    radial-gradient(800px 500px at 100% 20%, var(--bg-glow-b), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 16.5px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.015em; font-weight: 700; }
h1 { font-size: clamp(1.7rem, 4.2vw, 2.4rem); margin-bottom: .4em; }
h2 { font-size: 1.35rem; margin-top: 2em; }
h3 { font-size: 1.08rem; margin-top: 1.1em; }
h3:first-child { margin-top: 0; }
p { margin: 0 0 1em; }
a { color: var(--link); }
ul, ol { padding-left: 1.2em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.big { font-size: 1.15rem; font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: .5em 1em; z-index: 40; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 4px; }

/* ---------- app shell: top bar on phones, sidebar from 960px ---------- */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; gap: 12px; align-items: center; padding: 10px 14px; }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); flex: none; }
.brand strong { display: block; line-height: 1.1; font-size: 1.05rem; letter-spacing: -.01em; }
.brand small { display: block; font-size: .72rem; color: var(--muted); line-height: 1.2; }
.logo { display: grid; place-items: center; width: 36px; height: 36px; background: linear-gradient(135deg, #ff4d7d, #6d4aff 60%, #22d3ee); color: #fff; border-radius: 11px; font-size: 1.1rem; box-shadow: 0 6px 18px rgba(255, 77, 125, calc(.3 * var(--glow))); }

#nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
#nav::-webkit-scrollbar { display: none; }
#nav a { display: flex; align-items: center; gap: 8px; white-space: nowrap; text-decoration: none; color: var(--muted); font-size: .9rem; padding: 7px 12px; border-radius: 10px; border: 1px solid transparent; }
#nav a:hover { color: var(--ink); background: var(--surface); }
#nav a .n { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 7px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
#nav a .t-long { display: none; }
#nav a.done .n { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
#nav a.current { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
#nav a.current .n { background: var(--cta); color: var(--accent-ink); border-color: transparent; }

.side-foot { display: flex; align-items: center; gap: 10px; flex: none; }
.side-progress { display: none; }
.icon-btn { font: inherit; display: grid; place-items: center; width: 38px; height: 38px; cursor: pointer; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; font-size: 1.05rem; }
.icon-btn .lbl { display: none; }
.icon-btn:hover { border-color: var(--line-2); background: var(--surface-2); }

@media (min-width: 960px) {
  body { grid-template-columns: 268px minmax(0, 1fr); }
  .top { grid-column: 1; grid-row: 1 / span 3; height: 100vh; align-self: start; border-bottom: 0; border-right: 1px solid var(--line); }
  .top-inner { flex-direction: column; align-items: stretch; height: 100%; padding: 22px 16px 18px; gap: 18px; overflow-y: auto; }
  .lessons-label { margin: 4px 0 -12px; }
  #nav { flex-direction: column; overflow: visible; flex: 1; gap: 4px; }
  #nav a { padding: 10px 12px; font-size: .96rem; }
  #nav a .t-short { display: none; }
  #nav a .t-long { display: inline; white-space: normal; }
  .side-foot { flex-direction: column; align-items: stretch; gap: 12px; }
  .side-progress { display: block; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
  .side-progress .meter { margin: 0 0 8px; }
  .side-progress p { margin: 0; }
  .icon-btn .lbl { display: inline; }
  .topics { display: grid; gap: 4px; }
  .side-label { display: block; }
  .icon-btn { width: 100%; height: 40px; font-size: .9rem; gap: 8px; grid-auto-flow: column; justify-content: center; }
}

/* topic switcher (sidebar, desktop only) and topic cards (home pages) */
.topics, .side-label { display: none; }
.side-label { margin: 0 0 6px; padding: 0 6px; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.topic { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .92rem; }
.topic:hover { border-color: var(--line-2); background: var(--surface-2); }
.topic[aria-current="page"] { border-color: var(--line-2); background: var(--surface-2); font-weight: 600; }
.topic .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.topic.bio .dot, .tag.bio { background: var(--oxy); }
.topic.phys .dot, .tag.phys { background: var(--ray-i); }
.topic-card { display: grid; gap: 6px; text-decoration: none; color: var(--ink); }
.topic-card:hover { border-color: var(--line-2); }
.topic-card.current { border-color: var(--teal); }
.topic-card b { font-size: 1.08rem; }
.topic-card .tag { justify-self: start; padding: 2px 10px; border-radius: 99px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #06101c; }

/* ---------- layout ---------- */
main { grid-column: 1; grid-row: 2; width: 100%; padding: 26px 16px 40px; outline: none; min-width: 0; }
.foot { grid-column: 1; grid-row: 3; }
@media (min-width: 960px) {
  main { grid-column: 2; grid-row: 1 / span 2; padding: 40px 32px 48px; }
  .foot { grid-column: 2; grid-row: 3; }
}
.lesson { max-width: 920px; margin: 0 auto; }
.lesson[hidden] { display: none; }
.lesson.wide { max-width: 1360px; }
.lesson.wide > :not(.lab) { max-width: 920px; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .75rem; font-weight: 700; color: var(--teal); margin-bottom: .6em; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; }
.grid { display: grid; gap: 16px; margin: 20px 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.card { background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 55%, var(--surface)), var(--surface)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.card :last-child { margin-bottom: 0; }
.card-kicker { margin: 0 0 6px; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--teal); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }

.hero-lesson h1 { font-size: clamp(2rem, 5.2vw, 3.1rem); max-width: 26ch; }

.callout { border: 1px solid color-mix(in srgb, var(--note-line) 45%, transparent); background: var(--note); border-radius: var(--radius); padding: 14px 18px; margin: 20px 0; }
.callout.key { border-color: color-mix(in srgb, var(--key-line) 55%, transparent); background: var(--key); }
.callout.maths { border-color: color-mix(in srgb, var(--teal) 45%, transparent); background: var(--maths); }
.callout > b:first-child { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.callout p:last-child { margin-bottom: 0; }
.grid .callout { margin: 0; }

.ticks { list-style: none; padding: 0; margin: 0; }
.ticks li { padding-left: 1.6em; position: relative; margin-bottom: .45em; }
.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--good); font-weight: 700; }

/* ---------- buttons ---------- */
.btn, .chip { font: inherit; font-size: .95rem; cursor: pointer; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 9px 18px; border-radius: 12px; text-decoration: none; display: inline-block; transition: transform .08s, border-color .15s, background .15s; }
.btn:hover, .chip:hover:not(:disabled) { border-color: var(--teal); background: var(--surface-2); }
.btn:active, .chip:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--cta); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); background: var(--cta); }
.btn.sm { padding: 6px 14px; font-size: .88rem; border-radius: 10px; }
.btn[aria-pressed="true"] { background: color-mix(in srgb, var(--teal) 20%, var(--surface)); border-color: var(--teal); color: var(--ink); }
.chip { padding: 7px 14px; border-radius: 10px; }
.chip:disabled { cursor: default; }
.chip.wrong { opacity: .4; text-decoration: line-through; }
.chip.right { background: var(--good-bg); border-color: var(--good); color: var(--good); font-weight: 700; }
.chip.shake { animation: shake .3s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
input[type="number"] { font: inherit; padding: 8px 12px; width: 8em; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); color: var(--ink); }
textarea { font: inherit; width: 100%; min-height: 6.5em; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg); color: var(--ink); resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--teal); }

.score { margin: 8px 0; font-weight: 600; min-height: 1.4em; }
.score.good { color: var(--good); }
.score.bad { color: var(--bad); }

.meter { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.meter span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), #6d8cff); border-radius: 99px; transform: scaleX(0); transform-origin: left; transition: transform .4s; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; padding: 5px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; width: fit-content; max-width: 100%; }
.tabs button { font: inherit; font-size: .93rem; cursor: pointer; padding: 8px 18px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); font-weight: 600; }
.tabpanel[hidden] { display: none; }

/* ---------- ladder ---------- */
.ladder { list-style: none; padding: 0; margin: 24px 0; display: grid; gap: 8px; }
.ladder li { display: grid; grid-template-columns: 8.5em 1fr; gap: 14px; align-items: center; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.ladder li b { font-size: 1.05rem; }
.ladder li:nth-child(1) { margin-right: 32%; }
.ladder li:nth-child(2) { margin-right: 24%; }
.ladder li:nth-child(3) { margin-right: 16%; }
.ladder li:nth-child(4) { margin-right: 8%; }
.ladder li:nth-child(3) { border-color: var(--oxy); }
.ladder span { color: var(--muted); font-size: .95rem; }
@media (max-width: 640px) {
  .ladder li { grid-template-columns: 1fr; gap: 2px; margin-right: 0 !important; }
}

/* ---------- classify activity ---------- */
.classify { display: grid; gap: 10px; margin: 12px 0; }
.q-row { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.q-row.done { border-color: var(--good); }
.q-row .label { font-weight: 600; margin-bottom: 8px; }
.q-row .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.q-row .why { margin: 8px 0 0; font-size: .92rem; color: var(--good); min-height: 0; }

/* ======================= HEART LAB ======================= */
.lab { display: grid; gap: 16px; margin: 16px 0 28px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "info" "rate"; align-items: start; }
.lab-stage { grid-area: stage; padding: 14px; container-type: inline-size; }
.lab-info { grid-area: info; }
.lab-rate { grid-area: rate; }
@media (min-width: 1040px) {
  .lab { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "stage info" "stage rate"; }
  .lab-stage { position: sticky; top: 16px; }
}
@media (min-width: 1700px) {
  .lab { grid-template-columns: 300px minmax(0, 1fr) 330px; grid-template-areas: "rate stage info"; }
}

.stage-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stage-actions { display: flex; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: .85rem; color: var(--muted); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }
.sw.oxy { background: var(--oxy); box-shadow: 0 0 calc(8px * var(--glow)) var(--oxy); }
.sw.deoxy { background: var(--deoxy); box-shadow: 0 0 calc(8px * var(--glow)) var(--deoxy); }

.test-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; align-items: baseline; padding: 10px 14px; margin-bottom: 8px; border-radius: 12px; background: var(--note); border: 1px solid color-mix(in srgb, var(--note-line) 50%, transparent); font-size: 1.05rem; }
.test-bar[hidden] { display: none; }
.test-bar .score { margin: 0; min-height: 0; font-size: .92rem; color: var(--muted); }

.heart-stage { border-radius: 14px; background: radial-gradient(60% 60% at 50% 48%, color-mix(in srgb, var(--surface-2) 90%, transparent), transparent 75%); }
#heart-svg { width: 100%; height: auto; max-height: 640px; display: block; margin: 0 auto; overflow: visible; }

/* picture + clickable regions (drawing units are pixels of assets/heart.webp, 1254 wide) */
#heart-svg .heart-img { filter: drop-shadow(0 30px 50px rgba(0, 0, 0, calc(.45 * var(--glow)))) drop-shadow(0 0 60px rgba(56, 189, 248, calc(.10 * var(--glow)))); }
:root[data-theme="light"] #heart-svg .heart-img { filter: drop-shadow(0 24px 30px rgba(29, 39, 51, .22)); }
#heart-svg .zone { fill: transparent; stroke: transparent; stroke-width: 7; stroke-linejoin: round; transition: fill .15s, stroke .15s; }
#heart-svg .hit { fill: transparent; }
#heart-svg .hit-line { fill: none; stroke: transparent; stroke-width: 44; stroke-linecap: round; }
#heart-svg .coronary { fill: none; stroke: #f6b21a; stroke-width: 9; stroke-linecap: round; opacity: .95; filter: drop-shadow(0 0 calc(10px * var(--glow)) #f6b21a); }
#heart-svg .san { fill: #ffd166; stroke: #fff4c9; stroke-width: 4; filter: drop-shadow(0 0 calc(12px * var(--glow)) #ffd166); }
#heart-svg .san-ring { fill: none; stroke: #ffd166; stroke-width: 4; transform-box: fill-box; transform-origin: center; animation: ring var(--beat, .83s) ease-out infinite; }
#heart-svg .san-ring.r2 { animation-delay: calc(var(--beat, .83s) * .35); }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(4.2); opacity: 0; } }
#heart-svg .off { display: none; }

/* parts react like buttons */
#heart-svg [data-part] { cursor: pointer; outline: none; }
#heart-svg [data-part]:hover .zone { fill: rgba(255, 255, 255, .13); stroke: rgba(255, 255, 255, .45); }
#heart-svg [data-part]:focus-visible .zone { stroke: var(--teal); stroke-width: 10; fill: color-mix(in srgb, var(--teal) 16%, transparent); }
#heart-svg [data-part].sel .zone { fill: color-mix(in srgb, var(--sel) 20%, transparent); stroke: var(--sel); stroke-width: 9; filter: drop-shadow(0 0 calc(14px * var(--glow)) var(--sel)); }
#heart-svg [data-part].sel .coronary { stroke: #fff2b0; stroke-width: 13; }
#heart-svg [data-part].flash-right .zone { fill: color-mix(in srgb, var(--good) 28%, transparent); stroke: var(--good); stroke-width: 10; filter: drop-shadow(0 0 calc(14px * var(--glow)) var(--good)); }
#heart-svg [data-part].flash-wrong .zone { fill: color-mix(in srgb, var(--bad) 28%, transparent); stroke: var(--bad); stroke-width: 10; }
#heart-svg [data-part].flash-right .coronary, #heart-svg [data-part].flash-right .san { stroke: var(--good); }
#heart-svg [data-part].flash-wrong .coronary { stroke: var(--bad); }

/* beat + flow */
.heart-beat { transform-box: fill-box; transform-origin: center; animation: beat var(--beat, .83s) ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.022); } 28% { transform: scale(.996); } 42% { transform: scale(1.012); } 70% { transform: scale(1); } }
#heart-svg .flow { pointer-events: none; }
#heart-svg .stream { fill: none; stroke-width: 16; stroke-linecap: round; opacity: .38; }
#heart-svg .stream.d { stroke: #5ce1ff; }
#heart-svg .stream.o { stroke: #ff7fa6; }
#heart-svg .dots { fill: none; stroke-width: 12; stroke-linecap: round; stroke-dasharray: .1 50; animation: flow calc(var(--beat, .83s) * .5) linear infinite; }
#heart-svg .dots.d { stroke: #e8fcff; filter: drop-shadow(0 0 calc(9px * var(--glow)) #22d3ee); }
#heart-svg .dots.o { stroke: #fff0f5; filter: drop-shadow(0 0 calc(9px * var(--glow)) #ff4d7d); }
@keyframes flow { to { stroke-dashoffset: -50.1; } }
#heart-svg .mk-d { fill: #5ce1ff; }
#heart-svg .mk-o { fill: #ff7fa6; }
#heart-svg.no-flow .flow { display: none; }
.lab.paused .heart-beat, .lab.paused .dots, .lab.paused .san-ring { animation-play-state: paused; }

/* name tags with leader lines */
#heart-svg .cl { cursor: pointer; }
#heart-svg .cl .line { fill: none; stroke-width: 3; stroke-dasharray: 8 7; opacity: .8; }
#heart-svg .cl.oxy .line, #heart-svg .cl.oxy .anchor, #heart-svg .cl.oxy .pill { stroke: var(--oxy-line); }
#heart-svg .cl.deoxy .line, #heart-svg .cl.deoxy .anchor, #heart-svg .cl.deoxy .pill { stroke: var(--deoxy-line); }
#heart-svg .cl .anchor { fill: var(--bg); stroke-width: 4; }
#heart-svg .cl .pill { fill: var(--surface); stroke-width: 3; }
#heart-svg .cl .dot { stroke: none; }
#heart-svg .cl.oxy .dot { fill: var(--oxy); }
#heart-svg .cl.deoxy .dot { fill: var(--deoxy); }
#heart-svg .cl text { font: 600 25px system-ui, sans-serif; fill: var(--ink); stroke: none; }
#heart-svg .cl:hover .pill { fill: var(--surface-2); }
#heart-svg .cl.sel .pill { stroke: var(--sel); stroke-width: 5; fill: var(--surface-2); }
#heart-svg .cl.sel .line { stroke: var(--sel); stroke-dasharray: none; opacity: 1; }
#heart-svg .cl.sel .anchor { stroke: var(--sel); }
.lab-stage.compact .callouts, #heart-svg.testing .callouts { display: none; }

.part-chips { display: none; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.lab-stage.compact .part-chips { display: flex; }
.part-chips .chip { padding: 6px 11px; font-size: .84rem; }
.part-chips .chip[aria-pressed="true"] { border-color: var(--sel); color: var(--ink); background: color-mix(in srgb, var(--sel) 16%, var(--surface)); }
.lab-stage.testing .part-chips { display: none; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 12px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.switch { display: inline-flex; align-items: center; gap: 9px; font-size: .9rem; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--teal); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 3px solid var(--teal); outline-offset: 2px; }
.lab-stage .note { margin: 8px 0 0; }

/* inspector */
.inspector h3 { margin: 0 0 .4em; font-size: 1.25rem; }
.inspector ul { margin: .4em 0 0; padding-left: 1.1em; }
.inspector li { margin-bottom: .4em; }
.inspector > :last-child { margin-bottom: 0; }
.tip { margin-top: 14px; padding: 11px 14px; border-radius: 12px; background: var(--key); border: 1px solid color-mix(in srgb, var(--key-line) 55%, transparent); font-size: .93rem; }
.tip > b:first-child { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--key-line); margin-bottom: 3px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; min-height: 5.5em; }
.panel h3 { margin: 0 0 .3em; font-size: 1.2rem; }
.panel ul { margin: .4em 0 0; padding-left: 1.1em; }
.panel li { margin-bottom: .35em; }
.panel > :last-child { margin-bottom: 0; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 9px; border-radius: 99px; vertical-align: 3px; margin-left: 8px; border: 1px solid; }
.badge.oxy { color: var(--oxy-line); border-color: color-mix(in srgb, var(--oxy-line) 55%, transparent); background: color-mix(in srgb, var(--oxy) 14%, transparent); }
.badge.deoxy { color: var(--deoxy-line); border-color: color-mix(in srgb, var(--deoxy-line) 55%, transparent); background: color-mix(in srgb, var(--deoxy) 14%, transparent); }

/* heart-rate simulator */
.lab-rate h3 { font-size: 1.1rem; margin: 0 0 12px; }
.ecg { position: relative; height: 112px; border-radius: 12px; overflow: hidden; background-color: var(--ecg-bg); border: 1px solid color-mix(in srgb, var(--ecg) 30%, transparent); margin-bottom: 14px;
  background-image: linear-gradient(color-mix(in srgb, var(--ecg) 14%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--ecg) 14%, transparent) 1px, transparent 1px);
  background-size: 18px 18px; }
.ecg svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#ecg-path { fill: none; stroke: var(--ecg); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 calc(4px * var(--glow)) var(--ecg)); }
.ecg-read { position: absolute; right: 12px; bottom: 8px; display: flex; align-items: baseline; gap: 5px; padding: 2px 8px; border-radius: 8px; background: color-mix(in srgb, var(--ecg-bg) 80%, transparent); }
.ecg-read b { font-size: 1.9rem; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
.ecg-read span { font-size: .75rem; font-weight: 700; color: var(--ecg); letter-spacing: .06em; }
.rate-label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.rate-label output { color: var(--teal); font-weight: 700; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 14px; }
.presets .btn { padding: 8px 6px; text-align: center; font-size: .88rem; }
.co { padding: 12px 14px; border-radius: 12px; background: var(--note); border: 1px solid color-mix(in srgb, var(--note-line) 45%, transparent); margin-bottom: 10px; }
.co-title { margin: 0 0 2px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.co-eq { margin: 0; font-size: 1.15rem; font-weight: 600; }
.co-eq b { font-size: 1.6rem; color: var(--teal); font-variant-numeric: tabular-nums; }
.co-eq small { color: var(--muted); font-size: .85rem; }
.co-sub { margin: 2px 0 0; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#rate-note { margin: 0; }

/* ---------- blood flow order ---------- */
.flow-slots { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 48px; padding: 10px; border: 2px dashed var(--line-2); border-radius: 12px; margin: 10px 0; }
.flow-slots .step { background: var(--good-bg); color: var(--good); font-weight: 600; padding: 4px 12px; border-radius: 10px; font-size: .92rem; }
.flow-slots .step:not(:last-child)::after { content: " →"; opacity: .6; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

/* ---------- vessels ---------- */
.vessel-view { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
@media (max-width: 560px) { .vessel-view { grid-template-columns: 1fr; justify-items: center; } }
.vessel-view svg { width: 180px; height: 180px; }
.vessel-view ul { margin: 0; padding-left: 1.1em; }
.vessel-view li { margin-bottom: .4em; }
.vessel-view .scale { font-size: .78rem; color: var(--muted); text-align: center; }
.wall-outer { fill: #d9a07a; }
.wall-mid { fill: #b9654f; }
.wall-inner { fill: #e9c3a8; }
.lumen { fill: var(--oxy); }
.rbc { fill: #8f2a30; }

/* ---------- blood cards ---------- */
.bcard { display: grid; grid-template-columns: 2.2rem 1fr; gap: 6px 12px; }
.bcard .ico { font-size: 1.6rem; line-height: 1.1; }
.bcard h3 { margin: 0 0 .2em; }
.bcard p { margin: 0; font-size: .96rem; }

/* ---------- CHD ---------- */
.chd-lab { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: center; }
@media (max-width: 560px) { .chd-lab { grid-template-columns: 1fr; justify-items: center; } .chd-controls { width: 100%; } }
#chd-svg { width: 220px; height: 220px; }
.chd-controls label { display: flex; justify-content: space-between; margin-bottom: 4px; }
.chd-controls .panel { margin: 12px 0; min-height: 4.5em; }
.fat { fill: #f1d36b; }
.fat-edge { fill: #d3a92a; }
.art-wall { fill: #c9785f; }
.art-lumen { fill: var(--oxy); }
.stent { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-dasharray: 3 3; }

.tcard h3 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tcard .tag { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--teal); }
.tcard dl { margin: .6em 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .95rem; }
.tcard dt { font-weight: 700; }
.tcard dt.pro { color: var(--good); }
.tcard dt.con { color: var(--bad); }
.tcard dd { margin: 0; }

/* ---------- quiz ---------- */
.quiz-top { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; margin: 8px 0; }
.quiz-q { font-size: 1.25rem; font-weight: 650; margin: 6px 0 14px; }
.opts-col { display: grid; gap: 8px; }
.opt { text-align: left; font: inherit; cursor: pointer; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }
.opt:hover:not(:disabled) { border-color: var(--teal); background: var(--surface-2); }
.opt:disabled { cursor: default; }
.opt.right { background: var(--good-bg); border-color: var(--good); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.explain { margin: 14px 0; padding: 10px 14px; background: var(--note); border-radius: 10px; border: 1px solid color-mix(in srgb, var(--note-line) 45%, transparent); }
.result { text-align: center; padding: 24px 12px; }
.result .num { font-size: 3.2rem; font-weight: 800; line-height: 1; }

/* ---------- flashcards ---------- */
.fc-wrap { max-width: 480px; margin: 12px auto; }
.fc { width: 100%; min-height: 220px; font: inherit; cursor: pointer; background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); padding: 24px; display: grid; place-items: center; text-align: center; color: var(--ink); transition: transform .15s; }
.fc:hover { transform: translateY(-2px); }
.fc .term { font-size: 1.7rem; font-weight: 700; }
.fc .hint { display: block; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.fc .def { font-size: 1.1rem; }
.fc.back { background: var(--note); border-color: var(--note-line); }
.fc-actions { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }

/* ---------- exam ---------- */
.eq { margin-bottom: 18px; }
.eq .marks { float: right; font-weight: 700; color: var(--teal); }
.eq h3 { font-size: 1.1rem; }
.ms { margin-top: 12px; padding: 12px 16px; background: var(--note); border-radius: 12px; }
.ms label { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; cursor: pointer; }
.ms input { margin-top: .35em; accent-color: var(--teal); width: 18px; height: 18px; flex: none; }
.ms .need { font-size: .85rem; color: var(--muted); }

.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 20px 16px 40px; }
.pager { display: flex; justify-content: space-between; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }

/* Reduced motion: stop decorative animation and transitions. The heart lab starts paused
   and its Play button is an explicit opt-in, so its animations are left alone. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  *:not(.heart-beat):not(.dots):not(.san-ring) { animation: none !important; }
}

/* ======================= REFLECTION LAB ======================= */
.boundary-fig { margin: 22px 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.boundary-fig svg { width: 100%; height: auto; display: block; max-height: 300px; }
.boundary-fig figcaption { margin-top: 8px; }
.boundary-fig .block { fill: color-mix(in srgb, var(--deoxy) 14%, var(--surface-2)); stroke: var(--line-2); stroke-width: 2; }
.boundary-fig .blk-label { fill: var(--muted); font: 600 13px system-ui, sans-serif; }
.boundary-fig .ray { fill: none; stroke-width: 4; stroke-linecap: round; }
.boundary-fig .ray.i { stroke: var(--ray-i); }
.boundary-fig .ray.r { stroke: var(--ray-r); }
.boundary-fig .ray.t { stroke: var(--ray-i); opacity: .55; }
.boundary-fig .ray.a { stroke: var(--bad); stroke-dasharray: 2 7; }
.boundary-fig .heat { fill: var(--bad); }
.boundary-fig .mk-i, .boundary-fig .mk-t { fill: var(--ray-i); }
.boundary-fig .mk-r { fill: var(--ray-r); }
.boundary-fig text[class^="tag-"] { font: 700 14px system-ui, sans-serif; }
.boundary-fig .tag-i, .boundary-fig .tag-t { fill: var(--ray-i); }
.boundary-fig .tag-r { fill: var(--ray-r); }
.boundary-fig .tag-a { fill: var(--bad); }

.ray-lab { padding: 14px; }
.ray-svg { width: 100%; height: auto; display: block; max-height: 420px; touch-action: none; border-radius: 12px; background: radial-gradient(70% 80% at 50% 40%, color-mix(in srgb, var(--surface-2) 90%, transparent), transparent 80%); }
.sw.ray-i { background: var(--ray-i); box-shadow: 0 0 calc(8px * var(--glow)) var(--ray-i); }
.sw.ray-r { background: var(--ray-r); box-shadow: 0 0 calc(8px * var(--glow)) var(--ray-r); }
.ray-svg .hatch { stroke: var(--line-2); stroke-width: 2; }
.ray-svg .mirror-body { stroke: none; }
.ray-svg .mirror-face { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; filter: drop-shadow(0 0 calc(5px * var(--glow)) #9bd7ff); }
.ray-svg .mirror-face.rough { stroke-linejoin: round; stroke: var(--muted); filter: none; }
.ray-svg .normal { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 7 6; }
.ray-svg .normal-label { fill: var(--muted); font: 600 14px system-ui, sans-serif; }
.ray-svg .right-angle { fill: none; stroke: var(--muted); stroke-width: 2; }
.ray-svg .ray line { stroke-width: 5; stroke-linecap: round; }
.ray-svg .ray.i line { stroke: var(--ray-i); filter: drop-shadow(0 0 calc(6px * var(--glow)) var(--ray-i)); }
.ray-svg .ray.r line { stroke: var(--ray-r); filter: drop-shadow(0 0 calc(6px * var(--glow)) var(--ray-r)); }
.ray-svg .ray.i polygon { fill: var(--ray-i); }
.ray-svg .ray.r polygon { fill: var(--ray-r); }
.ray-svg .arc { fill: none; stroke-width: 3; }
.ray-svg .arc.i { stroke: var(--ray-i); }
.ray-svg .arc.r { stroke: var(--ray-r); }
.ray-svg .arc.bad { stroke: var(--bad); stroke-dasharray: 5 5; }
.ray-svg .lbl { font: 700 19px system-ui, sans-serif; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.ray-svg .lbl.i { fill: var(--ray-i); }
.ray-svg .lbl.r { fill: var(--ray-r); }
.ray-svg .lbl.bad { fill: var(--bad); font-size: 16px; }
.ray-svg .lbl.small { font-size: 13px; font-weight: 600; }
.ray-svg .lamp { cursor: grab; }
.ray-svg .lamp.drag { cursor: grabbing; }
.ray-svg .lamp-hit { fill: transparent; }
.ray-svg .lamp-ring { fill: none; stroke: var(--ray-i); stroke-width: 2; stroke-dasharray: 4 5; opacity: .7; }
.ray-svg .lamp-body { fill: var(--surface-2); stroke: var(--line-2); stroke-width: 2; }
.ray-svg .lamp-nose { fill: var(--line-2); stroke: var(--muted); stroke-width: 1.5; }
.ray-svg .lamp-glow { fill: #fff; filter: drop-shadow(0 0 calc(8px * var(--glow)) var(--ray-i)); }
.ray-controls { margin-top: 12px; }
.readouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.readouts div { padding: 8px 12px; border-radius: 12px; background: var(--note); border: 1px solid color-mix(in srgb, var(--note-line) 40%, transparent); }
.readouts span { display: block; font-size: .72rem; color: var(--muted); letter-spacing: .02em; }
.readouts b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.readouts div:nth-child(1) b { color: var(--ray-i); }
.readouts div:nth-child(2) b { color: var(--ray-r); }
@media (max-width: 560px) { .readouts { grid-template-columns: 1fr; } .readouts div { display: flex; justify-content: space-between; align-items: baseline; } }
.surface-note { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--note); border: 1px solid color-mix(in srgb, var(--note-line) 40%, transparent); font-size: .95rem; }
.seg { gap: 6px; }
.surface-note.mistake { margin: 0 0 12px; border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: var(--bad-bg); }
.surface-note[hidden] { display: none; }

.prac-results { align-items: start; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.data-table th { font-size: .8rem; font-weight: 700; color: var(--muted); }
.data-table .empty td { color: var(--muted); font-style: italic; }
.plot { width: 100%; height: auto; max-height: 320px; display: block; }
.plot .grid { stroke: var(--line); stroke-width: 1; }
.plot .axisline { stroke: var(--muted); stroke-width: 1.5; }
.plot .ideal { stroke: var(--teal); stroke-width: 1.5; stroke-dasharray: 5 5; }
.plot .pt { fill: var(--ray-r); stroke: var(--surface); stroke-width: 1.5; }
.plot .tick { fill: var(--muted); font: 11px system-ui, sans-serif; }
.plot .axis { fill: var(--ink); font: 600 12px system-ui, sans-serif; }
.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin-bottom: .55em; }

/* topic switcher shows in the sidebar from 960px (placed last so it wins over the base hide rule) */
@media (min-width: 960px) {
  .topics { display: grid; gap: 4px; }
  .side-label { display: block; }
}
