.stage-module-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; margin-bottom: 1.2rem; font-size: .7rem; }
.stage-section { border-bottom: 1px solid var(--ece-border); padding: 1rem 0 1.8rem; margin-bottom: 1.5rem; scroll-margin-top: 1.5rem; }
.stage-section h2 { font-size: 1.15rem; margin: .4rem 0 1rem; line-height: 1.5; }
.stage-section h3 { font-size: .9rem; line-height: 1.6; }
.stage-lesson p,.stage-lesson li { font-size: .8rem; line-height: 1.8; }
.stage-opening,.stage-closing { border: 1px solid #ddd0eb; border-radius: 10px; padding: 1.1rem; background: #f6f1fb; font-size: .85rem; line-height: 1.9; }
.stage-opening p { margin: .4rem 0 0; }
.stage-goals { padding-left: 1.2rem; margin: 1.1rem 0; }
.stage-concept-figure { margin: 1.2rem 0; }
.stage-concept-figure img { width: 100%; height: auto; display: block; }
.stage-concept-figure figcaption { color: var(--ece-muted); font-size: .65rem; line-height: 1.7; margin-top: .5rem; }
.stage-concepts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; }
.stage-concepts article { border: 1px solid var(--ece-border); padding: 1rem; border-radius: 9px; min-width: 0; }
.stage-concepts h3 { margin-top: 0; }
.stage-concepts p { margin-bottom: 0; }
.stage-math { margin: .6rem 0; overflow-x: auto; padding: .2rem 0; font-size: .75rem; }
.stage-math .katex-display { text-align: left; margin: .5rem 0; }
.stage-math .katex-display > .katex { text-align: left; }
.stage-worked { padding-left: 1.2rem; }
.stage-worked li { padding: .45rem .2rem; }
.stage-source,.stage-advanced,.stage-checks,.stage-solution { border: 1px solid var(--ece-border); border-radius: 8px; padding: .8rem 1rem; margin: .9rem 0; background: #fff; }
.stage-source summary,.stage-advanced summary,.stage-checks summary,.stage-solution summary { font-size: .73rem; font-weight: 550; }
.stage-source ul { padding-left: 1rem; }
.stage-lab { border: 1px solid var(--ece-border); border-radius: 12px; padding: 1.1rem; background: var(--ece-paper); }
.stage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .7rem 0 1rem; }
.stage-actions button { font: inherit; font-size: .72rem; padding: .6rem .8rem; border-radius: 6px; border: 1px solid #c9badb; color: var(--ece-purple); background: #fff; cursor: pointer; min-height: 40px; }
.stage-controls { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem 1.2rem; }
.stage-advanced .stage-controls { margin-top: 1rem; }
.stage-control { min-width: 0; }
.stage-control label { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .68rem; font-weight: 500; line-height: 1.6; margin-bottom: .4rem; }
.stage-control output { color: var(--ece-purple); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage-control input[type="range"] { display: block; width: 100%; height: 32px; padding: 0; margin: 0; accent-color: var(--ece-purple); background: transparent; box-shadow: none; }
.stage-control input[type="number"],.stage-control select { width: 100%; box-sizing: border-box; padding: .6rem; height: 40px; margin: 0; border: 1px solid #cfc4dc; border-radius: 6px; background: #fff; color: var(--ece-ink); font: inherit; font-size: .75rem; box-shadow: none; }
.stage-lesson .stage-status { color: var(--ece-muted); font-size: .68rem; margin: .8rem 0; }
.stage-status[data-state="error"] { color: #a64f28 !important; }
.stage-metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .6rem; margin: 1rem 0; }
.stage-metrics > div { border: 1px solid var(--ece-border); border-radius: 7px; padding: .75rem; background: #fff; min-width: 0; }
.stage-metrics span { display: block; font-size: .6rem; color: var(--ece-muted); margin-bottom: .4rem; line-height: 1.6; }
.stage-metrics strong { font-size: .75rem; line-height: 1.6; display: block; font-variant-numeric: tabular-nums; }
.stage-lesson svg { display: block; width: 100%; height: auto; }
.stage-diagram-figure { background: #fff; border: 1px solid var(--ece-border); border-radius: 8px; padding: .6rem; margin: .9rem 0; }
.stage-diagram-figure svg { max-width: 820px; margin: auto; }
.stage-svg-text { font: 13px system-ui,sans-serif; fill: #5a5363; }
.stage-svg-title { font: 600 14px system-ui,sans-serif; fill: #512888; }
.stage-axis { stroke: #918697; stroke-width: 1.3; fill: none; }
.stage-grid { stroke: #e6e1ed; stroke-width: 1; fill: none; }
.stage-plots { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; }
.stage-plots figure { min-width: 0; background: #fff; border: 1px solid var(--ece-border); border-radius: 8px; padding: .7rem; margin: 0; }
.stage-plots h3 { font-size: .78rem; margin: .3rem 0 .5rem; }
.stage-plots figcaption { font-size: .62rem; line-height: 1.8; color: var(--ece-muted); margin-top: .5rem; }
.stage-checks pre { font: 12px/1.8 ui-monospace,SFMono-Regular,Consolas,monospace; white-space: pre-wrap; overflow-wrap: anywhere; background: #fff; padding: .6rem 0 0; margin-bottom: 0; }
.ece-body .stage-note { color: var(--ece-muted); font-size: .68rem; line-height: 1.8; }
.stage-code .bf-code { padding: 1.1rem; border: 1px solid var(--ece-border); border-radius: 10px; }
.stage-code label { display: block; margin: .6rem 0; font-size: .75rem; font-weight: 600; }
.stage-code textarea { display: block; width: 100%; box-sizing: border-box; resize: vertical; padding: .8rem; border-radius: 7px; border: 1px solid #cfc4dc; background: #fdfcfe; color: #31283e; font: 13px/1.65 ui-monospace,SFMono-Regular,Consolas,monospace; tab-size: 4; white-space: pre; }
.stage-code .bf-code-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .9rem 0; font-size: .7rem; }
.stage-code .btn { margin: 0; padding: .6rem .8rem; min-height: 40px; border-radius: 6px; background: var(--ece-purple); color: #fff; font-size: .7rem; cursor: pointer; }
.stage-code .btn:disabled { opacity: .45; cursor: default; }
.stage-code .bf-console { min-height: 3rem; max-height: 350px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: .9rem; background: #282232; color: #f0e8fa; font: 12px/1.8 ui-monospace,SFMono-Regular,Consolas,monospace; border-radius: 7px; }
.stage-code .bf-caption,.stage-code .bf-code-status { font-size: .68rem; }
.stage-code .bf-code-result { margin: 1rem 0; }
.stage-code .bf-code-result svg { max-width: 820px; margin: auto; }
.stage-code .bf-details { margin-top: 1rem; border-top: 1px solid var(--ece-border); padding-top: .9rem; }
.stage-code .bf-details summary { font-size: .72rem; font-weight: 600; }
.stage-code .bf-details button { margin-top: .8rem; }
.stage-answer-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .9rem; margin: 1rem 0; }
.stage-answer-grid label { display: block; font-size: .7rem; line-height: 1.6; margin: 0 0 .4rem; }
.stage-answer-grid input { width: 100%; box-sizing: border-box; border: 1px solid #cfc4dc; border-radius: 6px; background: #fff; padding: .6rem; font: inherit; font-size: .78rem; margin: 0; }
.stage-answer-grid input[aria-invalid="true"] { border-color: #a64f28; }
.stage-answer-grid input[aria-invalid="false"] { border-color: #4c896b; }
.stage-answer-grid small { display: block; margin-top: .4rem; font-size: .62rem; line-height: 1.7; color: var(--ece-muted); }
.stage-lesson [data-stage-feedback] { color: #92551f; min-height: 1.4rem; }
.stage-lesson [data-stage-feedback][data-correct="true"] { color: #21644c; }
.stage-quiz { margin: 1.4rem 0; }
.stage-quiz fieldset { border: 0; margin: 0 0 .8rem; padding: 0; }
.stage-quiz legend { font-size: .8rem; line-height: 1.8; font-weight: 600; margin-bottom: .65rem; }
.stage-quiz label { display: flex; gap: .6rem; font-size: .76rem; font-weight: 400; line-height: 1.8; padding: .45rem 0; cursor: pointer; }
.stage-quiz input { margin: .4rem 0 0; accent-color: var(--ece-purple); flex: 0 0 auto; }
.stage-closing h3 { margin-top: 0; }
@media(max-width:1100px) { .stage-concepts,.stage-plots { grid-template-columns: 1fr; } .stage-plots svg { max-width: 650px; margin: auto; } .stage-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width:550px) { .stage-controls,.stage-answer-grid { grid-template-columns: 1fr; } .stage-lab,.stage-code .bf-code,.stage-opening,.stage-closing { padding: .8rem; } .stage-concept-figure { overflow-x: auto; } .stage-concept-figure img { min-width: 620px; } .stage-code textarea { font-size: 12px; } .stage-svg-text { font-size: 14px; } }
@media(max-width:550px) {
  .stage-diagram-figure,.stage-plots figure,.stage-code .bf-code-result { overflow-x: auto; }
  .stage-diagram-figure svg,.stage-plots svg,.stage-code .bf-code-result svg { min-width: 520px; }
}
