html:has(body[data-screen=child]) {scrollbar-gutter:stable}
body[data-screen=child] {
  --lesson-wash:#f4f3ee;
  --lesson-paper:#fffefa;
  --lesson-line:#eceae1;
  --lesson-highlight:#f2f1e9;
  --lesson-mark:#5c625a;
  --notebook-ink:#262824;
  --lesson-font:var(--rounded-font);
  --teacher-wash:#fbfaf6;
  --teacher-border:#dedbd0;
  --choice-wash:#e9efea;
  --lesson-action:#34534a;
  --lesson-action-hover:#253f38;
  --notebook-border:#dcd9ce;
  --workspace-inset:clamp(1.25rem,4.4vw,5rem);
  background:var(--lesson-wash);
  min-height:100dvh;
}
body[data-screen=child][data-theme=mint] {
  --lesson-wash:#edf4ee;
  --teacher-wash:#f6faf5;
  --teacher-border:#cadbcf;
}
body[data-screen=child][data-theme=peach] {
  --lesson-wash:#f8f1eb;
  --teacher-wash:#fdf7f1;
  --teacher-border:#e4d2c4;
}
body[data-screen=child][data-contrast=true] {
  --lesson-wash:#fff;
  --lesson-paper:#fff;
  --lesson-highlight:#ececea;
  --lesson-line:#d1d1cd;
  --lesson-mark:#242721;
  --notebook-ink:#141512;
  --teacher-wash:#fff;
  --teacher-border:#555550;
  --notebook-border:#555550;
  --choice-wash:#e9efea;
  --lesson-action:#1f3930;
}
body[data-screen=child] .rail,
body[data-screen=child] .top-nav,
body[data-screen=child] .brand small {display:none}
body[data-screen=child] .topbar {background:#fffefa;border-bottom:1px solid var(--notebook-border)}
body[data-screen=child] .top-inner {min-height:65px;max-width:1800px;padding-inline:var(--workspace-inset)}
body[data-screen=child] .brand {font:740 1.17rem/1.2 var(--lesson-font);letter-spacing:-.015em;cursor:default;pointer-events:none;opacity:1}
body[data-screen=child] .brand-mark {width:34px;height:34px;border-radius:10px}
body[data-screen=child] .layout {display:block;max-width:1800px;padding:clamp(1.25rem,3vw,3.5rem) var(--workspace-inset) 1.5rem}
.child-lesson {
  display:grid;
  grid-template-columns:minmax(0,1.66fr) minmax(0,1fr);
  grid-template-areas:"paper teacher";
  gap:clamp(1.75rem,4vw,4.75rem);
  align-items:start;
  text-align:center;
}
.child-teacher {
  grid-area:teacher;
  min-width:0;
  padding:clamp(1.45rem,3.2vw,3.2rem);
  border:1px solid var(--teacher-border);
  border-radius:24px;
  background:var(--teacher-wash);
  font-family:var(--lesson-font);
  text-align:left;
}
.child-prompt {display:grid;justify-items:start;gap:.8rem}
.child-prompt > * {animation:show-instruction 190ms ease-out both}
@keyframes show-instruction {from{opacity:.35;transform:translateY(3px)}to{opacity:1;transform:none}}
.child-prompt h1 {
  font:750 clamp(1.875rem,1.46rem + .72vw,2.375rem)/1.16 var(--lesson-font);
  letter-spacing:-.025em;
  color:var(--ink);
  max-width:22ch;
  text-wrap:balance;
}
.child-prompt h1:focus:not(:focus-visible){outline:none}
.child-prompt p {
  color:var(--muted);
  font-size:clamp(1.375rem,1.17rem + .53vw,1.75rem);
  font-weight:500;
  line-height:1.42;
  max-width:30ch;
}
.child-problem-number {margin:0 0 .75rem;color:var(--muted);font-size:.95rem;font-weight:650}
.child-prompt .child-question {
  color:var(--ink);
  font-size:clamp(1.8rem,1.4rem + 1.5vw,2.9rem);
  font-variant-numeric:tabular-nums;
  font-weight:750;
  line-height:1.18;
}
.child-actions:has([data-child=yes]) {margin-top:1rem}
.child-paper {
  grid-area:paper;
  width:100%;
  margin:0;
  padding:clamp(1rem,2.5vw,2.5rem) clamp(.7rem,3.4vw,4rem);
  border:1px solid var(--notebook-border);
  border-radius:25px;
  box-shadow:0 4px 0 #e6e2d7,0 10px 28px #37302a0a;
  background:repeating-linear-gradient(to bottom,var(--lesson-paper) 0 32px,var(--lesson-line) 32px 33px);
}
body[data-contrast=true] .child-paper {box-shadow:none}
.child-columns {
  --label-h:clamp(30px,3vw,46px);
  --rewrite-h:clamp(46px,4vw,66px);
  --upper-rewrite-h:var(--rewrite-h);
  --digit-h:clamp(87px,8.7vw,136px);
  --answer-h:clamp(77px,7.75vw,124px);
  --digit-size:clamp(5rem,7.65vw,8.25rem);
  position:relative;
  display:grid;
  grid-template-columns:minmax(27px,.43fr) repeat(3,minmax(0,1fr));
  width:min(100%,770px);
  margin:auto;
}
.child-column {
  display:grid;
  grid-template-rows:var(--label-h) var(--upper-rewrite-h) var(--rewrite-h) repeat(2,var(--digit-h)) 5px var(--answer-h);
  justify-items:center;
  align-items:center;
  border-radius:15px;
  position:relative;
  isolation:isolate;
}
.child-column:is(.child-active,.child-changed,.child-receiving,.child-blocked):before {
  content:"";
  position:absolute;
  inset:0 3px;
  border-radius:15px;
  background:var(--lesson-highlight);
  z-index:-1;
  pointer-events:none;
}
.child-column.child-active:before {box-shadow:inset 0 0 0 1.5px var(--lesson-mark)}
.child-column:is(.child-changed,.child-receiving):before {border:1px dashed var(--lesson-mark)}
.child-column.child-blocked:before {border:1px dashed var(--lesson-mark);background:transparent}
.child-column.child-giving::after {
  content:"";
  position:absolute;
  z-index:2;
  inset-block-start:calc(var(--label-h) / 2 - 4px);
  inset-inline-end:-4px;
  width:8px;
  height:8px;
  border-block-start:2px solid var(--lesson-mark);
  border-inline-end:2px solid var(--lesson-mark);
  transform:rotate(45deg);
  pointer-events:none;
}
.child-new-value{border-radius:.2em;background:var(--lesson-highlight);padding:.04em .2em .08em;font-weight:750}
.child-place {
  font:650 clamp(.94rem,1.4vw,1.24rem)/1.15 var(--lesson-font);
  color:var(--muted);
  white-space:nowrap;
}
.child-digit,.child-answer {
  font:650 var(--digit-size)/.96 var(--lesson-font);
  font-variant-numeric:lining-nums tabular-nums;
  letter-spacing:-.045em;
  position:relative;
  color:var(--notebook-ink);
}
.child-digit {display:grid;place-items:center;min-width:1ch}
.child-rewrite {font-size:clamp(2.35rem,3.2vw,3.55rem);color:var(--lesson-mark)}
.child-stroke:after {
  position:absolute;
  content:"";
  inset:49% 0 auto 0;
  height:3px;
  background:var(--lesson-mark);
  border-radius:50% 43% 45% 50%;
  transform:rotate(-15deg);
  transform-origin:left center;
}
.child-rule {
  position:absolute;
  z-index:1;
  top:calc(var(--label-h) + var(--upper-rewrite-h) + var(--rewrite-h) + 2 * var(--digit-h));
  height:3px;
  background:var(--ink);
  left:3px;
  right:3px;
  border-radius:4px;
}
.child-minus {grid-row:5;font:600 calc(var(--digit-size) * .64)/1 var(--lesson-font);color:var(--notebook-ink)}
.child-borrow {
  border:2px solid var(--lesson-mark);
  border-radius:13px;
  background:var(--lesson-paper);
  min-width:66%;
  min-height:calc(var(--digit-h) - 4px);
  outline-offset:2px;
}
.child-borrow.child-rewrite {min-height:44px}
.child-borrow:hover,.child-borrow:focus-visible {background:var(--lesson-highlight)}
.child-answer {
  min-width:0;
  width:72%;
  height:max(44px,calc(var(--answer-h) - 9px));
  font-size:calc(var(--digit-size) * .78);
  text-align:center;
  border-radius:12px;
  border:2px solid var(--lesson-mark);
  background:var(--lesson-paper);
}
.child-answer::selection{background:var(--lesson-highlight)}
.child-empty {
  width:48%;
  height:52%;
  max-width:45px;
  border-bottom:2px dashed var(--lesson-mark);
  opacity:.62;
}
.child-actions {display:flex;flex-wrap:wrap;gap:.7rem;margin-top:clamp(1.15rem,2.3vw,1.9rem)}
.child-primary {
  min-width:min(100%,132px);
  min-height:55px;
  border-radius:13px;
  padding:.62rem 1rem;
  background:var(--lesson-action);
  color:white;
  font-weight:720;
  font-size:clamp(1.12rem,1rem + .35vw,1.38rem);
}
.child-primary:hover {background:var(--lesson-action-hover)}
.child-actions:has([data-child=yes]) {display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
.child-actions:has([data-child=yes]) button {min-width:0}
.child-primary[data-child=no] {background:var(--choice-wash);color:var(--ink);box-shadow:inset 0 0 0 1px var(--teacher-border)}
.child-primary[data-child=no]:hover {background:#dce7de}
.child-support {margin-top:1rem;display:flex;flex-wrap:wrap;gap:.5rem}
.child-support[hidden] {display:none}
.child-trade-notes {
  width:100%;
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:.5rem;
  margin-top:.2rem;
  color:var(--muted);
  font-size:.96rem;
}
.child-trade-notes > span {
  display:grid;
  gap:.12rem;
  justify-items:start;
  padding:.48rem .65rem;
  border:1px solid var(--teacher-border);
  border-radius:10px;
  background:var(--lesson-paper);
}
.trade-values{color:var(--ink);font-size:clamp(1.02rem,1rem + .45vw,1.5rem);font-weight:650;white-space:nowrap}
.trade-donor-note{animation:show-instruction var(--speed) ease-out calc(var(--speed) * .48) both}
.trade-receiver-note{animation:show-instruction var(--speed) ease-out calc(var(--speed) * 1.35) both}
.child-help {
  min-height:44px;
  padding:.4rem .7rem;
  border:1px solid var(--teacher-border);
  border-radius:10px;
  font-size:1rem;
  font-weight:650;
  color:var(--ink);
}
.child-help:hover{background:var(--lesson-highlight)}
.voice-notice{flex-basis:100%;margin:.35rem 0;color:var(--muted);font-size:1rem}
.child-footer {display:flex;flex-wrap:wrap;gap:.55rem;margin:1.15rem 0 0}
.child-footer button {border-radius:9px;min-height:44px;padding:.48rem .8rem;color:var(--muted);font-size:.9rem}
.child-footer button:hover {background:var(--lesson-highlight);color:var(--ink)}
.child-check {margin:.8rem 0 0;color:var(--ink);font-size:clamp(1.18rem,2.3vw,1.5rem);font-weight:680}
.child-count {display:grid;grid-template-columns:auto 1fr;align-items:center;text-align:left;gap:.25rem .65rem;font-weight:650;color:var(--muted)}
.child-dots {display:flex;align-items:center;flex-wrap:wrap;gap:5px;min-height:13px}
.child-dots i,.child-packet i {width:12px;height:12px;border-radius:50%;background:var(--accent);border:1px solid var(--accent);position:relative}
.child-dots.needed i {background:var(--lesson-paper)}
.child-dots i.taken {background:var(--lesson-paper)}
.child-dots i.taken:after {content:"";position:absolute;top:45%;left:-2px;width:14px;height:1.5px;background:var(--accent);transform:rotate(-45deg)}
.child-dots.count-back {max-width:260px;justify-content:center}
.child-bundle{display:flex;justify-content:center;align-items:center;gap:.5rem;flex-wrap:wrap}
.child-packet{display:grid;grid-template-columns:repeat(5,8px);gap:2px;padding:.24rem;border:1.5px solid var(--accent);border-radius:6px}
.child-packet i{width:8px;height:8px;border-radius:2px}
.child-packet.opened{grid-template-columns:repeat(10,8px);border-color:transparent;gap:4px}
.child-bundle-label {color:var(--muted);font-size:.85rem}
.child-stroke.cross-donor:after {animation:draw-strike var(--speed) ease-out both}
.child-stroke.cross-receiver:after {animation:draw-strike var(--speed) ease-out calc(var(--speed) * .85) both}
.child-rewrite.write-donor {animation:write-rewrite var(--speed) ease-out calc(var(--speed) * .48) both}
.child-rewrite.write-receiver {animation:write-rewrite var(--speed) ease-out calc(var(--speed) * 1.35) both}
@keyframes draw-strike {from{transform:rotate(-15deg) scaleX(0)}to{transform:rotate(-15deg) scaleX(1)}}
@keyframes write-rewrite {from{opacity:0;clip-path:inset(0 100% 0 0)}to{opacity:1;clip-path:inset(0)}}
body[data-screen=child][data-reading=true] {--lesson-font:Verdana,system-ui,sans-serif}
body[data-screen=child][data-reading=true] .child-prompt h1,
body[data-screen=child][data-reading=true] .child-digit,
body[data-screen=child][data-reading=true] .child-answer {font-family:Verdana,system-ui,sans-serif;letter-spacing:0}
@media (max-width:960px){
  body[data-screen=child] {--workspace-inset:clamp(.7rem,3.5vw,1.7rem)}
  body[data-screen=child] .layout{width:min(100%,650px);padding-top:.7rem}
  body[data-screen=child] .top-inner{min-height:53px;justify-content:center}
  body[data-screen=child] .brand {font-size:clamp(.94rem,4.3vw,1.1rem)}
  body[data-screen=child] .brand-mark {width:28px;height:28px;border-radius:9px}
  .child-lesson{grid-template-columns:minmax(0,1fr);grid-template-areas:"paper" "teacher";gap:clamp(21px,5.9vw,31px)}
  .child-teacher{padding:clamp(1.1rem,4.5vw,1.8rem);border-radius:20px}
  .child-prompt h1{font-size:clamp(1.75rem,1.45rem + 1.06vw,2.125rem)}
  .child-prompt p{font-size:clamp(1.375rem,1.16rem + .76vw,1.75rem)}
  .child-paper{padding-block:.55rem;border-radius:19px}
  .child-columns{--label-h:24px;--upper-rewrite-h:32px;--rewrite-h:44px;--digit-h:clamp(47px,12.6vw,65px);--answer-h:clamp(48px,12vw,60px);--digit-size:clamp(2.75rem,13vw,3.85rem)}
  .child-place{font-size:clamp(.78rem,2.65vw,1rem)}
  .child-rewrite{font-size:clamp(1.75rem,7vw,2.15rem)}
  .child-column.child-giving::after{width:6px;height:6px;inset-inline-end:-3px}
}
@media print{.child-lesson,.child-footer{display:none!important}}
