:root {
  color-scheme: dark;
  --bg: #101d29; --panel: #162633; --line: #2b404d; --text: #edf2ed; --muted: #a9bdc6;
  --u: #f5c76b; --i: #78d8e6; --r: #c3aff7; --p: #f3a885; --hot: #ff5c4d; --ok: #7ed6a0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 20px; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.65; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, select, summary { cursor: pointer; }
button { min-height: 44px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; background: #203644; color: var(--text); transition: background .2s, transform .2s; }
button:hover { background: #304c5b; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--u); outline-offset: 4px; }
a { color: inherit; text-decoration: none; }
p { margin: .6rem 0 1rem; }
h1, h2, h3 { line-height: 1.18; margin: 0 0 18px; }
h1 { font-size: clamp(2.5rem, 5.5vw, 4.6rem); font-weight: 650; letter-spacing: -.055em; max-width: 900px; }
h1 em { font-family: Georgia, serif; color: var(--u); font-weight: 400; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.025em; }
h3 { font-size: 1.16rem; }
main { max-width: 1180px; margin: auto; padding: 0 28px; }

.topbar { max-width: 1320px; margin: auto; padding: 26px 32px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.brand { font-weight: 800; font-size: 1.2rem; letter-spacing: .07em; }
.brand span, .edition { font-size: .72rem; color: var(--muted); font-weight: 500; letter-spacing: .14em; }
.intro { padding: 62px 0 28px; }
.intro > p:last-child { color: var(--muted); font-size: 1.1rem; }
.eyebrow { font-size: .7rem; letter-spacing: .16em; font-weight: 750; color: var(--u); margin: 0 0 14px; }
.lesson-nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 30px; }
.lesson-nav a { border: 1px solid var(--line); padding: 10px 18px; border-radius: 30px; font-size: .85rem; }
.lesson-nav a:hover { background: var(--panel); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 30px; margin: 0 0 24px; overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.section-heading h2 { margin-bottom: 0; }
.quiet { font-size: .78rem; background: transparent; color: var(--muted); }
.fine { font-size: .73rem; color: var(--muted); }
.center { text-align: center; }

/* 01 Live circuit */
.lab-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 30px; }
.controls { padding-top: 12px; }
.slider-label { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: .86rem; }
.slider-label b { font-size: 1.35rem; margin-right: 6px; }
.slider-label output { font-size: 1.2rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.u { color: var(--u); } .i { color: var(--i); } .r { color: var(--r); } .p { color: var(--p); }
input[type=range] { width: 100%; accent-color: var(--u); height: 34px; cursor: pointer; margin: 6px 0 0; }
#resistance, #resistance2 { accent-color: var(--r); }
input[type=range]:disabled { opacity: .5; cursor: default; }
.controls p { color: var(--muted); font-size: .8rem; margin-bottom: 20px; }
.load-row select { width: 100%; margin-top: 6px; min-height: 40px; padding: 6px 10px; font-size: .86rem; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: .88rem; margin: 4px 0 10px; cursor: pointer; }
.toggle input { width: 1.05rem; height: 1.05rem; accent-color: var(--u); }
.second-box { border-left: 2px solid var(--line); padding-left: 12px; margin: 0 0 16px; }
.topology { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.topology button { font-size: .8rem; min-height: 38px; }
.topology button[aria-pressed=true] { border-color: var(--r); color: var(--r); background: #22303f; }
.switch { width: 100%; border-color: #5e9b90; background: #213d3c; }
.switch[aria-pressed=false] { border-color: var(--line); background: #23303c; }
.danger { width: 100%; margin-top: 8px; border-color: #7a3a33; background: #2c2024; }
.danger[aria-pressed=true] { border-color: var(--hot); background: #4a1f1c; color: #ffd4cf; }
.presets { display: grid; gap: 7px; margin-top: 14px; }
.presets button { font-size: .78rem; min-height: 40px; }
.controls .experiment-hint { font-size: .7rem; margin-top: 10px; }
.scene { min-width: 0; background: #10202c; border: 1px solid var(--line); border-radius: 14px; padding: 15px; }
.scene-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .62rem; letter-spacing: .06em; }
.scene-bar button { font-size: .65rem; }
svg { display: block; width: 100%; height: auto; margin: 10px 0; }
svg text { fill: var(--text); font-family: inherit; font-size: 17px; }
svg .mid { text-anchor: middle; }
.wire { fill: none; stroke: #537380; stroke-width: 5; stroke-linecap: round; }
.flow { fill: none; stroke: var(--i); stroke-width: 5; stroke-dasharray: 1 23; stroke-linecap: round; animation: flow var(--duration, 2s) linear infinite; opacity: .9; }
.battery path, #switch-arm { stroke: var(--u); stroke-width: 5; fill: none; }
.contact { fill: var(--u); }
.load { fill: #866f52; stroke: var(--u); stroke-width: 3; }
.load.bypassed { opacity: .35; }
.load-label { font-size: 14px; fill: var(--muted); }
.glow { transition: opacity .2s; }
.scene-caption { font-size: 11px; fill: var(--muted); letter-spacing: 1px; }
#current-large { font-size: 40px; fill: var(--i); }
#current-large.hot { fill: var(--hot); }
.fuse rect { fill: #1d3242; stroke: #6f8896; stroke-width: 2; }
.fuse path { stroke: #e9ecea; stroke-width: 3; fill: none; stroke-linecap: round; }
.fuse.blown rect { stroke: var(--hot); }
.fuse.blown .fuse-x { stroke: var(--hot); }
.short-wire { fill: none; stroke: #e08a4b; stroke-width: 7; stroke-linecap: round; }
.spark { fill: none; stroke: #fff2a8; stroke-width: 3; stroke-linejoin: round; opacity: 0; }
.spark.on { opacity: 1; filter: drop-shadow(0 0 6px #ffd27a); animation: spark .25s steps(2) infinite; }
@keyframes spark { 50% { opacity: .3; } }
.fuse-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; background: #3a1b1a; border: 1px solid var(--hot); border-radius: 10px; padding: 10px 14px; font-size: .88rem; margin-bottom: 12px; }
.fuse-note b { color: #ffb3a8; }
.fuse-note button { min-height: 36px; font-size: .8rem; margin-left: auto; }
.readouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.readouts span { display: block; font-size: .65rem; }
.readouts strong { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.loads-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: 12px; font-variant-numeric: tabular-nums; }
.loads-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .7rem; letter-spacing: .06em; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.loads-table td { padding: 6px 8px; border-bottom: 1px solid #1d2f3c; }
.observation { font-size: .86rem; margin: 18px 0 10px; color: #d9e6e9; min-height: 3em; }
.bridge { font-size: .86rem; margin: 0; padding: 10px 14px; border-left: 3px solid var(--u); background: #16283680; border-radius: 0 8px 8px 0; }
.bridge a { color: var(--u); }
.water, .simplify { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { min-height: 44px; padding: 8px 0; font-weight: 650; }
.simplify ul { margin: 6px 0 10px; padding-left: 20px; color: var(--muted); font-size: .82rem; }
.simplify li { margin-bottom: 6px; }
.water-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 30px; align-items: center; margin-top: 15px; }
.water-grid p { font-size: .86rem; }
.water-picture { display: flex; align-items: center; padding: 25px 0; min-width: 0; }
.tank { width: 80px; height: 128px; border: 3px solid #7cb7ca; border-top: 0; border-radius: 0 0 12px 12px; position: relative; overflow: hidden; flex-shrink: 0; }
.tank span { position: absolute; bottom: 12px; left: 20px; font-size: .8rem; }
.tank > div { position: absolute; bottom: 0; width: 100%; background: #3d9ab1; height: 50%; transition: height .25s; }
.pipe { height: 44px; border-block: 3px solid #7cb7ca; flex: 1; position: relative; overflow: hidden; }
.pipe > div:first-child { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, #24627b 0 18px, #70d8e7 18px 24px); animation: water var(--duration, 2s) linear infinite; }
.pipe #valve { position: absolute; inset: 0 45%; background: #c3aff7; clip-path: polygon(0 0, 100% 0, 100% var(--gap-top, 25%), 0 var(--gap-top, 25%), 0 var(--gap-bottom, 75%), 100% var(--gap-bottom, 75%), 100% 100%, 0 100%); }
.water-end { font-size: 3rem; color: var(--i); padding-left: 6px; }

/* 02 Triangle */
.triangle-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 36px; align-items: center; }
.triangle { position: relative; width: 300px; height: 275px; margin: auto; }
.triangle-shape { position: absolute; inset: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); background: #2f4554; }
.triangle:after { content: ""; position: absolute; left: 50%; top: 58%; height: 42%; border-left: 2px solid var(--bg); pointer-events: none; }
.triangle-divider { position: absolute; left: 20%; right: 20%; top: 58%; height: 2px; background: var(--bg); }
.triangle button { position: absolute; width: 80px; height: 86px; border: 1px solid transparent; background: transparent; font-size: 2.4rem; z-index: 1; line-height: 1.1; border-radius: 12px; }
.triangle button small { display: block; font-size: .65rem; color: var(--muted); margin-top: 5px; }
.triangle button[aria-pressed=true] { color: transparent; }
.triangle button[aria-pressed=true] small { color: transparent; }
.triangle button[aria-pressed=true]::after { content: "?"; position: absolute; inset: -4px; display: grid; place-items: center; background: var(--u); color: #18202a; border-radius: 12px; font-size: 2.2rem; font-weight: 700; box-shadow: 0 8px 22px #08111b88; transform: rotate(-4deg); }
.triangle [data-quantity=U] { top: 64px; left: 110px; }
.triangle [data-quantity=I] { bottom: 12px; left: 48px; }
.triangle [data-quantity=R] { bottom: 12px; right: 48px; }
.multiply { position: absolute; left: 140px; bottom: 39px; font-size: 1.3rem; z-index: 1; }
.formula-card { background: #10202c; border-radius: 14px; padding: 28px; border-left: 3px solid var(--i); }
.formula { font-size: clamp(2rem, 4vw, 3.3rem); font-weight: 650; letter-spacing: -.025em; margin-bottom: 16px; color: var(--i); }
#substitution { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
#formula-explanation { color: var(--muted); font-size: .9rem; }
.tag { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; white-space: nowrap; font-size: .8rem; }
.power-note { display: flex; gap: 24px; border-top: 1px solid var(--line); padding-top: 24px; margin-top: 18px; }
.power-note > b { min-width: 150px; }
.power-note p { font-size: .9rem; margin: 0; }
.triangle button small i { font-style: normal; opacity: .7; }
.formula-units { margin: -10px 0 14px; font-size: .78rem; letter-spacing: .08em; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 02b Bench multimeter: the dirty, real version */
.bench { margin-top: 28px; padding: 26px; border: 1px dashed #3b5463; border-radius: 16px; background: repeating-linear-gradient(135deg, #142330 0 14px, #13212d 14px 28px); }
.bench-head h3 { margin-bottom: 6px; }
.bench-head .fine { max-width: 760px; margin: 0 0 18px; }
.bench-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 30px; align-items: start; }
.meter { margin: 0; filter: drop-shadow(0 14px 22px #050c13aa); }
.meter svg { display: block; width: 100%; height: auto; }
.meter .holster { fill: #e2a93a; stroke: #a87a22; stroke-width: 2; }
.meter .face { fill: #1d252b; }
.meter .brand-mark { fill: #7f939d; font-size: 9px; letter-spacing: .2em; text-anchor: middle; }
.meter .lcd { fill: #a8b598; stroke: #5d6a55; stroke-width: 3; }
.meter .lcd-auto { fill: #3b4636; font-size: 9px; letter-spacing: .1em; }
.meter .lcd-digits { fill: #18201a; font: 600 40px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; text-anchor: end; letter-spacing: .04em; }
.meter .lcd-unit { fill: #18201a; font-size: 13px; font-weight: 700; text-anchor: end; }
.meter .dial-ring { fill: #2a3339; stroke: #10161a; stroke-width: 4; }
.meter .knob rect { fill: #46525b; stroke: #151b1f; stroke-width: 2; }
.meter .knob path { stroke: #f4f1e8; stroke-width: 4; stroke-linecap: round; }
.meter .dial-label { fill: #8fa3ad; font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
.meter .dial-label[data-mode] { cursor: pointer; }
.meter .dial-label.on { fill: var(--u); }
.meter .jack { fill: #0b0f12; stroke: #4a555c; stroke-width: 3; }
.meter .jack-label { fill: #8fa3ad; font-size: 10px; text-anchor: middle; letter-spacing: .06em; }
.meter .lead { fill: none; stroke-width: 7; stroke-linecap: round; }
.meter .red { stroke: #c9443b; fill: #c9443b; }
.meter .black { stroke: #0e1215; fill: #2b3237; }
.meter .plug { stroke-width: 2; }
.dial { display: flex; gap: 8px; flex-wrap: wrap; }
.dial button { flex: 1 1 110px; font-size: .86rem; }
.dial button b { margin-right: 4px; }
.dial button[aria-pressed=true] { border-color: var(--u); color: var(--u); background: #2a3a3e; }
.meter-how { font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }
.meter-reading { font-size: .95rem; margin: 0 0 16px; }
.watt-card { background: #10202c; border-radius: 12px; padding: 16px 18px; border-left: 3px solid var(--p); }
.watt-slots { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.slot { padding: 6px 10px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); white-space: nowrap; }
.slot.set { border-style: solid; color: var(--text); }
.slot.stale { text-decoration: line-through; opacity: .6; }
strong.slot { font-size: 1.2rem; }
strong.slot.set { color: var(--p); border-color: var(--p); }
.op { color: var(--muted); }
#watt-verdict { font-size: .88rem; margin: 12px 0 0; }
.dirt { margin: 16px 0 0; padding-left: 18px; font-size: .84rem; color: var(--muted); }
.dirt li { margin-bottom: 6px; }
.dirt li::marker { color: var(--p); }
.watt-scale { margin-top: 26px; }
.scale-title { font-size: .9rem; margin: 0; }
.scale-title span { color: var(--muted); }
.scale { position: relative; height: 128px; margin: 6px 6% 4px; }
.scale .track { position: absolute; left: 0; right: 0; top: 62px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, #2b404d, var(--u), var(--p), var(--hot)); }
.scale .mark { position: absolute; top: 4px; transform: translateX(-50%); width: 104px; text-align: center; font-size: .68rem; line-height: 1.3; color: var(--muted); }
.scale .mark::after { content: ""; position: absolute; left: 50%; top: 100%; height: 14px; border-left: 1px solid var(--line); }
.scale .mark.below { top: 80px; }
.scale .mark.below::after { top: auto; bottom: 100%; }
.scale .mark b { display: block; color: var(--text); font-weight: 650; }
.scale .here { position: absolute; top: 54px; transform: translateX(-50%); padding: 2px 8px; border-radius: 999px; background: var(--p); color: #1b1410; font-size: .7rem; white-space: nowrap; transition: left .4s; }
.scale .here b { font-weight: 750; }

/* 03 Calculator */
.calculator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 46px; }
label { display: block; font-size: .85rem; margin-bottom: 6px; }
input[type=text], select { border: 1px solid #47606e; color: var(--text); background: #10202c; padding: 12px; border-radius: 8px; min-width: 0; width: 100%; min-height: 48px; }
#calculation { margin-bottom: 20px; }
.input-row { display: flex; gap: 8px; margin-bottom: 16px; }
.input-row input { flex: 1; width: 50%; }
.input-row select { width: 110px; }
#calculator-result { margin-top: 6px; min-height: 84px; font-size: 1rem; }
#calculator-result strong { display: block; color: var(--u); font-size: 1.75rem; }
.units { border-left: 1px solid var(--line); padding-left: 35px; }
.units p { font-size: .85rem; color: var(--muted); }
.unit-equation { font-size: 1.3rem; color: var(--i); margin: 22px 0; line-height: 1.9; }
.units details { border-top: 1px solid var(--line); margin-top: 25px; font-size: .85rem; }

/* 04 Quiz */
.quiz-bar { display: flex; align-items: center; gap: 12px; font-size: .9rem; white-space: nowrap; }
.challenges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.challenge { background: #10202c; border: 1px solid var(--line); padding: 20px; border-radius: 12px; }
.challenge.ok { border-color: #3d6b52; }
.challenge h3 { font-size: 1rem; line-height: 1.6; min-height: 76px; }
.challenge .eyebrow { color: var(--muted); }
.answers { display: flex; flex-wrap: wrap; gap: 8px; }
.answers button { font-size: .8rem; }
.answers button[aria-pressed=true] { border-color: var(--u); color: var(--u); }
.challenge.ok .answers button[aria-pressed=true] { border-color: var(--ok); color: var(--ok); }
.feedback { font-size: .8rem; min-height: 65px; margin-bottom: 0; }

/* Hub */
.roadmap { padding: 34px 0; }
.modules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 28px 0; }
.module { border-top: 2px solid var(--line); padding-top: 18px; }
.module span { color: var(--muted); font-size: .72rem; }
.module h3 { margin: 12px 0; font-size: 1rem; }
.module h3 a { color: var(--u); }
.module p { color: var(--muted); font-size: .85rem; }
.module .parts { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.module .parts a { display: inline-block; font-size: .76rem; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.module .parts a:hover { background: var(--panel); }
.module .progress { font-size: .76rem; color: var(--muted); }
.module .progress.done { color: var(--ok); }

.paused .flow, .paused #water-stream { animation-play-state: paused; }
.no-current .flow { visibility: hidden; }
.no-current #water-stream { opacity: .25; animation-play-state: paused; }
@keyframes flow { to { stroke-dashoffset: -96; } }
@keyframes water { to { background-position: 96px 0; } }

@media (max-width: 800px) {
  .lab-grid { grid-template-columns: 1fr; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
  .controls label, .controls input, .controls p, .controls button, .controls .presets, .controls .load-row, .controls .toggle, .controls .second-box { grid-column: 1 / -1; }
  .triangle-grid { gap: 20px; }
  .panel { padding: 22px; }
  .challenges { grid-template-columns: 1fr; }
  .challenge h3 { min-height: 0; }
  .feedback { min-height: 0; }
  .modules { gap: 15px; }
}
@media (max-width: 600px) {
  main { padding: 0 14px; }
  .topbar { padding: 19px 16px; }
  .brand { font-size: 1rem; }
  .brand span { font-size: .6rem; }
  .edition { display: none; }
  .intro { padding: 38px 4px 18px; }
  .intro > p:last-child { font-size: .95rem; }
  .intro br { display: none; }
  .lesson-nav { gap: 6px; }
  .lesson-nav a { padding: 9px 12px; font-size: .75rem; }
  .panel { padding: 18px; border-radius: 14px; }
  .section-heading { align-items: flex-start; flex-wrap: wrap; }
  .lab-grid { gap: 12px; }
  .scene { padding: 10px; }
  .scene-bar { font-size: .55rem; }
  .scene-bar button { font-size: .6rem; padding: 6px; }
  .readouts { gap: 8px; }
  .readouts strong { font-size: 1.14rem; }
  .readouts span { font-size: .58rem; }
  .loads-table { font-size: .72rem; }
  .loads-table th, .loads-table td { padding: 4px; }
  .water-grid, .triangle-grid, .calculator-grid, .modules { grid-template-columns: 1fr; gap: 24px; }
  .water-picture { max-width: 310px; width: 100%; margin: auto; padding: 8px 0; }
  .triangle { transform: scale(.92); transform-origin: center; width: 280px; height: 257px; }
  .triangle [data-quantity=U] { left: 100px; top: 54px; }
  .triangle [data-quantity=I] { left: 39px; }
  .triangle [data-quantity=R] { right: 39px; }
  .multiply { left: 130px; }
  .formula-card { padding: 22px; }
  .power-note { display: block; }
  .power-note p { margin-top: 12px; }
  .bench { padding: 16px; margin-top: 22px; }
  .bench-grid { grid-template-columns: 1fr; gap: 18px; }
  .meter { max-width: 190px; margin: auto; }
  .scale { height: 150px; margin: 6px 12% 4px; }
  .scale .mark { width: 74px; font-size: .6rem; }
  .scale .mark.below { top: 86px; }
  .scale .mark.wide { display: none; }
  .units { border-left: 0; border-top: 1px solid var(--line); padding: 24px 0 0; }
  .tag { display: none; }
  .modules { gap: 14px; }
  .module p { margin-bottom: 4px; }
  .fine { font-size: .72rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *:before, *:after { animation: none !important; transition: none !important; }
}
