/* Reading length follows the lesson: explanation, mechanism, evidence, then a decision. */
#quiz-feedback,#case-feedback,#challenge-results,.case-focus-decision h2{scroll-margin-block:90px 24px}
html[data-reading=true] body{height:auto;overflow:auto}
html[data-reading=true] .app{height:auto;min-height:100dvh;grid-template-rows:64px auto 34px}
html[data-reading=true] .topbar{position:sticky;top:0;z-index:18}
html[data-reading=true] main{height:auto;min-height:calc(100dvh - 98px);overflow:visible;gap:20px;padding-top:28px;padding-bottom:30px}
html[data-reading=true] .screen-content{overflow:visible;flex:none;display:block}
html[data-reading=true] .screen-content>.panel{max-width:none;width:100%;margin:0}
html[data-reading=true] .lesson-chunk,html[data-reading=true] .worked-example{padding:28px 32px}
html[data-reading=true] .lesson-chunk .chunk-prose{max-width:850px;line-height:1.8;font-size:15px}
html[data-reading=true] .flow-controls{gap:18px;grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr)}
html[data-reading=true] .screen-navigation{margin-top:8px;padding-top:18px}
html[data-reading=true] .code-block{max-height:none;white-space:pre-wrap;overflow-wrap:anywhere}
html[data-reading=true] .case-focus{overflow:visible;flex:none;align-items:start;grid-template-rows:auto;gap:24px}
html[data-reading=true] .case-focus>.case-context,html[data-reading=true] .case-focus>.case-focus-decision{height:auto;min-height:0}
html[data-reading=true] .case-focus>.embedded-mechanism{grid-column:1/-1;background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:24px;margin:0}
html[data-reading=true] .lab-layout{flex:none;align-items:start;grid-template-columns:minmax(300px,.85fr) minmax(0,1.15fr)}
html[data-reading=true] .lab-instructions .embedded-mechanism{margin-top:24px}
html[data-reading=true] .terminal-body{height:300px;max-height:300px}
.embedded-mechanism{margin-top:30px;padding-top:26px;border-top:1px solid var(--line);min-width:0}
.embedded-heading{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:12px}
.embedded-heading h3{font-size:22px;line-height:1.3;letter-spacing:-.5px}
.embedded-heading .eyebrow{margin-bottom:7px}
.embedded-heading .text-button{display:inline-flex;gap:7px;white-space:nowrap;min-height:44px}
.embedded-caption{font-size:14px;line-height:1.75;color:var(--muted);max-width:900px;margin-bottom:20px}
.embedded-flow{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);gap:26px;align-items:start}
.embedded-mechanism .lecture-visual{height:390px;max-height:none;min-height:0;display:flex;flex-direction:column}
.embedded-mechanism .lecture-stage{min-height:130px;flex:1}
.embedded-mechanism .lecture-diagram{height:100%;max-height:100%}
.embedded-mechanism .mechanism-event{min-height:65px}
.embedded-mechanism .mechanism-event code{display:block;max-height:none;font-size:11px}
.embedded-mechanism .mechanism-event select{max-width:145px;min-height:36px;font-size:11px}
.embedded-mechanism .lecture-transport{padding:10px 16px 14px}
.embedded-reading{padding:18px 0;min-width:0}
.embedded-reading>[data-mechanism-detail]{font-size:15px;line-height:1.85;min-height:96px}
.embedded-principle{margin:20px 0;border-left:2px solid var(--purple);padding-left:16px}
.embedded-principle>b{font-size:11px;color:var(--muted)}
.embedded-principle>p{margin-top:7px;font-size:14px;line-height:1.7}
.embedded-scenes{display:flex;align-items:end;gap:16px;justify-content:space-between;margin-top:20px}
.embedded-scenes label{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}
.embedded-scenes label>span{font-size:11px;color:var(--muted)}
.embedded-scenes select{width:100%;min-width:0;font:600 12px var(--body);background:var(--surface-soft);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:11px}
.embedded-scenes button{display:inline-flex;align-items:center;gap:7px;min-height:44px;white-space:nowrap}
.embedded-trace{margin-top:22px;border-top:1px solid var(--line);padding-top:12px}
.embedded-trace summary{font-size:13px;color:var(--purple);cursor:pointer;padding:8px 0}
.embedded-trace .mechanism-trace{max-width:820px}
.embedded-trace .mechanism-trace li{padding:12px 0}
.lab-instructions .embedded-flow,#modal .embedded-flow{grid-template-columns:minmax(0,1fr);gap:12px}
.lab-instructions .embedded-mechanism .lecture-visual{height:340px}
.lab-instructions .embedded-reading{padding:0}
.lab-instructions .embedded-heading h3{font-size:18px}
.lab-instructions .embedded-scenes{align-items:start;flex-direction:column;gap:8px}
.lab-instructions .embedded-scenes label{width:100%}
#modal .embedded-mechanism .lecture-visual{height:380px}
@media(min-width:1000px){.embedded-flow>.lecture-visual{position:sticky;top:84px}}
@media(max-width:900px){.embedded-flow{grid-template-columns:minmax(0,1fr);gap:12px}.embedded-reading{padding:8px 0}.embedded-reading>[data-mechanism-detail]{min-height:0}html[data-reading=true] .lab-layout{grid-template-columns:minmax(0,1fr);display:grid;gap:22px}}
@media(max-width:720px){
 html[data-reading=true] .app{grid-template-rows:54px auto 25px}
 html[data-reading=true] main{padding:20px 16px 24px;gap:18px;min-height:calc(100dvh - 79px)}
 html[data-reading=true] .lesson-chunk,html[data-reading=true] .worked-example{padding:20px 17px}
 html[data-reading=true] .flow-controls{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:9px}
 html[data-reading=true] .case-focus{display:flex;flex-direction:column;align-items:stretch;gap:18px}
 html[data-reading=true] .case-focus>.embedded-mechanism{padding:20px 16px}
 .embedded-heading{gap:10px;align-items:start}.embedded-heading h3{font-size:19px}.embedded-heading .text-button{font-size:10px}
 .embedded-caption{font-size:13px;line-height:1.75}
 .embedded-mechanism{margin-top:22px;padding-top:22px}
 .embedded-mechanism .lecture-visual{height:360px}
 .embedded-mechanism .lecture-stage{min-height:150px}
 .embedded-mechanism .mechanism-event{min-height:74px;padding:8px 12px}
 .embedded-mechanism .mechanism-event strong{font-size:11px}
 .embedded-mechanism .mechanism-event code{font-size:10px;margin-left:0}
 .embedded-mechanism .mechanism-event-line{flex-wrap:wrap;gap:7px}
 .embedded-mechanism .mechanism-event select{max-width:100%;margin-left:auto}
 .embedded-mechanism .lecture-mode{font-size:9px}
 .embedded-reading>[data-mechanism-detail]{font-size:14px;line-height:1.8}
 .embedded-scenes{align-items:start;flex-direction:column;gap:9px}.embedded-scenes label{width:100%}
 .embedded-scenes select{font-size:11px;min-height:44px}
 html[data-reading=true] .code-block{font-size:11px;line-height:1.8}
}
.embedded-command{margin-top:18px}
.embedded-command summary{font-size:13px;color:var(--purple);cursor:pointer;padding:8px 0}
.embedded-command .code-block{margin-top:12px;font-size:12px;line-height:1.7;white-space:pre-wrap;overflow-wrap:anywhere}

/* Keep the system in view while events change its state. */
.embedded-flow{grid-template-columns:minmax(0,1fr)}
.embedded-flow>.lecture-visual{position:relative;top:auto}
.embedded-mechanism .lecture-visual,.lab-instructions .embedded-mechanism .lecture-visual,#modal .embedded-mechanism .lecture-visual{height:auto;min-height:0;padding-bottom:12px}
.mechanism-viewport{width:100%;overflow:auto;overscroll-behavior-x:contain;scrollbar-color:#577892 #102333;scrollbar-width:thin;outline-offset:-3px}
.embedded-mechanism .lecture-stage{display:block;flex:none;width:100%;min-width:0px;height:auto;min-height:0;aspect-ratio:2/1;max-width:1040px;margin:auto}
.embedded-mechanism .mechanism-diagram{width:100%;height:100%;display:block}
.mechanism-node.idle{opacity:.83}
.mechanism-node.gone{opacity:.55}
.mechanism-node.gone .node-title{text-decoration:line-through}
.mechanism-node .node-state{fill:#bbccda;font-size:11px;font-weight:600}
.mechanism-node.error .node-state{fill:#ffb8b4}
.mechanism-node.ready .node-state{fill:#a3eed8}
.mechanism-node.participant rect{stroke-width:2.5}
.mechanism-wire{opacity:.35;stroke-width:1.6}
.mechanism-wire.engaged{stroke-width:3;opacity:1}
.mechanism-wire.read{stroke-dasharray:5 4}
.mechanism-wire.control{stroke-dasharray:2 4}
.mechanism-wire.write{stroke:#e5c591}
.mechanism-overview-label{margin-left:auto;color:#b7cddf;font-size:11px}
.mechanism-map-help{margin:0;padding:0 20px;color:#b7cddf;font-size:12px;line-height:1.6}
.mechanism-legend{display:flex;gap:18px;flex-wrap:wrap;padding:8px 20px;color:#c3d3e0;font-size:11px}
.mechanism-legend span{display:flex;align-items:center;gap:7px}
.mechanism-legend span:before{content:'';width:22px;border-top:2px solid #b6c8d6}
.mechanism-legend .network:before{border-color:#a9c9ff}
.mechanism-legend .control:before{border-top-style:dotted}
.mechanism-legend .read:before{border-top-style:dashed}
.mechanism-legend .write:before{border-color:#e5c591}
.mechanism-transfer{display:flex;gap:12px;justify-content:space-between;align-items:start;margin:4px 20px 8px;padding:10px 0;border-top:1px solid #375067;color:#c3d3e0;font-size:12px;line-height:1.6}
[data-mechanism-status]{font-weight:600;white-space:nowrap;color:#cce6ff}
[data-mechanism-route]{text-align:right;overflow-wrap:anywhere}
.embedded-reading{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px 28px;padding:8px 0}
.embedded-reading>.eyebrow{grid-column:1}
.embedded-reading>[data-mechanism-detail]{grid-column:1;min-height:0;margin:0}
.embedded-reading>.embedded-principle{grid-column:2;grid-row:1/3}
.embedded-reading>.learning-note{grid-column:1/-1}
.embedded-trace{border-top:1px solid var(--line);margin-top:20px;padding-top:4px}
.mechanism-roadmap{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;list-style:none;padding:0!important}
.mechanism-roadmap>li{border:1px solid var(--line);border-radius:12px;padding:14px 16px;background:var(--surface-soft)}
.mechanism-roadmap button{display:flex;gap:10px;align-items:start;min-height:44px;width:100%;text-align:left;background:transparent;border:0;color:var(--ink);padding:4px 0;font:inherit;border-radius:6px;cursor:pointer}
.mechanism-roadmap button.current{color:var(--purple)}
.mechanism-roadmap button.current .mechanism-step-number{background:var(--purple);color:var(--surface)}
.mechanism-step-number{display:grid;place-items:center;flex:none;width:28px;height:28px;border:1px solid var(--line);border-radius:50%;font:11px var(--mono)}
.mechanism-roadmap button b{padding-top:3px}
.mechanism-roadmap li p{margin:8px 0;font-size:13px}
.mechanism-roadmap li code{background:var(--surface);margin-bottom:0}
.mechanism-model-notes{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);gap:28px}
.mechanism-event-line{flex-wrap:wrap}
.mechanism-event strong{font-size:13px}
.mechanism-event select{max-width:240px;font-size:12px;min-height:40px}
.mechanism-event code{display:block!important;font-size:11px}
@media(max-width:720px){
 .mechanism-overview-label{font-size:10px}
 .mechanism-map-help{padding:0 12px;font-size:11px}
 .mechanism-legend{padding:8px 12px;gap:12px}
 .mechanism-transfer{flex-direction:column;gap:2px;margin:4px 12px}
 [data-mechanism-route]{text-align:left}
 .mechanism-event{padding:8px 12px 0}
 .mechanism-event strong{font-size:12px;flex-basis:calc(100% - 28px)}
 .mechanism-event select{max-width:none;width:100%;margin-top:5px}
 .embedded-reading,.mechanism-model-notes,.mechanism-roadmap{grid-template-columns:minmax(0,1fr)}
 .embedded-reading>.embedded-principle{grid-column:1;grid-row:auto;margin-top:12px}
 .mechanism-model-notes{gap:0}
 .mechanism-roadmap>li{padding:12px}
}

.mechanism-viewport{flex:none}
.embedded-trace .mechanism-trace{max-width:none}
.embedded-trace .mechanism-roadmap>li{padding:14px 16px}

.mechanism-legend [hidden]{display:none}
.mechanism-node .node-state{font:600 11px var(--body)}

.embedded-mechanism .lecture-visual{scroll-margin-top:80px}

.embedded-scenes select,.embedded-scenes button,[data-mechanism-title]{scroll-margin-block:var(--storage-inset,86px) 18px}
.embedded-scenes select:focus-visible{outline:3px solid var(--purple);outline-offset:4px}
[data-mechanism-title]:focus-visible{outline:2px solid currentColor;outline-offset:4px;border-radius:2px}

.mechanism-share{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;margin-top:12px}
.mechanism-share button{display:inline-flex;align-items:center;gap:7px;min-height:44px}
.mechanism-share [role=status]{font-size:12px;color:var(--muted)}
.mechanism-share input{width:100%;min-width:0;padding:10px;border:1px solid var(--line);border-radius:7px;background:var(--surface);color:var(--ink);font:12px var(--mono);scroll-margin-block:var(--storage-inset,86px) 18px}
.mechanism-share input[hidden]{display:none}

.module-code-example{margin:24px 0;padding-top:16px;border-top:1px solid var(--line)}.module-code-example h3{font-size:14px;line-height:1.6;margin:0 0 10px;color:var(--ink)}.module-code-example>.learning-note{font-size:13px;line-height:1.8;margin:10px 0 16px;color:var(--muted)}.module-code-example .flow-code{margin-bottom:0}
.module-code-example .flow-code>[data-copy]{min-height:44px}

.embedded-command > .learning-note{font-size:14px;line-height:1.7;margin:12px 0}
