/* ======================================================================
   Pi Leo Academy — Visual Maths
   Feature styles only. Colour, type, spacing, radius, shadow and motion
   values intentionally inherit the shared Pi Leo design tokens.
   ====================================================================== */

/* ----------------------------------------------------------------------
   Shared feature frame
   ---------------------------------------------------------------------- */
.vm-page {
  position: relative;
  min-width: 0;
  overflow-x: clip;
  color: var(--ink);
  background: var(--bg);
}

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

.vm-page :where(img, svg, canvas, video) {
  display: block;
  max-width: 100%;
  height: auto;
}

.vm-page :where(p, li, dd, figcaption, label, legend) {
  overflow-wrap: anywhere;
}

.vm-container {
  width: min(var(--max-width, 1200px), calc(100% - 2rem));
  margin-inline: auto;
}

.vm-section {
  padding-block: clamp(2.75rem, 7vw, 6rem);
}

.vm-section--soft {
  background: var(--surface-soft);
  border-block: 1px solid var(--border);
}

.vm-section__header {
  max-width: 46rem;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.vm-section__header--centred {
  margin-inline: auto;
  text-align: center;
}

.vm-section__header p,
.vm-lead {
  max-width: 62ch;
  color: var(--ink-light);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
}

.vm-section__header--centred p {
  margin-inline: auto;
}

.vm-eyebrow,
.vm-code,
.vm-status,
.vm-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.035em;
}

.vm-eyebrow,
.vm-code,
.vm-chip {
  color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-code {
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}

.vm-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  margin: 0 0 1.25rem;
  padding: 0;
  color: var(--ink-light);
  font-size: 0.88rem;
  list-style: none;
}

.vm-breadcrumbs li {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.vm-breadcrumbs li:not(:last-child)::after {
  content: "/";
  color: var(--muted);
}

.vm-breadcrumbs a {
  color: var(--primary-dark);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.2em;
}

.vm-breadcrumbs a:hover {
  text-decoration-color: currentColor;
}

.vm-button,
.vm-icon-button,
.vm-filter-button,
.vm-choice,
.vm-builder button,
.vm-trick button {
  min-height: 44px;
  min-width: 44px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  font: inherit;
  font-weight: 750;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--transition), border-color var(--transition),
              box-shadow var(--transition), color var(--transition),
              background-color var(--transition);
}

.vm-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.7rem 1.15rem;
  text-align: center;
  text-decoration: none;
}

.vm-button--primary {
  color: var(--surface);
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: var(--shadow-primary);
}

.vm-button--primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.vm-button--secondary:hover,
.vm-icon-button:hover,
.vm-filter-button:hover,
.vm-builder button:hover,
.vm-trick button:hover {
  color: var(--primary-dark);
  border-color: var(--primary);
  background: var(--primary-tint);
}

.vm-button:hover,
.vm-icon-button:hover,
.vm-filter-button:hover,
.vm-challenge-card:hover {
  transform: translateY(-2px);
}

.vm-button:active,
.vm-icon-button:active,
.vm-filter-button:active {
  transform: translateY(0);
}

.vm-page :where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--surface);
}

.vm-page :where(button, input, select, textarea):disabled,
.vm-page [aria-disabled="true"] {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Keep all script-managed hidden content out of the accessibility tree and
   visual flow. Print restores useful learning content below. */
.vm-page [hidden],
.vm-page .vm-hidden,
.vm-page [data-vm-hidden="true"] {
  display: none !important;
}

/* ----------------------------------------------------------------------
   Landing page
   ---------------------------------------------------------------------- */
.vm-hero {
  position: relative;
  isolation: isolate;
  padding-block: clamp(3rem, 8vw, 6.5rem);
  background:
    radial-gradient(circle at 82% 18%, var(--primary-tint), transparent 30%),
    radial-gradient(circle at 15% 85%, var(--secondary-tint), transparent 28%),
    var(--surface);
  border-bottom: 1px solid var(--border);
}

.vm-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(17rem, 0.95fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 5rem);
}

.vm-hero__copy,
.vm-hero__visual {
  min-width: 0;
}

.vm-hero h1 {
  max-width: 15ch;
  margin-bottom: 1rem;
  font-size: clamp(2.35rem, 5.4vw, 4.5rem);
}

.vm-hero__actions,
.vm-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.vm-hero__visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(17rem, 34vw, 25rem);
  padding: clamp(1rem, 4vw, 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  box-shadow: var(--shadow);
}

.vm-hero__visual::before,
.vm-hero__visual::after {
  position: absolute;
  z-index: -1;
  border-radius: 999px;
  content: "";
}

.vm-hero__visual::before {
  width: 5rem;
  height: 5rem;
  top: -1rem;
  right: -0.75rem;
  background: var(--accent-tint);
}

.vm-hero__visual::after {
  width: 3.5rem;
  height: 3.5rem;
  bottom: -0.75rem;
  left: -0.5rem;
  background: var(--secondary-tint);
}

.vm-hero__visual > :where(svg, figure, .vm-visual-model) {
  width: min(100%, 27rem);
}

.vm-hero__lead {
  max-width: 34ch;
  margin-bottom: 0.75rem;
  color: var(--primary-dark);
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  font-weight: 800;
  line-height: 1.4;
}

.vm-hero-model {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 0.65rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  box-shadow: var(--shadow);
}

.vm-hero-model > div {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: center;
  gap: 0.15rem 0.65rem;
  min-height: 7rem;
  padding: 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.vm-hero-model > div:nth-of-type(3),
.vm-hero-model > div:nth-of-type(4) {
  grid-row: 3;
}

.vm-hero-model > div:nth-of-type(3) {
  grid-column: 3;
}

.vm-hero-model > div:nth-of-type(4) {
  grid-column: 1;
}

.vm-hero-model > div > span {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  grid-row: 1 / span 2;
  place-items: center;
  border-radius: 50%;
  color: var(--surface);
  background: var(--primary-dark);
  font-weight: 900;
}

.vm-hero-model strong,
.vm-hero-model small {
  min-width: 0;
}

.vm-hero-model small {
  color: var(--ink-light);
  line-height: 1.35;
}

.vm-hero-model > i {
  align-self: center;
  color: var(--primary-dark);
  font-size: 1.35rem;
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

.vm-hero-model > i:nth-of-type(2) {
  grid-column: 3;
  grid-row: 2;
  transform: rotate(90deg);
}

.vm-hero-model > i:nth-of-type(3) {
  grid-column: 2;
  grid-row: 3;
  transform: rotate(180deg);
}

.vm-feature-grid,
.vm-year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
}

.vm-feature-card,
.vm-year-card {
  min-width: 0;
  padding: clamp(1.15rem, 3vw, 1.6rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.vm-feature-card__icon,
.vm-year-card__icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-xs);
  color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-feature-card p,
.vm-year-card p {
  color: var(--ink-light);
}

.vm-feature-grid > article {
  min-width: 0;
  padding: clamp(1.15rem, 3vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.vm-feature-grid > article > span:first-child {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  place-items: center;
  border-radius: var(--radius-xs);
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-size: 1.35rem;
  font-weight: 900;
}

.vm-feature-grid > article p {
  margin-bottom: 0;
  color: var(--ink-light);
}

.vm-section-heading {
  max-width: 44rem;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.vm-year-card {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(17rem, 0.75fr);
  align-items: center;
  gap: clamp(1.5rem, 5vw, 3rem);
  padding: clamp(1.25rem, 4vw, 2.25rem);
}

.vm-year-card__copy,
.vm-year-card__progress {
  min-width: 0;
}

.vm-year-card__progress {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.vm-year-card__progress .btn {
  width: 100%;
  margin-top: 0.85rem;
}

.vm-progress-note {
  margin: 0.75rem 0 0;
  color: var(--muted) !important;
  font-size: 0.82rem;
  line-height: 1.5;
}

.vm-card-kicker {
  margin-bottom: 0.35rem !important;
  color: var(--primary-dark) !important;
  font-size: 0.78rem !important;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.vm-strand-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.vm-strand-chips li {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-size: 0.82rem;
  font-weight: 800;
}

.vm-year-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ----------------------------------------------------------------------
   Year 4 catalogue, grouping and filters
   ---------------------------------------------------------------------- */
.vm-year-hero {
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(circle at 88% 18%, var(--secondary-tint), transparent 27%),
    var(--surface);
}

.vm-year-hero__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 0.42fr);
  align-items: end;
  gap: 1.5rem 3rem;
  margin-top: 1.25rem;
}

.vm-year-hero__layout > * {
  min-width: 0;
}

.vm-year-hero__layout h1 {
  max-width: 20ch;
  margin-bottom: 0.75rem;
  font-size: clamp(2rem, 4.7vw, 3.6rem);
}

.vm-year-hero__layout p {
  max-width: 58ch;
  color: var(--ink-light);
}

.vm-catalogue-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, auto);
  align-items: end;
  gap: 1rem 2rem;
  margin-bottom: 0.75rem;
}

.vm-catalogue-toolbar > * {
  min-width: 0;
}

.vm-catalogue-toolbar h2 {
  margin-bottom: 0.35rem;
}

.vm-catalogue-toolbar p {
  margin: 0;
  color: var(--ink-light);
}

.vm-catalogue-header {
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(1.75rem, 4vw, 3rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.vm-catalogue-header h1 {
  max-width: 20ch;
}

.vm-filter {
  position: sticky;
  z-index: 10;
  top: calc(var(--header-height, 72px) + 0.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem 1.5rem;
  margin-bottom: 2rem;
  padding: 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.vm-catalogue-toolbar .vm-filter {
  position: static;
  margin: 0;
}

.vm-filter__label {
  flex: 0 0 auto;
  margin: 0;
  font-weight: 800;
}

.vm-filter__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.vm-filter > label {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
}

.vm-filter > select {
  display: none;
  min-height: 44px;
}

.vm-filter__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.vm-filter__buttons button,
[data-vm-filter] {
  min-width: 44px;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--ink-light);
  background: var(--surface);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: border-color var(--transition), background-color var(--transition),
              color var(--transition), transform var(--transition);
}

.vm-filter__buttons button:hover,
[data-vm-filter]:hover {
  color: var(--primary-dark);
  border-color: var(--primary);
  background: var(--primary-tint);
}

.vm-filter-button {
  padding: 0.55rem 0.85rem;
  color: var(--ink-light);
}

.vm-filter-button[aria-pressed="true"],
[data-vm-filter][aria-pressed="true"],
.vm-filter-button.is-active,
.vm-filter__buttons button.is-active {
  color: var(--surface);
  border-color: var(--primary);
  background: var(--primary);
}

.vm-strand + .vm-strand {
  margin-top: clamp(2.5rem, 6vw, 4.25rem);
}

.vm-strand__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-tint);
}

.vm-strand__heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-tint);
}

.vm-strand__heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.vm-strand__heading > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.vm-filter-result {
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.vm-strand__header h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.vm-strand__count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.vm-challenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 1rem;
}

.vm-challenge-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 13rem;
  flex-direction: column;
  padding: 1.25rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition);
}

.vm-challenge-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}

.vm-challenge-card:focus-within {
  border-color: var(--primary);
}

.vm-challenge-card__top,
.vm-challenge-card__footer,
.vm-challenge-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.vm-challenge-card__top,
.vm-challenge-card__footer {
  justify-content: space-between;
}

.vm-challenge-card h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1.12rem;
}

.vm-challenge-card h3 a {
  color: var(--ink);
  text-decoration: none;
}

.vm-challenge-card h3 a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.vm-challenge-card p {
  margin-bottom: 1rem;
  color: var(--ink-light);
  font-size: 0.94rem;
}

.vm-number {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border-radius: 50%;
  color: var(--surface);
  background: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.vm-curriculum-details {
  margin: 0 0 1rem;
  border-block: 1px solid var(--border);
}

.vm-curriculum-details summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}

.vm-curriculum-details summary::after {
  content: "+";
  font-size: 1.15rem;
}

.vm-curriculum-details[open] summary::after {
  content: "\2212";
}

.vm-curriculum-details dl {
  margin: 0;
  padding: 0 0 0.85rem;
}

.vm-curriculum-details dl > div {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: 0.6rem;
  padding-block: 0.3rem;
}

.vm-curriculum-details dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.vm-curriculum-details dd {
  margin: 0;
  color: var(--ink-light);
  font-size: 0.82rem;
}

.vm-card-action {
  width: 100%;
  margin-top: auto;
}

.vm-challenge-card__footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.vm-challenge-card__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

.vm-challenge-card__link::after {
  margin-left: 0.45rem;
  content: "\2192";
}

.vm-status {
  color: var(--ink-light);
  background: var(--surface-strong);
}

.vm-challenge-card.is-current,
.vm-challenge-card[aria-current="step"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

.vm-challenge-card.is-started,
.vm-challenge-card[data-vm-status="started"] {
  border-color: var(--primary-light);
  background: linear-gradient(180deg, var(--surface), var(--primary-tint));
}

.vm-challenge-card.is-started .vm-status,
.vm-challenge-card[data-vm-status="started"] .vm-status {
  color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-challenge-card.is-complete,
.vm-challenge-card[data-vm-complete="true"] {
  border-color: var(--secondary);
  background: linear-gradient(180deg, var(--surface), var(--secondary-tint));
}

.vm-challenge-card.is-complete .vm-status,
.vm-challenge-card[data-vm-complete="true"] .vm-status,
.vm-status--complete {
  color: var(--secondary-dark);
  background: var(--secondary-tint);
}

.vm-challenge-card.is-complete .vm-status::before,
.vm-challenge-card[data-vm-complete="true"] .vm-status::before,
.vm-status--complete::before {
  margin-right: 0.3rem;
  content: "\2713";
}

.vm-progress {
  width: 100%;
  min-width: 0;
}

.vm-progress__copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.5rem;
  color: var(--ink-light);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.vm-progress__copy strong {
  color: var(--ink);
}

.vm-progress__track {
  width: 100%;
  height: 0.65rem;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-strong);
}

.vm-progress__bar,
.vm-progress__track > [data-vm-progress-fill] {
  display: block;
  width: var(--vm-progress, 0%);
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--secondary-dark);
  transition: width var(--transition-slow);
}

.vm-progress--compact .vm-progress__copy {
  font-size: 0.78rem;
}

.vm-progress--compact .vm-progress__track {
  height: 0.5rem;
}

.vm-progress-text {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.vm-empty-state {
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-light);
  background: var(--surface-soft);
  text-align: center;
}

/* ----------------------------------------------------------------------
   Challenge shell
   ---------------------------------------------------------------------- */
.vm-challenge-intro {
  padding-block: clamp(1.25rem, 4vw, 2.5rem) 0;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--primary-tint), var(--bg));
}

.vm-stage-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.vm-stage-label > span {
  display: inline-grid;
  min-width: 1.75rem;
  min-height: 1.75rem;
  place-items: center;
  padding-inline: 0.35rem;
  border-radius: 999px;
  color: var(--surface);
  background: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}

.vm-question-note,
.vm-accessible-description {
  color: var(--ink-light);
  font-size: 0.9rem;
}

.vm-step-count {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.vm-visual-placeholder {
  display: grid;
  max-width: 24rem;
  place-items: center;
  gap: 0.5rem;
  color: var(--ink-light);
  text-align: center;
}

.vm-visual-placeholder > span {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  border-radius: 50%;
  color: var(--surface);
  background: var(--primary);
  font-size: 2rem;
  font-weight: 900;
}

.vm-visual-placeholder small {
  display: block;
}

.vm-challenge-shell {
  padding-block: clamp(1.5rem, 5vw, 3.5rem) clamp(3rem, 7vw, 6rem);
}

.vm-challenge-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 1rem 2rem;
  margin-bottom: 1.5rem;
}

.vm-challenge-header h1 {
  max-width: 23ch;
  margin: 0.5rem 0;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
}

.vm-challenge-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0;
  padding: 0;
  color: var(--ink-light);
  font-size: 0.9rem;
  list-style: none;
}

.vm-challenge-meta li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.vm-challenge-progress {
  width: min(100%, 16rem);
}

.vm-challenge-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 0.82fr) minmax(0, 1.18fr);
  align-items: start;
  gap: clamp(1rem, 3vw, 2rem);
}

.vm-question-panel,
.vm-visual-workspace,
.vm-panel {
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.vm-question-panel {
  position: sticky;
  top: calc(var(--header-height, 72px) + 1rem);
  padding: clamp(1.15rem, 3vw, 1.75rem);
}

.vm-question-panel__header,
.vm-visual-workspace__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.vm-question-panel__header h2,
.vm-visual-workspace__header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.65rem);
}

.vm-question {
  font-size: clamp(1.06rem, 1.7vw, 1.2rem);
  font-weight: 700;
  line-height: 1.55;
}

.vm-question :where(.vm-math, data, output) {
  font-variant-numeric: lining-nums tabular-nums;
}

.vm-question-help,
.vm-response-help {
  color: var(--ink-light);
  font-size: 0.9rem;
}

.vm-visual-workspace {
  padding: clamp(1rem, 3vw, 1.75rem);
}

.vm-visual-workspace__stage,
.vm-visual-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(17rem, 45vw, 31rem);
  overflow: hidden;
  padding: clamp(0.75rem, 3vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.vm-visual-workspace__stage > *,
.vm-visual-stage > * {
  min-width: 0;
  max-width: 100%;
}

.vm-visual-workspace__caption {
  margin: 0.75rem 0 0;
  color: var(--ink-light);
  font-size: 0.9rem;
  text-align: center;
}

.vm-panel {
  margin-top: 1rem;
  padding: clamp(1rem, 3vw, 1.5rem);
}

/* ----------------------------------------------------------------------
   Response controls
   ---------------------------------------------------------------------- */
.vm-response {
  margin-top: 1.25rem;
}

.vm-response-field {
  min-width: 0;
  margin: 0 0 1rem;
}

fieldset.vm-response-field {
  padding: 0;
  border: 0;
}

.vm-response-field > :where(label, legend) {
  display: block;
  width: 100%;
  margin-bottom: 0.55rem;
  font-weight: 800;
}

.vm-page .vm-response-field :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--ink);
  background: var(--surface);
}

.vm-page .vm-response-field :where(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rose) 20%, transparent);
}

.vm-field-help {
  margin: -0.2rem 0 0.7rem;
  color: var(--ink-light);
  font-size: 0.86rem;
}

.vm-response fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.vm-response legend,
.vm-response__label {
  display: block;
  width: 100%;
  margin: 0 0 0.6rem;
  font-weight: 800;
}

.vm-response :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--ink);
  background: var(--surface);
}

.vm-response :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):hover {
  border-color: var(--primary-light);
}

.vm-response :where(input, select, textarea)[aria-invalid="true"],
.vm-response .is-invalid {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rose) 20%, transparent);
}

.vm-response-row,
.vm-input-group,
.vm-answer-grid {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
}

.vm-response-row > *,
.vm-input-group > *,
.vm-answer-grid > * {
  min-width: min(100%, 8rem);
  flex: 1 1 8rem;
}

.vm-input-with-unit {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: stretch;
}

.vm-input-with-unit > span {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  padding-inline: 0.65rem;
  border: 1.5px solid var(--border-strong);
  color: var(--ink-light);
  background: var(--surface-strong);
  font-weight: 800;
}

.vm-input-with-unit > span:first-child {
  border-right: 0;
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
}

.vm-input-with-unit > span:first-child + input {
  border-radius: 0 !important;
}

.vm-input-with-unit > input:first-child {
  border-radius: var(--radius-xs) 0 0 var(--radius-xs) !important;
}

.vm-input-with-unit > span:last-child {
  border-left: 0;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.vm-input-with-unit > input:last-child {
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0 !important;
}

.vm-input-with-unit > input:only-child {
  border-radius: var(--radius-xs) !important;
}

.vm-input-with-unit input {
  min-width: 0;
  border-radius: var(--radius-xs) 0 0 var(--radius-xs) !important;
}

.vm-input-with-unit__unit {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  padding-inline: 0.75rem;
  border: 1.5px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: var(--ink-light);
  background: var(--surface-strong);
  font-weight: 800;
}

.vm-choice-list {
  display: grid;
  gap: 0.65rem;
}

.vm-choice-list--grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.vm-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.vm-choice {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 0.7rem;
  padding: 0.75rem;
  text-align: left;
}

.vm-choice:hover {
  border-color: var(--primary);
  background: var(--primary-tint);
}

.vm-choice :where(input[type="radio"], input[type="checkbox"]) {
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.25rem;
  margin: 0;
  accent-color: var(--primary);
}

.vm-choice:has(input:checked),
.vm-choice.is-selected,
.vm-choice[aria-pressed="true"] {
  color: var(--primary-dark);
  border-color: var(--primary);
  background: var(--primary-tint);
  box-shadow: 0 0 0 2px var(--primary-tint);
}

.vm-choice.is-correct {
  color: var(--secondary-dark);
  border-color: var(--secondary-dark);
  background: var(--secondary-tint);
}

.vm-choice.is-incorrect {
  color: var(--ink);
  border-color: var(--rose);
  background: color-mix(in srgb, var(--rose) 9%, var(--surface));
}

.vm-response__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Fractions, money and time use ordinary form controls with a compact visual
   grouping; validation remains based on values rather than screen geometry. */
.vm-fraction-input {
  display: inline-grid;
  width: min(100%, 9rem);
  grid-template-rows: 1fr auto 1fr;
  gap: 0.25rem;
  align-items: center;
}

.vm-fraction-input input {
  text-align: center;
}

.vm-fraction-input__bar {
  width: 100%;
  height: 2px;
  background: var(--ink);
}

.vm-money-input,
.vm-time-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
}

.vm-money-input__symbol,
.vm-time-input__separator {
  font-size: 1.2rem;
  font-weight: 800;
}

.vm-fraction-field {
  display: inline-grid;
  width: min(100%, 10rem);
  grid-template-rows: auto 3rem auto 3rem;
  align-items: center;
  gap: 0.2rem;
}

.vm-fraction-field legend {
  margin-bottom: 0.5rem;
}

.vm-fraction-field label,
.vm-fraction-field input,
.vm-fraction-field > span:last-of-type {
  width: 100%;
  text-align: center;
}

.vm-fraction-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--ink);
}

.vm-number-line-control > label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}

.vm-number-line-control output {
  min-width: 3rem;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.vm-number-line-control input[type="range"] {
  min-height: 44px;
  padding: 0;
  border: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.vm-number-line-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.vm-duration-field {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.vm-duration-field legend {
  grid-column: 1 / -1;
}

.vm-duration-field label {
  min-width: 0;
  color: var(--ink-light);
  font-size: 0.86rem;
  font-weight: 800;
}

.vm-duration-field input {
  margin-top: 0.35rem;
}

.vm-reference-grid,
.vm-symmetry-answer-grid {
  display: grid;
  width: min(100%, 19rem);
  grid-template-columns: minmax(0, 1fr);
  gap: 0.3rem;
  margin-inline: auto;
}

.vm-symmetry-answer-grid {
  width: min(100%, 16rem);
}

.vm-reference-grid > [role="row"],
.vm-symmetry-answer-grid > [role="row"] {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 0.3rem;
}

.vm-symmetry-answer-grid > [role="row"] {
  grid-template-columns: repeat(4, minmax(44px, 1fr));
}

.vm-reference-grid button,
.vm-symmetry-answer-grid button {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  aspect-ratio: 1;
  place-items: center;
  padding: 0.2rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 0.4rem;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.vm-reference-grid button:hover,
.vm-symmetry-answer-grid button:not(:disabled):hover,
.vm-reference-grid button[aria-selected="true"],
.vm-symmetry-answer-grid button[aria-selected="true"] {
  color: var(--primary-dark);
  border-color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-reference-grid button[aria-selected="true"],
.vm-symmetry-answer-grid button[aria-selected="true"] {
  box-shadow: inset 0 0 0 2px var(--primary-dark);
}

.vm-symmetry-answer-grid button:disabled {
  opacity: 1;
  border-color: var(--secondary-dark);
  background: var(--secondary-tint);
}

.vm-likelihood-builder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.vm-likelihood-builder > :where(legend, p) {
  grid-column: 1 / -1;
}

.vm-likelihood-builder label {
  min-width: 0;
  color: var(--ink-light);
  font-size: 0.86rem;
  font-weight: 800;
}

.vm-likelihood-builder select {
  margin-top: 0.35rem;
}

.vm-conclusion-builder p {
  line-height: 2.85;
}

.vm-conclusion-builder label {
  display: inline-block;
  width: min(100%, 10rem);
  margin-inline: 0.2rem;
  vertical-align: middle;
}

/* ----------------------------------------------------------------------
   Visual models and builders
   ---------------------------------------------------------------------- */
.vm-visual-model {
  width: 100%;
  min-width: 0;
  margin: 0;
  color: var(--ink);
}

.vm-visual-model svg {
  width: 100%;
  max-height: 30rem;
  overflow: visible;
}

.vm-visual-model svg :where(text, tspan) {
  fill: currentColor;
  font-family: var(--font-body);
}

.vm-visual-model figcaption,
.vm-model-caption {
  margin-top: 0.75rem;
  color: var(--ink-light);
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: center;
}

.vm-model-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.84rem;
  list-style: none;
}

.vm-model-key li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.vm-model-key__swatch {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--ink-light);
  border-radius: 0.2rem;
  background: var(--surface);
}

.vm-model-key__swatch--primary {
  border-color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-model-key__swatch--secondary {
  border-color: var(--secondary-dark);
  background: var(--secondary-tint);
}

.vm-number-line,
.vm-array-model,
.vm-fraction-model,
.vm-place-value-model,
.vm-graph-model,
.vm-clock-model,
.vm-shape-model,
.vm-money-model,
.vm-data-model {
  width: 100%;
  min-width: 0;
}

.vm-array-model {
  display: grid;
  grid-template-columns: repeat(var(--vm-columns, 4), minmax(1.75rem, 1fr));
  gap: clamp(0.3rem, 1.5vw, 0.65rem);
  width: min(100%, 28rem);
  margin-inline: auto;
}

.vm-array-model__cell,
.vm-grid-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border: 2px solid var(--primary-dark);
  border-radius: clamp(0.25rem, 1vw, 0.55rem);
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-weight: 800;
}

.vm-array-model__cell.is-highlighted,
.vm-grid-cell.is-highlighted,
[data-vm-cell][aria-selected="true"] {
  color: var(--secondary-dark);
  border-color: var(--secondary-dark);
  background: var(--secondary-tint);
}

.vm-place-value-model,
.vm-data-table-wrap {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.vm-place-value-table,
.vm-data-table {
  width: 100%;
  min-width: 30rem;
  border-collapse: collapse;
  background: var(--surface);
}

.vm-place-value-table :where(th, td),
.vm-data-table :where(th, td) {
  padding: 0.65rem;
  border: 1px solid var(--border-strong);
  text-align: center;
}

.vm-place-value-table th,
.vm-data-table th {
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-weight: 800;
}

.vm-fraction-model {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.vm-fraction-part {
  display: grid;
  place-items: center;
  min-width: 2.2rem;
  min-height: 2.2rem;
  border: 2px solid var(--primary-dark);
  color: var(--primary-dark);
  background: var(--surface);
}

.vm-fraction-part.is-filled,
.vm-fraction-part[data-filled="true"] {
  background: var(--primary-tint);
}

.vm-clock-model {
  display: grid;
  place-items: center;
  width: min(100%, 22rem);
  margin-inline: auto;
  aspect-ratio: 1;
  border: clamp(4px, 1vw, 8px) solid var(--primary-dark);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 4px var(--primary-tint);
}

.vm-clock-model > svg {
  width: 92%;
}

.vm-money-model,
.vm-shape-model,
.vm-data-model {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.vm-money-token,
.vm-shape-token,
.vm-data-token {
  display: grid;
  place-items: center;
  min-width: 3.25rem;
  min-height: 3.25rem;
  padding: 0.5rem;
  border: 2px solid var(--primary-dark);
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.vm-shape-token {
  border-radius: var(--radius-xs);
}

.vm-graph-model {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: minmax(12rem, 1fr) auto;
  gap: 0.4rem;
}

.vm-graph-model__plot {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-left: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  background:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px),
    var(--surface);
  background-size: 10% 10%;
}

.vm-graph-model__axis {
  display: grid;
  place-items: center;
  color: var(--ink-light);
  font-size: 0.8rem;
  font-weight: 700;
}

.vm-builder {
  min-width: 0;
  margin-top: 1rem;
  padding: clamp(0.85rem, 3vw, 1.25rem);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.vm-builder > legend {
  padding-inline: 0.35rem;
}

.vm-builder-key {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-xs);
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-size: 0.85rem;
  font-weight: 800;
}

.vm-builder-list {
  display: grid;
  gap: 0.65rem;
}

.vm-builder-row {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(5rem, 0.7fr) minmax(8.5rem, 1fr) minmax(3rem, 1fr);
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-soft);
}

.vm-builder-row > span:first-child {
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 800;
}

.vm-stepper {
  display: grid;
  min-width: 0;
  grid-template-columns: 44px minmax(3rem, 1fr) 44px;
  align-items: stretch;
}

.vm-stepper button {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 0;
  font-size: 1.1rem;
}

.vm-stepper button:first-child {
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
}

.vm-stepper button:last-child {
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.vm-page .vm-stepper input {
  min-width: 0;
  min-height: 44px;
  padding-inline: 0.2rem;
  border-inline: 0;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.vm-symbol-output {
  min-height: 2.2rem;
  color: var(--primary-dark);
  font-size: 1.2rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.vm-mini-bar {
  display: flex;
  height: 2.25rem;
  align-items: end;
  overflow: hidden;
  border-bottom: 2px solid var(--ink-light);
}

.vm-mini-bar i {
  display: block;
  width: var(--vm-bar-size, 0%);
  max-width: 100%;
  height: 0.85rem;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  background: var(--primary);
  transition: width var(--transition);
}

.vm-builder__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.vm-builder__toolbar button {
  padding: 0.5rem 0.75rem;
}

.vm-builder__toolbar button[aria-pressed="true"],
.vm-builder__toolbar button.is-active {
  color: var(--surface);
  border-color: var(--primary);
  background: var(--primary);
}

.vm-builder__canvas {
  display: grid;
  min-height: 12rem;
  min-width: 0;
  place-items: center;
  overflow: auto;
  padding: 1rem;
  overscroll-behavior: contain;
  touch-action: manipulation;
}

.vm-builder__item {
  min-width: 44px;
  min-height: 44px;
}

.vm-builder__item[aria-selected="true"],
.vm-builder__item.is-selected {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.vm-builder__instructions {
  margin: 0;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--ink-light);
  font-size: 0.88rem;
}

/* ----------------------------------------------------------------------
   Visual Trick sequence and motion controls
   ---------------------------------------------------------------------- */
.vm-trick {
  margin-top: 1rem;
  overflow: hidden;
  border: 1.5px solid var(--primary-light);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.vm-trick__intro {
  padding: 1rem clamp(1rem, 3vw, 1.5rem) 0;
}

.vm-trick__intro > :last-child {
  margin-bottom: 0;
}

.vm-trick-steps {
  margin: 0;
  list-style: none;
}

.vm-trick-steps > li {
  min-height: 5rem;
  align-content: center;
}

.vm-trick-steps > li > span {
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.vm-trick-steps > li > p {
  margin: 0.3rem 0 0;
}

.vm-trick__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 1.5rem);
  color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-trick__header h2,
.vm-trick__header h3 {
  margin: 0;
  color: inherit;
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
}

.vm-trick__controls,
.vm-motion-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.vm-trick__controls button,
.vm-motion-controls button {
  padding: 0.5rem 0.75rem;
  color: var(--primary-dark);
}

.vm-trick__body {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.vm-trick__stage {
  position: relative;
  min-height: clamp(12rem, 35vw, 22rem);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.vm-trick__stage > [data-vm-step],
.vm-trick-step {
  display: grid;
  min-height: inherit;
  place-items: center;
  padding: clamp(0.75rem, 3vw, 1.5rem);
}

.vm-trick__stage > [data-vm-step].is-active,
.vm-trick-step.is-active {
  animation: vm-step-reveal var(--transition-slow) both;
}

.vm-trick__footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.vm-trick__step-label {
  color: var(--ink-light);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.vm-trick__dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.vm-trick__dot {
  width: 0.75rem;
  height: 0.75rem;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 2px solid var(--primary-dark);
  border-radius: 50%;
  background: var(--surface);
}

.vm-trick__dot.is-active,
.vm-trick__dot[aria-current="step"] {
  background: var(--primary-dark);
}

.vm-trick__text {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--accent-dark);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: var(--ink);
  background: var(--accent-tint);
}

.vm-trick__text > :last-child {
  margin-bottom: 0;
}

.vm-trick.is-motion-paused [data-vm-animated],
.vm-page.is-motion-paused [data-vm-animated],
.vm-page .is-motion-paused [data-vm-animated],
[data-vm-motion].is-motion-paused {
  animation-play-state: paused !important;
  transition-duration: 0s !important;
}

.vm-trick.is-motion-paused [data-vm-pause] {
  color: var(--surface);
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

@keyframes vm-step-reveal {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------------------------------------------------------------
   Feedback, explanation and completion
   ---------------------------------------------------------------------- */
.vm-feedback,
.vm-explanation,
.vm-completion {
  margin-top: 1rem;
  padding: clamp(1rem, 3vw, 1.35rem);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.vm-feedback:empty,
.vm-explanation:empty {
  display: none;
}

.vm-feedback {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.vm-feedback__icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: var(--surface);
  background: var(--primary-dark);
  font-weight: 900;
}

.vm-feedback__body > :last-child,
.vm-explanation > :last-child,
.vm-completion > :last-child {
  margin-bottom: 0;
}

.vm-feedback[data-state="correct"],
.vm-feedback.is-correct {
  color: var(--secondary-dark);
  border-color: var(--secondary-dark);
  background: var(--secondary-tint);
}

.vm-feedback[data-state="correct"] .vm-feedback__icon,
.vm-feedback.is-correct .vm-feedback__icon {
  background: var(--secondary-dark);
}

.vm-feedback[data-state="incorrect"],
.vm-feedback.is-incorrect {
  color: var(--ink);
  border-color: var(--rose);
  background: color-mix(in srgb, var(--rose) 9%, var(--surface));
}

.vm-feedback[data-state="incorrect"] .vm-feedback__icon,
.vm-feedback.is-incorrect .vm-feedback__icon {
  background: var(--rose);
}

.vm-feedback.is-gentle {
  color: var(--ink);
  border-color: var(--accent-dark);
  background: var(--accent-tint);
}

.vm-feedback.is-gentle .vm-feedback__icon {
  color: var(--ink);
  background: var(--accent);
}

.vm-feedback[data-state="hint"],
.vm-feedback.is-hint {
  border-color: var(--accent-dark);
  background: var(--accent-tint);
}

.vm-feedback[data-state="hint"] .vm-feedback__icon,
.vm-feedback.is-hint .vm-feedback__icon {
  color: var(--ink);
  background: var(--accent);
}

.vm-explanation {
  border-color: var(--primary-light);
  background: var(--primary-tint);
}

.vm-explanation h2,
.vm-explanation h3 {
  color: var(--primary-dark);
}

.vm-completion {
  position: relative;
  overflow: hidden;
  border-color: var(--secondary-dark);
  background: var(--secondary-tint);
}

.vm-completion::before {
  position: absolute;
  width: 5rem;
  height: 5rem;
  top: -2.5rem;
  right: -2rem;
  border-radius: 50%;
  background: var(--accent-tint);
  content: "";
}

.vm-completion h2,
.vm-completion h3 {
  color: var(--secondary-dark);
}

.vm-challenge-shell.is-complete .vm-question-panel,
.vm-challenge-shell[data-vm-complete="true"] .vm-question-panel {
  border-color: var(--secondary-dark);
}

.vm-challenge-shell.is-complete .vm-challenge-progress .vm-progress__bar,
.vm-challenge-shell[data-vm-complete="true"] .vm-challenge-progress .vm-progress__bar {
  width: 100%;
}

.vm-challenge-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-strong);
}

.vm-challenge-nav__link {
  display: flex;
  min-width: 0;
  min-height: 64px;
  flex-direction: column;
  justify-content: center;
  padding: 0.8rem 1rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
}

.vm-challenge-nav__link:hover {
  border-color: var(--primary);
  background: var(--primary-tint);
}

.vm-challenge-nav__link--next {
  text-align: right;
}

.vm-challenge-nav__direction {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.vm-challenge-nav__title {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------------------
   JavaScript visual-renderer contract

   Renderers emit semantic SVG classes rather than inline colours. Every
   primitive below inherits the established Pi Leo tokens, remains legible
   without motion, and has a non-colour boundary or line-style distinction.
   ---------------------------------------------------------------------- */
.vm-visual-canvas,
[data-vm-visual-canvas] {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: clamp(0.6rem, 2.5vw, 1rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface-soft);
}

.vm-model-svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
  overflow: visible;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  touch-action: manipulation;
}

.vm-model-svg:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.vm-model-svg :where(rect, circle, path, polygon, polyline, line) {
  vector-effect: non-scaling-stroke;
  transition: fill var(--transition), stroke var(--transition),
              opacity var(--transition), transform var(--transition);
}

.vm-svg-text,
.vm-svg-heading,
.vm-svg-small,
.vm-svg-tiny,
.vm-svg-equation,
.vm-svg-jump-label {
  fill: var(--ink);
  stroke: none;
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
  user-select: none;
}

.vm-svg-heading {
  fill: var(--primary-dark);
  font-size: 23px;
  font-weight: 850;
}

.vm-svg-small {
  fill: var(--ink-light);
  font-size: 19px;
  font-weight: 700;
}

.vm-svg-tiny {
  fill: var(--ink-light);
  font-size: 16px;
  font-weight: 700;
}

.vm-svg-equation {
  fill: var(--primary-dark);
  font-size: 25px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.vm-svg-jump-label {
  fill: var(--primary-dark);
  font-size: 18px;
  font-weight: 850;
}

/* Structural lines and paths. Dashed guide/trick lines remain distinguishable
   when colour is unavailable. */
.vm-svg-line,
.vm-svg-axis,
.vm-svg-tick,
.vm-svg-grid-line,
.vm-svg-join,
.vm-svg-arrow,
.vm-svg-balance-beam,
.vm-svg-stand,
.vm-svg-hour-hand,
.vm-svg-minute-hand,
.vm-svg-base-ray,
.vm-svg-moving-ray,
.vm-svg-cut-line,
.vm-svg-guide-line,
.vm-svg-mirror-line,
.vm-svg-cube-edge,
.vm-svg-cube-edge-selected,
.vm-svg-perimeter,
.vm-svg-distance-guide,
.vm-svg-tally-mark,
.vm-svg-jump,
.vm-svg-turn-arc {
  fill: none;
  stroke: var(--ink-light);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.vm-svg-axis,
.vm-svg-balance-beam,
.vm-svg-stand,
.vm-svg-base-ray {
  stroke: var(--ink);
  stroke-width: 3;
}

.vm-svg-tick,
.vm-svg-grid-line {
  stroke: var(--muted-soft);
  stroke-width: 1.5;
}

.vm-svg-grid-line {
  opacity: 0.7;
}

.vm-svg-join,
.vm-svg-arrow {
  stroke: var(--primary-dark);
  stroke-width: 3;
}

.vm-svg-jump,
.vm-svg-turn-arc {
  stroke: var(--primary-dark);
  stroke-width: 3;
  stroke-dasharray: 9 6;
}

.vm-svg-cut-line,
.vm-svg-guide-line,
.vm-svg-mirror-line {
  stroke: var(--secondary-dark);
  stroke-width: 3;
  stroke-dasharray: 7 5;
}

.vm-svg-mirror-line {
  stroke-width: 4;
  stroke-dasharray: 10 5;
}

.vm-svg-perimeter {
  stroke: var(--accent-dark);
  stroke-width: 5;
  stroke-dasharray: 11 5;
}

.vm-svg-perimeter-guide {
  stroke: var(--secondary-dark);
  stroke-width: 4;
  stroke-dasharray: 5 6;
  opacity: 0.9;
}

.vm-svg-distance-guide {
  fill: none;
  stroke: var(--secondary-dark);
  stroke-width: 3;
  stroke-dasharray: 6 4;
}

.vm-svg-tally-mark {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
}

.vm-svg-tally-mark--survey {
  stroke: var(--primary-dark);
}

.vm-svg-hour-hand {
  stroke: var(--ink);
  stroke-width: 6;
}

.vm-svg-minute-hand {
  stroke: var(--primary-dark);
  stroke-width: 4;
}

.vm-svg-moving-ray {
  stroke: var(--accent-dark);
  stroke-width: 5;
}

.vm-svg-cube-edge {
  stroke: var(--primary-dark);
  stroke-width: 3;
}

.vm-svg-cube-edge-selected {
  stroke: var(--accent-dark);
  stroke-width: 7;
}

/* Neutral frames and empty cells. */
.vm-svg-block,
.vm-svg-room,
.vm-svg-group,
.vm-svg-fraction-empty,
.vm-svg-grid-cell,
.vm-svg-clock,
.vm-svg-turn-ring,
.vm-svg-cube-front,
.vm-svg-cube-back,
.vm-svg-tenths-model-empty,
.vm-svg-cube-face-gap {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 2;
}

.vm-svg-room,
.vm-svg-group {
  fill: var(--surface-soft);
  stroke: var(--primary-dark);
}

.vm-svg-fraction-empty,
.vm-svg-grid-cell,
.vm-svg-tenths-model-empty {
  fill: var(--surface);
  stroke: var(--ink-light);
}

.vm-svg-clock,
.vm-svg-turn-ring {
  fill: var(--surface);
  stroke: var(--primary-dark);
  stroke-width: 4;
}

.vm-svg-turn-ring {
  stroke-dasharray: 4 5;
}

/* Primary model pieces. */
.vm-svg-unit,
.vm-svg-price,
.vm-svg-ticket,
.vm-svg-bar,
.vm-svg-pass,
.vm-svg-start,
.vm-svg-branch,
.vm-svg-weight,
.vm-svg-cube-face,
.vm-svg-peeled-face,
.vm-svg-rocket-body,
.vm-svg-rocket-silhouette,
.vm-svg-symmetry-filled,
.vm-svg-ten-hundredths,
.vm-svg-tenths-model-filled,
.vm-svg-response-token,
.vm-svg-column--learner {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
  stroke-width: 2.5;
}

/* Secondary pieces and completed relationships. */
.vm-svg-tenth,
.vm-svg-fraction-shaded,
.vm-svg-counter,
.vm-svg-bar-alt,
.vm-svg-ticket-alt,
.vm-svg-branch-alt,
.vm-svg-water,
.vm-svg-weight-alt,
.vm-svg-rocket-nose,
.vm-svg-path-dot,
.vm-svg-guide-dot {
  fill: var(--secondary-tint);
  stroke: var(--secondary-dark);
  stroke-width: 2.5;
}

.vm-svg-water {
  opacity: 0.86;
}

/* Accent pieces indicate a target, current position, or quantity being
   transformed; their heavier outline prevents colour-only signalling. */
.vm-svg-hundredth,
.vm-svg-dot,
.vm-svg-marker,
.vm-svg-trick-marker,
.vm-svg-note,
.vm-svg-total-bar,
.vm-svg-decision,
.vm-svg-unknown,
.vm-svg-area-cell,
.vm-svg-landmark,
.vm-svg-clock-pin,
.vm-svg-vertex-selected,
.vm-svg-rocket-fin,
.vm-svg-window,
.vm-svg-start-dot {
  fill: var(--accent-tint);
  stroke: var(--accent-dark);
  stroke-width: 3;
}

.vm-svg-marker,
.vm-svg-trick-marker,
.vm-svg-start-dot,
.vm-svg-vertex-selected {
  stroke: var(--ink);
  stroke-width: 3.5;
}

.vm-svg-note {
  fill: var(--accent-tint);
  stroke-dasharray: 6 3;
}

.vm-svg-total-bar,
.vm-svg-area-cell {
  fill: var(--accent-tint);
  stroke-width: 3;
}

.vm-svg-fact-triangle,
.vm-svg-jug,
.vm-svg-rocket-nose,
.vm-svg-rocket-fin {
  stroke-linejoin: round;
}

.vm-svg-fact-triangle {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
  stroke-width: 3;
}

.vm-svg-jug {
  fill: color-mix(in srgb, var(--primary-tint) 34%, var(--surface));
  stroke: var(--primary-dark);
  stroke-width: 4;
}

.vm-svg-rocket-body {
  fill: var(--primary-tint);
}

.vm-svg-rocket-silhouette {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
  stroke-width: 4;
  stroke-linejoin: round;
}

.vm-svg-rocket-attached-part {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
  stroke-width: 2;
  stroke-linejoin: round;
}

.vm-svg-rocket-nose,
.vm-svg-rocket-fin {
  fill: var(--secondary-tint);
}

.vm-svg-window {
  fill: var(--surface);
  stroke: var(--primary-dark);
}

.vm-svg-ten-hundredths {
  fill: var(--accent-tint);
  stroke: var(--accent-dark);
  stroke-width: 2.5;
}

.vm-svg-tenths-model-filled {
  fill: var(--secondary-tint);
  stroke: var(--secondary-dark);
  stroke-width: 3;
}

.vm-svg-tenths-model-empty {
  stroke-dasharray: 5 3;
}

.vm-svg-cube-face-gap {
  fill: var(--surface);
  fill-opacity: 0.35;
  stroke: var(--accent-dark);
  stroke-width: 4;
  stroke-dasharray: 10 6;
}

.vm-svg-peeled-face {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
  stroke-width: 4;
}

.vm-svg-place-digit,
.vm-svg-final-answer {
  fill: var(--primary-dark);
  stroke: none;
  font-family: var(--font-body);
  font-size: 30px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  user-select: none;
}

.vm-svg-final-answer {
  fill: var(--ink);
  font-size: 32px;
}

/* Statistics and probability renderers. */
.vm-svg-fruit-symbol {
  fill: var(--surface);
  stroke: var(--ink-light);
  stroke-width: 3;
}

.vm-svg-fruit-symbol--trick {
  stroke-width: 4;
  stroke-dasharray: 5 3;
}

.vm-svg-fruit-symbol--winner {
  stroke: var(--ink);
  stroke-width: 6;
  stroke-dasharray: none;
}

.vm-svg-fruit-apple {
  fill: color-mix(in srgb, var(--rose) 18%, var(--surface));
  stroke: var(--rose);
}

.vm-svg-fruit-banana {
  fill: var(--accent-tint);
  stroke: var(--accent-dark);
}

.vm-svg-fruit-orange {
  fill: color-mix(in srgb, var(--accent) 28%, var(--surface));
  stroke: var(--accent-dark);
  stroke-dasharray: 4 2;
}

.vm-svg-fruit-pear {
  fill: var(--secondary-tint);
  stroke: var(--secondary-dark);
}

.vm-svg-dot-a,
.vm-svg-dot-b {
  stroke-width: 3;
}

.vm-svg-dot-a {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
}

.vm-svg-dot-b {
  fill: var(--secondary-dark);
  stroke: var(--ink);
}

.vm-svg-range-bracket {
  fill: none;
  stroke: var(--accent-dark);
  stroke-width: 4;
  stroke-linecap: square;
}

.vm-svg-pathway-step,
.vm-svg-pathway-active {
  stroke-width: 3;
}

.vm-svg-pathway-step {
  fill: var(--surface);
  stroke: var(--ink-light);
  stroke-dasharray: 4 3;
}

.vm-svg-pathway-active {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
}

.vm-svg-column {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
  stroke-width: 3;
}

.vm-svg-column--learner {
  fill: var(--surface);
  stroke-dasharray: 5 3;
}

.vm-svg-column--winner {
  fill: var(--accent-tint);
  stroke: var(--accent-dark);
  stroke-width: 5;
}

.vm-svg-response-token {
  fill: var(--surface);
  stroke: var(--primary-dark);
  stroke-width: 3;
}

.vm-svg-counter-bag {
  fill: var(--surface-strong);
  stroke: var(--primary-dark);
  stroke-width: 4;
  stroke-dasharray: 10 4;
  stroke-linejoin: round;
}

.vm-svg-counter-red,
.vm-svg-counter-blue,
.vm-svg-counter-green {
  stroke: var(--ink);
  stroke-width: 3;
}

.vm-svg-likelihood-trick {
  stroke-width: 5;
  stroke-dasharray: 4 2;
}

.vm-svg-removed-counter {
  stroke: var(--accent-dark);
  stroke-width: 6;
}

.vm-svg-counter-red {
  fill: color-mix(in srgb, var(--rose) 45%, var(--surface));
}

.vm-svg-counter-blue {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
}

.vm-svg-counter-green {
  fill: var(--secondary-tint);
  stroke: var(--secondary-dark);
  stroke-dasharray: 4 2;
}

.vm-svg-spinner-section,
.vm-svg-spinner-red,
.vm-svg-spinner-blue {
  fill: var(--surface-strong);
  stroke: var(--ink);
  stroke-width: 3;
}

.vm-svg-spinner-red {
  fill: color-mix(in srgb, var(--rose) 42%, var(--surface));
}

.vm-svg-spinner-blue {
  fill: var(--primary-tint);
  stroke: var(--primary-dark);
}

.vm-svg-spinner-pointer {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
}

/* Renderer state classes. */
.vm-model-svg.is-grid-emphasised .vm-svg-grid-line {
  stroke: var(--secondary-dark);
  stroke-width: 2.5;
  opacity: 1;
}

.vm-model-svg.is-grid-emphasised .vm-svg-ten-hundredths {
  fill: var(--accent-tint);
  stroke: var(--accent-dark);
  stroke-width: 4;
}

.vm-model-svg.is-previewing-tenths .vm-svg-fraction-empty {
  stroke: var(--primary-dark);
  stroke-width: 3;
  stroke-dasharray: 6 4;
}

.vm-model-svg.is-paired .vm-svg-group {
  fill: var(--secondary-tint);
  stroke: var(--secondary-dark);
  stroke-width: 3;
}

.vm-model-svg.is-bars-combined .vm-svg-total-bar {
  fill: var(--secondary-tint);
  stroke: var(--secondary-dark);
  stroke-width: 4;
}

.vm-svg-symmetry-grid {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 800ms var(--ease);
}

.vm-svg-symmetry-grid.is-half-turned {
  transform: rotate(180deg);
}

/* Prompt quantities and mathematical terms remain ordinary text until the
   student explicitly opens the Visual Trick. */
[data-vm-highlight] {
  border-radius: 0.25em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: color var(--transition), background-color var(--transition),
              box-shadow var(--transition);
}

.is-trick-visible [data-vm-highlight],
[data-vm-challenge].is-trick-visible [data-vm-highlight],
[data-vm-highlight].is-highlighted {
  padding-inline: 0.12em;
  color: var(--primary-dark);
  background: var(--primary-tint);
  box-shadow: inset 0 -2px 0 var(--primary-dark);
  font-weight: 850;
}

.is-trick-visible [data-vm-highlight="quantity"],
[data-vm-challenge].is-trick-visible [data-vm-highlight="quantity"],
[data-vm-highlight="quantity"].is-highlighted {
  color: var(--ink);
  background: var(--accent-tint);
  box-shadow: inset 0 -3px 0 var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

.vm-model-controls {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.vm-model-button {
  min-width: 44px;
  min-height: 44px;
  flex: 0 1 auto;
  white-space: normal;
}

.vm-model-button[aria-pressed="true"] {
  color: var(--surface);
  border-color: var(--primary-dark);
  background: var(--primary-dark);
  box-shadow: 0 0 0 2px var(--primary-tint);
}

.vm-model-button:focus-visible,
.vm-grid-button-map button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--surface);
}

.vm-model-status {
  width: 100%;
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.85rem;
  border-left: 4px solid var(--primary-dark);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: var(--ink-light);
  background: var(--primary-tint);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.5;
}

/* Drag-enhanced builders always retain the neighbouring button controls as
   their keyboard and touch alternative. */
.vm-shape-drag-tray,
.vm-shape-drop-zone,
.vm-likelihood-drag-scale,
.vm-model-data-table {
  width: 100%;
  min-width: 0;
  flex: 1 0 100%;
}

.vm-shape-drag-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-soft);
}

.vm-draggable-shape,
.vm-likelihood-token {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.75rem;
  border: 2px solid var(--primary-dark);
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: grab;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.vm-draggable-shape:active,
.vm-likelihood-token:active {
  cursor: grabbing;
}

.vm-shape-drop-zone {
  display: grid;
  min-height: 60px;
  place-items: center;
  padding: 0.75rem;
  border: 2px dashed var(--primary-dark);
  border-radius: var(--radius-xs);
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.vm-shape-drop-zone:hover,
.vm-shape-drop-zone:focus-visible {
  border-style: solid;
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

.vm-shape-drop-zone:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.vm-shape-build-board {
  display: grid;
  width: min(100%, 18rem);
  min-width: 0;
  min-height: 14rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(2.5rem, auto));
  gap: 0.25rem;
  margin-top: 0.5rem;
  padding: 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  overflow: hidden;
  isolation: isolate;
}

.vm-shape-build-empty {
  grid-area: 1 / 1 / -1 / -1;
  align-self: center;
  padding: 0.75rem;
  color: var(--ink-light);
  font-size: 0.8rem;
}

.vm-arranged-shape {
  display: grid;
  min-width: 0;
  min-height: 44px;
  place-items: center;
  padding: 0.2rem;
  border: 2px solid var(--primary-dark);
  color: var(--ink);
  background: var(--primary-tint);
  font-size: 0.65rem;
  font-weight: 850;
  line-height: 1.1;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.vm-arranged-shape--rectangle {
  z-index: 1;
  grid-area: 2 / 2 / 5 / 4;
  border-radius: 0.4rem;
}

.vm-arranged-shape--triangle {
  z-index: 2;
  grid-area: 1 / 2 / 3 / 4;
  padding-top: 1.3rem;
  background: var(--secondary-tint);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.vm-arranged-shape--right-triangle {
  z-index: 2;
  align-self: end;
  min-height: 4.5rem;
  background: var(--secondary-tint);
}

.vm-arranged-shape--right-triangle.vm-arranged-shape--copy-1 {
  grid-area: 4 / 1 / 6 / 3;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.vm-arranged-shape--right-triangle.vm-arranged-shape--copy-2 {
  grid-area: 4 / 3 / 6 / 5;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.vm-arranged-shape--circle {
  z-index: 3;
  align-self: center;
  aspect-ratio: 1;
  min-height: 44px;
  border-radius: 50%;
  background: var(--surface);
}

.vm-arranged-shape--circle.vm-arranged-shape--copy-1 {
  grid-area: 2 / 2 / 3 / 3;
}

.vm-arranged-shape--circle.vm-arranged-shape--copy-2 {
  grid-area: 3 / 3 / 4 / 4;
}

.vm-likelihood-drag-scale {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr));
  gap: 0.5rem;
  align-items: stretch;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-soft);
}

.vm-likelihood-drop-zone {
  display: grid;
  min-width: 0;
  min-height: 52px;
  place-items: center;
  padding: 0.5rem;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--ink-light);
  background: var(--surface);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
}

.vm-likelihood-drop-zone:hover {
  color: var(--primary-dark);
  border-color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-likelihood-token {
  width: 100%;
  border-radius: var(--radius-xs);
}

.vm-likelihood-token--red {
  color: var(--ink);
  border-color: var(--rose);
  background: color-mix(in srgb, var(--rose) 14%, var(--surface));
}

.vm-likelihood-token--blue {
  color: var(--primary-dark);
  border-color: var(--primary-dark);
  border-style: dashed;
  background: var(--primary-tint);
}

.vm-likelihood-token--green {
  color: var(--secondary-dark);
  border-color: var(--secondary-dark);
  border-style: double;
  background: var(--secondary-tint);
}

.vm-model-data-table {
  max-width: 100%;
  table-layout: fixed;
  border: 1px solid var(--border-strong);
  border-collapse: collapse;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.84rem;
  line-height: 1.4;
}

.vm-model-data-table caption {
  padding: 0.65rem 0.75rem;
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-weight: 850;
  text-align: left;
}

.vm-model-data-table :where(th, td) {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border-strong);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.vm-model-data-table thead th {
  color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-model-data-table tbody th {
  background: var(--surface-strong);
}

.vm-spinner-tally-table :where(th, td):not(:first-child) {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.vm-tally-marks,
.vm-tally-total {
  display: block;
  max-width: 100%;
}

.vm-tally-marks {
  color: var(--primary-dark);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.vm-tally-total {
  margin-top: 0.2rem;
  color: var(--ink-light);
  font-size: 0.72rem;
  font-weight: 800;
}

.vm-grid-button-map {
  display: grid;
  width: 100%;
  min-width: 14.75rem;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 0.25rem;
}

.vm-model-controls:has(.vm-grid-button-map) {
  display: block;
  overflow-x: auto;
  padding: 0.25rem 0.25rem 0.6rem;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.vm-grid-button-map.vm-grid-4 {
  min-width: 0;
  grid-template-columns: repeat(2, minmax(44px, 1fr));
}

.vm-grid-button-map button {
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 0.4rem;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.vm-grid-button-map button:hover {
  color: var(--primary-dark);
  border-color: var(--primary-dark);
  background: var(--primary-tint);
}

.vm-grid-button-map button[aria-pressed="true"],
.vm-grid-button-map button[aria-selected="true"] {
  color: var(--surface);
  border-color: var(--primary-dark);
  background: var(--primary-dark);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.is-trick-visible .vm-model-svg :where(rect, circle, path, polygon, polyline, line) {
  animation: vm-model-reveal 320ms var(--ease) both;
}

.is-motion-paused .vm-model-svg *,
.vm-page.is-motion-paused .vm-model-svg *,
.vm-model-svg.is-motion-paused *,
.is-trick-paused .vm-model-svg *,
[data-vm-challenge].is-trick-paused .vm-model-svg * {
  animation-play-state: paused !important;
  transition-duration: 0s !important;
}

.vm-reduced-motion :where(.vm-model-svg *, [data-vm-animated]) {
  scroll-behavior: auto !important;
  animation: none !important;
  transition: none !important;
}

@keyframes vm-model-reveal {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@media (max-width: 700px) {
  .vm-model-controls {
    align-items: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vm-model-button {
    width: 100%;
  }

  .vm-model-status {
    font-size: 0.9rem;
  }

  .vm-shape-drag-tray,
  .vm-shape-drop-zone,
  .vm-likelihood-drag-scale,
  .vm-model-data-table {
    grid-column: 1 / -1;
  }
}

/* At phone and small-tablet widths a 720–760 unit viewBox would otherwise
   shrink instructional labels below a readable size. Keep the model at a
   useful scale and contain horizontal movement inside the visual canvas;
   controls and explanatory copy remain pinned to the local viewport. */
@media screen and (max-width: 700px) {
  .vm-visual-canvas,
  [data-vm-visual-canvas] {
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
    align-items: start;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-behavior: auto;
    scroll-padding-inline: 0.5rem;
    scrollbar-gutter: stable;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .vm-model-svg {
    width: 100%;
    min-width: 36rem;
    max-width: none;
    margin-inline: 0;
  }

  .vm-model-controls,
  .vm-model-status,
  .vm-visual-canvas > [data-vm-visual-description] {
    position: sticky;
    z-index: 2;
    inset-inline-start: 0;
    width: 100%;
    max-width: 100%;
  }

  .vm-model-controls {
    background: var(--surface-soft);
  }

  .vm-svg-text { font-size: 22px; }
  .vm-svg-heading { font-size: 25px; }
  .vm-svg-small,
  .vm-svg-jump-label { font-size: 21px; }
  .vm-svg-tiny { font-size: 19px; }
  .vm-svg-equation { font-size: 27px; }

  .vm-stage-label,
  .vm-trick-steps > li > span {
    font-size: 0.875rem;
    line-height: 1.35;
  }

  .vm-trick-steps > li > p,
  .vm-trick__text,
  [data-vm-narration] {
    font-size: 1rem;
    line-height: 1.55;
  }
}

@media (max-width: 420px) {
  .vm-model-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .vm-model-controls:has(.vm-grid-button-map) {
    padding-inline: 0;
  }

  .vm-visual-canvas,
  [data-vm-visual-canvas] {
    padding: 0.4rem;
  }

  .vm-likelihood-drag-scale {
    grid-template-columns: minmax(0, 1fr);
  }

  .vm-model-data-table {
    font-size: 0.76rem;
  }

  .vm-model-data-table :where(th, td) {
    padding: 0.45rem;
  }

  .vm-shape-build-board {
    width: 100%;
    min-height: 12.5rem;
    padding: 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vm-model-svg *,
  .vm-svg-symmetry-grid,
  .is-trick-visible .vm-model-svg :where(rect, circle, path, polygon, polyline, line) {
    animation: none !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .vm-model-svg :where(rect, circle, path, polygon, polyline) {
    fill: Canvas;
    stroke: CanvasText;
  }

  .vm-model-svg :where(line, [class$="-line"], [class$="-ray"], [class$="-arc"], .vm-svg-axis, .vm-svg-jump) {
    fill: none;
    stroke: CanvasText;
  }

  .vm-model-svg :where(.vm-svg-marker, .vm-svg-trick-marker, .vm-svg-vertex-selected, .vm-svg-start-dot, .vm-svg-cube-edge-selected) {
    fill: Highlight;
    stroke: HighlightText;
    forced-color-adjust: none;
  }

  .vm-svg-text,
  .vm-svg-heading,
  .vm-svg-small,
  .vm-svg-tiny,
  .vm-svg-equation,
  .vm-svg-jump-label {
    fill: CanvasText;
  }

  .is-trick-visible [data-vm-highlight] {
    color: HighlightText;
    background: Highlight;
    box-shadow: none;
    forced-color-adjust: none;
  }

  .vm-shape-drag-tray,
  .vm-shape-drop-zone,
  .vm-shape-build-board,
  .vm-arranged-shape,
  .vm-shape-build-empty,
  .vm-likelihood-drag-scale,
  .vm-likelihood-drop-zone,
  .vm-draggable-shape,
  .vm-likelihood-token,
  .vm-model-data-table,
  .vm-model-data-table :where(caption, th, td) {
    color: CanvasText;
    border-color: CanvasText;
    background: Canvas;
    box-shadow: none;
  }

  .vm-arranged-shape {
    forced-color-adjust: none;
  }
}

@media print {
  .vm-model-controls {
    display: none !important;
  }

  .vm-model-controls:has(.vm-model-data-table) {
    display: block !important;
  }

  .vm-model-controls:has(.vm-model-data-table) > :not(.vm-model-data-table) {
    display: none !important;
  }

  .vm-model-data-table {
    display: table !important;
    break-inside: avoid;
    border-color: #000;
    color: #000;
    background: #fff;
  }

  .vm-model-data-table :where(caption, th, td) {
    border-color: #000;
    color: #000;
    background: #fff;
  }

  .vm-model-svg {
    max-height: 8in;
    border-color: #000;
    box-shadow: none;
  }

  .vm-model-status {
    border-color: #000;
    color: #000;
    background: #fff;
  }
}

/* ----------------------------------------------------------------------
   Responsive layout — including a 320px viewport
   ---------------------------------------------------------------------- */
@media (max-width: 900px) {
  .vm-hero__grid,
  .vm-challenge-layout,
  .vm-year-card,
  .vm-year-hero__layout,
  .vm-catalogue-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .vm-hero__visual {
    min-height: 16rem;
  }

  .vm-question-panel {
    position: static;
  }

  .vm-year-card__progress {
    width: 100%;
  }

  .vm-visual-workspace__stage,
  .vm-visual-stage {
    min-height: clamp(16rem, 66vw, 30rem);
  }
}

@media (max-width: 700px) {
  .vm-container {
    width: min(100% - 1.5rem, var(--max-width, 1200px));
  }

  .vm-filter {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .vm-filter__controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vm-filter > select {
    display: block;
    width: 100%;
  }

  .vm-filter__buttons {
    display: none;
  }

  .vm-filter-button {
    width: 100%;
  }

  .vm-challenge-header {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .vm-challenge-progress {
    width: 100%;
  }

  .vm-question-panel__header,
  .vm-visual-workspace__header,
  .vm-trick__header {
    align-items: stretch;
    flex-direction: column;
  }

  .vm-trick__controls,
  .vm-motion-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  }

  .vm-trick__controls button,
  .vm-motion-controls button {
    width: 100%;
  }

  .vm-builder-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }
}

@media (max-width: 520px) {
  .vm-hero__actions,
  .vm-action-row,
  .vm-response__actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .vm-hero__actions :where(.vm-button, .btn),
  .vm-action-row :where(.vm-button, .btn),
  .vm-response__actions :where(.vm-button, .btn, button) {
    width: 100%;
  }

  .vm-strand__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .vm-choice-list--grid,
  .vm-choice-grid,
  .vm-challenge-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .vm-hero-model {
    grid-template-columns: minmax(0, 1fr);
  }

  .vm-hero-model > div,
  .vm-hero-model > div:nth-of-type(3),
  .vm-hero-model > div:nth-of-type(4),
  .vm-hero-model > i,
  .vm-hero-model > i:nth-of-type(2),
  .vm-hero-model > i:nth-of-type(3) {
    grid-column: 1;
    grid-row: auto;
  }

  .vm-hero-model > i,
  .vm-hero-model > i:nth-of-type(2),
  .vm-hero-model > i:nth-of-type(3) {
    transform: rotate(90deg);
  }

  .vm-challenge-nav__link--next {
    text-align: left;
  }

  .vm-trick__footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vm-trick__step-label,
  .vm-trick__dots {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .vm-money-input,
  .vm-time-input {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .vm-place-value-table,
  .vm-data-table {
    min-width: 25rem;
  }

  .vm-duration-field,
  .vm-likelihood-builder,
  .vm-number-line-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 360px) {
  .vm-container {
    width: calc(100% - 1rem);
  }

  .vm-section,
  .vm-challenge-shell {
    padding-block: 2rem;
  }

  .vm-filter__controls,
  .vm-trick__controls,
  .vm-motion-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .vm-question-panel,
  .vm-visual-workspace,
  .vm-panel,
  .vm-trick__body {
    padding: 0.85rem;
  }

  .vm-visual-workspace__stage,
  .vm-visual-stage {
    min-height: 14rem;
    padding: 0.5rem;
  }

  .vm-response-row > *,
  .vm-input-group > *,
  .vm-answer-grid > * {
    flex-basis: 100%;
  }

  .vm-array-model {
    gap: 0.25rem;
  }

  .vm-array-model__cell,
  .vm-grid-cell {
    font-size: 0.8rem;
  }
}

/* ----------------------------------------------------------------------
   Motion, contrast and print accommodations
   ---------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .vm-page,
  .vm-page *,
  .vm-page *::before,
  .vm-page *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .vm-button:hover,
  .vm-icon-button:hover,
  .vm-filter-button:hover,
  .vm-challenge-card:hover {
    transform: none;
  }
}

@media (prefers-contrast: more) {
  .vm-question-panel,
  .vm-visual-workspace,
  .vm-panel,
  .vm-challenge-card,
  .vm-year-card,
  .vm-feature-card,
  .vm-trick,
  .vm-feedback,
  .vm-explanation,
  .vm-completion {
    border-color: var(--ink-light);
  }

  .vm-page :where(input, select, textarea, button) {
    border-color: var(--ink-light);
  }
}

@media (forced-colors: active) {
  .vm-page :where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid Highlight;
    box-shadow: none;
  }

  .vm-progress__bar,
  .vm-progress > [data-vm-progress-bar],
  .vm-filter-button[aria-pressed="true"],
  [data-vm-filter][aria-pressed="true"],
  .vm-builder__toolbar button[aria-pressed="true"],
  .vm-trick__dot.is-active,
  .vm-trick__dot[aria-current="step"] {
    background: Highlight;
    forced-color-adjust: none;
  }

  .vm-challenge-card.is-complete,
  .vm-feedback[data-state="correct"],
  .vm-completion {
    border: 3px solid CanvasText;
  }

  .vm-model-key__swatch,
  .vm-array-model__cell,
  .vm-grid-cell,
  .vm-fraction-part,
  .vm-money-token,
  .vm-shape-token,
  .vm-data-token {
    forced-color-adjust: auto;
  }
}

@media print {
  .vm-page {
    overflow: visible;
    color: #000;
    background: #fff;
  }

  .vm-container {
    width: 100%;
  }

  .vm-filter,
  .vm-hero__actions,
  .vm-action-row,
  .vm-response__actions,
  .vm-trick__controls,
  .vm-motion-controls,
  .vm-builder__toolbar,
  .vm-challenge-nav,
  [data-vm-check],
  [data-vm-reset],
  [data-vm-play],
  [data-vm-pause] {
    display: none !important;
  }

  .vm-hero,
  .vm-catalogue-header,
  .vm-section,
  .vm-challenge-shell {
    padding-block: 1rem;
    background: #fff;
  }

  .vm-hero__grid,
  .vm-challenge-layout {
    display: block;
  }

  .vm-hero__visual,
  .vm-question-panel,
  .vm-visual-workspace,
  .vm-panel,
  .vm-trick,
  .vm-feedback,
  .vm-explanation,
  .vm-completion,
  .vm-challenge-card {
    position: static;
    break-inside: avoid;
    margin-bottom: 1rem;
    border: 1px solid #000;
    box-shadow: none;
    background: #fff;
  }

  .vm-page [data-vm-step][hidden],
  .vm-page .vm-trick-step[hidden] {
    display: block !important;
    min-height: auto;
    border-top: 1px solid #000;
  }

  .vm-visual-workspace__stage,
  .vm-visual-stage,
  .vm-trick__stage {
    min-height: 0;
    overflow: visible;
    border-color: #000;
    background: #fff;
  }

  .vm-page a[href]::after {
    content: none;
  }
}
