:root{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;background:#071521;color:#eaf7ff;color-scheme:dark}
*{box-sizing:border-box}
body{margin:0;min-width:280px}
button,select,input{font:inherit}
button,select{border:1px solid #476780;border-radius:10px;background:#102d42;color:#f5fafb;padding:.53rem .7rem;min-height:40px}
button{cursor:pointer}
button:focus-visible,select:focus-visible,input:focus-visible,canvas:focus-visible{outline:3px solid #f9d16b;outline-offset:3px}
button:hover,select:hover{background:#24475e}
button.primary{background:#f1c56b;color:#142333;font-weight:800;border-color:#f1c56b}
button.primary:hover{background:#ffdc8b}
#speed{min-width:128px}
#organ{min-width:128px}
label{display:flex;gap:7px;align-items:center;font-size:.78rem;color:#c2dde9}
label span{white-space:nowrap}
.app-shell{max-width:1480px;margin:auto;min-height:100dvh;display:flex;flex-direction:column}
.topbar{padding:.75rem clamp(.75rem,2.5vw,1.8rem) .65rem;background:#0b1c2a;border-bottom:1px solid #244458;z-index:4}
.brandline{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.brandmark{font-size:.68rem;letter-spacing:.18em;font-weight:800;color:#b5ddec}
.pill{font-size:.65rem;padding:.16rem .5rem;border-radius:8px;background:#193c4b;color:#b4f0e2}
h1{font-size:clamp(1.14rem,2.5vw,1.7rem);margin:.35rem 0 .65rem}
.toolbar,.play-row,.tools-row,.select-row{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap}
.toolbar{justify-content:space-between;row-gap:.7rem}
.select-row,.tools-row,.play-row{flex:0 1 auto}
.scrubber{flex:1 1 140px}
#scrub{width:clamp(110px,14vw,220px);min-height:32px;accent-color:#f5cf74;cursor:pointer;touch-action:pan-x}
#stage-indicator{font-weight:700;color:#ffda82;font-variant-numeric:tabular-nums}
.stage-layout{display:grid;grid-template-columns:minmax(0,1.75fr) minmax(265px,.75fr);gap:0;flex:1;min-height:0}
.scene-wrap{position:relative;min-height:530px;background:radial-gradient(ellipse at 50% 40%,#16374c 0%,#091827 72%);overflow:hidden}
canvas{display:block;width:100%;height:100%;min-height:530px;touch-action:none;cursor:grab}
canvas:active{cursor:grabbing}
.stage-tag{position:absolute;top:18px;left:20px;display:flex;flex-direction:column;gap:4px;pointer-events:none;text-shadow:0 2px 4px #06131c}
.stage-tag strong{font-size:clamp(1.1rem,2vw,1.5rem)}
.small-label,.eyebrow{font-size:.65rem;letter-spacing:.13em;color:#7ddac6;font-weight:800}
.organ-pin{position:absolute;pointer-events:none;width:13px;height:13px;border:3px solid #ffdf73;background:#ffbf48;box-shadow:0 0 0 5px #ffcf5944,0 0 15px #f2cb66;border-radius:50%;display:none;transform:translate(-50%,-50%)}
.scene-hint{position:absolute;left:18px;bottom:15px;font-size:.72rem;color:#aec9d7;pointer-events:none}
.renderer-status{position:absolute;right:18px;bottom:15px;font-size:.64rem;color:#96bdcf;pointer-events:none}
.learning-panel{padding:clamp(1rem,2.3vw,2rem);background:#102435;border-left:1px solid #26485a;overflow-y:auto}
.learning-panel h2{font-size:clamp(1.4rem,2.5vw,1.9rem);margin:.55rem 0 .5rem}
.learning-panel p{line-height:1.55}
#focus-description{font-size:1.02rem;color:#d4eaf0;min-height:5.2rem}
.organ-details{padding:1rem;border:1px solid #4a7181;border-radius:13px;background:#193849}
.organ-details h3{margin:0}
.divider{border-top:1px solid #345567;margin-top:1.4rem}
.disclaimer{font-size:.82rem;color:#f6db96}
.help-text{font-size:.79rem;color:#a3bdca}
.static-journey{padding:1.25rem 2rem;max-width:930px;margin:auto}
.static-journey li{padding:.15rem 0;line-height:1.5}
.js.webgl-ready .static-journey{display:none}
.app-shell:fullscreen{height:100dvh;width:100%;max-width:none;overflow-y:auto;background:#071521}
.app-shell:fullscreen .topbar{position:sticky;top:0}
.app-shell:fullscreen .scene-wrap{min-height:clamp(360px,60dvh,860px)}
.app-shell:fullscreen canvas{min-height:clamp(360px,60dvh,860px)}
@media(max-width:900px){
 .stage-layout{grid-template-columns:minmax(0,1fr)}
 .scene-wrap{height:min(66dvh,620px);min-height:370px}
 canvas{min-height:370px}
 .learning-panel{border-left:0;border-top:1px solid #26485a}
 #focus-description{min-height:0}
}
@media(max-width:460px){
 .topbar{padding:.65rem}
 h1{margin:.25rem 0 .55rem}
 .toolbar{align-items:stretch;gap:.42rem}
 .select-row,.play-row,.tools-row{width:100%;justify-content:space-between;gap:.4rem}
 .select-row label{flex:1}
 .select-row select{flex:1;min-width:0}
 .tools-row label{flex:1 1 132px;min-width:132px;flex-direction:column;align-items:stretch;gap:4px}
 .tools-row select{width:100%;min-width:128px;min-height:42px}
 .tools-row label>span{display:block;font-size:.69rem;white-space:normal;color:#c5deea}
 .play-row>button{padding:.42rem .38rem;min-height:42px}
 .play-row button span{font-size:.72rem}
 .play-row #prev-label,.play-row #next-label{font-size:.68rem}

 .scrubber{flex:1 0 100%;order:4;justify-content:space-between}
 #scrub{width:100%;flex:1}
 .scene-wrap{height:clamp(310px,53dvh,500px);min-height:310px}
 canvas{min-height:310px}
 .stage-tag{top:12px;left:12px}
 .scene-hint{left:12px;bottom:12px}
 .renderer-status{right:12px;bottom:12px}
 .static-journey{padding:1rem}
}

@media(max-width:360px){
 .play-row #prev-label,.play-row #next-label{display:none}
 .play-row>button{min-width:48px}
}

/* P3 — deliberate inside views, not measured anatomy. */
[hidden]{display:none!important}
#view-toggle{background:#254d56;color:#d3fff2;border:1px solid #51aa99;font-weight:700}
#view-toggle[aria-pressed="true"]{background:#4d8a8b;color:#071c24}
.annotations{position:absolute;inset:0;pointer-events:none}
.annotation{
 position:absolute;transform:translate(-50%,-105%);
 font:700 .68rem/1.25 system-ui,"Segoe UI",sans-serif;
 letter-spacing:.01em;text-align:center;white-space:normal;
 max-width:clamp(85px,18vw,175px);
 padding:.34rem .48rem;color:#eaf7ff;
 border:1px solid #8ebec6;border-radius:10px;
 background:#0e283add;box-shadow:0 4px 12px #00172255;
 pointer-events:auto;
}
.annotation:focus-visible{outline:3px solid #ffdb78}
.annotation[data-visual="true"]{pointer-events:none;border-color:#598d98;color:#d6eaf2}
.annotation::after{content:"";position:absolute;left:50%;top:100%;
 height:12px;border-left:2px solid #e8d59a;opacity:.8}
.inside-note{position:absolute;top:57px;left:18px;max-width:210px;
 color:#fff1c1;font-weight:650;font-size:.71rem;padding:.3rem .45rem;
 border-radius:8px;background:#263b4de8}
.scene-caption{position:absolute;left:18px;bottom:48px;
 max-width:min(52%,425px);padding:.58rem .8rem;
 background:#102c3bf2;border:1px solid #3a7182;border-radius:13px;
 display:flex;flex-direction:column;gap:4px;pointer-events:none}
.scene-caption span:first-child{font-weight:800;font-size:.61rem;letter-spacing:.1em;color:#a8eadc}
.scene-caption span:last-child{font-size:clamp(.73rem,.95vw,.9rem);line-height:1.4;color:#f4fafc}
.detail-legend{position:absolute;right:14px;top:16px;width:min(35%,225px);
 display:flex;flex-direction:column;gap:5px;padding:.5rem .55rem;
 border-radius:12px;background:#0e2637ed;border:1px solid #376579;pointer-events:none}
.legend-item{display:flex;align-items:start;gap:.45rem;font-size:.7rem;line-height:1.3;color:#eff9fc}
.legend-color{margin-top:2px;flex:0 0 12px;height:12px;border-radius:50%;border:1px solid #eff9fcaa}
@media(max-width:900px){
 .scene-caption{max-width:65%}
 .detail-legend{top:auto;right:8px;bottom:43px;width:min(32%,150px)}
}
@media(max-width:460px){
 .annotations .annotation{font-size:.59rem;max-width:112px;padding:.25rem .35rem}
 .annotation::after{height:7px}
 .inside-note{left:10px;top:49px;font-size:.62rem;max-width:160px}
 .scene-caption{left:8px;bottom:37px;max-width:68%;padding:.4rem .55rem}
 .scene-caption span:last-child{font-size:.68rem;line-height:1.23}
 .detail-legend{right:6px;bottom:38px;width:30%;padding:.25rem .35rem;gap:3px}
 .legend-item{font-size:.56rem;gap:.25rem}
 .legend-color{flex-basis:9px;height:9px}
 .scene-hint{display:none}
 .stage-tag strong{font-size:1.03rem}
}

/* Narrow phones: never cover the lymph/blood close-up with its legend. */
@media(max-width:460px){
 .learning-panel .detail-legend.legend-inline{
  position:static;inset:auto;width:100%;max-width:none;
  display:flex;flex-direction:row;flex-wrap:wrap;
  padding:.5rem .65rem;margin:0 0 1rem;
  gap:.45rem;background:#193849;
 }
 .learning-panel .detail-legend.legend-inline .legend-item{
  flex:1 1 115px;font-size:.69rem;line-height:1.32;gap:.4rem;
 }
 .learning-panel .detail-legend.legend-inline .legend-color{
  flex-basis:11px;height:11px;
 }
}

/* P3.6 real geometry selection — visible in both toolbar and fullscreen. */
#isolate-organ{background:#355b58;border-color:#85c6ae;color:#f1fff5;font-weight:750}
#isolate-organ[aria-pressed="true"]{background:#bfe5c8;border-color:#bfe5c8;color:#173327}
#isolate-organ:focus-visible{outline:3px solid #ffe38a;outline-offset:3px}
@media(max-width:460px){
 #isolate-organ{flex:1 1 140px;min-height:43px;font-size:.78rem;white-space:normal}
}

/* P4: readable scientific caveat; never hide its meaning in a hover tooltip. */
.scope-note{font-size:.81rem;color:#c9e0ec;line-height:1.5;border-left:3px solid #7dc1b6;padding:.3rem 0 .3rem .7rem}
@media(max-width:460px){.scope-note{font-size:.77rem}}

/* P4 fullscreen: reserve screen real estate for the actual science scene.
 * Portrait keeps all essential controls above scene. Landscape with a short
 * viewport uses an independently scrollable side rail and the scene fills
 * the remaining screen; the in-scene caption remains accessible.
 */
.app-shell:fullscreen .brandline,
.app-shell:fullscreen h1{display:none}
.app-shell:fullscreen .topbar{padding:.45rem .65rem}
@media (max-width:460px) {
 .app-shell:fullscreen .select-row label{
  flex:1 1 135px;min-width:0;flex-direction:column;align-items:stretch;gap:3px
 }
 .app-shell:fullscreen .select-row label>span{font-size:.67rem}
 .app-shell:fullscreen .select-row select{width:100%;min-width:0}
 .app-shell:fullscreen .toolbar{gap:.34rem}
 .app-shell:fullscreen .scene-wrap,
 .app-shell:fullscreen canvas{min-height:clamp(330px,58dvh,700px)}
}
@media (orientation:landscape) and (max-height:500px) and (min-width:600px){
 .app-shell:fullscreen{
  position:relative;display:block;max-width:none;width:100%;height:100dvh;
  overflow:hidden
 }
 .app-shell:fullscreen .topbar{
  position:absolute;left:0;top:0;bottom:0;width:302px;height:100dvh;
  overflow-y:auto;overflow-x:hidden;z-index:10;
  border-right:1px solid #3c6574;border-bottom:none;padding:.42rem
 }
 .app-shell:fullscreen .toolbar{
  display:flex;flex-direction:column;align-items:stretch;gap:.42rem;
 }
 .app-shell:fullscreen .select-row,
 .app-shell:fullscreen .play-row,
 .app-shell:fullscreen .tools-row{width:100%;gap:.35rem}
 .app-shell:fullscreen .select-row{display:grid;grid-template-columns:1fr 1fr}
 .app-shell:fullscreen .select-row label{min-width:0;display:flex;flex-direction:column;align-items:stretch;gap:2px}
 .app-shell:fullscreen .select-row select{min-width:0;width:100%;padding:.3rem}
 .app-shell:fullscreen .play-row{display:grid;grid-template-columns:1fr 1fr 1fr}
 .app-shell:fullscreen .play-row button{padding:.3rem;min-width:0}
 .app-shell:fullscreen .play-row button span{font-size:.73rem}
 .app-shell:fullscreen .play-row .scrubber{
  grid-column:1 / -1;order:4;min-width:0;width:100%
 }
 .app-shell:fullscreen .play-row #scrub{width:100%;min-width:0}
 .app-shell:fullscreen .tools-row{display:grid;grid-template-columns:1fr 1fr}
 .app-shell:fullscreen .tools-row label{min-width:0;flex:1;display:flex;flex-direction:column;align-items:stretch;gap:2px}
 .app-shell:fullscreen .tools-row label>span{font-size:.68rem}
 .app-shell:fullscreen .tools-row select{min-width:0!important;width:100%;padding:.3rem}
 .app-shell:fullscreen #fullscreen{grid-column:1 / -1}
 .app-shell:fullscreen .stage-layout{
  display:flex;flex-direction:column;margin-left:302px;
  width:calc(100% - 302px);height:100dvh;overflow-y:auto
 }
 .app-shell:fullscreen .scene-wrap,
 .app-shell:fullscreen canvas{
  height:100dvh!important;min-height:100dvh!important;
  max-height:none
 }
 .app-shell:fullscreen .learning-panel{flex:0 0 auto}
 .app-shell:fullscreen .scene-caption{max-width:75%}
}


/* P4C: genuinely separate cute 2D Kids animation, not a simplified 3D skin. */
#kids-canvas{position:absolute;inset:0;width:100%;height:100%;touch-action:auto;cursor:default}
#kids-canvas[hidden],#science-canvas[hidden]{display:none!important}
html.kids-mode{background:#fff8f0;color:#29455a;color-scheme:light}
html.kids-mode .topbar{background:#fff3e5;border-color:#edd5b2}
html.kids-mode .brandmark{color:#a5628a}
html.kids-mode h1{color:#344c6d}
html.kids-mode .pill{background:#ffe3bd;color:#844c66}
html.kids-mode label{color:#54617a}
html.kids-mode button:not(.primary),html.kids-mode select{
 background:#ffffff;color:#34455f;border-color:#dcb6b8
}
html.kids-mode button:hover,html.kids-mode select:hover{background:#fff3d9}
html.kids-mode .learning-panel{background:#fff5eb;border-color:#e8caaf}
html.kids-mode .learning-panel h2{color:#8a456c}
html.kids-mode #focus-description{color:#334d66}
html.kids-mode .eyebrow{color:#a25d7b}
html.kids-mode .scene-wrap{background:#fff3e6}
html.kids-mode .stage-tag{text-shadow:0 1px 1px #ffffff}
html.kids-mode .stage-tag strong{color:#854a75}
html.kids-mode .stage-tag .small-label{color:#a15c81}
html.kids-mode .scene-caption{
 background:#fffdf0ef;border:1px solid #e9bb9e;box-shadow:0 5px 18px #bc8e7430
}
html.kids-mode .scene-caption span:first-child{color:#a45d84}
html.kids-mode .scene-caption span:last-child{color:#334c69}
html.kids-mode .scene-hint,html.kids-mode .annotations,html.kids-mode #organ-pin{display:none!important}
html.kids-mode .renderer-status{color:#865471}
html.kids-mode .disclaimer{color:#996333}
html.kids-mode .scope-note{color:#5b657b;border-color:#e7a4b8}
html.kids-mode .help-text{color:#5b6d80}
html.kids-mode .static-journey{display:none}
@media(max-width:460px){
 html.kids-mode .scene-wrap{min-height:310px}
 html.kids-mode .stage-tag{left:10px;top:11px}
 html.kids-mode .scene-caption{max-width:70%;left:8px;bottom:38px}
 html.kids-mode .renderer-status{font-size:.58rem;bottom:9px;right:8px}
}
