:root{--page:#D8E4EE;--card:#FFF;--text:#172A3A;--sub:#44586A;--rule:#D5DDE3;--head:#FFF;--field:#FFF;--fieldLine:#6B7C8B;--chip:#EEF1F3;--btn:#172A3A;--btnFg:#FFF;--selBg:#172A3A;--selLine:#172A3A;color-scheme:light}
:root[data-theme=night]{--page:#3B566F;--card:#22374B;--text:#FFF;--sub:#C9D8E6;--rule:#45627C;--head:#172A3A;--field:#172A3A;--fieldLine:#8FA9C0;--chip:#22374B;--btn:#2FF3D0;--btnFg:#172A3A;--selBg:#0F2030;--selLine:#2FF3D0;color-scheme:dark}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]){--page:#3B566F;--card:#22374B;--text:#FFF;--sub:#C9D8E6;--rule:#45627C;--head:#172A3A;--field:#172A3A;--fieldLine:#8FA9C0;--chip:#22374B;--btn:#2FF3D0;--btnFg:#172A3A;--selBg:#0F2030;--selLine:#2FF3D0;color-scheme:dark}}
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent}
body{margin:0;min-height:100vh;display:flex;flex-direction:column;background:var(--page);color:var(--text);font-family:'Atkinson Hyperlegible Next','Atkinson Hyperlegible',system-ui,sans-serif;font-variant-numeric:tabular-nums;font-size:16px;line-height:1.45}
[hidden]{display:none!important}
h1,h2,h3,p,ul{margin:0}
h1,h2,h3{text-wrap:balance}
p,li{text-wrap:pretty}
h1{font-size:28px;line-height:1.15;font-weight:800}
h2{font-size:21px;line-height:1.25}
h3{font-size:19px;line-height:1.3}
button,input{font:inherit;color:inherit}
button{cursor:pointer;touch-action:manipulation}
a{color:inherit;text-decoration:none;touch-action:manipulation}
:focus-visible{outline:3px solid #2B59C3;outline-offset:2px;box-shadow:0 0 0 7px #FFF}
/* a tighter edge on boxes, so it never covers the label */
input:focus-visible{outline-offset:0;box-shadow:0 0 0 5px #FFF}
input::placeholder{color:inherit;opacity:.8}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

.skip{position:absolute;left:8px;top:-80px;z-index:2;display:flex;align-items:center;min-height:44px;padding:0 16px;border:1.5px solid var(--text);border-radius:22px;background:var(--card)}
.skip:focus{top:12px}
main:focus{outline:none;box-shadow:none}
.bar{background:var(--head);border-bottom:1px solid var(--rule)}
.bar>div{max-width:1280px;margin:0 auto;display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:68px;padding:11px 16px}
.brand{display:flex;align-items:center;min-height:44px;font-size:19px;font-weight:800}
.bar nav{display:flex;gap:8px}
.search-link{display:flex;align-items:center;min-height:44px;width:120px;padding:0 16px;border:1.5px solid var(--text);border-radius:22px;background:var(--chip);color:var(--sub);font-size:15px}
.iconbtn{width:44px;height:44px;flex:none;display:flex;align-items:center;justify-content:center;padding:0;border:1.5px solid var(--text);border-radius:22px;background:var(--chip)}
.iconbtn .sun{display:none}
:root[data-theme=night] .iconbtn .sun{display:block}
:root[data-theme=night] .iconbtn .moon{display:none}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]) .iconbtn .sun{display:block}:root:not([data-theme=light]) .iconbtn .moon{display:none}}

main{width:100%;max-width:560px;margin:0 auto;flex:1}
.intro{display:flex;flex-direction:column;gap:6px;padding:20px 16px 18px}

/* small supporting buttons: 34px round pill in a 44px tap area */
.pill{display:inline-flex;align-items:center;min-height:44px;padding:0;border:0;background:transparent;color:var(--text);font-size:15px}
.pill>span{display:flex;align-items:center;min-height:34px;padding:2px 13px;border:1.5px solid currentColor;border-radius:17px}
.pill:focus-visible{border-radius:22px}
.body .pill{color:#FFF}
.pills{display:flex;flex-wrap:wrap;gap:0 8px}

/* round pill buttons that take you to a page */
.go{display:flex;align-items:center;justify-content:center;min-height:52px;padding:8px 20px;border-radius:999px;background:#2FF3D0;color:#172A3A;font-size:17px;font-weight:700;text-align:center}
.item{display:flex;align-items:center;justify-content:center;min-height:52px;margin-bottom:10px;padding:8px 20px;border:2px solid var(--fieldLine);border-radius:999px;font-size:17px;font-weight:700}

.body{margin:0 8px;padding:16px 12px;border-radius:22px;background:#172A3A;color:#FFF;display:flex;flex-direction:column;gap:14px}
.card{margin:16px 8px 0;padding:18px 12px;border-radius:18px;background:var(--card);display:flex;flex-direction:column;gap:10px}
.field{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px;font-size:14px;color:#B7C9D8}
.num,.step-btn{height:48px;border:2px solid #6C8CA8;border-radius:10px;background:#223B50;color:#FFF;font-weight:700}
.num{width:100%;min-width:0;padding:0 10px;font-size:22px}
.num.long{font-size:16px;padding:0 4px}
.num.lit{background:#2FF3D0;border-color:#2FF3D0;color:#172A3A}
.num[aria-invalid=true]{border-color:#C2A3FF;border-style:dashed}
.point{display:flex;align-items:flex-end;gap:10px}
.point-name{width:64px;flex:none;line-height:48px;font-size:15px;font-weight:700;color:#C2A3FF}
.answer{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:0 12px;padding:12px 16px;border:4px solid #D3E4D6;border-radius:12px;background:#D3E4D6;color:#172A3A}
.answer.lit{border-color:#2FF3D0}
.answer b{font-size:40px;line-height:1.1;font-weight:800;overflow-wrap:anywhere}
.answer .label{font-weight:700}
.answer .note{flex-basis:100%;font-size:15px}
.stage{border-radius:12px;background:#0F2030;padding:4px 0;display:flex;justify-content:center}
.stage>svg{display:block;width:100%;max-width:400px;height:auto}

/* in-page working lines keep square corners */
.line{width:100%;min-height:68px;display:flex;flex-direction:column;justify-content:center;gap:3px;padding:9px 14px;border:2px solid var(--fieldLine);border-radius:12px;background:var(--card);color:var(--text);text-align:left}
.line small{font-size:14px}
.line strong{font-size:19px;overflow-wrap:anywhere}
.line[aria-pressed=true]{background:var(--selBg);border-color:var(--selLine);color:#FFF}
.line[aria-pressed=true] strong{color:#2FF3D0}
.hint-text{font-size:15px;color:var(--sub)}
.try{margin:0 -4px;padding:16px 8px}
/* these only group things for the desktop layout */
.top,.practice-head,.panel,.practice-work{display:contents}
.fixed{height:48px;line-height:44px;border:2px solid #6C8CA8;border-radius:10px;background:#223B50;color:#FFF;font-size:20px;font-weight:700;padding:0 12px}
.fixed.lit{background:#2FF3D0;border-color:#2FF3D0;color:#172A3A}
.check-row{display:flex;gap:10px;margin-top:8px}
.check-row input{flex:1;min-width:0;height:48px;padding:0 12px;border:2px solid var(--fieldLine);border-radius:10px;background:var(--field);font-size:20px}
.check-row button{height:48px;padding:0 22px;border:0;border-radius:10px;background:var(--btn);color:var(--btnFg);font-weight:700}
.feedback{min-height:22px;font-size:15px}
/* the boxes on the left, one button on their right (randomise question, my decimal repeats) */
.ask{container-type:inline-size;display:flex;align-items:flex-end;gap:10px}
.ask-q{flex:1;min-width:0;display:flex;flex-direction:column;gap:10px}
.beside{flex:none;display:flex;align-items:center;justify-content:center;gap:10px;width:228px;min-height:48px;padding:4px 16px;border:0;border-radius:10px;background:#FFF;color:#172A3A;font-size:15px;line-height:1.15;font-weight:700}
.beside svg{flex:none}
/* two rows of boxes: the button stands as tall as both, dice above the words */
.ask.rows{align-items:stretch}
.rows .beside{flex-direction:column;gap:6px;width:112px;margin-top:26px;padding:4px 6px;text-align:center}
@container (max-width:380px){
  .beside{gap:8px;width:156px;padding:4px 10px}
  .beside span{max-width:6.4em}
  .rows .beside{width:88px;padding:4px 2px}
  .rows .point{gap:6px}
  .rows .point-name{width:50px;font-size:14px}
  .rows .fixed{padding:0 8px}
}
/* the smallest phones: a slimmer button leaves room for the number */
@container (max-width:300px){
  .ask:not(.rows) .beside{width:128px;gap:6px;padding:4px 6px}
  .ask:not(.rows) .beside svg{width:22px;height:22px}
}

/* home */
.hero{display:flex;flex-direction:column;gap:8px;padding:20px 16px 0}
.find{margin-top:6px;display:flex;flex-wrap:wrap;align-items:center;column-gap:12px;min-height:56px;padding:7px 20px;border-radius:28px;border:2px solid var(--fieldLine);background:var(--field);cursor:text}
.find:focus-within{outline:3px solid #2B59C3;outline-offset:2px;box-shadow:0 0 0 7px #FFF}
.find span{font-weight:700;white-space:nowrap}
.find input{flex:1 1 200px;min-width:0;height:30px;border:0;padding:0;background:transparent;font-size:16px}
.find input:focus-visible{outline:none;box-shadow:none}
.tabs{display:flex;gap:10px;padding:16px 8px 0}
.tabs button{flex:1;min-width:0;min-height:60px;padding:6px 8px;border-radius:14px;border:2px solid var(--fieldLine);background:var(--card);font-size:17px;line-height:1.25;font-weight:700}
.tabs button[aria-pressed=true]{background:var(--btn);border-color:var(--btn);color:var(--btnFg)}
.side{display:none;flex-direction:column}
.side.on{display:flex}
.side>h2{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.demo{margin:12px 8px 0}
.demo h3{font-size:19px}
.demo-row{display:flex;flex-wrap:wrap;gap:14px 16px;align-items:stretch}
.demo-in{container-type:inline-size;flex:1 1 208px;min-width:0;display:flex;flex-direction:column;justify-content:space-between;gap:12px}
.demo-in .num,.demo-in .step-btn{height:44px;font-size:20px}
.demo-in .num.long{font-size:16px}
.demo-row .stage{flex:1.4 1 280px;min-width:0;flex-direction:column;justify-content:center;align-items:center}
.demo-row .stage>svg{max-width:340px}
@container (max-width:300px){.gpair{flex-direction:column}.p2{gap:4px}.p2>.field:first-child{flex:0 0 52px}.p2 .stepper{gap:4px}}
.point-label{font-size:14px;font-weight:700;color:#C2A3FF;margin-bottom:2px}
.pair{display:flex;gap:10px}
.stepper{display:flex;gap:6px}
.stepper .num{flex:1;text-align:center;padding:0 2px;background:#2FF3D0;border-color:#2FF3D0;color:#172A3A}
.step-btn{width:44px;flex:none;padding:0;font-size:22px}
.step-btn[aria-disabled=true]{opacity:.45}
.demo .answer{padding:8px 12px;border-width:0}
.demo .answer b{font-size:34px;line-height:1.3}
.demo .answer b.long{font-size:24px}
.demo .answer .label{font-size:15px}
.demo .answer .note{flex-basis:auto;font-size:14px}
.list{margin:12px 8px 0;padding:16px 12px 6px;border-radius:18px;background:var(--card)}
.list h3{margin-bottom:8px}
.group+.group{margin-top:6px}
.empty{display:flex;flex-direction:column;align-items:flex-start;gap:12px;padding:20px 16px 0}

/* grade picture */
.pic{border-radius:12px;background:#0F2030;padding:14px;display:flex;flex-direction:column;gap:8px;width:100%}
.pic-title{font-size:15px;color:#B7C9D8}
.track{position:relative;height:78px}
.track>*{position:absolute}
.track .want-text{top:0;white-space:nowrap;font-size:15px;font-weight:700;color:#C2A3FF}
.track .base,.track .seg{top:28px;height:10px;border-radius:5px}
.track .base{left:0;right:0;background:#223B50}
.track .seg.earned{left:0}
.track .mark{top:22px;height:19px;width:3px;border-radius:2px;background:#C2A3FF}
/* highest possible grade: one amber marker with its words under the bar */
.track .best-mark{top:33px;height:20px;width:3px;border-radius:2px;background:#FFC247}
/* same number as "You want": one straight line, half each colour */
.track .best-mark.same{top:38px;height:16px;border-radius:0 0 2px 2px}
.track .best-text{top:56px;white-space:nowrap;font-size:15px;font-weight:700;color:#FFC247}
.key{display:flex;align-items:center;gap:10px;font-size:15px;font-weight:700}
.key i{width:18px;height:10px;flex:none;border-radius:5px}
.exam{position:relative;height:14px;border:2px solid #223B50;border-radius:7px;background:#223B50}
.exam i{position:absolute;top:0;left:0;height:10px;max-width:100%;border-radius:5px}
.scale{display:flex;justify-content:space-between;font-size:13px;color:#B7C9D8}
.pic .exam-title{margin-top:10px}
.exam-text{font-size:15px;font-weight:700}
.row-between{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:0 8px}
.help{margin:0 0 6px;padding:12px 14px 12px 30px;border-radius:12px;background:#223B50;font-size:15px}
.quarters{display:flex;gap:8px;margin-bottom:6px}
.muted{font-size:14px;color:#B7C9D8}
.table{display:flex;flex-direction:column;gap:6px;padding:12px 8px 8px;border-radius:12px;background:#D3E4D6;color:#172A3A}
.table .head{display:flex;justify-content:space-between;gap:12px;padding:0 14px;font-size:14px}
.table button{display:flex;justify-content:space-between;align-items:center;gap:12px;min-height:48px;padding:0 12px;border:2px solid #5E7568;border-radius:8px;background:transparent;color:#172A3A;font-size:18px;font-weight:700;text-align:left}
.table button[aria-pressed=true]{background:#172A3A;color:#FFF}
.table button[aria-pressed=true].lit{color:#2FF3D0}
.table .foot{padding:6px 12px 0;font-size:14px}

/* decimal to fraction */
.repeat{margin-top:8px}
.repeat-row{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:6px 12px}
.repeat-words{flex:1 1 190px;min-width:0;overflow-wrap:anywhere}
.repeat-words p{margin-top:5px;line-height:1.4}
.repeat label{font-size:15px}
.repeat .stepper .num{flex:none;width:56px;background:#223B50;border-color:#6C8CA8;color:#FFF}
.repeat .stepper .num.lit{background:#2FF3D0;border-color:#2FF3D0;color:#172A3A}
.over{text-decoration:overline;text-decoration-thickness:2px}
.answer b.long{font-size:28px}
.answer b.longer{font-size:22px}

.prose{display:flex;flex-direction:column;gap:12px}
.prose h2{margin-top:6px}
footer{width:100%;max-width:560px;margin:0 auto;padding:8px 16px 16px;display:flex;justify-content:center}
noscript p{margin:16px 8px 0;padding:14px 16px;border-radius:12px;background:var(--card)}

@media (min-width:600px){
  .hero,.intro,.empty{padding-left:8px;padding-right:8px}
}
@media (min-width:900px){
  .bar>div{padding-left:48px;padding-right:48px}
  .brand{font-size:21px}
  main{max-width:1280px;padding:0 48px}
  footer{max-width:1280px;padding:24px 48px;justify-content:flex-start}
  .hero{padding:28px 0}
  .hero h1{font-size:38px}
  .find{font-size:18px}
  .find input{font-size:18px}
  .tabs{display:none}
  .sides{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 48px;align-items:start}
  .side{display:flex;height:100%}
  .side>h2{position:static;width:auto;height:auto;overflow:visible;clip-path:none;white-space:normal;margin-bottom:12px;font-size:26px}
  .demo{margin:0;padding:20px;flex:1;justify-content:space-between}
  .demo h3{display:none}
  .demo-row{flex:1}
  .list{margin:16px 0 0;padding:16px 20px 8px;border-radius:16px}
  .empty{padding:16px 0}
  .intro{padding:28px 0 22px}
  .intro h1{font-size:38px}
  /* calculator pages: one page scroll; numbers, answer and working on the left, picture on the right */
  .intro:has(+noscript+.calc){padding:16px 0 12px}
  .top,.panel{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px 20px;padding:16px;border-radius:22px;background:#172A3A;color:#FFF}
  .top{grid-template-rows:auto auto auto 1fr}
  .panel{grid-template-rows:auto 1fr}
  .top>.body,.panel>.try{display:contents}
  .top>.body>*,.panel>.try>*,.top>.working,.panel>.practice-work{grid-column:1;min-width:0}
  .top>.body>.stage,.top>.body>.pic{grid-column:2;grid-row:1/span 4}
  .panel>.try>.stage{grid-column:2;grid-row:1/span 2}
  .top .stage,.panel .stage{position:relative;min-height:400px;padding:0}
  .top .stage>svg,.panel .stage>svg{position:absolute;inset:0;margin:auto;width:calc(100% - 24px);max-width:560px;height:calc(100% - 24px)}
  .top>.body>.pic{justify-content:center;gap:12px;padding:24px 28px}
  .calc .top>.working,.panel>.practice-work{display:flex;margin:0;padding:14px;border-radius:14px;background:var(--card);color:var(--text)}
  .calc .top>.working{flex-flow:row wrap;align-content:flex-start;align-items:baseline;justify-content:space-between;gap:8px 12px}
  .working>.line{flex:0 0 100%}
  .panel>.practice-work{flex-direction:column;gap:8px;min-height:410px}
  /* room for a two-line reply and every step, so nothing moves while a student works */
  .panel .feedback{min-height:45px}
  .panel .line{line-height:1.3}
  .top .line,.panel .line{min-height:56px;padding:4px 14px;gap:0}
  /* decimal to fraction can have five working lines, so they sit a little closer */
  .top:has(#dec) .working{row-gap:6px}
  .top:has(#dec) .line{min-height:50px;line-height:1.3}
  .calc>.card{margin:24px 0 0;padding:20px}
  .calc>.practice{margin-top:32px;padding:0;background:transparent;gap:14px}
  .practice-head{display:flex;flex-direction:column;gap:6px}
  .practice-head h2{font-size:30px}
  main.narrow{max-width:760px;padding:0 24px}
}
/* the narrowest desktop: keep each practice step's sum on one line */
@media (min-width:900px) and (max-width:999px){.panel .line strong{font-size:17px}}
/* hover and press */
.go,.item,.iconbtn,.search-link,.pill>span,.line,.tabs button,.step-btn,.check-row button,.beside,.table button{transition-property:transform,box-shadow,filter;transition-duration:.12s}
:is(.go,.item,.iconbtn,.search-link,.line,.tabs button,.step-btn,.check-row button,.beside,.table button):active,.pill:active>span{transform:scale(.97)}
@media (hover:hover){
  .pill:hover>span,.item:hover,.iconbtn:hover,.search-link:hover,.line:hover:not([aria-pressed=true]),.tabs button:hover:not([aria-pressed=true]){box-shadow:inset 0 0 0 1px currentColor}
  .go:hover{filter:brightness(.92)}
  .step-btn:hover,.check-row button:hover,.table button:hover{filter:brightness(1.18)}
  .beside:hover{filter:brightness(.9)}
  .brand:hover{text-decoration:underline;text-underline-offset:4px}
}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
