:root {
  --ink: #101722;
  --muted: #566273;
  --subtle: #718096;
  --line: #d9e1ea;
  --line-strong: #b8c4d2;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-alt: #eef4f8;
  --navy: #102033;
  --blue: #176b87;
  --green: #2f7d5a;
  --gold: #a16207;
  --coral: #c7553d;
  --violet: #5d5aa8;
  --danger: #b42318;
  --focus: #155eef;
  --shadow: 0 16px 44px rgba(17, 24, 39, 0.12);
  --radius: 8px;
  --max: 1180px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    linear-gradient(180deg, #edf4f8 0, #f7f9fc 340px, var(--bg) 100%);
  font-size: 16px;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(23, 107, 135, 0.06), transparent 34%),
    linear-gradient(180deg, rgba(199, 85, 61, 0.05), transparent 28%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.skip-link {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-140%);
  background: var(--navy);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 84px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(185, 196, 208, 0.8);
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--navy);
  font-weight: 850;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 0.9rem;
}

.student-pill {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.student-pill span {
  color: var(--subtle);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.student-pill strong {
  color: var(--navy);
  line-height: 1.1;
}

.student-switch {
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--navy);
  background: #fff;
  font-weight: 800;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fff;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.nav-btn:hover,
.nav-btn.is-active {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.today-button {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.more-menu {
  position: relative;
}

.more-menu summary {
  display: inline-flex;
  align-items: center;
  list-style: none;
}

.more-menu summary::-webkit-details-marker {
  display: none;
}

.more-menu summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.more-menu[open] summary::after {
  transform: translateY(2px) rotate(225deg);
}

.more-menu__list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: 240px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.menu-btn.nav-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

main {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 28px 20px 72px;
}

.view[hidden] {
  display: none;
}

.view.is-visible {
  animation: view-in 220ms ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard-grid,
.login-shell,
.diagnostic-grid,
.daily-layout,
.practice-shell,
.review-layout,
.progress-grid,
.parent-grid {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.diagnostic-grid,
.practice-shell,
.review-layout,
.progress-grid,
.parent-grid {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
}

.panel,
.command-panel,
.profile-panel,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.command-panel {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(16, 32, 51, 0.98), rgba(23, 107, 135, 0.93)),
    linear-gradient(90deg, transparent, rgba(161, 98, 7, 0.24));
  padding: 34px;
}

.login-shell {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.72fr);
  align-items: start;
}

.login-panel {
  min-height: 430px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(16, 32, 51, 0.98), rgba(23, 107, 135, 0.9)),
    linear-gradient(90deg, transparent, rgba(47, 125, 90, 0.18));
  padding: 34px;
}

.login-panel h1 {
  margin: 0;
  max-width: 720px;
  font-size: 2.5rem;
  line-height: 1.06;
}

.login-panel .label {
  color: #b9ecff;
}

.login-panel .lead {
  color: rgba(255, 255, 255, 0.84);
}

.account-list {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.account-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
}

.account-card.is-active {
  border-color: rgba(125, 211, 252, 0.82);
  box-shadow: inset 4px 0 0 #7dd3fc;
}

.account-card span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.account-card strong {
  display: block;
  margin-top: 3px;
  color: #fff;
  font-size: 1.25rem;
}

.account-card p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.78);
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.pin-field {
  min-width: 128px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.88rem;
}

.pin-field input {
  min-height: 44px;
}

.account-card .btn.secondary {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.32);
}

.account-form-panel .fine-print {
  margin: 14px 0 0;
}

.command-panel h1,
.section-head h1 {
  margin: 0;
  max-width: 850px;
  font-size: 2.6rem;
  line-height: 1.06;
}

.lead,
.command-panel .lead {
  max-width: 720px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.05rem;
}

.section-head {
  margin-bottom: 18px;
  padding: 8px 0 6px;
}

.section-head.compact {
  margin: 26px 0 12px;
  padding: 0;
}

.section-head h1,
.section-head h2 {
  color: var(--ink);
}

.section-head h2 {
  margin: 0;
  font-size: 1.4rem;
}

.section-head p {
  max-width: 740px;
  color: var(--muted);
}

.label {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.command-panel .label {
  color: #b9ecff;
}

.panel h2,
.profile-panel h2 {
  margin: 0 0 12px;
  font-size: 1.24rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.action-row,
.timer-controls,
.question-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn,
.text-btn,
.chip-btn {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 750;
  transition: transform 120ms ease, background 180ms ease, border-color 180ms ease;
}

.btn:active,
.text-btn:active,
.chip-btn:active {
  transform: scale(0.98);
}

.btn.primary {
  color: #fff;
  background: var(--blue);
}

.btn.primary:hover {
  background: #125b73;
}

.btn.secondary,
.chip-btn {
  color: var(--navy);
  background: #fff;
  border-color: var(--line-strong);
}

.btn.secondary:hover,
.chip-btn:hover {
  border-color: var(--navy);
}

.btn.small {
  min-height: 44px;
  padding: 8px 11px;
  font-size: 0.9rem;
}

.btn.full {
  width: 100%;
}

.text-btn {
  color: var(--blue);
  background: transparent;
  padding-left: 0;
}

.form-grid,
.score-form {
  display: grid;
  gap: 13px;
}

.score-form {
  grid-template-columns: repeat(2, 1fr);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(21, 94, 239, 0.14);
}

.metrics,
.engine-grid,
.strategy-grid,
.skill-grid,
.audit-grid,
.weekly-report,
.mini-stats {
  display: grid;
  gap: 14px;
}

.metrics {
  grid-template-columns: repeat(4, 1fr);
  margin: 18px 0;
}

.engine-grid {
  grid-template-columns: repeat(3, 1fr);
}

.strategy-grid {
  grid-template-columns: repeat(4, 1fr);
}

.metric,
.engine-card,
.strategy-card,
.skill-card,
.audit-card,
.report-item,
.mistake-item,
.review-row,
.recommendation-card,
.source-note {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric,
.engine-card,
.strategy-card,
.skill-card,
.audit-card,
.report-item,
.mistake-item,
.review-row,
.recommendation-card,
.source-note {
  padding: 16px;
}

.metric {
  min-height: 152px;
}

.metric span,
.engine-card span,
.strategy-card span,
.skill-card span,
.audit-card span,
.report-item span,
.mistake-item span,
.review-row span,
.recommendation-card span {
  display: block;
  color: var(--subtle);
  font-size: 0.85rem;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin: 8px 0;
  color: var(--navy);
  font-size: 1.46rem;
  line-height: 1.1;
}

.metric small,
.fine-print {
  color: var(--muted);
}

.engine-card h2 {
  margin: 8px 0 6px;
}

.engine-card span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--navy);
}

.strategy-card {
  min-height: 178px;
}

.strategy-card strong,
.skill-card strong,
.audit-card strong,
.report-item strong,
.mistake-item strong,
.review-row strong,
.recommendation-card strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

.engine-card p,
.strategy-card p,
.skill-card p,
.audit-card p,
.report-item p,
.mistake-item p,
.review-row p,
.recommendation-card p,
.source-note p {
  margin: 8px 0 0;
  color: var(--muted);
}

.recommendation-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.recommendation-card strong {
  font-size: 2rem;
}

.recommendation-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.recommendation-list p {
  margin: 0;
}

.daily-layout {
  grid-template-columns: 340px minmax(0, 1fr);
}

.assignment-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.36fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
  padding: 26px;
  border: 1px solid rgba(23, 107, 135, 0.24);
  border-radius: var(--radius);
  color: #fff;
  background:
    linear-gradient(135deg, rgba(16, 32, 51, 0.98), rgba(23, 107, 135, 0.92)),
    linear-gradient(90deg, transparent, rgba(199, 85, 61, 0.18));
  box-shadow: var(--shadow);
}

.assignment-copy h1 {
  margin: 0;
  font-size: 2.35rem;
  line-height: 1.06;
}

.assignment-copy p:not(.label) {
  max-width: 760px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.04rem;
}

.assignment-hero .label {
  color: #b9ecff;
}

.assignment-progress,
.assignment-next {
  align-self: stretch;
  display: grid;
  align-content: center;
  min-height: 114px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
}

.assignment-progress span,
.assignment-next span {
  display: block;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.assignment-progress .bar {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.22);
}

.assignment-progress .bar i {
  background: #7dd3fc;
}

.assignment-next {
  grid-column: 1 / -1;
}

.assignment-next strong {
  margin-top: 4px;
  font-size: 1.35rem;
}

.assignment-next p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.82);
}

.assignment-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.assignment-actions .btn.primary {
  background: #fff;
  color: var(--navy);
}

.assignment-actions .btn.secondary {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.32);
}

.timer {
  min-height: 120px;
  display: grid;
  place-items: center;
  margin: 12px 0;
  border-radius: var(--radius);
  color: var(--navy);
  background: var(--surface-alt);
  font-size: 3rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.mission-list,
.stack-list,
.mistake-list {
  display: grid;
  gap: 10px;
}

.mission-item,
.review-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.mission-time {
  min-height: 62px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--navy);
  font-weight: 800;
}

.mission-time span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.mission-item strong {
  display: block;
}

.mission-item p {
  margin: 4px 0 0;
  color: var(--muted);
}

.mission-item.is-done {
  border-color: rgba(47, 125, 90, 0.45);
  background: #f1f8f4;
}

.mission-item.is-next {
  border-color: rgba(23, 107, 135, 0.55);
  box-shadow: inset 4px 0 0 var(--blue);
}

.practice-shell {
  grid-template-columns: 320px minmax(0, 1fr);
  align-items: start;
}

.controls-panel {
  position: sticky;
  top: 104px;
}

.mini-stats {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
}

.mini-stats div {
  min-height: 78px;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.mini-stats span {
  display: block;
  color: var(--navy);
  font-size: 1.45rem;
  font-weight: 850;
}

.mini-stats small {
  color: var(--muted);
}

.question-topline {
  justify-content: space-between;
}

#question-meta,
#question-difficulty {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 10px;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 750;
}

#question-meta {
  background: var(--violet);
}

#question-difficulty {
  background: var(--gold);
}

.question-prompt {
  margin: 12px 0 14px;
  padding: 18px;
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.choices {
  display: grid;
  gap: 10px;
}

.choice {
  min-height: 50px;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.choice:hover,
.choice.is-selected {
  border-color: var(--blue);
  background: #edf6fa;
}

.choice-key {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--navy);
  font-weight: 800;
}

.hint-box,
.feedback,
.coach-response {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff8e8;
}

.feedback:empty,
.coach-response:empty {
  display: none;
}

.feedback.good {
  border-color: rgba(47, 125, 90, 0.4);
  background: #eff8f2;
}

.feedback.bad {
  border-color: rgba(180, 35, 24, 0.36);
  background: #fff1ef;
}

.feedback ol,
.coach-response ol {
  margin: 8px 0 0 20px;
  padding: 0;
}

.classify-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.coach-panel {
  margin-top: 18px;
}

.coach-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.45fr);
  gap: 12px;
  margin: 12px 0;
}

.skill-grid {
  grid-template-columns: repeat(2, 1fr);
}

.bar {
  height: 10px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e8ef;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.skill-card[data-band="high"] .bar i {
  background: var(--green);
}

.skill-card[data-band="mid"] .bar i {
  background: var(--gold);
}

.skill-card[data-band="low"] .bar i {
  background: var(--coral);
}

.empty-state {
  min-height: 140px;
  display: grid;
  place-items: center;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.source-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.audit-card[data-status="pass"] {
  border-color: rgba(47, 125, 90, 0.45);
}

.audit-card[data-status="watch"] {
  border-color: rgba(161, 98, 7, 0.55);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 80;
  width: min(92%, 520px);
  transform: translateX(-50%);
  padding: 13px 16px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--navy);
  box-shadow: var(--shadow);
}

@media (max-width: 1040px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  .nav {
    justify-content: flex-start;
  }

  .dashboard-grid,
  .login-shell,
  .diagnostic-grid,
  .daily-layout,
  .practice-shell,
  .review-layout,
  .progress-grid,
  .parent-grid,
  .metrics,
  .engine-grid,
  .strategy-grid {
    grid-template-columns: 1fr;
  }

  .assignment-hero {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
  }

  .command-panel {
    min-height: 310px;
  }

  .command-panel h1,
  .login-panel h1,
  .section-head h1,
  .assignment-copy h1 {
    font-size: 2rem;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px;
  }

  main {
    padding-inline: 12px;
  }

  .nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .student-pill {
    width: 100%;
  }

  .student-switch {
    margin-left: auto;
  }

  .nav-btn,
  .more-menu,
  .more-menu summary {
    width: 100%;
  }

  .more-menu__list {
    width: min(86vw, 280px);
  }

  .panel,
  .command-panel,
  .login-panel,
  .profile-panel,
  .assignment-hero {
    padding: 16px;
  }

  .account-card {
    grid-template-columns: 1fr;
  }

  .account-actions {
    justify-content: stretch;
  }

  .account-actions .btn,
  .pin-field {
    width: 100%;
  }

  .assignment-actions .btn {
    width: 100%;
  }

  .score-form,
  .coach-grid,
  .skill-grid,
  .mini-stats {
    grid-template-columns: 1fr;
  }

  .mission-item,
  .review-row {
    grid-template-columns: 1fr;
  }

  .mission-time {
    min-height: 44px;
    justify-content: start;
    padding-left: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Pagecrafter credit ---- */
.app-credit {
  text-align: center;
  padding: 22px 16px 32px;
  color: var(--subtle);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}
.app-credit a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}
.app-credit a:hover {
  text-decoration: underline;
}

/* ---- Emphasized single call-to-action ---- */
.btn.big {
  padding: 16px 30px;
  font-size: 1.08rem;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(23, 107, 135, 0.28);
}

/* ---- Math rendering (dependency-free) ---- */
.math {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.math sup,
.math sub {
  font-size: 0.72em;
  line-height: 0;
}
.mfrac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  margin: 0 0.15em;
}
.mfrac .mnum {
  border-bottom: 1.5px solid currentColor;
  padding: 0 0.3em;
}
.mfrac .mden {
  padding: 0 0.3em;
}
.mroot {
  display: inline-flex;
  align-items: flex-start;
}
.mroot .mradsign {
  margin-right: -0.1em;
}
.mroot .mrad {
  border-top: 1.5px solid currentColor;
  padding: 0 0.2em;
}
.mroot .mrootidx {
  font-size: 0.6em;
  margin-right: -0.35em;
  align-self: flex-start;
}

/* ---- Question figures and data tables ---- */
.question-figure {
  margin: 4px 0 16px;
}
.question-figure .q-figure {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.question-figure .q-figure svg {
  max-width: 100%;
  height: auto;
}
.q-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.95rem;
}
.q-table th,
.q-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: center;
}
.q-table th {
  background: var(--surface-alt);
  font-weight: 600;
}

/* ---- Grid-in (student-produced response) ---- */
.gridin label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}
.gridin input {
  min-height: 48px;
  padding: 10px 14px;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 240px;
}
.gridin input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---- Diagnostic quiz ---- */
.diagnostic-quiz {
  display: grid;
  gap: 16px;
}
.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--muted);
}
.quiz-progress .bar {
  flex: 1;
  height: 8px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
.quiz-progress .bar i {
  display: block;
  height: 100%;
  background: var(--blue);
  transition: width 0.25s ease;
}
.quiz-result {
  display: grid;
  gap: 12px;
}

/* ---- Score-trend sparkline ---- */
.sparkline {
  width: 100%;
  height: 64px;
  margin-top: 8px;
}
.sparkline .spark-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.sparkline .spark-dot {
  fill: var(--blue);
}
.sparkline .spark-area {
  fill: rgba(23, 107, 135, 0.1);
}
