.math-path,.math-lesson{max-width:740px;margin:32px auto 100px;padding:0 20px;color:var(--ink,#24454b)}
.math-unit{padding:24px 28px;border-radius:20px;background:#32c3d4;color:#072c34}.math-unit h1{font-size:1.7rem;margin:.35em 0}.math-unit p{margin:0}
.math-path-list{padding:35px 0}.math-path-row{display:flex;align-items:center;gap:24px;min-height:150px;margin-left:calc(10% + (var(--n, 0) * 10%))}.math-path-row:nth-child(4n+2){margin-left:24%}.math-path-row:nth-child(4n+3){margin-left:12%}.math-path-row h2{font-size:1.15rem;margin:.2em 0 .6em}.math-path-row small{font-weight:800;color:#008b9e}
.math-node{width:75px;height:67px;border:0;border-radius:50%;background:#35c5d6;box-shadow:0 7px #00a9bc;font-size:30px;font-weight:900;cursor:pointer;flex:none}.math-node.is-complete{background:#8be0e8}.math-node:disabled{background:#dce5e6;box-shadow:0 7px #c5d1d2;color:#819699;cursor:default}
.math-btn{min-height:48px;border:2px solid #a1e4ed;border-bottom-width:5px;border-radius:14px;background:var(--surface,#fff);color:inherit;padding:10px 18px;font-size:1rem;font-weight:750;cursor:pointer}.math-path-row .math-btn{margin:0 8px 8px 0}.math-btn:hover,.math-btn[aria-pressed=true]{background:#d6f5f8;border-color:#00bcd2}.math-btn:disabled{opacity:.45;cursor:default}.math-btn:focus-visible,.math-node:focus-visible{outline:3px solid #006d80;outline-offset:3px}
.math-lesson-top{display:flex;align-items:center;gap:20px;max-width:780px;margin:28px auto;padding:0 20px}.math-lesson-top a{font-size:32px;text-decoration:none;color:#73878a}.math-progress{height:15px;flex:1;border-radius:20px;background:#e3ebeb;overflow:hidden}.math-progress span{display:block;background:#00bdd2;height:100%;transition:width .2s}.math-lesson h1{font-size:clamp(1.4rem,3vw,2rem);line-height:1.4;margin:.6em 0 1em}.math-lesson small{font-weight:800;color:#008ea0}.math-balance{display:flex;align-items:center;justify-content:center;gap:12px;background:#dcf7f9;border-radius:22px;padding:30px 12px;margin:0 0 24px}.math-pan{background:#fff;border:3px solid #54c7d2;border-bottom-width:8px;border-radius:14px;min-width:32%;padding:20px 8px;text-align:center;font-size:clamp(1.1rem,4vw,1.65rem);font-weight:800;color:#24454b}.math-equal{font-size:2rem;font-weight:800}.math-choices{display:grid;gap:10px}.math-choices .math-btn{text-align:left;min-height:58px}.math-hint{padding:14px;border-radius:14px;background:#e7f8fa;line-height:1.5}.math-hint.is-wrong{background:#fff1e7;color:#824327}.math-hint.is-right{background:#e5f7ed;color:#226445}.math-footer{margin-top:24px;display:flex;justify-content:flex-end}.math-footer .math-btn,.math-result>.math-btn{background:#1dbbcf;color:#073238;border-color:#009fb1;min-width:135px}.math-result .math-btn{margin-right:10px}
[data-theme=dark] .math-lesson,[data-theme=dark] .math-path{color:#edf9fa}[data-theme=dark] .math-choices .math-btn{background:#17373d;color:#edf9fa}[data-theme=dark] .math-choices .math-btn[aria-pressed=true]{background:#126474}[data-theme=dark] .math-hint{color:#163e45}
@media(max-width:600px){.math-path,.math-lesson{margin-top:20px;padding:0 16px}.math-lesson-top{margin:15px auto}.math-balance{padding:18px 8px}.math-pan{padding:15px 4px}.math-choices{gap:8px}.math-choices .math-btn{min-height:50px}.math-footer{margin-top:16px}}
.math-order-workspace{display:grid;gap:8px;min-height:90px;border:2px dashed #62cbd7;border-radius:16px;padding:12px;margin-bottom:14px;background:#effbfc;color:#30575d}.math-order-workspace .math-btn{text-align:left}.math-order-pool [data-math-drag]{touch-action:none;cursor:grab}.math-order-workspace.is-drop{background:#c9f1f4;border-color:#009cae}.math-drag-ghost{position:fixed;pointer-events:none;z-index:10000;opacity:.9;transform:translate(-50%,-50%)}
.math-tokens{display:flex;justify-content:center;align-items:center;align-content:center;gap:4px;flex-wrap:wrap;max-width:180px;min-height:48px;margin:12px auto 0}.math-tokens i{width:10px;height:10px;border-radius:50%;background:#eeaa56}.math-token-x{display:inline-grid;place-items:center;width:31px;height:31px;border-radius:8px;background:#2bc0d1;color:#07353d;font-size:1rem}
.math-visual{display:block;width:min(100%,320px);height:auto;margin:0 auto 8px}
.math-visual-steps{display:flex;align-items:flex-start;justify-content:center;gap:7px;margin:12px auto 18px;color:#55757b}
.math-visual-steps span{display:flex;flex-direction:column;align-items:center;gap:5px;text-align:center;font-size:14px;font-weight:800;flex:1;max-width:115px}
.math-visual-steps span::first-line{color:#009cb0}
.math-visual-steps small{font-size:12px;font-weight:600;line-height:1.3}
.math-visual-steps .is-current{color:#007f90}
.math-visual-steps b{color:#83d4dd;font-size:18px}
.math-pan .math-btn{display:block;margin:10px auto 0;min-height:44px;padding:7px 12px;background:#fff;color:#164b54;font-size:.95rem}
.math-footer{gap:10px;flex-wrap:wrap}
.math-choices .math-btn[data-result=right]{background:#d7f3e0;border-color:#4aad70;color:#205b36}
.math-choices .math-btn[data-result=wrong]{background:#ffeadf;border-color:#d77a55;color:#783820}
[data-theme=dark] .math-choices .math-btn[data-result=right]{background:#245b3e;color:#f2fff6}
[data-theme=dark] .math-choices .math-btn[data-result=wrong]{background:#75402f;color:#fff4ee}
.math-instruction{margin:0 0 12px;font-weight:700;text-align:center}
.math-comparison{padding:16px;margin-bottom:16px;border:2px solid #a1e4ed;border-radius:18px;background:#f1fbfc;color:#24454b}
.math-comparison .math-btn{background:#fff;color:#164b54}
.math-comparison .math-btn[aria-pressed=true]{background:#bcecf1;border-color:#00a5b9;color:#073f48}
.math-comparison p{margin:0 0 10px;line-height:1.4}.math-control{display:flex;align-items:center;gap:8px;margin:8px 0}.math-control .math-btn{min-width:48px;padding:6px 10px}.math-pairs{display:flex;align-items:center;gap:12px;margin:12px 0}.math-pairs span{flex:1;padding:8px;border-radius:10px;background:#d6f5f8}.math-pairs strong{display:block;font-size:1.1rem}.math-comparison small{color:#225b63}
.index-groups{display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;margin:12px 0}.index-groups>div{display:flex;align-items:center;justify-content:center;gap:5px;flex-wrap:wrap;padding:10px;background:#fff;border:2px solid #8ddde6;border-radius:13px}.index-groups strong{width:100%;text-align:center}.index-factor{display:inline-grid;place-items:center;width:31px;height:31px;border-radius:8px;background:#30c0d1;color:#07353d;font-size:1rem;font-weight:800}.index-factor.is-cancelled{opacity:.4;text-decoration:line-through}.index-fraction{display:grid;justify-content:center;margin:14px 0}.index-fraction>div{min-width:130px;display:flex;justify-content:center;gap:5px;padding:7px}.index-fraction>div:first-child{border-bottom:3px solid #24545c}.index-result{padding:10px;border-radius:10px;background:#d6f5f8;font-weight:750}.index-equation{padding:16px 6px;font-size:clamp(1.25rem,4vw,1.7rem);font-weight:800;text-align:center}.index-numberline{display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;margin:15px 0}.index-numberline span{background:#d6f5f8;border-radius:10px;padding:8px}
/* Lessons use their own screen so the learning controls keep the phone space. */
.math-session{--math-screen:#fff;position:fixed;inset:0;z-index:100;background:var(--math-screen);overflow-y:auto;overscroll-behavior:contain;min-width:0}
.math-session .math-lesson-top{position:sticky;top:0;z-index:5;padding-top:12px;padding-bottom:12px;margin-top:0;background:var(--math-screen)}
.math-session .math-footer{position:sticky;bottom:0;z-index:4;padding:12px 0 max(12px,env(safe-area-inset-bottom));background:var(--math-screen)}
@media(max-width:700px){html[data-learning-layout=mobile] .math-session{height:var(--learning-mobile-height,100dvh);bottom:auto}.math-session .math-lesson{margin-top:12px;margin-bottom:30px}.math-session .math-lesson-top{gap:12px}}

[data-theme=dark] .math-session{--math-screen:#102c31}
[data-theme=dark] .math-path .math-btn{background:#17373d;color:#edf9fa}
.factor-bars{display:flex;align-items:stretch;gap:3px;margin:14px auto;max-width:380px}.factor-bars div{flex:1;display:grid;place-items:center;min-height:80px;background:#a9e9ef;border:2px solid #26b7c6;border-radius:8px;padding:8px;color:#124752}.factor-bars div:first-child{flex:2}.factor-bars b,.factor-bars span{display:block;text-align:center}.factor-bars span{font-size:.8rem}.factor-square-pair{display:flex;align-items:center;justify-content:center;gap:18px;flex-wrap:wrap;margin:14px 0}.factor-square-pair>div{display:grid;justify-items:center;gap:6px}.factor-grid{display:grid;grid-template-columns:repeat(var(--cols),20px);gap:2px}.factor-grid i{height:20px;background:#34bfce;border-radius:3px}.factor-grid i.removed{background:transparent;outline:1px dashed #6ba8ad}.factor-matrix{display:grid;grid-template-columns:repeat(3,minmax(45px,1fr));max-width:310px;margin:12px auto;gap:3px;text-align:center}.factor-matrix>*{padding:10px 4px;border-radius:7px;background:#c7eef2;font-style:normal}.factor-matrix i{background:#fff;border:2px solid #88dce5}.factor-roots{display:flex;gap:10px;margin:12px 0}.factor-roots span{flex:1;padding:12px;border-radius:12px;background:#c9f0f4;text-align:center}.factor-roots strong{display:block;margin-top:5px}

.factor-graph{display:block;width:min(100%,320px);height:auto;margin:8px auto}
.factor-square-control{position:relative;width:20px;height:20px;border:0;border-radius:3px;background:#34bfce;cursor:pointer;padding:0}.factor-square-control::after{content:'';position:absolute;inset:-12px}.factor-square-control.removed{background:transparent;outline:2px dashed #4d8e97}.factor-square-control:focus-visible{outline:3px solid #075f6c;outline-offset:3px}
.math-control{flex-wrap:wrap}.identity-area{display:grid;width:min(100%,240px);aspect-ratio:1;margin:12px auto;gap:2px}.identity-area span{display:grid;place-items:center;text-align:center;background:#9ce4eb;border:2px solid #2ab7c5;color:#164b54;border-radius:5px;font-weight:800}.identity-area span:nth-child(2),.identity-area span:nth-child(3){background:#c5eef2}.identity-area span:last-child{background:#f9e6bb}.identity-grid{justify-content:center;margin:14px auto}.identity-grid .is-removed{background:#d5e0e1;outline:1px dashed #829b9e}.identity-grid .is-overlap{background:#efba8b;outline:1px solid #b97840}
.identity-area-interactive .math-btn{min-width:0;min-height:0;padding:3px;border:2px solid #2ab7c5;border-radius:5px;background:#9ce4eb;color:#164b54}.identity-area-interactive .math-btn:nth-child(2),.identity-area-interactive .math-btn:nth-child(3){background:#c5eef2}.identity-area-interactive .math-btn:nth-child(4){background:#f9e6bb}.identity-area-interactive .math-btn[aria-pressed=true]{outline:3px solid #075f6c;outline-offset:-3px;background:#66d1dd;color:#073f48}

.math-earned{display:inline-block;padding:8px 15px;border-radius:12px;background:#d6f5f8;color:#075f6c;font-weight:800}

.system-graph{display:block;width:min(100%,300px);height:auto;margin:0 auto}.system-graph text{font-size:14px;fill:#34535a;font-weight:700}

.inequality-line{display:block;width:min(100%,380px);height:auto;margin:8px auto}.inequality-line text{font-size:13px;fill:#34535a}
.inequality-people{display:flex;justify-content:center;flex-wrap:wrap;gap:4px;margin:14px 0}.inequality-people .math-btn{width:44px;min-width:44px;min-height:52px;padding:4px;border-radius:10px;background:#edf5f5;color:#8da5a8}.inequality-people .math-btn[data-present=true]{background:#d4f4f6;color:#008fa1}.inequality-people svg{display:block;width:30px;height:38px;fill:currentColor}

.percent-bars{display:grid;gap:12px;margin:18px 0}.percent-bars>div{display:grid;grid-template-columns:5em minmax(0,1fr) 4em;align-items:center;gap:8px}.percent-track{height:24px;background:#e3f5f7;border-radius:8px;overflow:hidden}.percent-track i{display:block;height:100%;background:#00b6c9;border-radius:8px}.percent-bars strong{text-align:right}

.interest-steps{display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;margin:18px 0}.interest-steps span{display:grid;text-align:center;background:#d5f4f7;padding:10px;border-radius:12px}.interest-steps strong{font-size:1.15em}.interest-steps b{color:#008b9a}

.rounding-line{display:block;width:min(100%,380px);height:auto;margin:8px auto}.rounding-line text{font-size:14px;fill:#34535a}.rounding-slider{display:grid;gap:8px;font-weight:700}.rounding-slider input{width:100%;accent-color:#00b6c9}.rounding-digits{display:flex;justify-content:center;gap:4px;margin:18px 0;font-size:1.6rem;font-weight:800}.rounding-digits span{min-width:1em;text-align:center}.rounding-digits .is-significant{background:#bceef3;border-radius:5px}

.binary-bits{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin:16px 0}.binary-bits>div{display:grid;gap:8px;text-align:center;min-width:58px}.binary-bits button,.binary-bits strong{font-size:1.4rem}.binary-table{border-collapse:collapse;margin:12px auto;text-align:center}.binary-table th,.binary-table td{padding:8px 18px;border-bottom:1px solid #b8e7eb}

.factor-chips{display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap;margin:18px 0}.factor-chips span,.factor-chips button{min-width:48px;text-align:center;font-weight:800}

.algebra-fraction{display:inline-grid;vertical-align:middle;text-align:center;line-height:1.25;max-width:100%}.algebra-fraction>span{padding:2px 7px}.algebra-fraction>span:first-child{border-bottom:2px solid currentColor}

.rate-graph{display:block;width:min(100%,340px);height:auto;margin:8px auto}.rate-graph text{font-size:13px;fill:#34535a}

.ratio-bars{display:grid;gap:10px;margin:18px 0}.ratio-bars>div{display:grid;grid-template-columns:7em minmax(0,1fr) 4em;gap:8px;align-items:center}.ratio-bars span{display:flex;gap:3px;flex-wrap:wrap}.ratio-bars i{display:block;flex:0 0 24px;height:24px;background:#63d4df;border:1px solid #00a6b8;border-radius:4px}.ratio-bars b{text-align:right}

.error-area{display:block;width:min(100%,320px);height:auto;margin:8px auto}.error-area text{font-size:14px;fill:#34535a}

.transform-graph{display:block;width:min(100%,320px);height:auto;margin:8px auto}.transform-graph text{font-size:13px;fill:#34535a}

.centres-graph{display:block;width:min(100%,320px);height:auto;max-width:100%;margin:8px auto}.centres-graph text{font-size:12px;fill:#34535a}
.math-sequence-terms{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin:14px 0}.math-sequence-term{display:flex;min-width:58px;padding:9px;flex-direction:column;align-items:center;gap:4px;border:2px solid #80dce6;border-radius:14px;background:#e0f8fa;color:#23464b}.math-sequence-term small{font-size:13px}.math-sequence-term strong{font-size:20px}
[data-theme=dark] .math-session .math-btn[aria-pressed=true]{background:#126474;border-color:#55d5e1;color:#fff}
.system-ratio-bars{display:block;width:min(100%,360px);height:auto;margin:8px auto;font-size:14px;font-weight:700}.system-ratio-bars text{font-family:inherit}
.interest-stack{display:block;width:min(100%,360px);height:auto;margin:8px auto;font:600 14px system-ui,sans-serif;fill:#254e55}
.math-practice{width:min(100%,720px);margin:0 auto;padding:24px 16px 100px;color:var(--ink,#30474b)}
.math-practice>h1{font-size:clamp(26px,5vw,34px);margin:0 0 8px}.math-practice>p{line-height:1.5;color:var(--muted,#60777a);margin:0 0 22px}
.math-practice-card{display:flex;align-items:center;justify-content:space-between;gap:16px;border:2px solid #9be5ee;border-radius:18px;padding:16px;margin:12px 0}.math-practice-card h2{font-size:19px;margin:3px 0}.math-practice-card small,.math-practice-card p{color:var(--muted,#60777a);margin:0}.math-practice-card .math-btn{flex:none;min-width:80px}
/* Touchable factors for cancelling a fraction, with an explicit selected state. */
.index-fraction .index-factor-button{width:44px;height:44px;min-width:44px;border:2px solid #078c9c;cursor:pointer}
.index-fraction .index-factor-button.is-cancelled{opacity:1;background:#e5eeee;color:#496b70;border-color:#9fb9bc;text-decoration:line-through}
.index-fraction .index-factor-button:focus-visible{outline:3px solid #14616e;outline-offset:2px}
.hcf-groups{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:12px 0}
.hcf-groups>div{display:grid;gap:4px;padding:10px 6px;border:2px solid #a4dfe5;border-radius:12px;background:var(--math-screen,#fff);text-align:center}
.hcf-groups small{font-weight:700;color:#27636b}.hcf-groups span{font-size:14px;color:var(--math-ink,#244b50)}

/* Keep values and controls readable on narrow phones without horizontal clipping. */
@media (max-width: 600px) {
  .math-session .math-pairs { flex-wrap: wrap; gap: 8px; }
  .math-session .math-pairs span { flex: 1 1 110px; min-width: 0; overflow-wrap: anywhere; }
  .math-session .math-order-workspace { min-width: 0; overflow-wrap: anywhere; }
  .math-session .math-control { flex-wrap: wrap; }
  .math-session .math-control .math-btn { max-width: 100%; min-height: 44px; overflow-wrap: anywhere; }
  .math-practice-card > div { min-width: 0; overflow-wrap: anywhere; }
}
