:root {
  --slate: #2a3538;
  --slate-deep: #1f282a;
  --grid: rgba(222, 234, 229, 0.085);
  --chalk: #f1eee6;
  --chalk-dim: rgba(241, 238, 230, 0.7);
  --chalk-yellow: #f2c94c;
  --chalk-coral: #ef8a74;
  --coral-wash: rgba(239, 138, 116, 0.12);
  --pine: #c28b55;
  --pine-light: #cd9860;
  --pine-deep: #93602f;
  --burn: #3f250f;
  --chalk-mint: #8fd3b6;
  --chalk-sky: #8ec5e8;
  --chalk-lilac: #c7a6e8;
  --chalk-pink: #f2a9c9;
  --chalk-white: #f1eee6;
  --paper: #f8f3e6;
  --paper-rule: #ddd3bd;
  --paper-margin: #d9907f;
  --ink: #2b2925;
  --ink-soft: #5d574c;
  --font-ui: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-hand: "Andika", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-ui);
  color: var(--burn);
  background-color: var(--pine);
  /* A quiet pine grain: long vertical streaks, nothing photographic. */
  background-image:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 11px),
    repeating-linear-gradient(90deg, rgba(90, 50, 15, 0.05) 0 1px, transparent 1px 23px),
    linear-gradient(180deg, var(--pine-light), var(--pine) 40%, var(--pine) 70%, var(--pine-deep));
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.frame {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
}

@media (min-width: 900px) {
  .frame { padding-inline: 26px; }
}

/* ---------- top rail ---------- */

.rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.brand {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.01em;
  color: var(--burn);
}

.rail-right { display: flex; align-items: center; gap: 14px; min-width: 0; }

.status, .meter { margin: 0; font-size: 15px; white-space: nowrap; }

.status { display: flex; align-items: center; gap: 8px; font-weight: 600; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(63, 37, 15, 0.35);
}

[data-voice="listening"] .dot { background: var(--burn); }
[data-voice="talking"] .dot { background: var(--burn); animation: pulse 0.9s ease-in-out infinite alternate; }
[data-voice="connecting"] .dot { background: transparent; border: 2px solid var(--burn); }
[data-voice="error"] .dot { background: #8f2412; }

@keyframes pulse { to { transform: scale(1.6); opacity: 0.55; } }

.meter { font-family: var(--font-mono); font-size: 14px; }

.stars { margin: 0; display: flex; align-items: center; gap: 5px; font: 700 17px var(--font-ui); color: var(--burn); }
.stars svg { width: 22px; height: 22px; fill: var(--chalk-yellow); stroke: var(--burn); stroke-width: 1.3; stroke-linejoin: round; }
.stars.pop svg { animation: star-pop 0.6s ease-out; }
@keyframes star-pop { 40% { transform: scale(1.5) rotate(12deg); } }

.rail-button {
  white-space: nowrap;
  font: 600 14px var(--font-ui);
  color: var(--burn);
  background: none;
  border: 0;
  padding: 10px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- the slate ---------- */

.slate {
  position: relative;
  min-height: 0;
  border-radius: 10px;
  background: radial-gradient(120% 90% at 30% 20%, #2f3b3e, var(--slate) 55%, var(--slate-deep));
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.28),
    inset 0 10px 28px rgba(0, 0, 0, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

#board {
  display: block;
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}

#board[data-tool="eraser"] { cursor: cell; }
#board[data-tool="lasso"] { cursor: crosshair; }

.echo {
  position: absolute;
  top: 12px;
  right: 14px;
  margin: 0;
  max-width: calc(100% - 28px);
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(20, 27, 29, 0.72);
  color: var(--chalk);
  display: flex;
  align-items: baseline;
  gap: 10px;
  pointer-events: none;
}

.echo-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}

.echo-value { font-family: var(--font-hand); font-size: 26px; line-height: 1.1; }
.echo-value .unsure { color: var(--chalk-coral); font-family: var(--font-ui); font-size: 14px; margin-left: 8px; }

/* Pip's words: a chalk speech bubble coming from Pip's beak, along the bottom of the board. */
.caption {
  position: absolute;
  left: calc(var(--pip-size) + 18px);
  bottom: calc(var(--pip-size) * 0.34);
  width: max-content;
  max-width: min(720px, calc(100% - var(--pip-size) - 34px));
  margin: 0;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(20, 27, 29, 0.84);
  border: 1.5px solid rgba(241, 238, 230, 0.34);
  color: var(--chalk);
  font-size: clamp(16px, 1.9vw, 20px);
  line-height: 1.38;
  pointer-events: none;
  z-index: 1;
}
.caption::before {
  /* the bubble's tail, pointing at Pip's beak */
  content: "";
  position: absolute;
  left: -9px;
  bottom: 12px;
  width: 14px;
  height: 14px;
  background: inherit;
  border-left: inherit;
  border-bottom: inherit;
  transform: rotate(45deg) skew(12deg, 12deg);
}

/* Moved out of the problem's way (see placeCaption): under the sign at the top, no tail. */
.caption.at-top { top: 50px; bottom: auto; left: auto; right: 14px; }
.caption.at-top::before { display: none; }

/* ---------- Pip, perched on the bottom edge of the board ---------- */

.slate { --pip-size: 92px; }
@media (max-width: 900px) { .slate { --pip-size: 76px; } }
@media (max-width: 640px) { .slate { --pip-size: 58px; } }

.pip {
  position: absolute;
  left: 10px;
  bottom: -2px;
  width: var(--pip-size);
  height: calc(var(--pip-size) * 112 / 120);
  pointer-events: none;
  z-index: 1;
  transition: opacity 400ms ease;
  --open: 0;
}
.pip.faded { opacity: 0.28; }
.pip[data-state="away"] { opacity: 0.55; }
.pip-art { width: 100%; height: 100%; overflow: visible; display: block; }

.pip .bird { transform-box: view-box; transform-origin: 58px 106px; }
.pip .body, .pip .wing, .pip .tuft, .pip .tail, .pip .legs {
  fill: none; stroke: var(--chalk); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}
.pip .body { fill: rgba(241, 238, 230, 0.07); }
.pip .wing { fill: rgba(241, 238, 230, 0.1); stroke-width: 2.6; }
.pip .tail { stroke-width: 2.6; fill: rgba(241, 238, 230, 0.05); }
.pip .tail, .pip .legs { stroke-width: 2.6; }
.pip .cheek { fill: var(--chalk-coral); opacity: 0.45; }
.pip .beak path { fill: var(--chalk-yellow); stroke: none; }
.pip .beak-top, .pip .beak-bottom { transform-box: view-box; transform-origin: 83px 58.5px; }
.pip .beak-top { transform: rotate(calc(var(--open) * -9deg)); }
.pip .beak-bottom { transform: rotate(calc(var(--open) * 26deg)); }
.pip .eye { transform-box: view-box; transform-origin: 70px 50px; animation: blink 5.2s infinite; }
.pip .white { fill: var(--chalk); }
.pip .pupil { fill: var(--slate-deep); transition: transform 260ms ease; }
.pip .wing { transform-box: view-box; transform-origin: 40px 62px; transition: transform 200ms ease; }

.pip .dots circle { fill: var(--chalk); opacity: 0; }
.pip .sparks path { fill: var(--chalk-yellow); opacity: 0; transform-box: fill-box; transform-origin: center; }

/* idle: breathing, slow and small */
.pip[data-state="idle"] .bird, .pip[data-state="away"] .bird { animation: breathe 3.8s ease-in-out infinite; }
/* listening: leaning in toward the board */
.pip[data-state="listening"] .bird { transform: rotate(-4deg); transition: transform 300ms ease; }
/* talking: a small bob in time with the words (the beak follows the voice) */
.pip[data-state="talking"] .bird { transform: translateY(calc(var(--open) * -1.5px)) rotate(-1deg); }
/* watching the child write: eyes on the board */
.pip.looking .pupil { transform: translate(1.8px, -1.4px); }
/* thinking: three chalk dots, one after another */
.pip.thinking .dots circle, .pip[data-state="thinking"] .dots circle { animation: think 1.4s ease-in-out infinite; }
.pip.thinking .dots circle:nth-child(2), .pip[data-state="thinking"] .dots circle:nth-child(2) { animation-delay: 0.2s; }
.pip.thinking .dots circle:nth-child(3), .pip[data-state="thinking"] .dots circle:nth-child(3) { animation-delay: 0.4s; }
/* a right answer: a hop, a flap, and stars */
.pip.cheer .bird { animation: hop 0.55s ease-out 2; }
.pip.cheer .wing, .pip.cheer-big .wing { transform: rotate(-38deg); }
.pip.cheer .sparks path { animation: spark 1.1s ease-out; }
.pip.cheer-big .bird { animation: hop 0.5s ease-out 4; }
.pip.cheer-big .sparks path { animation: spark 1.2s ease-out 2; }
.pip .sparks path:nth-child(2) { animation-delay: 0.12s !important; }
.pip .sparks path:nth-child(3) { animation-delay: 0.22s !important; }
.pip .sparks path:nth-child(4) { animation-delay: 0.3s !important; }

.pip-tag {
  position: absolute;
  left: 58%;
  bottom: 100%;
  margin-bottom: 2px;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  font: 700 12px var(--font-ui);
  color: #262422;
  background: var(--chalk-coral);
  display: none;
}
.pip.muted .pip-tag { display: block; }

@keyframes breathe { 50% { transform: scale(1.012, 1.03); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(0.08); } }
@keyframes think { 0%, 100% { opacity: 0.15; } 45% { opacity: 0.9; } }
@keyframes hop { 40% { transform: translateY(-11px) rotate(-3deg); } 70% { transform: translateY(0) scale(1.04, 0.96); } }
@keyframes spark { 0% { opacity: 0; transform: scale(0.3); } 35% { opacity: 1; transform: scale(1.15) rotate(20deg); } 100% { opacity: 0; transform: scale(0.8) rotate(50deg); } }

/* ---------- today's lesson, as a short chalk path in the rail ---------- */

.path {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font: 700 14px var(--font-ui);
  color: rgba(63, 37, 15, 0.62);
  min-width: 0;
}
.path li { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.path li + li::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: rgba(63, 37, 15, 0.28); margin-right: 2px; }
.path .mark { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; flex: none; }
.path .mark svg { width: 10px; height: 10px; fill: none; stroke: var(--chalk); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.path [data-at="done"] { color: var(--burn); }
.path [data-at="done"] .mark { background: var(--burn); border-color: var(--burn); }
.path [data-at="now"] { color: var(--chalk); background: var(--burn); padding: 4px 11px 4px 5px; border-radius: 999px; }
.path [data-at="now"] .mark { border-color: var(--chalk-yellow); background: var(--chalk-yellow); }
.path .count { display: inline-flex; gap: 3px; margin-left: 3px; }
.path .count i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid rgba(241, 238, 230, 0.7); }
.path .count i.on { background: var(--chalk-yellow); border-color: var(--chalk-yellow); }
@media (max-width: 1000px) { .path li:not([data-at="now"]) { display: none; } .path li + li::before { display: none; } }

/* ---------- what the student should do right now ---------- */

.mode {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px 9px 14px;
  border-radius: 999px;
  font: 700 19px/1.1 var(--font-ui);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  z-index: 1;
}

.mode[data-mode="listen"] { background: rgba(241, 238, 230, 0.16); color: var(--chalk); border: 2px solid rgba(241, 238, 230, 0.55); }
.mode[data-mode="say"] { background: var(--chalk-yellow); color: #262422; }
.mode[data-mode="write"], .mode[data-mode="tap"], .mode[data-mode="draw"], .mode[data-mode="work"] { background: var(--chalk); color: #262422; }
.mode.changed { animation: nudge 0.5s ease-out 2; }

.mode-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: none; }
.mode[data-mode="listen"] .mode-icon[data-for="listen"],
.mode[data-mode="say"] .mode-icon[data-for="say"],
.mode[data-mode="write"] .mode-icon[data-for="write"],
.mode[data-mode="tap"] .mode-icon[data-for="write"],
.mode[data-mode="draw"] .mode-icon[data-for="write"],
.mode[data-mode="work"] .mode-icon[data-for="write"] { display: block; }

@keyframes nudge { 50% { transform: translateX(-50%) scale(1.08); } }

@media (max-width: 640px) {
  .mode { font-size: 15px; padding: 7px 12px 7px 10px; top: 8px; }
  .mode-icon { width: 20px; height: 20px; }
}

/* ---------- start card ---------- */

.start-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100% - 32px));
  padding: 30px 28px 24px;
  border-radius: 16px;
  background: rgba(24, 31, 33, 0.94);
  border: 1.5px solid rgba(241, 238, 230, 0.28);
  color: var(--chalk);
  display: grid;
  gap: 16px;
  z-index: 2;
}

.start-card h1 { margin: 0; font: 700 30px/1.15 var(--font-hand); color: var(--chalk-yellow); }
.start-card .view { display: grid; gap: 16px; }
.start-card .row { display: flex; flex-wrap: wrap; gap: 10px; }
.start-card .plan { margin: 0; font-size: 17px; line-height: 1.5; color: var(--chalk); }
.start-card .plan b { font-family: var(--font-hand); font-size: 19px; color: var(--chalk-yellow); font-weight: 700; }
.field-label { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--chalk-dim); padding: 0; }
.choices { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }

/* Each learner is their name in their own chalk color. */
.learners { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.learner {
  width: 100%;
  display: grid;
  gap: 2px;
  justify-items: start;
  padding: 12px 14px 10px;
  border-radius: 12px;
  border: 1.5px solid rgba(241, 238, 230, 0.2);
  background: rgba(241, 238, 230, 0.05);
  color: var(--learner, var(--chalk-yellow));
  cursor: pointer;
  text-align: left;
}
.learner:hover { background: rgba(241, 238, 230, 0.1); border-color: var(--learner, var(--chalk-yellow)); }
.learner .who { font: 700 26px/1.1 var(--font-hand); }
.learner .who::after { content: ""; display: block; height: 3px; margin-top: 3px; border-radius: 3px; background: currentColor; opacity: 0.55; transform: rotate(-1deg); }
.learner .grade { font-size: 14px; color: var(--chalk-dim); }
.add-learner, .link {
  justify-self: start;
  font: 700 16px var(--font-ui);
  color: var(--chalk);
  background: none;
  border: 1.5px dashed rgba(241, 238, 230, 0.45);
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
}
.add-learner span { font-family: var(--font-hand); font-size: 20px; margin-right: 4px; }
.link { border: 0; padding: 6px 0; font-weight: 600; font-size: 15px; color: var(--chalk-dim); text-decoration: underline; text-underline-offset: 3px; }
.chalk.ghost { background: transparent; color: var(--chalk); box-shadow: inset 0 0 0 1.5px rgba(241, 238, 230, 0.5); }

.grade-pick, .color-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.grade-pick label, .color-pick label { position: relative; cursor: pointer; }
.grade-pick input, .color-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.grade-pick { gap: 6px; }
.grade-pick span {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  font: 700 22px var(--font-hand); color: var(--chalk); border: 1.5px solid rgba(241, 238, 230, 0.35);
}
.grade-pick input:checked + span { background: var(--chalk-yellow); color: #262422; border-color: var(--chalk-yellow); }
.color-pick span { display: block; width: 44px; height: 44px; border-radius: 50%; background: var(--swatch); border: 3px solid transparent; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15); }
.color-pick input:checked + span { border-color: var(--chalk); outline: 2px solid var(--swatch); outline-offset: 2px; }
.grade-pick input:focus-visible + span, .color-pick input:focus-visible + span { outline: 3px solid var(--chalk-yellow); outline-offset: 3px; }

.start-card input {
  font: 400 26px var(--font-hand);
  color: var(--chalk);
  background: transparent;
  border: 0;
  border-bottom: 2px solid rgba(241, 238, 230, 0.45);
  padding: 6px 2px;
  border-radius: 0;
}

.start-card input::placeholder { color: rgba(241, 238, 230, 0.45); }
.start-card input:focus-visible { outline: none; border-bottom-color: var(--chalk-yellow); }
.start-card .fine { margin: 0; font-size: 14px; line-height: 1.45; color: var(--chalk-dim); }
.start-card .lede { margin: -4px 0 0; font-size: 17px; line-height: 1.5; color: var(--chalk); }

/* Today's plan on the start card: the same stops the rail shows during the lesson. */
.plan-path { list-style: none; margin: -2px 0 2px; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; font: 700 15px var(--font-ui); }
.plan-path:empty { display: none; }
.plan-path li { display: flex; align-items: center; gap: 7px; color: var(--chalk); }
.plan-path li + li::before { content: ""; width: 16px; height: 2px; border-radius: 2px; background: rgba(241, 238, 230, 0.35); margin-right: 3px; }
.plan-path .mark { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--chalk-dim); flex: none; }
.plan-path li:first-child .mark { border-color: var(--chalk-yellow); background: var(--chalk-yellow); }
.plan-path .what { font-family: var(--font-hand); color: var(--chalk-yellow); font-size: 17px; }

/* When something stops the lesson from starting: what happened and what to do, right on the card. */
.problem-note { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--coral-wash); border: 1.5px solid rgba(239, 138, 116, 0.55); font-size: 16px; line-height: 1.45; color: var(--chalk); }
.problem-note b { color: var(--chalk-coral); display: block; margin-bottom: 2px; }
.start-card :focus-visible { outline-color: var(--chalk-yellow); }

/* ---------- days this week: chalk tally marks on the rail ---------- */

.week { margin: 0; display: flex; align-items: center; gap: 6px; font: 600 14px var(--font-ui); white-space: nowrap; }
.week .tally { display: flex; gap: 3px; }
.week .tally i { width: 3px; height: 16px; border-radius: 2px; background: rgba(63, 37, 15, 0.22); transform: rotate(4deg); }
.week .tally i.on { background: var(--burn); }

/* Press and hold: the button fills while it's held, so grown-ups get in and kids don't by accident. */
.rail-button.hold { position: relative; overflow: hidden; border-radius: 8px; padding-inline: 8px; }
.hold-fill { position: absolute; inset: 0; background: rgba(63, 37, 15, 0.18); transform: scaleX(0); transform-origin: left; }
.hold.holding .hold-fill { transform: scaleX(1); transition: transform 1.1s linear; }

/* ---------- dialogs ---------- */

dialog { padding: 0; border: 0; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(20, 14, 8, 0.55); }
.close {
  font: 700 15px var(--font-ui); background: none; border: 1.5px solid currentColor; border-radius: 999px;
  padding: 9px 16px; min-height: 44px; color: inherit; cursor: pointer;
}

/* ---------- the math map: the whole ladder as a numbered chalk trail ---------- */

.map {
  width: min(1100px, calc(100vw - 24px));
  height: min(820px, calc(100dvh - 24px));
  border-radius: 14px;
  background: radial-gradient(120% 90% at 30% 20%, #2f3b3e, var(--slate) 55%, var(--slate-deep));
  color: var(--chalk);
  overflow: hidden;
}
.map[open] { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); }
.map-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 18px 20px 8px; }
.map-head h2 { margin: 0 auto 0 0; font: 700 28px/1.1 var(--font-hand); color: var(--chalk-yellow); }
.grade-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.grade-tabs button {
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid rgba(241, 238, 230, 0.3);
  background: none; color: var(--chalk); font: 700 15px var(--font-ui); cursor: pointer;
}
.grade-tabs button[aria-selected="true"] { background: var(--chalk); color: #262422; border-color: var(--chalk); }
.grade-tabs .done-mark { color: var(--chalk-yellow); margin-left: 4px; }
.grade-tabs .course-grade { font-size: 12px; font-weight: 600; opacity: 0.7; margin-left: 5px; }
.map-legend { margin: 0; padding: 0 20px 10px; display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; color: var(--chalk-dim); }
.map-legend .key::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--chalk-dim); }
.map-legend .next::before { border-color: var(--chalk-yellow); box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.25); }
.map-legend .learning::before { border-color: var(--chalk-sky); border-right-color: transparent; }
.map-legend .mastered::before { background: var(--chalk-yellow); border-color: var(--chalk-yellow); }

/* Badges: a chalk star for each family of skills in the grade, lit once it's all learned. */
.badges { list-style: none; margin: 0; padding: 0 20px 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.badges li { display: flex; align-items: center; gap: 6px; padding: 5px 12px 5px 8px; border-radius: 999px; font: 700 13px var(--font-ui); color: var(--chalk-dim); border: 1.5px dashed rgba(241, 238, 230, 0.28); }
.badges li svg { width: 16px; height: 16px; fill: none; stroke: rgba(241, 238, 230, 0.45); stroke-width: 1.6; stroke-linejoin: round; }
.badges li.on { color: #262422; background: var(--chalk-yellow); border: 1.5px solid var(--chalk-yellow); }
.badges li.on svg { fill: #262422; stroke: #262422; }

.trail {
  list-style: none; margin: 0; padding: 6px 20px 24px; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; align-content: start;
  counter-reset: stop;
}
.stop {
  position: relative; width: 100%; height: 100%; min-height: 96px; display: grid; align-content: start; gap: 6px; text-align: left;
  padding: 12px 14px 12px 50px; border-radius: 12px; cursor: pointer; color: var(--chalk);
  background: rgba(241, 238, 230, 0.04); border: 1.5px solid rgba(241, 238, 230, 0.16); font: 600 15px/1.3 var(--font-ui);
}
.stop:hover { background: rgba(241, 238, 230, 0.09); }
.stop .n {
  position: absolute; left: 12px; top: 12px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  font: 700 15px var(--font-hand); border: 1.5px solid rgba(241, 238, 230, 0.45); color: var(--chalk-dim);
}
.stop .state { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; color: var(--chalk-dim); }
.stop[data-state="mastered"] .n, .stop[data-state="known"] .n { background: var(--chalk-yellow); border-color: var(--chalk-yellow); color: #262422; }
.stop[data-state="mastered"] .state, .stop[data-state="known"] .state { color: var(--chalk-yellow); }
.stop[data-state="learning"] .n { border-color: var(--chalk-sky); border-right-color: transparent; color: var(--chalk); }
.stop[data-state="learning"] .state { color: var(--chalk-sky); }
.stop[data-state="next"] { border-color: var(--chalk-yellow); box-shadow: 0 0 0 4px rgba(242, 201, 76, 0.16); }
.stop[data-state="next"] .n { border-color: var(--chalk-yellow); color: var(--chalk-yellow); animation: glow 1.8s ease-in-out infinite alternate; }
.stop[data-state="next"] .state { color: var(--chalk-yellow); }
.stop[aria-current="true"] { background: rgba(241, 238, 230, 0.12); }
.stop .star { position: absolute; right: 10px; top: 10px; width: 22px; height: 22px; fill: var(--chalk-yellow); }
.stop .lvl { display: inline-flex; gap: 2px; margin-left: 7px; vertical-align: -2px; }
.stop .lvl svg { width: 14px; height: 14px; fill: var(--chalk-yellow); }
@keyframes glow { to { box-shadow: 0 0 0 6px rgba(242, 201, 76, 0.22); } }
.map :focus-visible, .summary :focus-visible, .start-card :focus-visible { outline: 3px solid var(--chalk-yellow); outline-offset: 3px; }

/* ---------- the handwriting check (grown-ups) ---------- */

.hwcheck {
  width: min(980px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; border-radius: 14px; padding: 18px 22px 22px;
  background: radial-gradient(120% 90% at 30% 20%, #2f3b3e, var(--slate) 55%, var(--slate-deep)); color: var(--chalk);
}
.hwcheck[open] { display: grid; gap: 14px; }
.hw-head { display: flex; align-items: center; gap: 16px; }
.hw-head h2 { margin: 0 auto 0 0; font: 700 28px/1.1 var(--font-hand); color: var(--chalk-yellow); }
.hw-count { margin: 0; font: 600 15px var(--font-ui); color: var(--chalk-dim); }
.hw-say { margin: 0; font-size: 17px; }
.hw-target { display: block; max-width: 100%; }
.hw-pad { display: block; width: 100%; border-radius: 10px; background: rgba(0, 0, 0, 0.18); border: 1.5px solid rgba(241, 238, 230, 0.2); touch-action: none; cursor: crosshair; }
.hw-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.hw-status { margin: 0; font-size: 15px; color: var(--chalk-dim); }
.hwcheck :focus-visible { outline: 3px solid var(--chalk-yellow); outline-offset: 3px; }

/* ---------- end of lesson ---------- */

.summary {
  width: min(520px, calc(100vw - 24px)); border-radius: 16px; padding: 26px 26px 22px;
  background: rgba(24, 31, 33, 0.97); color: var(--chalk); border: 1.5px solid rgba(241, 238, 230, 0.28);
}
.summary[open] { display: grid; gap: 14px; position: relative; }
.summary .pip-card { position: absolute; left: auto; right: 18px; top: 14px; bottom: auto; width: 76px; height: 71px; }
.summary h2 { padding-right: 84px; }
.summary h2 { margin: 0; font: 700 30px/1.15 var(--font-hand); color: var(--chalk-yellow); }
.summary-stars { margin: 0; display: flex; align-items: center; gap: 8px; font: 700 20px var(--font-ui); }
.summary-stars svg { width: 30px; height: 30px; fill: var(--chalk-yellow); }
.summary-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 17px; line-height: 1.4; }
.summary-list li { display: flex; gap: 10px; align-items: baseline; }
.summary-list li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--chalk-dim); transform: translateY(-2px); }
.summary-list li.win::before { background: var(--chalk-yellow); }
.summary-list li.badge::before { background: var(--chalk-mint); }
.summary-headline { margin: 0; font-size: 15px; line-height: 1.5; color: var(--chalk-dim); min-height: 1.5em; }
.summary-next { margin: 0; font-size: 16px; line-height: 1.45; color: var(--chalk); padding-top: 12px; border-top: 1px solid rgba(241, 238, 230, 0.16); }
.summary-next b { font-family: var(--font-hand); font-size: 18px; color: var(--chalk-yellow); }
.summary .row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- for grown-ups: a teacher's grade book, on paper ---------- */

.grownups {
  width: min(880px, calc(100vw - 24px)); height: min(860px, calc(100dvh - 24px)); border-radius: 6px;
  color: var(--ink); background-color: var(--paper);
  /* The red margin line of a teacher's grade book; no ruled lines, so nothing crosses the text. */
  background-image: linear-gradient(90deg, transparent 54px, var(--paper-margin) 54px, var(--paper-margin) 56px, transparent 56px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
}
.grownups[open] { display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.gu-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 6px 72px; }
.gu-head h2 { margin: 0; font: 700 28px var(--font-hand); }
.gu-learners { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 24px 10px 72px; }
.gu-learners button {
  min-height: 40px; padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--ink-soft); background: transparent;
  font: 700 15px var(--font-ui); color: var(--ink); cursor: pointer;
}
.gu-learners button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.gu-body { overflow: auto; padding: 4px 24px 28px 72px; display: grid; gap: 26px; align-content: start; }
.gu-body section { display: grid; gap: 10px; }
.gu-body h3 { margin: 0; font: 700 13px var(--font-ui); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.gu-body p { margin: 0; font-size: 16px; line-height: 1.55; }
.gu-body .headline { font: 700 21px/1.35 var(--font-hand); }
.gu-body dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 16px; line-height: 1.5; }
.gu-body dt { font-weight: 700; color: var(--ink-soft); }
.gu-body dd { margin: 0; }
.gu-week { display: flex; gap: 6px; }
.gu-week span { width: 38px; height: 44px; display: grid; place-items: center; border: 1.5px solid var(--paper-rule); border-radius: 6px; font-size: 13px; font-weight: 700; color: var(--ink-soft); background: rgba(255, 255, 255, 0.4); }
.gu-week span.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.gu-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.gu-stats p { font-size: 15px; color: var(--ink-soft); }
.gu-stats b { display: block; font: 700 28px/1.1 var(--font-hand); color: var(--ink); }
.gu-grades { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gu-grades li { display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 12px; font-size: 15px; }
.gu-bar { height: 10px; border-radius: 6px; background: var(--paper-rule); overflow: hidden; }
.gu-bar i { display: block; height: 100%; background: var(--ink); border-radius: 6px; }
.gu-grades .cert { font: 700 14px var(--font-ui); background: none; border: 1.5px solid var(--ink); border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--ink); }
.gu-sessions { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.gu-sessions li { display: grid; gap: 3px; padding-bottom: 12px; border-bottom: 1px solid var(--paper-rule); }
.gu-sessions .when { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.gu-settings { display: grid; gap: 12px; }
.gu-settings label { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.gu-settings select, .gu-settings input[type="text"] { font: 16px var(--font-ui); padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--ink-soft); background: #fffdf7; color: var(--ink); min-height: 40px; }
.gu-settings input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ink); }
.gu-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.gu-actions button { min-height: 44px; font: 700 15px var(--font-ui); padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.gu-actions .danger { border-color: #9a2c17; color: #9a2c17; }
.gu-note { font-size: 14px !important; color: var(--ink-soft); }
.grownups :focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

@media (max-width: 640px) {
  .gu-head, .gu-learners, .gu-body { padding-left: 24px; }
  .grownups { background-image: none; }
  .trail { grid-template-columns: 1fr; padding-inline: 14px; gap: 8px; }
  .stop { min-height: 0; padding-block: 10px; }
  .map-head { display: grid; grid-template-columns: 1fr auto; padding-inline: 14px; }
  .map-head h2 { font-size: 24px; }
  .map-head .close { grid-row: 1; grid-column: 2; }
  .grade-tabs { grid-column: 1 / -1; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .grade-tabs button { flex: none; }
  .map-legend { padding-inline: 14px; }
  .badges { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-inline: 14px; }
  .badges li { flex: none; }
  .week .label { display: none; }
}

/* ---------- a printable certificate ---------- */

.certificate { display: none; }
@media print {
  body { background: #fff; overflow: visible; }
  .frame, dialog { display: none !important; }
  .certificate {
    display: grid !important; place-items: center; align-content: center; gap: 18px; min-height: 100vh; text-align: center;
    border: 10px double #3f250f; padding: 60px; color: #2b2925; font-family: var(--font-ui);
  }
  .certificate h1 { font: 700 54px var(--font-hand); margin: 0; }
  .certificate .name { font: 700 64px var(--font-hand); margin: 0; }
  .certificate p { font-size: 22px; margin: 0; }
}

/* ---------- a break in the lesson ---------- */

.paused { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: rgba(20, 27, 29, 0.62); }
.paused-card { width: min(420px, calc(100% - 32px)); padding: 26px 26px 22px; border-radius: 16px; background: rgba(24, 31, 33, 0.96); border: 1.5px solid rgba(241, 238, 230, 0.28); color: var(--chalk); display: grid; gap: 14px; justify-items: start; }
.paused-card h2 { margin: 0; font: 700 28px/1.15 var(--font-hand); color: var(--chalk-yellow); }
.paused-card p { margin: 0; font-size: 17px; line-height: 1.5; }
.paused-card :focus-visible { outline: 3px solid var(--chalk-yellow); outline-offset: 3px; }

/* ---------- log ---------- */

.log {
  position: absolute;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: min(430px, calc(100% - 24px));
  overflow: auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(14, 19, 20, 0.92);
  color: var(--chalk);
  font: 12.5px/1.45 var(--font-mono);
  z-index: 3;
}

.log ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.log .meter { margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(241, 238, 230, 0.2); color: var(--chalk-yellow); font: 600 13px var(--font-mono); }
.log li { white-space: pre-wrap; word-break: break-word; }
.log .kind { color: var(--chalk-yellow); }
.log .t { color: var(--chalk-dim); margin-right: 6px; }

/* ---------- the ledge ---------- */

.ledge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding: 12px 2px 14px;
}

.group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.chalk {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 18px;
  font: 700 16px/1.1 var(--font-ui);
  color: #262422;
  background: var(--chalk);
  box-shadow: 0 2px 0 rgba(63, 37, 15, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.07);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.chalk:hover { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(63, 37, 15, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.07); }
.chalk:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(63, 37, 15, 0.45); }
.chalk:disabled { opacity: 0.5; cursor: default; transform: none; }
.chalk.yellow { background: var(--chalk-yellow); }
.chalk.coral { background: var(--chalk-coral); }
.chalk.quiet { background: rgba(255, 244, 228, 0.32); color: var(--burn); box-shadow: none; }
.chalk[aria-pressed="true"] { background: var(--burn); color: var(--chalk); }

/* The chalk tray: a groove cut into the ledge, holding the board tools. The tool in hand sits
   lifted in white chalk; the others rest in the groove. */
.tray {
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(63, 37, 15, 0.34), rgba(63, 37, 15, 0.2));
  box-shadow: inset 0 2px 3px rgba(40, 22, 6, 0.45), inset 0 -1px 0 rgba(255, 236, 205, 0.22), 0 1px 0 rgba(255, 236, 205, 0.25);
}
.tool {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  min-width: 44px;
  padding: 8px 13px 8px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff7ea;
  font: 700 15px/1 var(--font-ui);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}
.tool svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool .hl-bar { stroke: var(--chalk-yellow); stroke-width: 4; opacity: 0.85; }
.tool:hover { background: rgba(255, 244, 228, 0.16); }
.tool[aria-pressed="true"] {
  background: var(--chalk);
  color: var(--burn);
  box-shadow: 0 2px 0 rgba(63, 37, 15, 0.45), inset 0 -2px 0 rgba(0, 0, 0, 0.07);
  transform: translateY(-1px);
}
.tool:disabled { opacity: 0.42; cursor: default; background: transparent; }
.tool.danger { background: var(--chalk-coral); color: #2b1208; }
.tray-rule { width: 1.5px; align-self: stretch; margin: 8px 4px; background: rgba(255, 236, 205, 0.3); border-radius: 2px; }
.tray .tool:focus-visible { outline: 3px solid var(--chalk); outline-offset: 1px; }
/* With the construction tools out, the tray is long: only the tool in hand keeps its word. */
@media (max-width: 1600px) {
  .tray:has(.geo:not([hidden])) .tool:not([aria-pressed="true"]) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .tray:has(.geo:not([hidden])) .tool:not([aria-pressed="true"]) { padding-inline: 10px; }
}
.tray-toggle { display: none; }

/* Pages: which page is in view, and a way up and down for a mouse or keyboard. */
.pager {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(20, 27, 29, 0.84);
  border: 1.5px solid rgba(241, 238, 230, 0.34);
  color: var(--chalk);
  font: 600 14px/1 var(--font-ui);
}
.pager span { padding: 0 6px; white-space: nowrap; }
.pager button {
  appearance: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--chalk);
  cursor: pointer;
}
.pager button:hover { background: rgba(241, 238, 230, 0.14); }
.pager button:disabled { opacity: 0.35; cursor: default; background: transparent; }
.pager svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pager button:focus-visible, .offer :focus-visible { outline: 3px solid var(--chalk-yellow); outline-offset: 2px; }

/* A one-time offer on the board, in the same voice as the speech bubble. */
.offer {
  position: absolute;
  right: 14px;
  bottom: 62px;
  max-width: min(360px, calc(100% - 28px));
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(20, 27, 29, 0.92);
  border: 1.5px solid rgba(241, 238, 230, 0.34);
  color: var(--chalk);
  font-size: 16px;
  line-height: 1.4;
}
.offer p { margin: 0 0 12px; }
.offer .row { display: flex; flex-wrap: wrap; gap: 8px; }

.select {
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, #262422 50%), linear-gradient(135deg, #262422 50%, transparent 50%);
  background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  max-width: 100%;
}

:focus-visible { outline: 3px solid var(--burn); outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Tablets: let every button flow on its own so rows pack tightly. */
@media (max-width: 1100px) {
  .ledge { gap: 8px; }
  .group { display: contents; }
  .ledge .group.tray { display: flex; }
  /* Tablets: the tool in hand keeps its word, the rest are icons, so the ledge stays one row. */
  .tool:not([aria-pressed="true"]) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .tool:not([aria-pressed="true"]) { padding-inline: 10px; }
}

@media (max-width: 640px) {
  /* Phones: one scrolling row of chalk, the lesson actions first, a fade showing there is more. */
  .ledge {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-inline: 2px 48px;
    -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent);
    mask-image: linear-gradient(90deg, #000 82%, transparent);
  }
  .ledge::-webkit-scrollbar { display: none; }
  .chalk { white-space: nowrap; padding: 9px 14px; font-size: 15px; flex: none; }
  /* The tray folds to the tool in hand and Undo; tapping the tool in hand opens the rest. */
  .tray { flex: none; }
  .tool span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .tool { padding: 8px 10px; }
  .tray[data-open="false"] .tool[data-tool][aria-pressed="false"],
  .tray[data-open="false"] #redo,
  .tray[data-open="false"] .tray-rule { display: none; }
  .brand { font-size: 21px; }
  .status { font-size: 13px; }
  /* Pip on the board already shows listening and talking; the words stay for screen readers. */
  .status #status-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .echo-value { font-size: 21px; }
}

/* On a phone the sign at the top spans the board, so what Pip read sits just under it. */
@media (max-width: 640px) {
  .echo { top: 54px; padding: 6px 12px; }
}

@media (max-width: 420px) {
  .week { display: none; }
  .rail-right { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Short screens (a phone turned sideways): one scrolling row of chalk, a slimmer rail, a smaller
   Pip, and a shorter speech bubble, so the board keeps its height and the problem stays in view. */
@media (max-height: 500px) {
  .rail { min-height: 40px; }
  .brand { font-size: 20px; }
  .ledge {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 6px 48px 8px 2px;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
    mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .ledge::-webkit-scrollbar { display: none; }
  .ledge .group { display: contents; }
  .ledge .group.tray { display: flex; flex: none; }
  .tool { min-height: 36px; }
  .chalk { white-space: nowrap; min-height: 38px; padding: 7px 14px; font-size: 14px; flex: none; }
  .slate { --pip-size: 46px; }
  .caption { max-width: min(460px, calc(100% - var(--pip-size) - 34px)); font-size: 15px; padding: 7px 12px; }
  .mode { top: 6px; font-size: 14px; padding: 5px 12px 5px 9px; }
  .mode-icon { width: 18px; height: 18px; }
}

/* While a proof is open, the board's pen tools rest: the proof panel is the work surface. */
.proving #tray, .proving #more-room, .proving #wipe { display: none !important; }
