:root{color-scheme:dark;--bg:#0f111b;--ann-bg:var(--bg);--ink:#f3f5fc;--muted:#a0adc3;--soft:#cdd6e8;--blue:#97bbff;--purple:#ba9ffc;--li:#89fcd8;--line:#2a3245;font-family:var(--fig-font,Arial,sans-serif);font-synthesis:none}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--bg);color:var(--ink);font-size:16px;line-height:1.5}button,input,select{font:inherit}button,a,summary,input,select{-webkit-tap-highlight-color:transparent}button{color:inherit;cursor:pointer}button:disabled{cursor:default}a{color:inherit;text-decoration:none}button:focus-visible,a:focus-visible,input:focus-visible,summary:focus-visible,select:focus-visible{outline:2px solid var(--li);outline-offset:5px}button,select{touch-action:manipulation}button{border:0}h1,h2,h3,p{margin:0}h1,h2,h3{font-family:var(--fig-font,Arial,sans-serif);font-weight:500}button,a,summary{transition:color .2s,background .2s,opacity .2s}header,main,footer{max-width:1600px;margin:auto;padding-left:clamp(22px,4.2vw,72px);padding-right:clamp(22px,4.2vw,72px)}header{height:94px;display:flex;align-items:center;gap:42px}.brand{font-family:var(--fig-font,Arial,sans-serif);font-size:25px;font-weight:600;letter-spacing:-1.4px;white-space:nowrap;display:inline-flex;align-items:baseline}.brand span{font-weight:400}.brand i{width:5px;height:5px;border-radius:50%;background:var(--blue);align-self:center;margin:4px 0 0 8px}.collection-link{font-size:14px;color:var(--soft)}.collection-link:hover{color:white}.header-topic{font-size:12px;letter-spacing:.12em;color:var(--muted);margin-left:auto}.lesson-title{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;padding:28px 0 30px}.eyebrow{color:var(--muted);font-size:12px;letter-spacing:.14em;line-height:1.5;font-weight:500}.lesson-title h1{font-size:clamp(30px,3.8vw,55px);letter-spacing:-.055em;line-height:1.12;margin-top:9px}.lesson-title h1 span{color:var(--blue)}.mode-switch{border:0;margin:0;padding:4px;display:flex;gap:4px;border-radius:30px;background:#181f2f;white-space:nowrap}.mode-switch legend{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}.mode-switch button{padding:10px 23px;font-size:14px;border-radius:25px;background:transparent;color:#acb7ce}.mode-switch button[aria-pressed=true]{background:#e1ebff;color:#10182a}.mode-switch button:hover:not([aria-pressed=true]){background:#253147;color:white}.explorer{display:grid;grid-template-columns:minmax(0,1fr) 292px;gap:0 48px;scroll-margin-top:18px}.visual-column{min-width:0}.view-toolbar{display:flex;justify-content:space-between;align-items:center;gap:18px;min-height:44px}.view-toolbar nav{display:flex;gap:23px}.view-toolbar nav button{background:transparent;padding:7px 0;font-size:14px;color:var(--muted);border-bottom:2px solid transparent}.view-toolbar nav button[aria-current]{color:var(--ink);border-bottom-color:var(--blue)}.viewport{view-transition-name:battery-scene;position:relative;height:clamp(380px,38vw,555px);min-width:0;background:radial-gradient(ellipse at 50% 50%,#17213370,transparent 65%);isolation:isolate;overflow:hidden}.viewport canvas{display:block;width:100%;height:100%;touch-action:none;cursor:grab}.viewport canvas:active{cursor:grabbing}.scene-labels{position:absolute;inset:0;pointer-events:none}.camera-controls{position:absolute;bottom:4px;right:0;display:flex;gap:13px;align-items:center;font-size:12px;color:var(--muted)}.camera-controls button{background:transparent;color:var(--soft);font-size:12px;padding:8px}.camera-controls button:hover{color:white}.scene-key{display:flex;gap:23px;align-items:center;font-size:14px;min-height:38px}.scene-key>span{display:flex;align-items:center;gap:8px}.scene-key i{width:7px;height:7px;border-radius:50%;flex-shrink:0}.key-lithium{background:var(--li)}.key-electron{background:#cea8ff}.key-carbon{background:#7d9dc3}.scene-key .key-hint{font-size:12px;color:var(--muted);margin-left:auto}.scene-key>[hidden]{display:none}.explanation{padding-top:46px}.explanation h2{font-size:clamp(27px,2.6vw,36px);line-height:1.08;letter-spacing:-.035em;margin-top:10px}.explanation>#view-copy{color:var(--soft);font-size:16px;line-height:1.6;margin-top:20px}.electrode-roles{margin-top:25px;display:flex;flex-direction:column;gap:15px}.electrode-roles>div{display:flex;gap:10px}.role-dot{width:5px;height:5px;border-radius:50%;margin-top:8px;flex-shrink:0}.negative-dot{background:var(--blue)}.positive-dot{background:var(--purple)}.electrode-roles strong{font-size:14px;font-weight:550}.electrode-roles strong span{font-weight:400;color:var(--muted);margin-left:6px;font-size:12px}.electrode-roles p{color:var(--muted);font-size:14px;margin-top:2px}.primary-action{font-size:14px;color:#06121e;background:var(--blue);padding:12px 19px;border-radius:3px;margin-top:25px;width:100%;font-weight:600}.primary-action:hover{background:#d0e2ff}.selection{margin-top:30px}.selection h3{font-size:18px;margin-top:7px;line-height:1.3}.selection>p:not(.eyebrow){color:var(--muted);font-size:14px;line-height:1.55;margin-top:9px}.selection button{background:transparent;color:var(--blue);padding:10px 0 0;font-size:14px}.transport{grid-column:1/-1;display:grid;grid-template-columns:168px minmax(0,1fr) 112px;align-items:center;gap:30px;margin-top:34px;padding:22px 0;border-top:1px solid var(--line)}.progress-control label{display:flex;justify-content:space-between;font-size:14px;gap:15px}.progress-control output{font-variant-numeric:tabular-nums;color:var(--blue)}input[type=range]{accent-color:var(--blue);width:100%;height:24px;margin:6px 0 0;cursor:pointer;background:transparent}#progress-help{font-size:12px;color:var(--muted);line-height:1.4}.state-section{display:grid;grid-template-columns:1fr 1.2fr;gap:8vw;align-items:center;padding:76px 0 38px}.state-copy h2{font-size:clamp(25px,3vw,39px);line-height:1.12;letter-spacing:-.04em;margin-top:13px}.state-copy>p:not(.eyebrow):not(.small){color:var(--soft);margin-top:20px;max-width:400px}.inventory-values{display:flex;gap:35px;margin:25px 0 7px}.inventory-values span{font-size:14px;color:var(--muted)}.inventory-values strong{display:block;font-family:var(--fig-font,Arial,sans-serif);font-size:32px;line-height:1.2;font-weight:400;color:var(--blue);font-variant-numeric:tabular-nums;margin-top:7px}.inventory-values>div+div strong{color:var(--purple)}.small{font-size:12px;color:var(--muted);line-height:1.5}.graph{min-width:0}.graph svg{width:100%;height:auto;display:block;overflow:visible}.chart-grid{stroke:#2c364f;fill:none;stroke-width:1}.chart-label{fill:#a5b2cb;font-family:var(--fig-font,Arial,sans-serif);font-size:14px}.negative-line{fill:none;stroke:var(--blue);stroke-width:2.6}.positive-line{fill:none;stroke:var(--purple);stroke-width:2.6}#chart-cursor{stroke:#818ea8;stroke-width:1;stroke-dasharray:3 5;fill:none}#negative-dot{fill:var(--blue);stroke:var(--bg);stroke-width:2}#positive-dot{fill:var(--purple);stroke:var(--bg);stroke-width:2}.chart-negative-label{fill:var(--blue)}.chart-positive-label{fill:var(--purple)}.chemistry{padding:33px 0 64px}.reaction-pair{display:grid;grid-template-columns:1fr 1fr;gap:35px;margin-top:25px}.reaction-pair>div>p{font-size:12px;letter-spacing:.08em;color:var(--blue);margin-bottom:12px}.reaction-pair>div+div>p{color:var(--purple)}.formula{font-size:clamp(15px,1.6vw,21px);color:#e0e8f8;white-space:normal;line-height:1.9;font-variant-numeric:tabular-nums}.formula sub,.formula sup{font-size:.68em}.chemistry>.small{margin-top:22px}.formula .rx-arrow{color:var(--muted);margin:0 8px}.model-notes{padding-bottom:36px;border-top:1px solid var(--line)}.model-notes summary{display:flex;align-items:center;justify-content:space-between;padding:25px 0;font-size:16px;cursor:pointer;list-style:none;color:var(--soft)}.model-notes summary::-webkit-details-marker{display:none}.model-notes summary span{font-size:24px;color:var(--muted)}.model-notes details[open] summary span{transform:rotate(45deg)}.notes-grid{display:grid;grid-template-columns:1fr 1fr;gap:6vw;padding:10px 0 25px}.notes-grid h3{font-size:20px;margin:20px 0 14px}.notes-grid p{font-size:16px;color:var(--muted);margin:0 0 14px;line-height:1.65}.notes-grid a{color:var(--blue)}.notes-grid a:hover{text-decoration:underline}.notes-grid ol{padding-left:20px}.notes-grid li{padding-left:5px;margin-bottom:17px}.notes-grid li p{font-size:14px;margin:5px 0}.record-link{font-size:14px}footer{display:flex;align-items:center;gap:30px;min-height:114px}footer>span{font-size:12px;letter-spacing:.12em;color:var(--muted)}footer>a:last-child{margin-left:auto;font-size:14px;color:var(--soft)}.skip{position:fixed;left:20px;top:-100px;padding:12px;background:white;color:black;z-index:100}.skip:focus{top:15px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.scene-fallback{position:absolute;inset:15%;display:grid;align-content:center;color:var(--soft);gap:20px;font-size:16px}.scene-fallback[hidden]{display:none}.no-script{padding:24px;color:white;background:#253654}[hidden]{display:none!important}
@media(min-width:1450px){.explorer{grid-template-columns:minmax(0,1fr) 320px;gap:0 70px}.explanation{padding-top:65px}.explanation>#view-copy{font-size:17px}.selection{margin-top:38px}}
@media(max-width:1100px){.explorer{gap:0 26px;grid-template-columns:minmax(0,1fr) 255px}.scene-key .key-hint{display:none}.viewport{height:420px}.explanation{padding-top:33px}.explanation h2{font-size:29px}.electrode-roles{margin-top:17px;gap:9px}.primary-action{margin-top:18px}.selection{margin-top:20px}.selection>p:not(.eyebrow){font-size:14px}.state-section{gap:45px}.formula{font-size:16px}}
@media(max-width:800px){header{height:77px;gap:26px}.header-topic{display:none}.collection-link{margin-left:auto}.lesson-title{padding-top:17px}.explorer{grid-template-columns:1fr;gap:0}.viewport{height:450px}.explanation{display:grid;grid-template-columns:1fr 1fr;gap:0 30px;padding-top:25px}.explanation>.eyebrow,.explanation>h2,.explanation>#view-copy{grid-column:1}.explanation h2{font-size:30px}.explanation>#view-copy{margin-top:13px}.electrode-roles{grid-column:2;grid-row:1/4;align-self:center}.primary-action{grid-column:2;margin-top:15px;align-self:start}.selection{grid-column:1/-1;margin-top:25px;max-width:640px}.selection h3{font-size:20px}.selection>p:not(.eyebrow){font-size:16px}.transport{margin-top:27px;grid-template-columns:155px 1fr 90px;gap:20px}.state-section{padding-top:65px;gap:30px}.state-copy h2{font-size:28px}.reaction-pair{grid-template-columns:1fr;gap:25px}.formula{font-size:19px}.notes-grid{grid-template-columns:1fr}footer{gap:22px}footer>span{display:none}}
@media(max-width:520px){header,main,footer{padding-left:20px;padding-right:20px}.lesson-title{display:block;padding-bottom:25px}.lesson-title h1{font-size:35px;letter-spacing:-.05em}.view-toolbar{gap:12px}.view-toolbar nav{gap:17px}.view-toolbar nav button{font-size:14px}.viewport{height:390px;margin-left:-12px;margin-right:-12px}.camera-controls{bottom:3px;right:8px}.scene-key{font-size:14px;gap:20px;margin-top:7px}.explanation{display:block;padding-top:29px}.explanation h2 br{display:none}.explanation h2{font-size:30px}.explanation>#view-copy{font-size:16px;line-height:1.6}.electrode-roles{display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-top:22px}.electrode-roles strong{font-size:14px}.electrode-roles strong span{display:block;margin:1px 0 0}.electrode-roles p{font-size:14px;margin-top:5px}.primary-action{margin-top:24px;width:auto;min-width:210px}.selection{margin-top:27px}.transport{grid-template-columns:1fr 104px;gap:21px 17px;padding-top:25px}.progress-control{grid-column:1/-1;grid-row:2}.state-section{grid-template-columns:1fr;gap:33px;padding-top:56px}.state-copy h2{font-size:31px}.inventory-values{gap:45px}.graph{margin-left:-8px;margin-right:-4px}.chemistry{padding-top:23px}.formula{font-size:16px}.reaction-pair{gap:26px}.model-notes summary{font-size:15px;gap:20px}.notes-grid p{font-size:16px}footer{padding-top:15px;padding-bottom:30px;min-height:100px}footer>a:last-child{font-size:13px;max-width:150px;text-align:right}}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}*,*::before,*::after{transition:none!important;animation:none!important}}

.selection{transition:opacity .22s ease,transform .22s ease}.selection.is-changing{animation:selection-entry .28s ease both}@keyframes selection-entry{from{opacity:.45;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}

/* Composition is independent of the quiet continuous direction animation. */
.transport{grid-template-columns:minmax(0,1fr) 260px;gap:45px}.composition-note{font-size:14px;line-height:1.6;color:var(--muted)}.camera-controls button{font-size:14px}.camera-controls{gap:8px}@media(max-width:800px){.transport{grid-template-columns:1fr 210px;gap:25px}.camera-controls span{display:none}}@media(max-width:520px){.transport{grid-template-columns:1fr;gap:12px}.transport .progress-control{grid-column:1;grid-row:1}.composition-note{font-size:13px}.camera-controls button{font-size:13px}.camera-controls{gap:4px}}

/* Controls live outside the projected scene, preserving label and geometry clearance. */
.scene-tools{display:flex;align-items:center;justify-content:space-between;gap:12px 24px;padding-top:14px;min-width:0;flex-wrap:wrap}
.scene-tools .scene-key{margin:0;min-height:36px;flex-wrap:wrap}
.scene-tools .scene-key .key-hint{display:none}
.scene-tools .camera-controls{position:static;inset:auto;flex-shrink:0;min-height:36px;gap:9px;margin-left:auto}
.scene-tools .camera-controls button{font-size:14px;padding:9px 7px}
@media(max-width:520px){.scene-tools{gap:4px 18px;padding-top:16px}.scene-tools .camera-controls{width:100%;justify-content:flex-end}.scene-tools .camera-controls button{padding:9px 5px}.scene-tools .scene-key{gap:20px}}

/* The chart viewBox scales to ~0.58x on phones; keep its labels legible. */
@media(max-width:520px){.chart-label{font-size:22px}}

/* The direction arrows draw in an SVG layer over the canvas; callouts come from the shared annotations.css. */
/* Callouts are placed and faded by annotations.mjs every frame. The generic button transitions must not apply to them: a new callout would
   otherwise glide in from the stage's top-left corner (under the view tabs) while its opacity eased down from 1. */
.scene-labels .fig-ann-label{transition:none}
.scene-annotations{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none}
/* Direction arrows share the homepage's hairline-and-notched-head drawing. */
.flow-arrow .line{fill:none;stroke-width:1.5;stroke-linecap:round}
.flow-ion .line,.flow-gallery .line{stroke:#89fcd8}.flow-ion .head,.flow-gallery .head{fill:#a9ffe6}
.flow-electron .line{stroke:#cea8ff}.flow-electron .head{fill:#dfc5ff}
/* The canvas scrolls the page on vertical swipes and turns the cell on sideways ones. */
.viewport canvas{touch-action:pan-y;outline:none}
.viewport canvas.is-dragging{cursor:grabbing}
.viewport:has(canvas:focus-visible){box-shadow:inset 0 0 0 1px #89fcd866}
/* The explanation starts on the same line as the view tabs, and the slider row uses the explorer's columns. */
.explanation{padding-top:11px}
.transport{grid-template-columns:minmax(0,1fr) 292px;gap:48px;align-items:start}
.composition-note{padding-top:1px}
@media(min-width:1450px){.explanation{padding-top:11px}.transport{grid-template-columns:minmax(0,1fr) 320px;gap:70px}}
@media(max-width:1100px){.explanation{padding-top:11px}.transport{grid-template-columns:minmax(0,1fr) 255px;gap:26px}}
@media(max-width:800px){.explanation{padding-top:25px}.transport{grid-template-columns:1fr 210px;gap:25px}}
@media(max-width:520px){.explanation h2 br{display:inline}.transport{grid-template-columns:1fr;gap:12px}}
.formula .term{white-space:nowrap}
/* The graphite headlines are longer: size them so each line fits the column on one line. */
.explanation{container-type:inline-size}
.explanation h2.is-long{font-size:min(36px,8.4cqi)}
@media(max-width:800px){.explanation h2.is-long{font-size:min(30px,calc((100cqi - 30px)/2/11.6))}}
@media(max-width:520px){.explanation h2.is-long{font-size:min(30px,calc(100cqi/11.6))}}

/* Introduction above the explorer */
.lesson-title .fig-question{max-width:44ch}
main>.fig-intro{margin:0 0 34px;--fig-intro-line:var(--line)}

/* One fixed composition axis in both modes: the arrow at the cursor turns to show which way the selected mode moves graphite x, and words keep a halo where the cursor crosses them. */
#chart-direction path{fill:none;stroke:var(--li);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;transform-box:fill-box;transform-origin:center;transform:scaleX(-1);transition:transform .45s var(--fig-ease,ease),stroke .3s ease}#chart-direction.charge path{stroke:#cea8ff;transform:none}
.graph text{paint-order:stroke;stroke:var(--bg);stroke-width:5px;stroke-linejoin:round}

/* The mode switch sits on the stage's own toolbar, so the control and the cell it reverses are seen together; on phones it takes its own row above the views. */
.view-toolbar .mode-switch button{padding:10px 20px}
/* Touch screens get full 44 px targets on the stage toolbar (the switch and the view tabs). */
@media(pointer:coarse){.view-toolbar .mode-switch button,.view-toolbar nav button{min-height:44px}}
/* The views, the mode text and the switch need about 545 px in one row. Where the stage column is narrower (phones, and the two-column layout
   just above 800 px), the switch takes its own full-width row above the other two. */
.visual-column{container-type:inline-size}
@container (max-width:560px){.view-toolbar{flex-wrap:wrap;row-gap:8px}.view-toolbar .mode-switch{order:-1;width:100%}.view-toolbar .mode-switch button{flex:1;padding:10px 12px}}
/* The contract's persistent mode text, on the stage toolbar beside the switch. Both words share one grid cell and cross-fade, so it never snaps. */
.mode-label{display:inline-grid;justify-items:end;margin-left:auto;font-size:12px;letter-spacing:.11em;line-height:1.5;white-space:nowrap}
.mode-label>span{grid-area:1/1;transition:opacity .3s ease}#mode-discharging{color:var(--li)}#mode-charging{color:#cea8ff;opacity:0}
.mode-label.charging #mode-discharging{opacity:0}.mode-label.charging #mode-charging{opacity:1}
/* The chart scales to ~0.58x on phones: the direction arrow is drawn 1.8x larger there so the cue stays readable (about 25 × 9 px). */
@media(max-width:520px){#chart-direction path{transform:scale(-1.8,1.8)}#chart-direction.charge path{transform:scale(1.8)}}
.notes-grid sub,.inventory-values sub{font-size:.72em;line-height:0}
