:root {
  --paper:#f8f8f4; --ink:#192e30; --muted:#526367; --teal:#086965;
  --border:#cbd6d2; --soft:#edf5ef; --diagram:#163c40; --amber:#ffd788;
  color-scheme:light; font:16px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
* {box-sizing:border-box}
body {margin:0;color:var(--ink);background:var(--paper)}
a {color:var(--teal);text-underline-offset:4px}
h1,h2,h3,p {margin:0}
header {border-bottom:1px solid var(--border)}
.top,main {max-width:1260px;margin:auto;padding-inline:clamp(16px,4vw,50px)}
.top {display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:58px}
.top a {text-decoration:none;font-weight:600;font-size:.88rem}
.brand {color:var(--ink)}
.brand span {margin-left:12px;padding-left:12px;border-left:1px solid var(--border);font-weight:450}
.intro {padding:clamp(21px,3vw,38px) 0 24px}
.eyebrow,.label,.dark-label {font-size:.71rem;text-transform:uppercase;letter-spacing:.105em;font-weight:750;color:var(--teal)}
.eyebrow span {margin-inline:4px}
h1 {font-family:Georgia,serif;font-size:clamp(2.2rem,4.3vw,3.7rem);font-weight:500;line-height:1.08;letter-spacing:-.045em;margin:5px 0 8px}
.intro>p:last-child,#goal {color:var(--muted);font-size:1rem}
#topics {display:flex;border-bottom:1px solid var(--border);gap:7px}
button,select,textarea {font:inherit}
button,select {min-height:40px;border-radius:7px;border:1px solid var(--border);background:#fff;color:var(--ink);font-weight:600;font-size:.88rem;padding:7px 13px}
button {cursor:pointer}
button:hover:not(:disabled),select:hover {border-color:var(--teal);background:#f0f7f3}
button.primary {background:var(--teal);color:white;border-color:var(--teal)}
button.primary:hover:not(:disabled) {background:#08534f}
button:disabled {opacity:.47;cursor:default}
button.quiet {background:transparent;border-color:transparent;color:var(--muted)}
button:focus-visible,select:focus-visible,a:focus-visible,textarea:focus-visible,[tabindex]:focus-visible {outline:3px solid #a85f08;outline-offset:3px}
#topics button {flex:1;display:flex;align-items:center;justify-content:center;gap:.6em;border:0;border-bottom:3px solid transparent;border-radius:7px 7px 0 0;background:transparent;text-align:left;line-height:1.25;padding:12px}
#topics button[aria-pressed=true] {background:#e3eeea;border-bottom-color:var(--teal);color:#074e4e}
.topic-num {font:1.1rem Georgia,serif;color:var(--teal)}
.lessonhead {display:flex;justify-content:space-between;align-items:center;gap:20px;padding:21px 0 17px}
h2 {font-size:clamp(1.35rem,2.4vw,1.85rem);letter-spacing:-.04em;margin:2px 0 3px;line-height:1.17}
#goal {max-width:740px}
.variant-box {flex-shrink:0;max-width:40%}
.variant-box label {display:block;font-size:.78rem;font-weight:600;color:var(--muted);margin:0 0 4px}
select {width:100%;padding-right:24px}
#prediction {display:flex;align-items:center;flex-wrap:wrap;gap:9px 20px;background:#fffaf0;border:1px solid #dfd0aa;border-radius:10px;padding:12px 17px;margin-bottom:14px}
.prediction-copy {flex:1 1 240px}
.prediction-copy .label {color:#79540c}
h3 {font-size:1rem;line-height:1.35}
#choices {display:flex;flex-wrap:wrap;gap:5px}
#choices button {min-height:36px;padding:6px 10px;white-space:pre-line}
#choices button[aria-pressed=true] {outline:2px solid #84691a;outline-offset:-2px}
#feedback {flex-basis:100%;font-size:.88rem;color:#694c15}
#feedback[data-correct=true] {color:var(--teal)}
.workspace {display:grid;grid-template-columns:minmax(0,1.08fr) minmax(0,.92fr);align-items:start;gap:14px}
.visual,.codepane {border:1px solid var(--border);border-radius:13px;overflow:hidden;background:white;min-width:0}
.diagram {padding:15px 19px 11px;background-color:var(--diagram);background-image:radial-gradient(#86ada32d .85px,transparent .85px);background-size:14px 14px;color:white}
.diagramhead,.steptop,.codehead,.controls,.edit-controls {display:flex;align-items:center;gap:8px}
.diagramhead,.steptop,.codehead {justify-content:space-between}
.dark-label {color:#d0e6df}
.diagram-key,.direction {font-size:.74rem;color:#d2e2de}
.diagram-key i {display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--amber);margin-right:4px}
#graph {display:block;width:100%;height:auto;min-height:138px;max-height:206px}
.direction {text-align:center}
.wire {fill:none;stroke:#8eb6ac;stroke-width:2}
.node rect {fill:#254e52;stroke:#8bb6aa;stroke-width:1.5}
.node text {fill:#fff;font:bold 16px Consolas,monospace;text-anchor:middle;dominant-baseline:middle}
.node.active rect {stroke:var(--amber);stroke-width:3;fill:#423e29}
.node.active text {fill:#fff3cf}
.cursor {fill:var(--amber);stroke:var(--diagram);stroke-width:3;transition:transform .28s}
.step {padding:16px 18px;background:#f1f7f3}
#position,.small {font-size:.8rem;color:var(--muted)}
#caption {margin:7px 0 11px;min-height:2.95em;font-size:1.02rem;font-weight:550}
#seek {display:block;width:100%;height:20px;margin:0 0 9px;accent-color:var(--teal);cursor:pointer}
.controls {flex-wrap:wrap}
.inspectors {display:grid;grid-template-columns:1fr 1fr;border-top:1px solid var(--border)}
.inspectors section {padding:14px 17px;min-width:0}
.inspectors section+section {border-left:1px solid var(--border)}
.inspectors h3 {font-size:.88rem;margin-bottom:4px}
dl {margin:5px 0;display:grid;grid-template-columns:minmax(0,auto) 1fr;gap:4px 8px;font: .86rem/1.45 Consolas,monospace}
dt {color:var(--muted);overflow-wrap:anywhere}
dd {margin:0;font-weight:600;overflow-wrap:anywhere}
#output,#error {white-space:pre-wrap;overflow-wrap:anywhere;font:.87rem/1.45 Consolas,monospace;margin:6px 0;max-height:170px;overflow:auto}
#error {color:#8f382c}
.codehead {padding:14px 16px;border-bottom:1px solid var(--border)}
.codehead h3 {font-size:1.08rem}
.listing,textarea {font: .85rem/1.7 "SFMono-Regular",Consolas,monospace;tab-size:4}
.listing {background:#fcfcf8;height:clamp(270px,38vh,410px);overflow:auto;padding:10px 0}
.listing .line {display:flex;min-width:100%;width:max-content;border-left:3px solid transparent;min-height:1.7em}
.listing .line.active {border-left-color:#a05c03;background:#fff0c9}
.line .ln {flex:0 0 39px;text-align:right;padding-right:10px;color:#6b7776;user-select:none}
.line code {font:inherit;white-space:pre;padding-right:13px}
#editor-panel {padding:13px}
textarea {display:block;width:100%;height:clamp(270px,38vh,410px);resize:vertical;background:#fafcfb;border:1px solid var(--border);border-radius:6px;color:var(--ink);padding:10px;white-space:pre}
#editor-tip,.status {font-size:.81rem;color:var(--muted)}
#editor-tip {margin:7px 0}
.edit-controls {flex-wrap:wrap}
.status {padding:10px 16px;min-height:39px;border-top:1px solid var(--border)}
footer {display:flex;align-items:center;justify-content:space-between;gap:16px;margin:26px 0 22px;padding-top:17px;border-top:1px solid var(--border);font-size:.82rem;color:var(--muted)}
footer div {display:flex;gap:14px;flex-wrap:wrap}
footer strong {color:var(--ink)}
[hidden] {display:none !important}
.sr,.skip:not(:focus) {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
.skip:focus {position:fixed;top:6px;left:6px;background:white;padding:8px;z-index:3}
@media(max-width:780px) {
  .workspace {grid-template-columns:1fr}
  .intro {padding-block:18px}
  #topics button {padding:9px 4px;font-size:.8rem}
  .lessonhead {align-items:start;flex-wrap:wrap;gap:8px}
  .variant-box {max-width:100%}
  .variant-box label {display:inline-block;margin-right:7px}
  .variant-box select {width:auto;max-width:100%}
  footer {align-items:start;flex-direction:column}
}
@media(max-width:430px) {
  #topics button {flex-direction:column;align-items:start}
  .controls {gap:5px}.controls button {padding-inline:9px}
  .diagram {padding-inline:10px}.inspectors section {padding:11px}
  #choices {gap:6px}#choices button {min-height:42px}
}
@media(prefers-reduced-motion:reduce) {* {transition:none!important;scroll-behavior:auto!important}}
#mro {text-align:center;color:#fff;font:.83rem/1.5 Consolas,monospace;margin:4px 0 0}
#calls {font:.8rem/1.5 Consolas,monospace;color:var(--muted);overflow-wrap:anywhere;margin:0 0 9px}
#guided {margin:0 16px 13px}

.activities {display:flex;gap:1.3rem;border-bottom:1px solid var(--border);margin:0 0 4px}
.activities a {padding:.6rem .1rem .7rem;text-decoration:none;color:var(--muted);font-weight:650;border-bottom:3px solid transparent}
.activities a[aria-current] {color:var(--teal);border-bottom-color:currentColor}
.lessonhead a.eyebrow {text-decoration:none}.lessonhead a.eyebrow:hover{text-decoration:underline}
.lessonhead>div>p,.work-controls .result {color:var(--muted)}
.bench,.task-strip {display:grid;grid-template-columns:minmax(0,1.13fr) minmax(0,.87fr);gap:0;border:1px solid var(--border);border-radius:14px;overflow:hidden;background:#fff}
.shape-stage,.fruit-stage {background-color:var(--diagram);background-image:linear-gradient(#93bdb312 1px,transparent 1px),linear-gradient(90deg,#93bdb312 1px,transparent 1px);background-size:22px 22px;color:#d6ece6;display:flex;flex-direction:column}
.stagehead,.lookup-band {padding:15px 21px;display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.stagehead code,.stagehead>span:last-child {font:.85rem Consolas,monospace;color:#edf6f0}
#shape-picture {display:block;width:100%;height:clamp(185px,21vw,262px);margin:auto 0}
#shape-picture .guide {stroke:#a0d8c1;stroke-opacity:.27;stroke-dasharray:4 5;fill:none}
#circle-drawing,#rect-drawing {stroke-width:3.5;fill-opacity:.68;transition:r .15s,width .15s,height .15s,x .15s,y .15s,fill .15s}
#dimension-line {fill:none;stroke:white;stroke-width:1.5}
#dimension-text {fill:white;font:14px Consolas,monospace}
.lookup-band {border-top:1px solid #91cdb336;background:#0b303550}
#lookup-route {font:600 .9rem Consolas,monospace}
#lookup-route .found {color:#ffdb88;text-decoration:underline;text-underline-offset:4px}
.work-controls {padding:clamp(15px,2vw,26px);display:grid;align-content:center;gap:12px}
.work-controls label,.work-controls legend {font-size:.85rem;font-weight:650}
.work-controls fieldset {border:0;padding:0;margin:0;min-width:0}
.work-controls legend {margin-bottom:4px}
.work-controls label>select {display:block;margin-top:4px}
.switch,.choices {display:flex;gap:7px;flex-wrap:wrap}
button[aria-pressed=true] {border-color:var(--teal);color:var(--teal);background:#e1f0e8}
#dimensions {display:flex;gap:14px}
#dimensions label {flex:1;min-width:0}
#dimensions input {width:100%;display:block;margin:3px 0 0;accent-color:var(--teal)}
#dimensions output {float:right;font:600 .93rem Consolas,monospace}
.property-row {display:flex;gap:20px;align-items:center}
.property-row>label:first-child {flex:1}.property-row .check {display:flex;align-items:center;gap:4px}
input[type=checkbox] {accent-color:var(--teal);width:17px;height:17px}
.task-strip {margin:12px 0 0}
.task-strip>div {padding:16px 21px}
.task-strip h3 {margin:4px 0 9px}
.script-card {background:#ecf3ee;border-left:1px solid var(--border)}
.script-card pre,.inline-code {font:.88rem/1.6 Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:5px 0 10px}
.result {font-size:.92rem;line-height:1.5;margin-top:8px;min-height:1.5em}
.fruit-stage {justify-content:center}.tree-grid {position:relative;aspect-ratio:600/245;width:100%;margin:auto;min-height:205px}
.tree-grid svg,#tree-nodes {position:absolute;inset:0;width:100%;height:100%}
#tree-lines path {stroke:#b2cfc6;fill:none;stroke-width:2}
#tree-lines .onpath {stroke:#ffdb88;stroke-width:3}
#tree-nodes button {position:absolute;transform:translate(-50%,-50%);border-radius:5px;font:600 clamp(.66rem,1vw,.85rem) Consolas,monospace;min-height:32px;padding:5px 8px;background:#225054;border:1px solid #94bdb2;color:white}
#tree-nodes button.object-node {border-style:double;border-width:3px}
#tree-nodes button.ancestor {border-color:#ffda88;color:#ffda88}
#tree-nodes button[aria-pressed=true] {outline:2px solid white;outline-offset:2px}
.fruit-bench .inline-code {background:#edf4ef;border-radius:5px;padding:8px;margin:0}
#topics {align-items:center;margin-top:16px;border:0;flex-wrap:wrap}
#topics label {font-size:.82rem;font-weight:650;color:var(--muted)}#topic-picker {width:auto;max-width:100%;min-width:14rem}
#topics .path-controls {display:flex;gap:5px}#topics .path-controls button {display:inline-block;flex:none;text-align:center;border:1px solid var(--border);border-radius:5px;background:white;padding:3px 11px}
#topics .path-controls button:disabled{cursor:default}
@media(max-width:700px) {
 .bench,.task-strip {grid-template-columns:minmax(0,1fr)}
 .work-controls {gap:10px}.stagehead,.lookup-band {padding:11px 15px}
 .script-card {border:0;border-top:1px solid var(--border)}
 .activities {gap:1rem}.activities a{font-size:.9rem}
 #topic-picker {min-width:0;flex:1}#topics>label {flex-basis:100%}
 .fruit-bench #tree-nodes button {font-size:.73rem}
}
