:root{color-scheme:dark;--ink:#eaf8ff;--muted:#bbd4e5;--edge:#315a78;--mint:#77eeda;font:16px/1.46 system-ui,"Segoe UI",Arial,sans-serif}
*{box-sizing:border-box}[hidden]{display:none!important}
html,body{margin:0;min-height:100%;background:#071421;color:var(--ink)}
body{background:radial-gradient(ellipse at 50% 0%,#145263 0%,#071421 65%)}
.gly-shell{max-width:1250px;margin:0 auto;padding:20px clamp(10px,3vw,28px) 38px}
.intro h1{font-size:clamp(24px,3vw,36px);margin:0 0 4px;line-height:1.17}
.intro p{color:var(--muted);margin:4px 0}.intro .eyebrow{font-size:11px;letter-spacing:.14em;color:var(--mint);font-weight:800}
a{color:#9af6eb}a:focus-visible,button:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid #8af0e7;outline-offset:3px}
.toolbar{position:relative;z-index:10;background:#0b2a3e;border:1px solid var(--edge);border-radius:15px;margin:15px 0 12px;padding:12px}
.toolbar-row{display:flex;align-items:end;flex-wrap:wrap;gap:10px}
.toolbar-row+.toolbar-row{margin-top:8px}
.toolbar label{display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--muted)}
.toolbar select,.toolbar button{font:inherit;font-size:14px;background:#13364c;color:var(--ink);border:1px solid #50788d;border-radius:8px;min-height:40px;padding:7px 11px;cursor:pointer}
.toolbar button{font-weight:800}.toolbar button.primary{background:#087f86;border-color:#1ee1d1}
.toolbar .timeline label{min-width:100px;flex:1 1 200px}
.toolbar input[type=range]{width:100%;accent-color:#77eeda;margin:7px 0 9px}
.chapter-viewer{border:1px solid #32728b;border-radius:16px;overflow:hidden;background:#092436}
.scene{position:relative;isolation:isolate;overflow:hidden;min-height:520px;padding:19px clamp(12px,3vw,28px) 14px;background:radial-gradient(ellipse at 50% 40%,#174865 0%,#092941 67%,#091c32 100%)}
.scene:before{content:"";pointer-events:none;z-index:-1;position:absolute;inset:0;background:repeating-linear-gradient(0deg,transparent 0 77px,#86e9dc1a 78px 79px)}
.stage-top{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.phase,.repeat,.step-number{border-radius:18px;border:1px solid #477d83;background:#0b293d;padding:5px 11px;font-size:11px;font-weight:850;letter-spacing:.06em}
.phase{background:#214345;color:#caffe0}.step-number{margin-left:auto;color:#b0e9ee}
.repeat{color:#ffd482;border-color:#dfb75c;background:#5c3c273b}
.scene h2{margin:10px 0 14px;font-size:clamp(20px,2.1vw,29px);line-height:1.25}
.reaction-layout{display:grid;grid-template-columns:minmax(0,1fr) 54px minmax(0,1fr);gap:5px;align-items:stretch}
.molecule-side{min-width:0;border:1px solid #5e87916b;border-radius:14px;background:#061e31dd;padding:12px;min-height:257px;display:flex;flex-direction:column}
.molecule-side h3{margin:0 0 8px;color:#93dfda;font-size:10px;letter-spacing:.15em}
.carbon-collection{display:flex;gap:9px;flex-wrap:wrap;align-items:stretch;justify-content:center;flex:1}
.carbon-card{flex:1 1 155px;max-width:260px;min-width:0;border:1px solid #4db9b9a1;background:linear-gradient(150deg,#114c60,#0c304b);padding:11px 8px;border-radius:13px;box-shadow:0 5px 18px #0015;display:flex;flex-direction:column;gap:6px;justify-content:space-between}
.carbon-card.three-carbon{background:linear-gradient(150deg,#335368,#19374c);border-color:#9bbfe8ad}
.carbon-card h4{font-size:clamp(12px,1.35vw,16px);margin:0;line-height:1.3;overflow-wrap:anywhere}
.carbon-card .symbol{font-size:21px;font-weight:900;letter-spacing:.015em;color:#a8f8e9}
.carbon-card .formula{font-size:12px;color:#c0e7f5;overflow-wrap:anywhere}
.carbon-card .chips{display:flex;flex-wrap:wrap;gap:5px}
.carbon-card .chips span{font-size:10px;border-radius:6px;background:#0b293e;padding:3px 6px;color:#b4f7d7;border:1px solid #4f9089}
.carbon-beads{display:flex;flex-wrap:wrap;gap:5px;margin-top:2px}
.carbon-beads span{display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;background:radial-gradient(circle at 30% 25%,#abe9ff,#2388ae);border:2px solid #a6d7f3;color:#073048;font-weight:900;font-size:10px}
.empty-carbon{font-size:12px;color:#d5e7ed;margin:auto;max-width:250px;text-align:center}
.transfer{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px}
.transfer-line{display:block;width:6px;height:90px;border-radius:8px;background:#1b445c;position:relative;overflow:hidden}
#motionBeam{display:block;position:absolute;left:0;right:0;top:0;height:100%;background:#60e5d1;transform:scaleY(0);transform-origin:top;box-shadow:0 0 12px #70fff5}
.transfer-arrow{font-size:34px;color:#9ce9dc;font-weight:800}
.cofactor-collection{display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:6px;min-height:45px;margin-top:8px}
.cofactor{font-size:11px;line-height:1.3;border:1px solid #d7b67e7f;background:#61462952;color:#ffe1a4;padding:5px 7px;border-radius:9px}
.cofactor.is-nad{border-color:#b6a9f4;background:#5542775c;color:#e7dbff}
.cofactor.is-water{border-color:#8ecbdd;background:#2b546a69;color:#d8f6ff}
.two-branch,.two-times{margin:9px 0 0;color:#f9d594;font-weight:700;text-align:center;font-size:12px}
.mechanism{border-top:1px solid #50919966;margin-top:14px;padding-top:11px;color:#d7edef;font-size:12px}
.mechanism>span{color:#8de9dd;font-weight:750}
.mechanism p{font-weight:650;margin:6px 0;line-height:1.55;overflow-wrap:anywhere}
.completion{height:7px;background:#1c3b51}.completion div{height:100%;background:linear-gradient(90deg,#24b6a9,#98fae1);width:0}
.explanation{padding:14px 19px 19px;min-height:124px;background:#0a283a}
.explanation-head{display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:8px}
.explanation-head h2{font-size:19px;color:var(--mint);margin:0}
.explanation-head span{font-size:11px;color:var(--muted)}
.explanation p{margin:10px 0 0;font-size:14px}
.ledger{margin-top:13px;padding:14px;background:#0c273a;border:1px solid var(--edge);border-radius:14px}
.ledger header{display:flex;align-items:center;justify-content:space-between;gap:10px}
.ledger h2{margin:0;font-size:17px;color:#9eebdb}
.ledger header strong{color:#9ad9ff;border:1px solid #376b80;background:#143d58;border-radius:8px;padding:3px 10px;white-space:nowrap}
.ledger-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px;margin-top:12px}
.ledger-stats>div{display:flex;flex-direction:column;gap:6px;background:#143b50;border:1px solid #466e82;border-radius:10px;padding:11px}
.ledger-stats span{font-size:12px;color:#bdd9e8}.ledger-stats strong{font-size:26px;line-height:1;color:#dcfff2}
.ledger p{color:#97eedc;font-size:11px;margin:10px 0 0}
.ledger #ledgerNote{color:#afcedc;font-size:11px}
.scope{font-size:13px;color:#bed6e4;margin:11px 3px}
footer{font-size:12px;color:#acc4d8;border-top:1px solid #31586e;padding-top:12px;margin-top:19px}
.no-js{padding:15px;border:1px solid #51788a;border-radius:12px}
.chapter-viewer[data-mode=kids] .carbon-beads span{width:26px;height:26px;font-size:12px;background:radial-gradient(circle at 32% 26%,#fff4af,#e6ac53);border-color:#ffe29b;color:#5d3b1f}
.chapter-viewer[data-mode=kids] .carbon-card{border-color:#ffd584;background:linear-gradient(145deg,#315770,#21435e)}
.gly-shell:fullscreen{height:100dvh;overflow:auto;max-width:none;padding:12px;background:#071d2d}
.gly-shell:fullscreen .toolbar{position:relative;top:auto}
.gly-shell:fullscreen .scene{min-height:clamp(350px,58vh,650px)}
@media(max-width:720px){
 .scene{min-height:540px;padding:13px 9px}
 .reaction-layout{grid-template-columns:minmax(0,1fr) 27px minmax(0,1fr);gap:3px}
 .molecule-side{padding:7px;min-height:300px}
 .carbon-card{padding:8px 5px;flex-basis:110px}
 .carbon-card h4{font-size:12px}
 .carbon-card .symbol{font-size:17px}
 .carbon-beads span{width:19px;height:19px;font-size:9px}
 .transfer-arrow{font-size:23px}
 .ledger-stats{grid-template-columns:repeat(2,minmax(0,1fr))}
 .explanation{min-height:155px;padding:12px}
}
@media(max-width:430px){
 .gly-shell{padding:10px 9px}
 .toolbar{padding:9px}
 .toolbar-row{gap:5px}
 .toolbar select,.toolbar button{font-size:12px;min-height:37px;padding:5px 7px}
 .toolbar .timeline label{flex-basis:100%;order:3}
 /* Source review: side-by-side 320/390px panels made long biochemical
    names barely legible. Stack the two chemically separate reaction sides
    with an explicit downward reaction arrow instead of shrinking text. */
 .reaction-layout{grid-template-columns:minmax(0,1fr);gap:7px}
 .molecule-side{min-height:0;padding:10px}
 .carbon-collection{justify-content:stretch;align-items:stretch;gap:8px}
 .carbon-card{flex:1 1 120px;min-width:0;max-width:none;min-height:147px;padding:9px}
 .carbon-card h4{font-size:13px;line-height:1.33}
 .carbon-card .formula{font-size:11px}
 .carbon-card .chips span{font-size:10px;padding:3px 5px}
 .carbon-beads{gap:4px}
 .carbon-beads span{width:20px;height:20px;font-size:9px}
 .transfer{min-height:31px;flex-direction:row;gap:12px}
 .transfer-line{width:75px;height:5px}
 /* The inline scaleY() visualizes reaction progress in both layouts. */
 .transfer-line{width:5px;height:38px}
 .transfer-arrow{font-size:23px;transform:rotate(90deg)}
 .cofactor{font-size:11px;padding:5px}
 .scene h2{font-size:18px}
}
@media(prefers-reduced-motion:reduce){#motionBeam{transition:none}}/* Explicit Play drives continuous motion regardless of preference. */
