/* The hand-worked examples of a math book page (layout from the simple viewer's tutorial.css; the paper from the playground). */
.mb{margin:1rem 0;padding:.75rem 1rem;border:1px solid #d0d7de;border-radius:6px;background:#fffdf7;background-image:linear-gradient(#eef1f4 1px,transparent 1px);background-size:100% 1.9em}
.mb-static{margin:0;font:18px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.mb-ask{display:flex;align-items:center;gap:.4rem;flex-wrap:wrap;font:20px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.mb-num{font:inherit;width:auto;padding:.25rem .4rem;border:1px solid #d0d7de;border-radius:4px;text-align:right;background:#fff}
.mb-num:focus-visible{outline:3px solid #0b57d0;outline-offset:1px}
.mb-op,.mb-eq{color:#57606a}
.mb-reset{font:14px system-ui,sans-serif;padding:.3rem .7rem;margin-left:.5rem}
.mb-bar{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin:.6rem 0}
.mb-bar button{font:inherit;padding:.35rem .9rem}
.mb-bar button:focus-visible,.mb-reset:focus-visible{outline:3px solid #0b57d0;outline-offset:2px}
.mb-rs{font-weight:600;padding:.1rem .5rem;border-radius:4px;border:1px solid;white-space:nowrap}
.mb-rs[data-rs=idle]{color:#57606a}.mb-rs[data-rs=run]{color:#0b57d0;background:#e8f0fe}.mb-rs[data-rs=done]{color:#116329;background:#e6f4ea}.mb-rs[data-rs=error]{color:#b3261e;background:#fde7e9}
.mb-steps{color:#57606a;font-size:.9rem}
.mb-paper{overflow-x:auto;min-height:4em}
.mb-caption{margin:.6rem 0 0;min-height:1.4em}
.mb-caption.error{color:#b3261e}
.mb-playground{margin:2rem 0 0;padding-top:1rem;border-top:1px solid #d0d7de}
.paper{--cell:1.7em;display:grid;grid-template-columns:repeat(var(--cols),var(--cell));font:22px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;width:max-content}
@media (max-width:30rem){.paper{font-size:19px}}
.prow{display:contents}
.cell{position:relative;height:1.6em;text-align:right;padding-right:.25em;box-sizing:border-box}
.prow.carries .cell{height:1.1em;font-size:.65em;color:#6639ba}
.prow.tall .cell{height:2.3em}
.prow.tall .cell .digit{position:absolute;right:.25em;bottom:0}
.above{position:absolute;right:.25em;top:0;font-size:.6em;color:#6639ba;white-space:nowrap;display:flex;gap:.25em}
.cell.struck .digit{text-decoration:line-through;text-decoration-thickness:2px;color:#8c959f}
.above .struck{text-decoration:line-through;color:#8c959f}
.prow.rule .cell,.cell.rule{border-bottom:2px solid #1b1f24}
.cell.op{text-align:left;padding-left:.1em;color:#57606a}
.cell.bracket{border-right:2px solid #1b1f24;border-radius:0 0 .4em 0;padding-right:.2em;color:transparent}
.cell.under-bracket{border-top:2px solid #1b1f24}
.cell.result .digit{color:#116329;font-weight:600}
.cell.cur{background:#fff0a0}
.cell.hl .digit,.cell.hl .above,.cell.hl.mark{color:#a34a00;font-weight:700}
.cell.new .digit{animation:appear .25s ease-out}
@keyframes appear{from{transform:scale(1.6);opacity:.2}to{transform:none;opacity:1}}
.with-trials{display:flex;gap:1.5rem;align-items:flex-start;flex-wrap:wrap}
.trials{margin:.2rem 0 0;padding:0 0 0 1rem;font:15px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#57606a;list-style:none}
.trials li.too-big,.trials li.too-small{color:#8c959f;text-decoration:line-through}
.trials li.right{color:#116329;font-weight:600}
.cell.under-bracket.hl .digit{outline:2px solid #a34a00;outline-offset:-2px;border-radius:3px}   /* the digit pair in focus */
.trials li.hl{color:#a34a00;font-weight:700}
@media (prefers-reduced-motion:reduce){.cell.new .digit{animation:none}}
/* representation panels */
.mb-panel{margin-top:.5rem}
.mb-panel+.mb-panel{border-top:1px dashed #d0d7de;padding-top:.6rem;margin-top:1rem}
.mb-panel-title{font:600 1rem/1.3 system-ui,sans-serif;margin:.2rem 0 .3rem;color:#33383f}
/* objects: rows on one shared grid, stacked and aligned cell for cell */
.objects{display:flex;flex-wrap:wrap;gap:.6rem 1.5rem;align-items:flex-start}
.objects .ogrid{display:grid;grid-template-columns:auto 1fr;gap:.35rem .6rem;align-items:center}
.objects .orow{display:contents}
.objects .ocells{display:grid;grid-template-columns:repeat(var(--cols,10),1.6rem);gap:.2rem;min-height:1.5rem;padding:.15rem;border-radius:4px}
.objects .orow.b .ocells,.objects .orow.pool .ocells{background:#f6f8fa}
.objects .shape{width:1.5rem;height:1.5rem;display:block}
.objects .shape.hl{filter:drop-shadow(0 0 2px #a34a00)}
.objects .olabel{font:14px/1.3 system-ui,sans-serif;color:#33383f;text-align:right;white-space:nowrap}
.objects .counter{font:700 1.6rem/1 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#a34a00;min-width:2ch;text-align:center;align-self:center}
.objects .note,.blocks .note{flex-basis:100%;font:600 1.1rem/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#116329}
@media (max-width:30rem){.objects .ocells{grid-template-columns:repeat(var(--cols,10),1.25rem)}.objects .shape{width:1.15rem;height:1.15rem}.objects .olabel{font-size:12px}}
/* blocks: base-ten rods and cubes */
.blocks{display:flex;flex-direction:column;gap:.6rem}
.blocks .brow{display:flex;align-items:flex-end;gap:.6rem;flex-wrap:wrap}
.blocks .tens,.blocks .ones{display:flex;gap:.25rem;align-items:flex-end;padding:.2rem;border-radius:4px;flex-wrap:wrap}
.blocks .tens{min-width:calc(var(--max-tens,1) * 1.05rem + .4rem)}   /* tens under tens, ones under ones */
.blocks .tens.hl,.blocks .ones.hl{background:#fff0a0}
.blocks .rod{display:inline-block;width:.8rem;height:4.4rem;border:1px solid #1b1f24;background:repeating-linear-gradient(to bottom,#1f5fbf 0 .4rem,#fff .4rem .44rem);box-sizing:border-box}
.blocks .cube{display:inline-block;width:.8rem;height:.8rem;border:1px solid #1b1f24;background:#d68910;box-sizing:border-box}
.blocks .red .rod{background:repeating-linear-gradient(to bottom,#c0392b 0 .4rem,#fff .4rem .44rem)}.blocks .red .cube{background:#c0392b}
.blocks .green .rod{background:repeating-linear-gradient(to bottom,#1e8449 0 .4rem,#fff .4rem .44rem)}.blocks .green .cube{background:#1e8449}
.blocks .rod.struck,.blocks .cube.struck{opacity:.35;background:repeating-linear-gradient(45deg,#8c959f 0 2px,#fff 2px 4px)}
.blocks .rod.hl,.blocks .cube.hl{outline:2px solid #a34a00;outline-offset:1px}
.blocks .blabel{font:14px/1.3 system-ui,sans-serif;color:#33383f}
/* tables: the full table and the practice table */
.mt-wrap{overflow-x:auto;padding-bottom:.25rem}
.mt{border-collapse:collapse;font:16px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:#fff}
.mt th,.mt td{border:1px solid #d0d7de;min-width:2.2rem;height:2rem;text-align:center;padding:0 .2rem;position:relative}
.mt th{background:#f6f8fa;font-weight:600}
.mt th.corner{color:#57606a}
.mt td{color:#1b1f24}
.mt td:focus-visible{outline:3px solid #0b57d0;outline-offset:-3px}
.mt .focus-row,.mt .focus-col{background:#fff0a0}
.mt th.focus-row,.mt th.focus-col{background:#ffe08a;outline:2px solid #9a6700;outline-offset:-2px}
.mt .mt-in{width:2.4rem;height:1.7rem;box-sizing:border-box;font:inherit;text-align:center;border:1px solid #8c959f;border-radius:3px;padding:0}
.mt .mt-in:focus-visible{outline:3px solid #0b57d0;outline-offset:1px}
.mt td.right{background:#e6f4ea}.mt td.wrong{background:#fde7e9}
.mt td.right .mt-in{border-color:#116329;color:#116329}.mt td.wrong .mt-in{border-color:#b3261e;color:#b3261e;text-decoration:line-through}
.mt .mt-mark{position:absolute;top:0;right:.15rem;font-size:.7rem}
.mt td.right .mt-mark{color:#116329}.mt td.wrong .mt-mark{color:#b3261e}
.mt .mt-answer{display:block;font-size:.75rem;color:#116329;line-height:1}
@media (max-width:30rem){.mt{font-size:13px}.mt th,.mt td{min-width:1.7rem;height:1.7rem;padding:0 .1rem}.mt .mt-in{width:1.8rem;height:1.4rem}}
/* problem examples: typeset problem, editable line, the blackboard, Try one */
.mb-problem{background:#fffdf7;background-image:none}
.mp-head{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem 1.2rem;margin-bottom:.4rem}
.mp-typeset .bb-math{color:#1b1f24;font-size:1.5rem;margin:0}
.mp-edit{display:flex;gap:.4rem;align-items:center;flex:1 1 16rem}
.mp-input{font:17px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;padding:.3rem .5rem;border:1px solid #d0d7de;border-radius:4px;flex:1 1 10rem;min-width:8rem}
.mp-level{font:inherit;padding:.3rem .4rem;max-width:14rem}
.mp-try{margin-left:auto}
.mp-board{margin:.5rem 0}
.mp-board .bb-board{max-height:420px}
.mp-quiz{margin-top:.8rem;padding:.6rem .8rem;border:1px dashed #9a6700;border-radius:6px;background:#fffbe6}
.mp-quiz-problem{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.mp-quiz-label{font-weight:600;color:#57606a}
.mp-quiz-problem .bb-math{color:#1b1f24;font-size:1.3rem;margin:0}
.mp-answer{display:flex;gap:.4rem;flex-wrap:wrap;align-items:center;margin-top:.4rem}
.mp-answer-input{font:17px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;padding:.3rem .5rem;border:1px solid #d0d7de;border-radius:4px;width:12rem}
.mp-answer button{font:inherit;padding:.35rem .8rem}
.mp-verdict{margin:.4rem 0 0;min-height:1.3em}
.mp-verdict.right{color:#116329;font-weight:600}.mp-verdict.wrong{color:#b3261e}
.mp-method{font:inherit;padding:.3rem .4rem;max-width:16rem}
.mb-old a{color:#57606a}
.mb-old-note{font-size:.85rem;color:#8c959f;margin:.1rem 0 0}
.mb-progress{color:#33383f;margin:.25rem 0 1rem}
/* A full traditional problem may be wider than a phone. Keep horizontal math
   scrolling inside its own line, including freshly generated exercises. */
.mp-typeset{min-width:0;max-width:100%;overflow-x:auto}
.mp-quiz-problem{min-width:0;max-width:100%;overflow-x:auto}
/* Fraction bars and number lines share the board's position, not a second timer. */
.mp-visual{margin:.6rem 0;padding:.5rem .7rem;border:1px solid #d0d7de;border-radius:6px;background:#fff}
.fb-title,.nl-caption{font:14px/1.4 system-ui,sans-serif;color:#57606a;margin-bottom:.45rem}
.fb-row{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin:.35rem 0}
.fb-label{min-width:3.5rem;font:17px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.fb-bar{display:inline-flex;border:1px solid #1b1f24;border-radius:3px;overflow:hidden}
.fb-cell{display:block;width:1.25rem;height:1.65rem;border-right:1px solid #7890a8;background:#eef4fb;box-sizing:border-box}
.fb-cell:last-child{border-right:0}.fb-cell.shaded{background:#18864b}
.fb-cell.shaded:nth-child(odd){background:#0b6bcb}
.nl-host{padding:.35rem 0}
.nl-labels{display:flex;justify-content:space-between;font:15px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.nl-line{position:relative;display:flex;justify-content:space-between;align-items:flex-end;height:2.4rem;border-bottom:3px solid #25384f;margin:0 .4rem}
.nl-tick{display:block;width:1px;height:.65rem;background:#25384f}
.nl-marker{position:absolute;bottom:1.2rem;transform:translateX(-50%);text-align:center;transition:left .25s ease-out}
.nl-marker:after{content:'';display:block;width:.8rem;height:.8rem;border-radius:50%;background:#a34a00;margin:.15rem auto 0}
.nl-marker-label{font:700 15px/1.2 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#a34a00;white-space:nowrap}
@media (prefers-reduced-motion:reduce){.nl-marker{transition:none}}
/* the exercise applet: a problem, the answer line, the verdict, the score, the worked solution on the board */
.ma{margin:1rem 0;background:#f4f9ff;border:1px solid #b6d0ee;border-radius:8px;padding:.7rem .9rem}
.ma-static{margin:0;color:#57606a}
.ma-head{display:flex;justify-content:space-between;align-items:baseline;gap:1rem;margin-bottom:.3rem}
.ma-title{font-weight:700;color:#0b3d91}
.ma-score{font:14px/1.3 system-ui,sans-serif;color:#33383f;background:#fff;border:1px solid #d0d7de;border-radius:999px;padding:.1rem .6rem;white-space:nowrap}
.ma-problem{display:flex;align-items:center;gap:.4rem .8rem;flex-wrap:wrap;min-width:0;max-width:100%;overflow-x:auto;padding:.2rem 0}
.ma-problem .bb-math{color:#1b1f24;font-size:1.4rem;margin:0}
.ma-n{font:14px/1.3 system-ui,sans-serif;color:#57606a}
.ma-form{display:flex;gap:.4rem;flex-wrap:wrap;align-items:center;margin-top:.4rem}
.ma-input{font:17px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;padding:.3rem .5rem;border:1px solid #8c959f;border-radius:4px;flex:1 1 9rem;min-width:7rem;max-width:18rem}
.ma-input[readonly]{background:#f6f8fa;color:#57606a}
.ma-form button{font:inherit;padding:.35rem .8rem}
.ma-next{margin-left:auto}
.ma-verdict{margin:.4rem 0 0;min-height:1.3em}
.ma-verdict.right{color:#116329;font-weight:600}.ma-verdict.wrong{color:#b3261e}
.ma-solution{margin-top:.6rem;border-top:1px dashed #b6d0ee;padding-top:.5rem}
@media (max-width:30rem){.ma-next{margin-left:0}.ma-problem .bb-math{font-size:1.2rem}}
.ma-formulation{font:1.5rem/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#1b1f24;white-space:nowrap}
.ma-digits .mb-panel{margin:0}

/* The blackboard: shared by the PoC (web/poc/blackboard) and the math book pages (web/math/page). Colours are variables so a page can theme the board. */
.bb-host{--board:#173f35;--chalk:#f5f1dc;--muted-chalk:#b9c9bc;--amber:#ffe08a;--cancel:#ff9b8f;background:var(--board);border-radius:8px;padding:0 18px}
.bb-board { max-height: 510px; margin: 0; padding: 12px 0 18px; overflow-y: auto; overscroll-behavior: contain; color: var(--chalk); list-style: none; counter-reset: board-line; scrollbar-color: #82998a #173f35; }
.bb-step { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 280px); gap: 22px; align-items: center; padding: 12px 10px 13px; border-bottom: 1px dashed #78908365; }
.bb-step:last-child { border-bottom: 0; }
.bb-step-lines { min-width: 0; overflow-x: auto; padding: 5px 2px 8px; scrollbar-color: #82998a #173f35; }
.bb-line { display: grid; grid-template-columns: 26px minmax(max-content, 1fr); align-items: center; min-height: 50px; counter-increment: board-line; }
.bb-line::before { content: counter(board-line); align-self: start; padding-top: .6em; color: #92a89a; font: .72rem/1 ui-monospace, monospace; }
.bb-math { min-width: max-content; padding: .12em .18em; color: var(--chalk); font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", Georgia, serif; font-size: 1.55rem; line-height: 1.45; }
.bb-note { position: relative; margin: 0; padding-left: 17px; color: var(--muted-chalk); font: .94rem/1.45 system-ui, sans-serif; }
.bb-note::before { content: ""; position: absolute; top: .15em; bottom: .15em; left: 0; border-left: 2px solid #d6b768; }
.bb-current .bb-step-lines { animation: write-line .32s ease-out; }
.bb-highlight { color: #241d08; background: var(--amber); border-radius: 2px; box-shadow: 0 0 0 2px var(--amber); }
.bb-strike { color: #ffc2b9; text-decoration: line-through; text-decoration-color: var(--cancel); text-decoration-thickness: 2px; }
.bb-highlight.bb-strike { color: #4d2822; }
.bb-column-carry { color: #f3ca67; font-size: .68em; }
.bb-column-carry mtd { padding-bottom: 0; line-height: 1; }
.bb-column-result { color: #c6e6b7; }
.bb-column-rule mtd { border-top: 2px solid currentColor; }
.bb-columns mtd { min-width: 1.2em; padding: 0 .12em; }
@keyframes write-line { from { opacity: .15; transform: translateY(7px); } to { opacity: 1; transform: none; } }
  .bb-board { max-height: 58vh; }
  .bb-step { grid-template-columns: minmax(0, 1fr); gap: 3px; padding: 10px 4px; }
  .bb-line { grid-template-columns: 21px minmax(max-content, 1fr); }
  .bb-math { font-size: 1.32rem; }
  .bb-note { margin: 0 8px 4px 23px; font-size: .84rem; }
  .bb-current .bb-step-lines { animation: none; }
@media (max-width: 650px) {
  .bb-host { padding: 0 6px; }
  .bb-board { max-height: 58vh; }
  .bb-step { grid-template-columns: minmax(0, 1fr); gap: 3px; padding: 10px 4px; }
  .bb-line { grid-template-columns: 21px minmax(max-content, 1fr); }
  .bb-math { font-size: 1.32rem; }
  .bb-note { margin: 0 8px 4px 23px; font-size: .84rem; }
}
@media (prefers-reduced-motion: reduce) { .bb-current .bb-step-lines { animation: none; } }
