/* The opening is a lesson as well as a viewer: keep its explanations readable. */
.smpl-intro {
  --smpl-accent: #357e75;
  container-type: inline-size;
  margin: 20px 0 40px;
  border: 1px solid #d5dfcf;
  border-radius: 18px;
  overflow: clip;
  background: #fbfcf7;
  color: #29433b;
  font: 16px/1.8 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}
.smpl-intro * { box-sizing: border-box; }
.smpl-intro [hidden], .smpl-intro[hidden] { display: none !important; }
.smpl-intro-header { padding: 28px 28px 20px; }
.smpl-intro h2 { margin: 7px 0 14px; font-size: 30px; line-height: 1.4; font-weight: 600; letter-spacing: -.4px; }
.smpl-intro .smpl-kicker { font-size: 13px; line-height: 1.6; letter-spacing: 1.6px; color: #476b5a; text-transform: uppercase; }
.smpl-intro p { margin: 12px 0; font-size: 16px; line-height: 1.85; overflow-wrap: anywhere; }
.smpl-intro button, .smpl-intro select, .smpl-intro input { font: inherit; }
.smpl-intro button, .smpl-intro select {
  max-width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #bdcdb5;
  border-radius: 8px;
  background: #fffefa;
  color: #294f42;
  font-size: 15px;
  line-height: 1.55;
  cursor: pointer;
}
.smpl-intro button:hover { border-color: #65a08e; background: #f1f6ec; }
.smpl-intro button[aria-pressed=true], .smpl-intro button.smpl-primary { background: #367d70; color: white; border-color: #367d70; }
.smpl-intro button:disabled { opacity: .55; cursor: default; }
.smpl-intro :is(button, select, input, canvas, a, summary):focus-visible { outline: 3px solid #6caa8d; outline-offset: 3px; }
.smpl-steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 0 24px 23px; }
.smpl-steps button { display: flex; gap: 9px; align-items: center; text-align: left; padding: 11px 10px; background: #f1f5eb; border-color: #d5dfce; }
.smpl-steps button[aria-current=step] { background: #e0eee2; border-color: #7da58c; box-shadow: inset 0 -2px #40826c; }
.smpl-step-number { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: #dce7d6; color: #3e6048; font-size: 14px; }
.smpl-steps button[aria-current=step] .smpl-step-number { background: #43846d; color: white; }
.smpl-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; border-top: 1px solid #dfe6d7; border-bottom: 1px solid #dfe6d7; }
.smpl-main-column { min-width: 0; }
.smpl-stage { position: relative; align-self: start; min-width: 0; min-height: 600px; overflow: hidden; background: #f0f4e9; }
.smpl-computation-mount { min-width: 0; border-top: 1px solid #dfe6d7; background: #fbfcf7; padding: 22px; }
.smpl-frame, .smpl-canvas { display: block; width: 100%; height: 600px; min-height: 600px; border: 0; background: #f0f4e9; }
.smpl-canvas { touch-action: none; cursor: grab; }
.smpl-canvas:active { cursor: grabbing; }
.smpl-stage-top { position: absolute; top: 14px; left: 14px; right: 14px; z-index: 2; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.smpl-stage-top>div, .smpl-stage-top>button { pointer-events: auto; }
.smpl-mode-caption { max-width: calc(100% - 120px); padding: 8px 10px; border-radius: 6px; background: #fffffff2; color: #36553e; font-size: 13px; line-height: 1.65; }
.smpl-stage-bottom { position: absolute; bottom: 14px; left: 14px; right: 14px; padding: 10px 12px; border: 1px solid #dfe6d7; border-radius: 8px; background: #fbfcf7f2; color: #405d45; font-size: 13px; line-height: 1.7; pointer-events: none; }
.smpl-joint-label { position: absolute; z-index: 2; padding: 5px 8px; border: 1px solid #c5d7ba; border-radius: 5px; box-shadow: 0 2px 8px #31564213; background: #ffffffed; font-size: 14px; white-space: nowrap; pointer-events: none; }
.smpl-panel { min-width: 0; padding: 24px 22px; border-left: 1px solid #dfe6d7; background: #fafbf5; }
.smpl-panel h3 { margin: 0 0 12px; font-size: 21px; line-height: 1.5; font-weight: 600; }
.smpl-panel h4 { margin: 23px 0 10px; font-size: 17px; line-height: 1.6; font-weight: 600; }
.smpl-definition { padding: 15px 16px; border-left: 3px solid #7fa474; border-radius: 9px; background: #edf3e6; font-size: 16px; line-height: 1.85; }
.smpl-definition strong { font-weight: 620; }
.smpl-actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 16px 0; }
.smpl-step-nav button { flex: 1; white-space: nowrap; }
.smpl-step-nav button[data-smpl-ask] { flex-basis: 100%; }
.smpl-label { display: block; margin-top: 20px; font-size: 15px; line-height: 1.7; font-weight: 550; }
.smpl-joint-select { width: 100%; margin: 8px 0 12px; }
.smpl-color-dot { display: inline-block; width: 13px; height: 13px; margin-right: 8px; border-radius: 50%; vertical-align: middle; }
.smpl-joint-name { font-size: 16px; line-height: 1.65; font-weight: 600; overflow-wrap: anywhere; }
.smpl-hierarchy { font-size: 15px; line-height: 1.8; }
.smpl-hierarchy p { overflow-wrap: anywhere; }
.smpl-hierarchy details>summary, .smpl-import>summary { padding: 10px 0; color: #365d41; font-size: 15px; line-height: 1.75; cursor: pointer; }
.smpl-legend { margin: 20px 0 14px; }
.smpl-legend-title { margin-bottom: 9px; font-size: 15px; line-height: 1.75; }
.smpl-colorbar { height: 18px; border: 1px solid #aebda3; border-radius: 4px; }
.smpl-color-ticks { display: flex; justify-content: space-between; padding-top: 5px; color: #4e6547; font-size: 14px; font-variant-numeric: tabular-nums; }
.smpl-angle { display: block; min-width: 0; margin: 16px 0; }
.smpl-angle>span { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 15px; line-height: 1.7; }
.smpl-angle output { color: #286454; font-variant-numeric: tabular-nums; }
.smpl-intro input[type=range] { display: block; width: 100%; height: 32px; margin: 5px 0; accent-color: var(--smpl-accent); }
.smpl-controls-note, .smpl-bone-help { color: #465e40; font-size: 14px !important; line-height: 1.8 !important; }
.smpl-controls-note strong { color: #345c46; }
.smpl-correctives { display: flex; align-items: flex-start; gap: 9px; margin: 17px 0; font-size: 15px; line-height: 1.8; }
.smpl-correctives input { flex: none; width: 18px; height: 18px; margin: 5px 0 0; accent-color: var(--smpl-accent); }
.smpl-vertex { margin: 22px 0 0; padding: 16px; border-radius: 9px; background: #edf3e7; }
.smpl-vertex h4 { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 13px; font-size: 16px; }
.smpl-vertex h4>button { flex: none; min-width: 40px; min-height: 40px; padding: 4px 8px; font-size: 20px; }
.smpl-vertex-list { display: grid; gap: 12px; }
.smpl-vertex-row { display: grid; grid-template-columns: minmax(0, 1fr) 63px; gap: 7px 9px; font-size: 14px; line-height: 1.7; }
.smpl-vertex-row>button { min-height: 36px; padding: 3px 0; border: 0; background: transparent; font-size: 14px; line-height: 1.7; text-align: left; overflow-wrap: anywhere; }
.smpl-weight-number { align-self: center; text-align: right; font-variant-numeric: tabular-nums; }
.smpl-tinybar { grid-column: 1/-1; height: 6px; margin-top: -5px; border-radius: 3px; overflow: hidden; background: #d2dfc9; }
.smpl-tinybar i { display: block; height: 100%; border-radius: 3px; }
.smpl-vertex-sum { margin-bottom: 0 !important; font-size: 13px !important; }
.smpl-vertex-search { display: flex; align-items: flex-end; gap: 10px; margin-top: 15px; }
.smpl-vertex-search label { flex: 1; min-width: 0; font-size: 14px; line-height: 1.7; }
.smpl-vertex-search input { display: block; width: 100%; min-height: 44px; margin-top: 7px; padding: 8px; border: 1px solid #bdcdb5; border-radius: 6px; background: #fffefa; font-size: 15px; }
.smpl-vertex-search button { flex: none; }
.smpl-vertex-position { min-width: 0; margin: 15px 0; overflow-x: auto; font-size: 15px; line-height: 1.8; }
.smpl-vertex-position>.katex-display { margin: 10px 0; font-size: 15px; }
.smpl-motion-file { display: block; margin: 14px 0; font-size: 14px; line-height: 1.8; }
.smpl-motion-file input { display: block; width: 100%; margin-top: 7px; padding: 8px 0; font-size: 14px; white-space: normal; }
.smpl-motion-file input::file-selector-button { min-height: 42px; margin-right: 7px; padding: 8px; border: 1px solid #bdcdb5; border-radius: 6px; background: #fffefa; color: #294f42; font: inherit; }
.smpl-motion-time { display: flex; justify-content: space-between; color: #465e40; font-size: 14px; line-height: 1.7; font-variant-numeric: tabular-nums; }
.smpl-motion-speed { display: flex; align-items: center; gap: 12px; margin: 14px 0; font-size: 15px; }
.smpl-motion-speed select { flex: 1; font-size: 15px; }
.smpl-motion-status { color: #465e40; font-size: 14px !important; }
.smpl-math-fold { margin-top: 23px; padding-top: 12px; border-top: 1px solid #d5dfce; }
.smpl-math-fold>summary { padding: 7px 0; color: #365d41; font-size: 15px; line-height: 1.75; cursor: pointer; }
.smpl-math-fold [data-tex] { display: block; max-width: 100%; padding: 9px 0; overflow-x: auto; font-size: 15px; }
.smpl-math-fold .katex-display { margin: 10px 0; }
.smpl-math-fold .katex-display>.katex { text-align: left; }
.smpl-panel .smpl-math-fold h4 { font-size: 17px; line-height: 1.7; }
.smpl-panel .smpl-math-fold p, .smpl-intro details>p { font-size: 15px; line-height: 1.85; }
.smpl-footer { padding: 24px 28px 26px; }
.smpl-flow { display: flex; flex-wrap: wrap; gap: 8px 13px; color: #465f3f; font-size: 15px; line-height: 1.8; }
.smpl-flow strong { color: #2f674c; }
.smpl-footer p { font-size: 15px; }
.smpl-footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 15px; margin-top: 19px; }
.smpl-footer-bottom>a { color: #2e684d; font-size: 16px; line-height: 1.8; }
.smpl-source { margin: 18px 0 0 !important; color: #4e6244; font-size: 13px !important; line-height: 1.8 !important; }
.smpl-source a { color: #365e41; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.smpl-status { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 30px; background: #f0f4e9; color: #4e6848; font-size: 16px; line-height: 1.8; text-align: center; }
.smpl-status strong { display: block; margin-bottom: 12px; color: #345b3e; font-size: 21px; line-height: 1.6; }
.smpl-status p { max-width: 400px; margin-left: auto; margin-right: auto; }
.smpl-error, .smpl-error strong { color: #85413a; }
.smpl-error pre { font-family: ui-monospace, monospace; font-size: 14px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.smpl-feedback { margin: 13px 0; color: #79513c; font-size: 14px; line-height: 1.8; }
.smpl-axes { margin: 14px 0; color: #465e40; font-size: 14px; line-height: 1.8; }
.smpl-axes span { margin-right: 12px; }
.smpl-muted { color: #465e40; }
.smpl-focus-marker { position: absolute; z-index: 2; width: 11px; height: 11px; border: 2px solid #304f39; border-radius: 50%; box-shadow: 0 0 0 2px #ffffffaa; background: white; transform: translate(-50%, -50%); pointer-events: none; }
.smpl-intro code { font-family: ui-monospace, monospace; font-size: .95em; overflow-wrap: anywhere; }
#smpl-opening { overflow: visible; }

/* Use the lesson's available width, including when the AI column is expanded. */
@container (max-width: 899px) {
  .smpl-workspace { grid-template-columns: 1fr; }
  .smpl-stage { position: relative; top: auto; }
  .smpl-stage, .smpl-frame, .smpl-canvas { height: 570px; min-height: 570px; }
  .smpl-panel { padding: 24px; border-left: 0; border-top: 1px solid #dfe6d7; }
  .smpl-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  .smpl-controls-note, .smpl-controls>.smpl-actions { grid-column: 1/-1; }
  .smpl-angle { margin: 8px 0; }
  .smpl-angle>span { flex-wrap: wrap; gap: 4px 10px; }
  .smpl-step-nav button[data-smpl-ask] { flex-basis: auto; }
  .smpl-steps { gap: 6px; padding-left: 18px; padding-right: 18px; }
  .smpl-steps button { gap: 7px; padding: 10px 8px; }
}
@container (max-width: 550px) {
  .smpl-intro-header { padding: 23px 18px 17px; }
  .smpl-intro h2 { font-size: 27px; }
  .smpl-steps { display: flex; gap: 8px; padding: 0 14px 18px; overflow-x: auto; scrollbar-width: thin; }
  .smpl-steps button { flex: 0 0 auto; padding: 10px 12px; white-space: nowrap; }
  .smpl-panel { padding: 22px 18px; }
  .smpl-computation-mount { padding: 20px 16px; }
  .smpl-stage, .smpl-frame, .smpl-canvas { height: 480px; min-height: 480px; }
  .smpl-stage-top { top: 10px; left: 10px; right: 10px; gap: 8px; }
  .smpl-stage-top button { padding: 8px 10px; font-size: 14px; }
  .smpl-stage-top .smpl-mode-caption { max-width: calc(100% - 107px); padding: 7px 8px; }
  .smpl-stage-bottom { bottom: 10px; left: 10px; right: 10px; padding: 9px 10px; }
  .smpl-controls { gap: 9px; }
  .smpl-step-nav { gap: 8px; }
  .smpl-step-nav button[data-smpl-ask] { flex-basis: 100%; }
  .smpl-footer { padding: 21px 18px 24px; }
  .smpl-footer-bottom>a { width: 100%; }
}
@media (max-width: 720px) {
  .smpl-intro { margin: 16px 0 30px; border-radius: 14px; }
  .smpl-stage { position: relative; top: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .smpl-intro * { scroll-behavior: auto !important; }
}

/* Wide-screen teaching workspace: computation | body | concepts / controls.
   Only the two text columns scroll; changing a matrix never pushes the body away. */
.reading-shell:has([data-smpl-root]) { padding-inline:24px; }
main:has([data-smpl-root]) { max-width:none; }
#smpl-opening { padding-inline:14px; }
.smpl-intro { --smpl-workspace-height:clamp(650px,calc(100dvh - var(--top,84px) - 30px),920px); overflow:visible; }
.smpl-column-jumps { display:flex; flex-wrap:wrap; align-items:center; gap:7px; padding:0 22px 18px; }
.smpl-column-jumps>span { margin-right:auto; color:#4b6654; font-size:14px; line-height:1.7; }
.smpl-column-jumps>button { min-height:38px; padding:7px 10px; font-size:14px; }
.smpl-workspace { grid-template-columns:minmax(365px,1fr) minmax(360px,1.25fr) minmax(270px,290px); grid-template-areas:"calculation viewer controls"; height:var(--smpl-workspace-height); min-height:650px; align-items:stretch; }
.smpl-computation-column, .smpl-view-column, .smpl-concepts-column { display:flex; flex-direction:column; min-width:0; min-height:0; height:100%; scroll-margin-top:calc(var(--top,84px) + 14px); outline-offset:-4px; }
.smpl-computation-column { grid-area:calculation; background:#fafcf5; }
.smpl-view-column { grid-area:viewer; border-inline:1px solid #d4decc; background:#f0f4e9; }
.smpl-concepts-column { grid-area:controls; background:#fafbf5; }
.smpl-intro .smpl-column-heading { display:flex; flex-wrap:wrap; gap:7px; align-items:center; min-height:65px; flex:none; margin:0; padding:13px 14px; border-bottom:1px solid #d7e1cd; background:#eaf1e3; }
.smpl-intro .smpl-column-heading h3 { flex:1; min-width:90px; margin:0; color:#335d46; font-size:17px; font-weight:600; line-height:1.6; }
.smpl-column-heading>span:last-child:not(.smpl-column-letter) { color:#4f6d49; font-size:13px; }
.smpl-column-letter { display:grid; place-items:center; width:24px; height:24px; border-radius:50%; background:#d6e4cf; color:#3c6b45; font-size:13px; }
.smpl-column-scroll { flex:1; min-width:0; min-height:0; overflow-y:auto; overflow-x:hidden; overscroll-behavior-y:contain; scrollbar-width:thin; scrollbar-color:#a2b596 #f3f6ed; scroll-padding-block:14px; }
.smpl-computation-mount { min-width:0; padding:0; border-top:0; }
.smpl-computation-scroll>.smpl-vertex { margin:15px; }
.smpl-intro .smpl-panel { padding:18px 16px 26px; border:0; }
.smpl-intro .smpl-panel h3 { font-size:19px; }
.smpl-intro .smpl-definition { padding:13px 12px; }
.smpl-intro .smpl-view-column .smpl-stage { flex:1; position:relative; top:auto; align-self:stretch; min-height:0; height:auto; }
.smpl-intro .smpl-view-column :is(.smpl-frame,.smpl-canvas) { height:100%; min-height:0; }
.smpl-intro .smpl-view-column .smpl-stage-top { top:10px; left:10px; right:10px; gap:7px; }
.smpl-intro .smpl-view-column .smpl-mode-caption { max-width:calc(100% - 112px); }
.smpl-intro .smpl-view-column .smpl-stage-top>button { min-height:39px; padding:8px 9px; font-size:14px; }
.smpl-intro .smpl-view-column .smpl-stage-bottom { left:9px; right:9px; bottom:9px; padding:9px 10px; font-size:13px; }
.smpl-intro .smpl-panel .smpl-controls { display:block; }
.smpl-intro .smpl-panel .smpl-angle { margin:13px 0; }
.smpl-intro .smpl-panel .smpl-step-nav button[data-smpl-ask] { flex-basis:100%; }
.smpl-intro .smpl-panel :is(.smpl-controls-note,.smpl-bone-help) { overflow-wrap:anywhere; }
/* This remains a real column, rather than shrinking a 4x4 matrix to fit. */
.smpl-computation-mount .smc-main-body { padding-inline:15px; }
.smpl-computation-mount .smc-main-fold>summary { padding:17px 15px; }
.smpl-computation-mount .smc-math { font-size:16px; }
.smpl-computation-mount .smc-term-symbol { max-width:100%; }
@container (max-width:1039px) {
  .smpl-workspace { grid-template-columns:minmax(0,1fr) 280px; grid-template-areas:"viewer controls" "calculation calculation"; height:auto; min-height:0; }
  .smpl-view-column, .smpl-concepts-column { height:620px; }
  .smpl-view-column { border-left:0; }
  .smpl-computation-column { height:760px; border-top:1px solid #d4decc; }
  .smpl-computation-mount .smc-main-body { padding-inline:22px; }
  .smpl-computation-mount .smc-main-fold>summary { padding-inline:22px; }
}
@container (max-width:719px) {
  .smpl-workspace { display:flex; flex-direction:column; height:auto; }
  .smpl-view-column { order:1; height:560px; border-inline:0; }
  .smpl-concepts-column { order:2; height:auto; border-top:1px solid #d4decc; }
  .smpl-computation-column { order:3; height:auto; border-top:1px solid #d4decc; }
  .smpl-column-scroll { flex:none; overflow:visible; overscroll-behavior-y:auto; }
  .smpl-intro .smpl-panel .smpl-controls { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:13px; }
  .smpl-intro .smpl-panel .smpl-controls>.smpl-controls-note, .smpl-intro .smpl-panel .smpl-controls>.smpl-actions { grid-column:1/-1; }
  .smpl-column-jumps { padding-inline:15px; }
  .smpl-column-jumps>span { width:100%; }
  .smpl-intro .smpl-panel { padding:21px 18px; }
  .smpl-computation-mount .smc-main-body { padding-inline:14px; }
  .smpl-computation-mount .smc-main-fold>summary { padding-inline:14px; }
}
@media(max-width:720px) {
  .reading-shell:has([data-smpl-root]) { padding-inline:15px; }
  #smpl-opening { padding-inline:9px; }
  .smpl-intro .smpl-column-heading { min-height:60px; }
}
@media(max-width:720px) {
  .reading-shell:has([data-smpl-root]) .content-block>.block-ask { right:-2px; }
}

/* Stage 5 is a continuous review sheet beside the same live body. */
.smpl-intro[data-formula-summary=true] .smpl-workspace { display:grid; grid-template-columns:minmax(0,1.55fr) minmax(340px,1fr); grid-template-areas:"calculation viewer"; align-items:start; height:auto; min-height:0; }
.smpl-intro[data-formula-summary=true] .smpl-computation-column { height:auto; min-width:0; border-top:0; }
.smpl-intro[data-formula-summary=true] .smpl-computation-scroll { overflow:visible; overscroll-behavior:auto; }
.smpl-intro[data-formula-summary=true] .smpl-view-column { position:sticky; top:calc(var(--top,64px) + 10px); height:clamp(520px,calc(100dvh - var(--top,64px) - 24px),740px); border-right:0; }
@container (max-width:719px) {
  .smpl-intro[data-formula-summary=true] .smpl-workspace { display:flex; }
  .smpl-intro[data-formula-summary=true] .smpl-view-column { position:relative; top:auto; height:480px; order:1; }
  .smpl-intro[data-formula-summary=true] .smpl-computation-column { order:2; border-top:1px solid #d4decc; }
}
