/* ABOUTME: Engineering-pad skin for numdamentals — quadrille grid, ink/paper palette, three-voice type. */
/* ABOUTME: Mobile-first (16px inputs, ~44px targets, no page overflow); pen-marked feedback; a11y focus + reduced-motion. */

:root {
  font-size: 100%; /* 16px base — no iOS zoom on input focus */
  --paper: #fbfcfe;
  --grid: #e3ebf6;
  --ink: #14213d;
  --muted: #5c6a85;
  --line: #d8e0ee;
  --accent: #2b39c9;
  --accent-tint: #ecefff;
  --correct: #0f7a54;
  --correct-bg: #e8f6ef;
  --wrong: #d23b22;
  --wrong-bg: #fdecea;
  --feedback-bg: #f3f6fb;
  --measure: 44rem;
  --pad: 1rem;
  --touch: 2.75rem; /* ~44px */
  --button-ink: #fff;
  --blue: #1761e8;
  --orange: #ca4f00;
  --red: #e32616;
  --green: #00814c;
  --purple: #8d31d8;
  --pink: #ef3d98;
  --pink-label: #000;
  --sans:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:
    ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.accessibility-control,
button,
select,
summary {
  min-height: var(--touch);
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  /* Quadrille grid substrate — pure CSS graph paper. */
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 1.5rem 1.5rem;
}

header,
main,
footer {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding: var(--pad);
}

header {
  display: flex;
  align-items: center;
  border-bottom: 2px solid var(--ink);
  background: transparent;
}

footer {
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

/* Wordmark: num as a mono number-tile, damentals in ink. */
.brand {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
}

.num-tile {
  font-family: var(--mono);
  font-weight: 700;
  background: var(--accent);
  color: var(--button-ink);
  padding: 0.05em 0.35em;
  border-radius: 4px;
  margin-right: 2px;
}

a {
  color: var(--accent);
}

img,
svg,
.katex-display {
  max-width: 100%;
}

/* Eyebrows and block labels: the mono utility voice. */
.eyebrow,
.block-label {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 1.25rem;
}

h2 {
  font-size: 1.25rem;
}

/* Lesson index as a numbered problem set. */
.lesson-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: lesson;
}

.lesson-list li {
  counter-increment: lesson;
}

.lesson-list a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.5rem;
  min-height: var(--touch);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}

.lesson-list a::before {
  content: counter(lesson, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.lesson-list a:hover {
  color: var(--accent);
}

.empty {
  color: var(--muted);
}

/* Content blocks. */
section {
  margin-block: 1.75rem;
}

.exposition {
  /* Sits directly on the grid — reading maths on graph paper. */
}

/* Cards lift problems off the grid onto solid paper. */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 0 rgba(20, 33, 61, 0.04);
  margin-block: 1rem;
}

.q-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.q-marker {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 0.18rem 0.42rem;
  border-radius: 4px;
  margin-top: 0.15rem;
  white-space: nowrap;
}

.q-row .problem {
  flex: 1;
  min-width: 0;
}

.prompt {
  margin: 0 0 0.6rem;
}

/* Answer input: the mono precision voice, touch-friendly, 16px. */
.answer {
  width: 100%;
  min-height: var(--touch);
  padding: 0.5rem 0.7rem;
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b7c0d4;
  border-radius: 6px;
}

.options {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--touch);
  padding: 0.35rem 0;
}

.option input[type="radio"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent);
}

button[type="submit"] {
  min-height: var(--touch);
  margin-top: 0.75rem;
  padding: 0.55rem 1.2rem;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--button-ink);
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button[type="submit"]:hover {
  background: #212ea8;
}

/* Pen-marked feedback: a coloured left stroke, like a teacher's pen. */
.feedback,
.outcome,
.quiz-results li {
  border-left: 4px solid var(--muted);
  border-radius: 0 6px 6px 0;
  padding: 0.55rem 0.8rem;
  margin-top: 0.7rem;
  background: var(--feedback-bg);
  animation: markin 0.2s ease-out;
}

.feedback.correct,
.outcome.correct,
.quiz-results li.correct {
  border-left-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
}

.feedback.incorrect,
.outcome.incorrect,
.quiz-results li.incorrect {
  border-left-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
}

.hint {
  color: var(--muted);
}

/* On-demand hint: native <details> disclosure, no JavaScript. */
.hint-box {
  margin-top: 0.6rem;
  font-size: 0.95rem;
}

:where(.hint-box[open]) > summary {
  margin-bottom: 0.25rem;
}

.hint-box > summary {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  cursor: pointer;
  display: inline-block;
  padding: 0.15rem 0;
  min-height: var(--touch);
}

.hint-text {
  margin: 0;
  padding: 0.5rem 0.7rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-tint);
  border-radius: 0 6px 6px 0;
  color: var(--ink);
}

.score {
  font-family: var(--mono);
  font-weight: 700;
}

.quiz-results {
  list-style: none;
  padding: 0;
}

.result .eyebrow {
  margin-bottom: 0.35rem;
}

/* Accessibility floor: visible keyboard focus. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@keyframes markin {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Respect reduced-motion: no non-essential animation. */
@media (prefers-reduced-motion: reduce) {
  .feedback,
  .outcome,
  .quiz-results li {
    animation: none;
  }
}

header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
}
.header-actions form {
  margin: 0;
}
.question-panel > .panel-body {
  padding: clamp(1.25rem, 3vw, 2rem);
}

.question-chevron svg {
  width: 1.5rem;
  height: 3rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linejoin: round;
}
.help-screen > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.control-icon {
  display: none;
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Tablet / desktop. */
.child-lesson {
  font-size: 1.125rem;
}

.child-lesson h1 {
  margin-block: 1.5rem 1rem;
}

.child-card {
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 1.25rem;
  padding: clamp(1rem, 4vw, 2rem);
}

.child-prompt {
  font-size: clamp(1.5rem, 6vw, 2.5rem);
  line-height: 1.3;
  overflow-wrap: anywhere;
  margin-top: 0;
}

.child-answer {
  display: block;
  width: 100%;
  max-width: 10rem;
  min-height: 3.5rem;
  font: inherit;
  font-size: 2rem;
  border: 2px solid var(--ink);
  border-radius: 0.5rem;
  padding: 0.5rem;
}

.child-lesson button[type="submit"],
.child-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  padding: 0.75rem 1.25rem;
  margin-top: 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--button-ink);
  border-radius: 0.75rem;
  text-decoration: none;
}

.child-back,
.child-option,
.child-course a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.75rem;
}

.child-option {
  border: 1px solid var(--ink);
  border-radius: 0.5rem;
  margin-block: 0.5rem;
}

.child-option input {
  width: 1.5rem;
  height: 1.5rem;
}

.child-lesson fieldset {
  min-width: 0;
  border: 0;
  padding: 0;
}

.child-feedback {
  font-weight: 700;
  padding: 0.75rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-tint);
}

.child-course {
  background: #fff;
  border-radius: 1rem;
  padding: 1rem 1rem 1rem 2.5rem;
}

.child-progress,
.child-note {
  color: var(--ink);
}

@media (min-width: 48rem) {
  :root {
    --pad: 1.5rem;
    --measure: 48rem;
  }

  h1 {
    font-size: 2rem;
  }
}

/* W004 display preferences are rendered by the server, including first paint. */
html[data-text-size="larger"] {
  font-size: 125%;
}
body[data-appearance="dark"] {
  --blue: #5492ff;
  --orange: #ff923a;
  --red: #ff493f;
  --green: #24c98b;
  --purple: #bd79ff;
  --pink: #ff8bd0;
  --pink-label: #131923;
  color-scheme: dark;
  --paper: #131923;
  --ink: #f2f4f8;
  --muted: #c5cede;
  --line: #71809a;
  --grid: #253045;
  --accent: #b8c6ff;
  --accent-tint: #273650;
  --button-ink: #131923;
  --feedback-bg: #273650;
  --correct: #a8efd4;
  --correct-bg: #0b3b2c;
  --wrong: #ffd0c4;
  --wrong-bg: #4a2119;
}
@media (prefers-color-scheme: dark) {
  body[data-appearance="system"] {
    --blue: #5492ff;
    --orange: #ff923a;
    --red: #ff493f;
    --green: #24c98b;
    --purple: #bd79ff;
    --pink: #ff8bd0;
    --pink-label: #131923;
    color-scheme: dark;
    --paper: #131923;
    --ink: #f2f4f8;
    --muted: #c5cede;
    --line: #71809a;
    --grid: #253045;
    --accent: #b8c6ff;
    --accent-tint: #273650;
    --button-ink: #131923;
    --feedback-bg: #273650;
    --correct: #a8efd4;
    --correct-bg: #0b3b2c;
    --wrong: #ffd0c4;
    --wrong-bg: #4a2119;
  }
}
body[data-contrast="high"] {
  --blue: #123579;
  --orange: #713000;
  --red: #820e00;
  --green: #074a28;
  --purple: #461572;
  --pink: #761244;
  --pink-label: #fff;
  --paper: #fff;
  --ink: #000;
  --muted: #000;
  --line: #000;
  --accent: #000;
  --accent-tint: #fff;
  --button-ink: #fff;
  --feedback-bg: var(--paper);
  --correct: var(--ink);
  --correct-bg: var(--paper);
  --wrong: var(--ink);
  --wrong-bg: var(--paper);
  background-image: none;
}
body[data-contrast="high"][data-appearance="dark"] {
  --blue: #c6d9ff;
  --orange: #ffdbb5;
  --red: #ffac8f;
  --green: #bbf4d4;
  --purple: #e5cfff;
  --pink: #ffd1ec;
  --pink-label: #000;
  --paper: #000;
  --ink: #fff;
  --muted: #fff;
  --line: #fff;
  --accent: #fff;
  --accent-tint: #000;
  --button-ink: #000;
}
@media (prefers-color-scheme: dark) {
  body[data-contrast="high"][data-appearance="system"] {
    --blue: #c6d9ff;
    --orange: #ffdbb5;
    --red: #ffac8f;
    --green: #bbf4d4;
    --purple: #e5cfff;
    --pink: #ffd1ec;
    --pink-label: #000;
    --paper: #000;
    --ink: #fff;
    --muted: #fff;
    --line: #fff;
    --accent: #fff;
    --accent-tint: #000;
    --button-ink: #000;
  }
}
header {
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.accessibility-control {
  padding: 0.6rem;
  border: 2px solid var(--accent);
  border-radius: 0.5rem;
}

.accessibility-control[type="submit"] {
  margin: 0;
  padding: 0.6rem;
  font-size: 1rem;
}
button,
select {
  font: inherit;
}
button,
select,
.answer,
.child-answer {
  background: var(--paper);
  color: var(--ink);
}
button[type="submit"]:hover {
  background: var(--ink);
  color: var(--paper);
}
select {
  display: block;
  width: 100%;
  padding: 0.5rem;
  margin-block: 0.5rem;
}
.card,
.child-card,
.child-course {
  background: var(--paper);
}
.primary-mode header,
.primary-mode main {
  padding-block: 0.65rem;
}
.primary-mode footer {
  margin-top: 0.75rem;
}
.primary-mode .child-lesson h1 {
  margin-block: 0.65rem;
  font-size: 1.5rem;
}
.primary-mode .child-back {
  min-height: var(--touch);
  padding: 0.35rem 0;
}
.child-progress {
  margin-block: 0.5rem;
}
.child-card {
  margin-block: 0.5rem;
  padding: 1rem;
  scroll-margin-top: 0.5rem;
}
.child-prompt {
  margin-bottom: 0.6rem;
}
.child-instructions {
  margin-block: 0.5rem;
}
.child-instructions summary,
.help-fallback summary {
  cursor: pointer;
  padding-block: 0.5rem;
}
.child-note {
  margin-block: 0.5rem;
  font-size: 1rem;
}
.feedback-space {
  min-height: 3.5rem;
}
.child-feedback {
  margin-block: 0.4rem;
  padding: 0.5rem;
}
.child-answer {
  border-color: var(--ink);
}
.child-answer[disabled] {
  border-style: dashed;
}
.child-next {
  margin-top: 0.6rem;
}
.option-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.option-bar label {
  flex: 1 1 7rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 3rem;
  padding: 0.65rem;
  border: 2px solid var(--line);
  border-radius: 0.5rem;
  cursor: pointer;
  margin: 0;
}
.option-bar input {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}
.display-preferences fieldset {
  margin-block: 1rem;
  padding: 0;
  border: 0;
  min-width: 0;
}
.display-preferences legend {
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.display-preferences p {
  font-size: 0.9rem;
}
dialog {
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--accent);
  border-radius: 1rem;
  padding: 1rem;
  width: min(92vw, 38rem);
  max-height: 88vh;
  overflow-y: auto;
}
dialog::backdrop {
  background: rgb(0 0 0 / 65%);
}
.dialog-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.dialog-heading h2 {
  margin: 0;
}
.dialog-heading button {
  border: 2px solid var(--accent);
  border-radius: 0.5rem;
  padding: 0.6rem;
  cursor: pointer;
}
.dialog-only {
  display: none;
}
.has-dialogs .dialog-only {
  display: inline-flex;
  align-items: center;
}
.has-dialogs .help-fallback {
  display: none;
}
.counter-group {
  margin-block: 0.4rem;
  min-width: 0;
}
.counter-group p {
  margin-block: 0.4rem;
}
.quantity-frames {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.ten-frame {
  list-style: none;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) 0.4fr repeat(
      5,
      minmax(0, 1fr)
    );
  gap: 0.1rem;
  width: 100%;
  padding: 0.2rem 0;
}
.shape-slot {
  display: block;
  color: var(--shape-ink, var(--accent));
  line-height: 0;
}

.shape-slot:nth-child(6) {
  grid-column: 7;
}
[data-colour="blue"] {
  --shape-ink: var(--blue);
}
[data-colour="orange"] {
  --shape-ink: var(--orange);
}
[data-colour="red"] {
  --shape-ink: var(--red);
}
[data-colour="green"] {
  --shape-ink: var(--green);
}
[data-colour="purple"] {
  --shape-ink: var(--purple);
}
[data-colour="pink"] {
  --shape-ink: var(--pink);
}
.welcome-form label {
  display: block;
  margin-block: 0.75rem 0.35rem;
  font-weight: 600;
}
.welcome-form .answer {
  max-width: 24rem;
}
.child-welcome {
  background: var(--paper);
  border-radius: 1rem;
  padding: 1rem;
}
.primary-mode .child-welcome h1 {
  margin-bottom: 0.5rem;
}
.child-welcome > p {
  margin-block: 0.5rem 1rem;
}
.favourite-group {
  border: 0;
  padding: 0;
  min-width: 0;
  margin: 0 0 1rem;
}
.favourite-group legend {
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.favourite-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}
[data-favourite-group="colour_1"] .favourite-bar {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
[data-favourite-group="colour_2"] .favourite-bar {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
[data-favourite-group="shape_2"] .favourite-bar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.welcome-form .favourite-option {
  margin: 0;
  min-width: 0;
  position: relative;
  font-weight: 400;
}
.favourite-option[hidden] {
  display: none;
}
.favourite-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 5.25rem;
  padding: 0.6rem 0.15rem;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 0.75rem;
  cursor: pointer;
}
.favourite-option input:checked + .favourite-tile {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.favourite-option input:focus-visible + .favourite-tile {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.colour-swatch,
.shape-swatch {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
}
.colour-swatch {
  background: var(--shape-ink);
  border-radius: 50%;
  border: 2px solid var(--ink);
}
.shape-swatch svg {
  width: 100%;
  height: 100%;
  fill: var(--shape-ink, var(--ink));
  stroke: var(--shape-ink, var(--ink));
  stroke-width: 1.5;
}
.choice-name {
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.choice-mark {
  display: none;
  position: absolute;
  top: 0.15rem;
  right: 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
}
.favourite-option input:checked + .favourite-tile .choice-mark {
  display: block;
}
.trial-note {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
@media (max-width: 28rem) {
  [data-favourite-group="colour_1"] .favourite-bar,
  [data-favourite-group="colour_2"] .favourite-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.child-exit button[type="submit"] {
  min-height: var(--touch);
  min-width: var(--touch);
  font-size: 1rem;
  padding: 0.5rem;
  margin: 0;
  background: transparent;
  color: var(--ink);
  border: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.shape-slot svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
.shape-slot.is-filled svg {
  fill: currentColor;
}
.shape-slot.is-extra svg {
  color: color-mix(in srgb, var(--shape-ink, var(--accent)) 80%, var(--ink));
}
body[data-contrast="high"] .shape-slot svg {
  stroke-width: 2.5;
}
@media (forced-colors: active) {
  .shape-slot {
    color: CanvasText;
  }
  .shape-slot svg {
    forced-color-adjust: none;
    stroke: CanvasText;
  }
  .shape-slot.is-filled svg {
    fill: CanvasText;
  }
}

dialog:not([open]) {
  display: none;
}
body[data-appearance="light"] {
  color-scheme: light;
}

/* The primary shell uses the viewport as a stage, with scrolling when space is needed. */
.primary-mode {
  --touch: 3rem;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background-image: none;
}
.primary-mode header {
  max-width: 76rem;
  border: 0;
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
}
.primary-mode main {
  flex: 1;
  max-width: 72rem;
  padding: 1rem clamp(1rem, 4vw, 3rem) 2rem;
}
.primary-mode footer {
  display: none;
}
.primary-mode .welcome {
  max-width: 56rem;
  margin-inline: auto;
}
.primary-mode .child-welcome {
  padding: 0;
  background: transparent;
}
.primary-mode .child-welcome h1 {
  max-width: 40rem;
  margin-inline: auto;
  text-align: center;
  font-size: clamp(1.25rem, 3.5vw, 2rem);
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
  max-width: 52rem;
  margin: 1rem auto 0;
}
.paint-choice[type="submit"],
.shape-choice[type="submit"] {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
  min-height: clamp(6rem, 18svh, 11rem);
  margin: 0;
  padding: 0.75rem;
  border: 3px solid transparent;
  border-radius: 1.5rem;
  background: transparent;
  color: var(--ink);
  isolation: isolate;
  touch-action: manipulation;
}
.paint-choice[type="submit"] {
  color: var(--button-ink);
}
.paint-swatch {
  position: absolute;
  inset: 0.25rem;
  z-index: -1;
  background: var(--shape-ink);
  mask: url("/static/paint.svg") center / contain no-repeat;
}
.paint-choice .choice-name {
  color: var(--button-ink);
  font-weight: 750;
  font-size: 1.15rem;
}
.shape-choice .choice-name {
  color: var(--ink);
  font-size: 1rem;
}
.paint-choice[type="submit"]:hover,
.shape-choice[type="submit"]:hover {
  background: var(--accent-tint);
}
.paint-choice[aria-pressed="true"],
.shape-choice[aria-pressed="true"] {
  border-color: var(--ink);
  border-style: dashed;
}
.shape-choice .shape-swatch {
  width: clamp(3rem, 12vw, 6rem);
  height: clamp(3rem, 12vw, 6rem);
}
.screen-back button[type="submit"] {
  width: 3rem;
  min-height: 3rem;
  margin: 0 0 0.5rem;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.5rem;
}
.primary-mode .lesson-list,
.primary-mode .child-course {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(0.75rem, 2vw, 1.5rem);
}
.primary-mode .lesson-list a {
  height: 100%;
  min-height: 5rem;
  padding: 1rem;
  border: 2px solid var(--line);
  border-radius: 1.25rem;
  background: var(--accent-tint);
}
.primary-mode .lesson-list a::before {
  content: "";
  display: block;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.primary-mode .quiet-action[type="submit"] {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--line);
}
#screen:focus {
  outline: none;
}
#navigation-error {
  border: 2px solid var(--ink);
  padding: 1rem;
  border-radius: 1rem;
  background: var(--paper);
}
body[aria-busy="true"] #screen {
  cursor: progress;
}
@media (min-width: 40rem) {
  .choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }
  .primary-mode .child-lesson {
    max-width: 48rem;
    margin-inline: auto;
  }
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 180ms;
  animation-timing-function: ease-out;
}
@view-transition {
  navigation: auto;
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}
@media (forced-colors: active) {
  .paint-choice[type="submit"],
  .shape-choice[type="submit"] {
    border-color: ButtonText;
    color: ButtonText;
  }
  .paint-choice .choice-name {
    color: ButtonText;
  }
}
.learner-identity {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.learner-identity button[type="submit"] {
  min-height: 3rem;
  padding: 0.5rem;
  margin: 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: 0.875rem;
  font-weight: 400;
}
.bar-title {
  font-weight: 700;
  font-size: 1.125rem;
}

/* Presentation screens retain the question DOM and its one answer input. */
[hidden] {
  display: none;
}
.screen-only {
  display: none;
}
.has-screen-navigation .screen-only {
  display: inline-flex;
}
button.screen-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  min-height: 3rem;
  padding: 0.25rem;
  font-size: 2rem;
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--accent);
  border-radius: 50%;
}
.help-screen,
.settings-screen {
  max-width: 48rem;
  margin-inline: auto;
}
.primary-mode .help-screen > h1,
.primary-mode .child-lesson h1.child-prompt {
  font-size: clamp(2.5rem, 8vw, 4rem);
  margin-block: 0.5rem;
}
.primary-mode #question.child-card {
  border: 0;
  padding: 0;
}

.primary-mode .feedback-space:empty {
  min-height: 0;
}
.primary-mode #question form {
  margin-block: 1.25rem 0.5rem;
}
.primary-mode .child-exit {
  margin-top: 1.5rem;
}

@keyframes screen-enter {
  from {
    opacity: 0;
    transform: translateY(0.3rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.learning-panel > .panel-body {
  padding: 1rem;
}
.has-screen-navigation .learning-panel[open] > .panel-body {
  animation: screen-enter 180ms ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .has-screen-navigation .learning-panel > .panel-body {
    animation: none;
  }
}

/* One open panel, with a coloured fold rail separated from the mathematics. */
.learning-panel {
  margin-block: 0.75rem;
  border: 2px solid var(--line);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--paper) 96%, var(--accent));
}
.learning-panel > summary {
  position: relative;
  min-height: 3rem;
  padding: 1rem 1.25rem 1rem 2rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.learning-panel > summary::-webkit-details-marker {
  display: none;
}
.learning-panel > summary::before {
  content: "";
  position: absolute;
  inset: 0.8rem auto 0.8rem 0.65rem;
  width: 0.3rem;
  border-radius: 0.2rem;
  background: var(--accent);
  opacity: 0.6;
}
.learning-panel > summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.learning-panel[open] > summary::before,
body[data-contrast="high"] .learning-panel > summary::before {
  opacity: 1;
}
.learning-panel[open] > summary {
  border-bottom: 2px solid var(--line);
}
.primary-mode .question-panel > summary h1.child-prompt {
  display: block;
  width: 100%;
  margin: 0;
}
.question-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.4;
}
.question-toolbar .child-progress {
  font: inherit;
  margin: 0;
}

.screen-navigation button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 3rem;
  padding: 0.5rem 0.8rem;
  border: 2px solid var(--line);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--ink);
  font: inherit;
}
.screen-navigation button[type="submit"] {
  margin: 0;
  font-size: 1rem;
}

header > .bar-title {
  grid-column: 2;
  text-align: center;
  max-width: 30ch;
  overflow-wrap: anywhere;
}
.header-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
  align-items: center;
  gap: 0.5rem;
}

.header-actions button[type="submit"] {
  margin: 0;
  min-height: 3rem;
  padding: 0.5rem 0.65rem;
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 0.5rem;
  font: inherit;
  font-size: 1rem;
  white-space: nowrap;
}
.brand-navigation {
  margin: 0;
}
.brand-navigation button.brand {
  margin: 0;
  padding: 0;
  min-height: 3rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.2rem;
}
.primary-mode #question {
  background: transparent;
}
.primary-mode #question form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  margin: 0 auto;
}
.primary-mode #question form button[type="submit"],
.primary-mode #question form .child-next {
  margin-top: 0;
}
.primary-mode .child-answer {
  text-align: center;
  margin: 0;
}
.primary-mode .child-answer:disabled {
  opacity: 1;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
}
.primary-mode .feedback-space {
  text-align: center;
}

.answer-stage {
  position: relative;
  padding-inline: clamp(3rem, 7vw, 4rem);
}
.question-navigation {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.question-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  min-height: 4rem;
  border-radius: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  pointer-events: auto;
}

.question-chevron:hover,
.question-chevron:focus-visible {
  color: var(--accent);
  background: var(--accent-tint);
}
.question-chevron.is-unavailable {
  opacity: 0.22;
  pointer-events: none;
}

.panel-return {
  display: none;
  font-weight: 400;
  font-size: 1rem;
  color: var(--accent);
}
.help-screen[open] > summary .panel-return {
  display: inline;
}
.header-actions
  button[type="submit"]:is(
    :hover,
    :active,
    [data-pressed="true"],
    [aria-expanded="true"]
  ) {
  background: var(--accent);
  color: var(--button-ink);
  border-color: var(--accent);
}

.onboarding-back {
  margin-bottom: 1rem;
}
@media (max-width: 48rem) {
  header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
  }
  .header-actions {
    grid-column: 2;
    grid-row: 1;
    flex-wrap: nowrap;
  }
  .header-actions button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    padding: 0;
  }
  .header-actions .control-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .control-icon {
    display: block;
  }
  header .brand,
  .brand-navigation button.brand {
    font-size: clamp(0.875rem, 4vw, 1.125rem);
    flex-wrap: wrap;
  }
  header > .bar-title {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    max-width: 100%;
    padding-block: 0.25rem;
  }
}
@media (max-width: 30rem) {
  .primary-mode header {
    padding-inline: 0.75rem;
  }
  .question-panel > .panel-body {
    padding: 1.25rem 0.75rem;
  }
}
.has-immediate-preferences .preference-save {
  display: none;
}
.has-immediate-preferences
  .display-preferences[data-save-state="failed"]
  .preference-save {
  display: inline-flex;
}
.paint-choice[data-colour="pink"] .choice-name {
  color: var(--pink-label);
}
.lesson-state {
  display: block;
  font-size: 0.875rem;
  font-weight: 400;
}
.completion-mark {
  color: var(--correct);
  font-size: 1.5em;
  font-weight: 700;
}
.completion-status {
  font-size: 1.25rem;
  font-weight: 600;
}
