/*
  privatetutor1 layouts. Rules: var(--tokens) only, never raw colors; no inline style="" (the CSP blocks it).
  Motion: cheerful on the dashboard and game moments, quiet on learning screens. All of it switches off
  under prefers-reduced-motion (bottom of this file).
*/

/* ---------- shell ---------- */
/* The router focuses <main> after each navigation so screen readers start there; it needs no ring. */
main.page:focus-visible {
  box-shadow: none;
}
.brand-logo {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--brand);
}
.xp-pill {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: var(--radius-full);
  padding: 0.15rem 0.7rem;
}
h1 {
  letter-spacing: -0.025em;
}
.h-small {
  font-size: var(--text-sm);
  font-weight: 650;
  letter-spacing: 0.01em;
  margin: 0;
}
.lede {
  font-size: var(--text-lg);
  color: var(--text-muted);
  max-width: 44rem;
  margin: 0;
}
.badge-gold {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--text);
}

/* ---------- breadcrumb ---------- */
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
}
.crumbs li + li::before {
  content: '›';
  color: var(--text-muted);
  margin-inline-end: var(--space-2);
}
.crumbs a {
  color: var(--text-muted);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--brand);
  text-decoration: underline;
}
.crumbs [aria-current='page'] {
  color: var(--text);
  font-weight: 600;
}

/* ---------- page heads ---------- */
.page-head,
.mode-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.page-head h1,
.mode-head h1 {
  margin: 0;
}
.mode-head .icon {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--brand);
}

/* ---------- dashboard ---------- */
.today-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
}
.today-head h1 {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 2.75rem);
}
.today-stats {
  display: flex;
  gap: var(--space-2);
  margin: 0;
}
.today-stat {
  min-width: 6.5rem;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.today-stat dt {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.today-stat dd {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.quest {
  border-top: 3px solid var(--brand);
}
.quest h2 {
  margin: 0;
}
.quest-list {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.quest-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease), background var(--duration) var(--ease);
}
.quest-item:hover {
  color: var(--text);
  border-color: var(--brand-border);
  background: var(--brand-soft);
  transform: translateX(3px);
}
.quest-icon {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border-radius: var(--radius-full);
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 800;
}
.quest-go {
  color: var(--brand);
  font-weight: 700;
}
.subject-grid,
.sub-grid,
.mode-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}
.subject-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}
.subject-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: 100%;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none;
  transition: transform var(--duration) var(--ease-bounce), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.subject-card:hover {
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--brand-border);
}
.subject-card.is-muted {
  opacity: 0.7;
}
.subject-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.subject-card h3 {
  margin: 0;
  font-size: var(--text-lg);
}
.subject-card p {
  margin: 0;
}
.subject-card .badge {
  align-self: flex-start;
}

/* ---------- progress ring ---------- */
.ring {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
}
.ring svg {
  transform: rotate(0deg);
}
.ring-track {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 3.2;
}
.ring-fill {
  fill: none;
  stroke: var(--brand);
  stroke-width: 3.2;
  stroke-linecap: round;
  transition: stroke-dasharray var(--duration-slow) var(--ease);
}
.ring-value {
  position: absolute;
  font-size: var(--text-xs);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

/* ---------- mastery dots and legend ---------- */
.dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  flex: none;
  border-radius: var(--radius-full);
  background: var(--m-none);
  border: 1px solid var(--border-strong);
}
.dot-learning {
  background: var(--m-learning);
  border-color: transparent;
}
.dot-solid {
  background: var(--m-solid);
  border-color: transparent;
}
.dot-due {
  background: var(--m-due);
  border-color: transparent;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.legend li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* ---------- topic map (a tree with connector lines) ---------- */
.tree,
.tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree-children {
  margin-inline-start: 0.95rem;
  padding-inline-start: var(--space-4);
  border-inline-start: 1px solid var(--border-strong);
}
.tree-node {
  position: relative;
}
.tree-children > .tree-node::before {
  content: '';
  position: absolute;
  inset-inline-start: calc(-1 * var(--space-4));
  top: 1.25rem;
  width: var(--space-3);
  border-top: 1px solid var(--border-strong);
}
.tree-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-block: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.tree-link:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.tree-link.depth-0 {
  font-size: var(--text-lg);
  font-weight: 700;
}
.tree-link.depth-1 {
  font-weight: 600;
}
.tree-link.depth-2,
.tree-link.depth-3 {
  font-size: var(--text-sm);
}

/* ---------- topic page ---------- */
.needs ul {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
}
.mode-group {
  display: grid;
  gap: var(--space-2);
}
.mode-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
}
.mode-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100%;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none;
  transition: transform var(--duration) var(--ease-bounce), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
a.mode-tile:hover {
  color: var(--text);
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.mode-tile .icon {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--brand);
}
.mode-tile.is-empty {
  background: var(--surface-2);
  color: var(--text-muted);
}
.mode-tile.is-empty .icon {
  color: var(--text-muted);
}
.mode-name {
  font-weight: 650;
}
.sub-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}
.sub-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100%;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.sub-card:hover {
  color: var(--text);
  border-color: var(--brand-border);
}

/* ---------- source chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.chip {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
}
.chip-example {
  border-style: dashed;
}
.mode-body {
  display: grid;
  gap: var(--space-5);
}

/* ---------- motion: cheerful where it helps, never where it distracts ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pop {
  0% {
    transform: scale(0.6);
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}
.rise {
  animation: rise var(--duration-slow) var(--ease) both;
}
.rise:nth-child(2) {
  animation-delay: 80ms;
}
.rise:nth-child(3) {
  animation-delay: 160ms;
}
.pop {
  display: inline-block;
  animation: pop var(--duration-slow) var(--ease-bounce) both;
}
.subject-grid > li {
  animation: rise var(--duration-slow) var(--ease) both;
}
.subject-grid > li:nth-child(2) {
  animation-delay: 60ms;
}
.subject-grid > li:nth-child(3) {
  animation-delay: 120ms;
}
.subject-grid > li:nth-child(4) {
  animation-delay: 180ms;
}
.subject-grid > li:nth-child(n + 5) {
  animation-delay: 240ms;
}

@media (max-width: 40rem) {
  .today-stats {
    width: 100%;
  }
  .today-stat {
    flex: 1;
    min-width: 0;
  }
  .page-head .ring {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rise,
  .pop,
  .subject-grid > li {
    animation: none;
  }
  .quest-item,
  .subject-card,
  .mode-tile,
  .ring-fill {
    transition: none;
  }
  .quest-item:hover,
  .subject-card:hover,
  a.mode-tile:hover {
    transform: none;
  }
}

.quest .empty {
  margin-top: var(--space-4);
}

/* =====================================================================
   Look: editorial and academic, not "app". Sharp corners, hairline rules,
   strong type, MIT red as the one accent; colour comes from progress and play.
   ===================================================================== */
.app-header {
  border-top: 4px solid var(--brand);
  background: color-mix(in oklab, var(--surface) 90%, transparent);
}
.brand {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.035em;
}
.nav a {
  border-radius: 0;
  border-bottom: 2px solid transparent;
  padding-inline: var(--space-2);
}
.nav a:hover {
  background: none;
}
.nav a[aria-current='page'] {
  background: none;
  color: var(--text);
  border-bottom-color: var(--brand);
}
h1,
h2 {
  font-weight: 800;
  letter-spacing: -0.03em;
}
.page-head h1,
.mode-head h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.08;
}
.eyebrow {
  color: var(--text-muted);
  letter-spacing: 0.12em;
}
.card {
  border-color: var(--border);
}

/* dashboard: stats as a ruled row, not boxes */
.today-stats {
  gap: 0;
  border-top: 1px solid var(--text);
}
.today-stat {
  background: none;
  border: 0;
  border-radius: 0;
  border-inline-end: 1px solid var(--border);
  padding: var(--space-2) var(--space-5) 0 0;
  margin-inline-end: var(--space-5);
}
.today-stat:last-child {
  border-inline-end: 0;
  margin-inline-end: 0;
}
.today-stat dd {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.quest {
  border-top: 0;
  border-inline-start: 4px solid var(--brand);
}
.quest-item {
  border-radius: 0;
  border-width: 0 0 1px;
  background: none;
  padding-inline: 0;
}
.quest-list li:last-child .quest-item {
  border-bottom: 0;
}
.quest-item:hover {
  background: none;
}
.quest-icon {
  border-radius: 0;
  width: auto;
  height: auto;
  background: none;
  color: var(--brand);
  font-size: var(--text-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  min-width: 2.5rem;
}
.subject-card {
  border-radius: 0;
  border-width: 4px 0 0;
  border-color: var(--text);
  background: var(--surface);
  padding: var(--space-4) var(--space-4) var(--space-5);
}
.subject-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
}
.subject-card .eyebrow {
  color: var(--brand);
  font-size: var(--text-sm);
}
.subject-card h3 {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.mode-tile {
  border-radius: 0;
}
a.mode-tile:hover {
  box-shadow: none;
  border-color: var(--text);
  background: var(--brand-soft);
}
.sub-card {
  border-radius: 0;
  border-width: 0 0 0 3px;
  border-color: var(--border-strong);
}
.sub-card:hover {
  border-color: var(--brand);
}
.xp-pill {
  border-radius: var(--radius);
}
.xp-pill {
  white-space: nowrap;
}
.xp-pill.pop {
  display: inline-block;
}

/* ---------- learning blocks ---------- */
.block h2,
.q-card h2 {
  margin: 0;
  font-size: var(--text-xl);
}
.from-topic {
  align-self: flex-start;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.from-topic::before {
  content: '↳ ';
}
.block-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.caption {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-style: italic;
}
.points {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: pt;
  display: grid;
  gap: var(--space-3);
}
.points li {
  counter-increment: pt;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: var(--space-2);
  font-size: var(--text-lg);
  line-height: 1.5;
}
.points li::before {
  content: counter(pt);
  font-weight: 800;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

/* glossary */
.glossary-search {
  max-width: 24rem;
}
.terms {
  margin: 0;
  padding: 0;
}
.term {
  display: grid;
  grid-template-columns: minmax(10rem, 16rem) 1fr;
  align-items: start;
  gap: var(--space-2) var(--space-5);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.term:last-child {
  border-bottom: 0;
}
.term dt {
  font-weight: 750;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.term dd {
  margin: 0;
  display: grid;
  gap: var(--space-2);
}

/* explain ladder */
.ladder {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rung {
  border-inline-start: 4px solid var(--brand);
}
.rung-text {
  font-size: var(--text-lg);
  margin: 0;
  max-width: 46rem;
}
.term-bullets {
  margin: 0;
  padding-inline-start: 1.1rem;
  display: grid;
  gap: var(--space-2);
  max-width: 46rem;
}
.check-box {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  padding: var(--space-4);
  background: var(--sky-soft);
  border-inline-start: 3px solid var(--sky);
}
.check-box p {
  margin: 0;
}
.check-answer {
  font-weight: 650;
}
.next-step {
  justify-self: start;
  align-self: flex-start;
}
.done-line {
  margin: 0;
  font-weight: 650;
  color: var(--success);
}

/* worked example */
.worked-q {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
  max-width: 46rem;
}
.worked-steps {
  margin: 0;
  padding-inline-start: 1.3rem;
  display: grid;
  gap: var(--space-3);
}
.worked-steps li::marker {
  color: var(--brand);
  font-weight: 800;
}
.worked-answer {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--success-soft);
  border-inline-start: 3px solid var(--success);
}

/* ---------- diagrams ---------- */
.diagram-controls {
  display: grid;
  gap: var(--space-2);
  max-width: 30rem;
}
.diagram-controls.two {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  max-width: 36rem;
  gap: var(--space-4);
}
.range {
  width: 100%;
  accent-color: var(--brand);
}
.diagram-out {
  display: grid;
  gap: var(--space-4);
}
.split-bar {
  width: 100%;
  height: 3rem;
  display: block;
}
.bar-track {
  fill: var(--surface-2);
}
.seg {
  transition: width var(--duration-slow) var(--ease), x var(--duration-slow) var(--ease);
}
.seg-1 {
  fill: var(--series-1);
  background: var(--series-1);
}
.seg-2 {
  fill: var(--series-2);
  background: var(--series-2);
}
.seg-3 {
  fill: var(--series-3);
  background: var(--series-3);
}
.diagram-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.diagram-legend li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.diagram-legend .legend-label {
  flex: 1;
}
.diagram-legend strong {
  font-variant-numeric: tabular-nums;
  font-size: var(--text-lg);
}
.swatch {
  width: 0.9rem;
  height: 0.9rem;
  flex: none;
}
.diagram-sentence {
  margin: 0;
  max-width: 46rem;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
}

/* fund map */
.fund-map {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    'lps . .'
    'fa . .'
    'fund f3 gp'
    'fb . .'
    'st . .';
  gap: var(--space-2) var(--space-3);
  align-items: center;
  max-width: 40rem;
}
.fm-node {
  font: inherit;
  font-weight: 750;
  padding: var(--space-4);
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border-strong);
  border-radius: 0;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.fm-node:hover {
  border-color: var(--text);
}
.fm-node[aria-pressed='true'] {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.fm-lps {
  grid-area: lps;
}
.fm-fund {
  grid-area: fund;
}
.fm-gp {
  grid-area: gp;
}
.fm-startups {
  grid-area: st;
}
.fm-flows {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 var(--space-3);
}
.fm-a {
  grid-area: fa;
}
.fm-b {
  grid-area: fb;
}
.fm-f3 {
  grid-area: f3;
}
.fm-flow {
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text-muted);
  padding: var(--space-1) 0;
  transition: color var(--duration) var(--ease);
}
.fm-flow.is-on {
  color: var(--brand);
}
.fm-detail {
  margin-top: var(--space-4);
}
.fm-detail h3 {
  margin: 0 0 var(--space-2);
}
.fm-detail p {
  margin: 0 0 var(--space-3);
}
.fm-io {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--space-4);
}
.fm-io ul {
  margin: var(--space-1) 0 0;
  padding-inline-start: 1.1rem;
}

/* life cycle chart */
.lc-chart {
  width: 100%;
  height: auto;
  display: block;
}
.lc-chart .axis {
  stroke: var(--border-strong);
}
.lc-call {
  fill: var(--series-neg);
  background: var(--series-neg);
}
.lc-dist {
  fill: var(--series-1);
  background: var(--series-1);
}
.lc-call.is-future,
.lc-dist.is-future {
  opacity: 0.18;
}
.lc-line {
  fill: none;
  stroke: var(--series-3);
  stroke-width: 3;
  stroke-linejoin: round;
}
.lc-line-swatch {
  background: var(--series-3);
  height: 3px;
}
.lc-year {
  fill: var(--text-muted);
  font-size: 12px;
}
.lc-phase {
  margin: 0;
}

/* ---------- practice: questions, feedback, flashcards ---------- */
.runner {
  max-width: 46rem;
}
.runner-top {
  display: grid;
  gap: var(--space-2);
}
.runner-bar {
  width: 100%;
  height: 6px;
  appearance: none;
  border: 0;
  background: var(--surface-2);
  accent-color: var(--brand);
}
.runner-bar::-webkit-progress-bar {
  background: var(--surface-2);
}
.runner-bar::-webkit-progress-value {
  background: var(--brand);
  transition: width var(--duration-slow) var(--ease);
}
.runner-bar::-moz-progress-bar {
  background: var(--brand);
}
.q-prompt {
  font-size: var(--text-lg);
  font-weight: 650;
  margin: 0 0 var(--space-3);
  padding: 0;
}
fieldset.q-choice {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.options {
  display: grid;
  gap: var(--space-2);
}
.option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  text-align: start;
  font: inherit;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.option:hover:not(:disabled) {
  border-color: var(--text);
}
.option:disabled {
  cursor: default;
  color: var(--text);
}
.option.is-right {
  border-color: var(--success);
  background: var(--success-soft);
  animation: pop var(--duration-slow) var(--ease-bounce);
}
.option.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  animation: shake 320ms var(--ease);
}
.q-input {
  max-width: 10rem;
}
.order-list {
  margin: 0;
  padding-inline-start: 1.5rem;
  display: grid;
  gap: var(--space-2);
}
.order-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  background: var(--surface);
}
.order-btns {
  display: flex;
  gap: var(--space-1);
  flex: none;
}
.match-grid {
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr;
  gap: var(--space-3);
  align-items: center;
}
.feedback {
  display: block;
  padding: var(--space-4);
  border-inline-start: 4px solid var(--success);
  background: var(--success-soft);
}
.feedback.is-wrong {
  border-color: var(--warning);
  background: var(--warning-soft);
}
.feedback p {
  margin: 0 0 var(--space-2);
}
.feedback p:last-child {
  margin: 0;
}
.feedback-head {
  font-size: var(--text-lg);
}
.xp-chip {
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--text);
  background: var(--gold);
  padding: 0.1rem 0.45rem;
  margin-inline-start: var(--space-2);
}
.q-result:empty {
  display: none;
}
.test-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: tq;
  max-width: 46rem;
}
.test-list > li {
  counter-increment: tq;
}
.test-list > li::before {
  content: 'Question ' counter(tq);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.test-form label.option {
  cursor: pointer;
}
.score {
  max-width: 46rem;
  border-top: 4px solid var(--gold);
  display: grid !important;
}
.score-big {
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.fc-wrap {
  max-width: 40rem;
  position: relative;
}
.fc-count {
  margin: 0;
  color: var(--text-muted);
}
.fc-count strong {
  color: var(--text);
}
.flashcard {
  min-height: 15rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  justify-content: center;
  border-top: 4px solid var(--brand);
}
.flashcard .badge {
  align-self: flex-start;
}
.fc-front {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
}
.fc-back p {
  font-size: var(--text-lg);
  margin: 0;
}
.fc-back hr {
  border: 0;
  border-top: 1px dashed var(--border-strong);
  margin: 0 0 var(--space-3);
}
.flashcard.is-flipped {
  animation: flip var(--duration-slow) var(--ease);
}
.fc-ask {
  flex-basis: 100%;
}
.xp-burst {
  position: absolute;
  inset-inline-end: var(--space-4);
  top: 0;
  font-weight: 800;
  color: var(--text);
  background: var(--gold);
  padding: 0.15rem 0.5rem;
  animation: float-up 1200ms var(--ease) both;
  pointer-events: none;
}

@keyframes shake {
  0%,
  100% {
    transform: none;
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}
@keyframes flip {
  from {
    transform: perspective(800px) rotateX(-12deg);
  }
  to {
    transform: none;
  }
}
@keyframes float-up {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1.1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-24px);
  }
}

@media (max-width: 40rem) {
  .term {
    grid-template-columns: 1fr;
  }
  .today-stat {
    padding-inline-end: var(--space-3);
    margin-inline-end: var(--space-3);
  }
  .fund-map {
    grid-template-columns: 1fr auto 0.8fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .option.is-right,
  .option.is-wrong,
  .flashcard.is-flipped,
  .xp-burst,
  .seg {
    animation: none;
    transition: none;
  }
}

.badge,
.chip {
  border-radius: var(--radius);
}

/* ---------- sign in ---------- */
.auth {
  max-width: 28rem;
  margin: var(--space-6) auto 0;
  width: 100%;
  border-top: 4px solid var(--brand);
}
.auth h1 {
  margin: 0;
}
.auth-msg {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
}
.auth-msg:empty {
  display: none;
}

/* ---------- inbox ---------- */
.inbox-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-4);
}
.dropzone {
  display: grid;
  justify-items: center;
  gap: var(--space-1);
  padding: var(--space-7) var(--space-4);
  border: 2px dashed var(--border-strong);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.dropzone:hover,
.dropzone.is-over,
.dropzone:focus-within {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.dropzone-big {
  font-size: var(--text-3xl);
  line-height: 1;
  color: var(--brand);
}
.upload-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.upload-list:empty {
  display: none;
}
.upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8rem 9rem 4.5rem;
  align-items: center;
  gap: var(--space-3);
}
@media (max-width: 40rem) {
  .upload {
    grid-template-columns: minmax(0, 1fr) 5rem;
  }
  .upload-size {
    display: none;
  }
}
.upload-summary {
  display: grid;
  gap: var(--space-1);
}
.upload-summary:empty {
  display: none;
}
.upload-summary-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: baseline;
  justify-content: space-between;
}
.upload-summary progress {
  width: 100%;
  height: 0.5rem;
  accent-color: var(--brand);
}
.upload-done {
  color: var(--success);
}
.upload progress {
  width: 100%;
  accent-color: var(--brand);
}
.upload-error {
  color: var(--danger);
}
.paste summary {
  cursor: pointer;
  font-weight: 600;
}
.paste form {
  margin-top: var(--space-3);
}
.h-section {
  font-size: var(--text-xl);
  margin: 0;
}
.count {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-muted);
  margin-inline-start: var(--space-1);
}
.inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.inbox-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.inbox-item:last-child {
  border-bottom: 0;
}
.inbox-kind {
  flex: none;
  width: 3rem;
  padding: var(--space-2) 0;
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brand);
  border: 1px solid var(--brand-border);
}
.inbox-title {
  overflow-wrap: anywhere;
}
.inbox-actions {
  flex: none;
}
@media (max-width: 40rem) {
  .inbox-item {
    flex-wrap: wrap;
  }
  .inbox-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .upload {
    grid-template-columns: minmax(0, 1fr) 5rem 3.5rem;
  }
}

/* ---------- scores ---------- */
.score-subject {
  gap: var(--space-3);
}
.score-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  border-top: 4px solid var(--text);
  padding-top: var(--space-3);
}
.score-head h2 {
  margin: 0;
}
.score-head p {
  margin: 0;
}
.score-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.score-row {
  display: grid;
  grid-template-columns: minmax(12rem, 2fr) minmax(8rem, 1.2fr) 4.5rem 6.5rem minmax(10rem, 1.3fr);
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.score-row:last-child {
  border-bottom: 0;
}
.score-row.depth-0 {
  background: var(--surface-2);
}
.score-row.depth-0 .score-topic {
  font-weight: 750;
}
.score-row.depth-1 .score-topic {
  padding-inline-start: var(--space-4);
}
.score-row.depth-2 .score-topic,
.score-row.depth-3 .score-topic {
  padding-inline-start: var(--space-6);
  font-size: var(--text-sm);
}
.score-topic {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  text-decoration: none;
}
.score-topic:hover {
  color: var(--brand);
}
.score-known {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.score-known meter {
  flex: 1;
  min-width: 3rem;
  height: 0.5rem;
}
.score-next {
  justify-self: end;
}
.label-sm {
  display: none;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.score-good {
  color: var(--success);
}
.score-mid {
  color: var(--warning);
}
.score-low {
  color: var(--danger);
}
@media (max-width: 52rem) {
  .score-row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-2) var(--space-3);
  }
  .score-topic {
    grid-column: 1 / -1;
  }
  .score-row .score-topic {
    padding-inline-start: 0 !important;
  }
  .score-next {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .label-sm {
    display: block;
  }
  .score-known,
  .score-acc,
  .score-last {
    display: grid;
    gap: var(--space-1);
  }
}

/* phone header: logo only, so every nav link fits */
@media (max-width: 30rem) {
  #brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .app-header-inner {
    gap: var(--space-3);
  }
  .nav a {
    padding-inline: var(--space-1);
  }
  /* XP is on Today; the header needs the room for its links */
  .xp-pill {
    display: none;
  }
}

/* ---------- deadlines ---------- */
.deadline-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.deadline {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.deadline:last-child {
  border-bottom: 0;
}
.deadline.is-done {
  opacity: 0.6;
}
.deadline-title {
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 650;
}
a.deadline-title:hover {
  color: var(--brand);
}
.deadline-actions {
  flex: none;
}
.date-block {
  flex: none;
  display: grid;
  justify-items: center;
  width: 3.25rem;
  padding: var(--space-1) 0;
  border-top: 3px solid var(--brand);
  background: var(--surface-2);
  line-height: 1.1;
}
.date-day {
  font-size: var(--text-xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.date-month {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.dl-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--space-3);
  align-items: end;
  margin-top: var(--space-3);
}
@media (max-width: 40rem) {
  .deadline {
    flex-wrap: wrap;
    padding-inline: var(--space-4);
  }
  .deadline-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ---------- ask ---------- */
.chat {
  max-width: 50rem;
}
.chat-scope .select {
  width: auto;
}
.msgs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}
.msg p {
  margin: 0 0 var(--space-2);
}
.msg p:last-child {
  margin-bottom: 0;
}
.msg-user {
  justify-self: end;
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  background: var(--brand-soft);
  border-inline-end: 3px solid var(--brand);
}
.msg-tutor {
  padding: var(--space-4);
  border-inline-start: 3px solid var(--text);
  background: var(--surface-2);
}
.msg-tutor .beyond {
  font-style: italic;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-strong);
  padding-top: var(--space-2);
}
.cite {
  font-size: 0.7em;
  font-weight: 800;
  color: var(--brand);
  padding-inline: 0.15em;
}
.msg-sources {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
  display: grid;
  gap: var(--space-1);
}
.msg-verdict {
  gap: var(--space-2);
}
.badge.checking {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  align-items: end;
}

/* ---------- general diagrams: explorer, flow, compare, chart ---------- */
.ex-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-3) var(--space-5);
}
.ex-val {
  margin-inline-start: var(--space-2);
  font-variant-numeric: tabular-nums;
  color: var(--brand);
}
.ex-chart {
  width: 100%;
  height: auto;
  display: block;
}
.ex-chart .axis {
  stroke: var(--border-strong);
}
.ex-line {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 3;
  stroke-linejoin: round;
}
.ex-line.series-2 {
  stroke: var(--series-2);
}
.ex-line.series-3 {
  stroke: var(--series-3);
}
.ex-dot {
  fill: var(--series-3);
}
.ex-dot.series-1 {
  fill: var(--series-1);
}
.ex-dot.series-2 {
  fill: var(--series-2);
}
.flow {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  counter-reset: none;
}
.flow li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.flow li + li::before {
  content: '→';
  color: var(--text-muted);
}
.flow-step {
  font: inherit;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border-strong);
  border-radius: 0;
  cursor: pointer;
}
.flow-step[aria-pressed='true'] {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.flow-n {
  font-weight: 800;
  color: var(--brand);
}
.flow-detail h3 {
  margin: 0 0 var(--space-2);
}
.flow-detail p {
  margin: 0;
}
.compare tbody tr {
  cursor: pointer;
}
.compare tbody tr.is-on {
  background: var(--brand-soft);
}

/* ---------- coverage ---------- */
.score-head meter {
  width: 8rem;
  height: 0.6rem;
}
.cov-doc {
  padding-block: var(--space-2);
}
.chat-buttons {
  display: flex;
  gap: var(--space-2);
}
#talk[aria-pressed='true'] {
  border-color: var(--brand);
  color: var(--brand);
}
.session {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  padding: 0 var(--space-2);
  white-space: nowrap;
}

/* ---------- glossary groups, formula sheet, course hub ---------- */
.term-group {
  display: grid;
  gap: var(--space-2);
}
.term-topic {
  font-size: var(--text-lg);
  margin: var(--space-3) 0 0;
  padding-bottom: var(--space-1);
  border-bottom: 2px solid var(--text);
}
.formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: var(--space-3);
}
.formula h3 {
  margin: 0;
  font-size: var(--text-base);
}
.formula p {
  margin: 0;
}
.formula-display {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  padding: var(--space-3);
  background: var(--surface-2);
  border-inline-start: 3px solid var(--brand);
  overflow-wrap: anywhere;
}
.formula-symbols {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  font-size: var(--text-sm);
}
.formula-symbols div {
  display: grid;
  grid-template-columns: minmax(3rem, auto) 1fr;
  gap: var(--space-2);
}
.formula-symbols dt {
  font-family: var(--font-mono);
  font-weight: 700;
}
.formula-symbols dd {
  margin: 0;
}
.formula-example {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.formula {
  display: grid;
  gap: var(--space-3);
  align-content: start;
}
.guide-cta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-inline-start: 6px solid var(--brand);
  color: var(--text);
  text-decoration: none;
}
.guide-cta:hover {
  color: var(--text);
  border-color: var(--brand);
}
.guide-cta strong {
  font-size: var(--text-xl);
}
.hub h2 {
  margin: var(--space-3) 0 0;
}

/* ---------- Ask bubble ---------- */
.bubble-host {
  position: fixed;
  inset-inline-end: var(--space-4);
  bottom: var(--space-4);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
}
.bubble {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-full);
  border: 0;
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: grid;
  place-items: center;
  order: 2;
  transition: transform var(--duration) var(--ease-bounce);
}
.bubble:hover {
  transform: scale(1.06);
}
.bubble-panel {
  order: 1;
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(36rem, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  animation: rise var(--duration-slow) var(--ease) both;
}
.bubble-panel[hidden] {
  display: none;
}
.bubble-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
}
.bubble-msgs {
  flex: 1;
  overflow-y: auto;
  min-height: 6rem;
}
.bubble-panel .chat-form {
  grid-template-columns: 1fr;
}
.bubble-panel .chat-buttons {
  justify-content: flex-end;
}
@media (max-width: 40rem) {
  .bubble-host {
    inset-inline-end: var(--space-3);
    bottom: var(--space-3);
  }
  .bubble-panel {
    width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 6rem);
  }
}
@media (prefers-reduced-motion: reduce) {
  .bubble-panel {
    animation: none;
  }
}

/* ---------- guided tutor ---------- */
.guide {
  max-width: 64rem;
}
.guide-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-3);
}
.guide-toc {
  list-style: none;
  margin: 0;
  padding: var(--space-3);
  max-height: 22rem;
  overflow-y: auto;
  display: grid;
  gap: var(--space-1);
}
.guide-toc .btn {
  width: 100%;
  justify-content: flex-start;
  text-align: start;
  gap: var(--space-2);
}
.slide {
  min-height: 26rem;
  padding: var(--space-6);
  border-top: 4px solid var(--brand);
}
.slide-title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
}
.slide-text {
  font-size: var(--text-lg);
  margin: 0;
  max-width: 40rem;
}
.slide-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: var(--space-6);
  align-items: start;
}
.slide-diagram {
  margin: 0;
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-2);
}
.slide-points {
  margin: 0;
  padding-inline-start: 1.2rem;
  display: grid;
  gap: var(--space-2);
}
.slide-intro .lede {
  font-size: var(--text-xl);
}
.guide-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  position: sticky;
  bottom: 0;
  padding: var(--space-3) 0;
  background: var(--bg);
}
.guide-nav .btn:disabled {
  opacity: 0.45;
}
@media (max-width: 52rem) {
  .slide-split {
    grid-template-columns: 1fr;
  }
  .slide {
    padding: var(--space-4);
    min-height: 0;
  }
  #g-hint {
    display: none;
  }
}
.slide-intro .session,
.stack > .session {
  align-self: flex-start;
}

/* ---------- summary sheets ---------- */
.summary-sheet {
  display: grid;
  gap: var(--space-4);
  border-top: 4px solid var(--brand);
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}
.sheet-head h2 {
  margin: 0;
}
.big-idea {
  margin: 0;
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-xl);
  font-weight: 650;
  line-height: 1.4;
  padding: var(--space-4) var(--space-5);
  background: var(--brand-soft);
  border-inline-start: 4px solid var(--brand);
}
.sheet-body.has-picture {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: var(--space-5);
  align-items: start;
}
.takeaways {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: tk;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-3);
}
.has-picture .takeaways {
  grid-template-columns: 1fr;
}
.takeaways li {
  counter-increment: tk;
  position: relative;
  padding: var(--space-3) var(--space-3) var(--space-3) 2.6rem;
  background: var(--surface-2);
  border-top: 3px solid var(--series-1);
}
.takeaways li:nth-child(3n + 2) {
  border-top-color: var(--series-2);
}
.takeaways li:nth-child(3n + 3) {
  border-top-color: var(--gold);
}
.takeaways li::before {
  content: counter(tk);
  position: absolute;
  inset-inline-start: var(--space-3);
  top: var(--space-3);
  font-weight: 800;
  font-size: var(--text-lg);
  color: var(--brand);
}
.sheet-picture {
  margin: 0;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface-2);
}
.sheet-formulas {
  display: grid;
  gap: var(--space-2);
}
.sheet-formulas .formula-display {
  margin: 0;
  font-size: var(--text-base);
}
.sheet-terms {
  display: grid;
  gap: var(--space-2);
}
.term-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.term-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: var(--text-sm);
}
.term-chip summary {
  cursor: pointer;
  padding: var(--space-1) var(--space-3);
  font-weight: 650;
  list-style: none;
}
.term-chip summary::-webkit-details-marker {
  display: none;
}
.term-chip[open] {
  flex-basis: 100%;
  border-color: var(--brand);
}
.term-chip p {
  margin: 0;
  padding: 0 var(--space-3) var(--space-2);
}
@media (max-width: 52rem) {
  .sheet-body.has-picture {
    grid-template-columns: 1fr;
  }
}

/* ---------- interactive diagram extras ---------- */
.ex-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.ex-challenge:empty {
  display: none;
}
.ex-challenge {
  padding: var(--space-1) var(--space-3);
  background: var(--gold-soft);
  border-inline-start: 3px solid var(--gold);
}
.ex-won {
  color: var(--success);
}
.ex-delta {
  font-size: var(--text-xs);
  margin-inline-end: var(--space-2);
  animation: pop var(--duration-slow) var(--ease-bounce);
}
.ex-delta.up {
  color: var(--success);
}
.ex-delta.down {
  color: var(--danger);
}
.diagram-legend li.is-target {
  outline: 2px dashed var(--gold);
  outline-offset: 4px;
}
.flow-nav {
  gap: var(--space-2);
}
.cmp-hidden {
  font: inherit;
  font-weight: 800;
  width: 100%;
  min-height: 2.2rem;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  cursor: pointer;
}
.cmp-hidden:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.chart-hit {
  cursor: pointer;
  outline: none;
}
.chart-hit.is-on,
.chart-hit:focus-visible {
  stroke: var(--text);
  stroke-width: 2;
}
.chart-readout {
  margin: 0;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  min-height: 1.5em;
}
.chart-legend button[aria-pressed='false'] {
  opacity: 0.45;
  text-decoration: line-through;
}
@media (prefers-reduced-motion: reduce) {
  .ex-delta {
    animation: none;
  }
}

/* ---------- due: ticking, calendar, subject colours ---------- */
.tick {
  width: 1.3rem;
  height: 1.3rem;
  flex: none;
  accent-color: var(--success);
  cursor: pointer;
}
.tick-done {
  width: 1.3rem;
  flex: none;
  text-align: center;
  color: var(--success);
  font-weight: 800;
}
.deadline.is-ticked .deadline-title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.deadline.is-ticked {
  background: var(--success-soft);
}
.deadline.is-leaving {
  animation: fade-out 400ms var(--ease) forwards;
}
@keyframes fade-out {
  to {
    opacity: 0;
    transform: translateX(12px);
  }
}
.dl-group > summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: var(--space-3);
}
.dl-group > summary::-webkit-details-marker {
  display: none;
}
.dl-group > summary h2::before {
  content: '▾ ';
  color: var(--text-muted);
}
.dl-group:not([open]) > summary h2::before {
  content: '▸ ';
}
.subj-0 { --subj: var(--series-1); }
.subj-1 { --subj: var(--series-2); }
.subj-2 { --subj: var(--series-3); }
.subj-3 { --subj: var(--gold); }
.subj-4 { --subj: var(--mit-gray); }
.subj-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-inline-end: var(--space-1);
  background: var(--subj);
}
.cal {
  display: grid;
  gap: var(--space-3);
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-head h2 {
  margin: 0;
  font-size: var(--text-xl);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border);
}
.cal-dow {
  background: var(--surface-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--space-1) var(--space-2);
}
.cal-day {
  font: inherit;
  text-align: start;
  min-height: 5.5rem;
  padding: var(--space-1) var(--space-2);
  background: var(--surface);
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
  cursor: default;
  min-width: 0;
}
.cal-day.has-items {
  cursor: pointer;
}
.cal-day.has-items:hover {
  background: var(--brand-soft);
}
.cal-day.is-out {
  background: var(--surface-2);
  color: var(--text-muted);
}
.cal-day.is-today .cal-n {
  background: var(--brand);
  color: var(--on-brand);
  padding: 0 var(--space-1);
}
.cal-day.is-picked {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.cal-n {
  font-size: var(--text-sm);
  font-weight: 700;
  align-self: flex-start;
}
.cal-item {
  font-size: var(--text-xs);
  line-height: 1.25;
  padding: 1px var(--space-1);
  border-inline-start: 3px solid var(--subj);
  background: var(--surface-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-item.is-done {
  text-decoration: line-through;
  opacity: 0.55;
}
.cal-more {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
@media (max-width: 40rem) {
  .cal-day {
    min-height: 3rem;
    padding: 2px;
  }
  .cal-item {
    font-size: 0;
    height: 5px;
    padding: 0;
    border-inline-start: 0;
    background: var(--subj);
  }
}
@media (prefers-reduced-motion: reduce) {
  .deadline.is-leaving {
    animation: none;
    opacity: 0;
  }
}

/* ---------- subjects menu, foldable topic map ---------- */
.nav-menu {
  position: relative;
}
.nav-menu-btn {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 550;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: var(--space-2);
  cursor: pointer;
  white-space: nowrap;
}
.nav-menu-btn:hover,
.nav-menu-btn[aria-expanded='true'],
.nav-menu-btn.is-current {
  color: var(--text);
}
.nav-menu-btn.is-current {
  border-bottom-color: var(--brand);
}
.nav-menu-list {
  position: fixed;
  top: calc(var(--header-h) + 2px);
  z-index: 30;
  list-style: none;
  margin: 0;
  padding: var(--space-2);
  min-width: 18rem;
  max-width: calc(100vw - 2rem);
  box-shadow: var(--shadow-lg);
}
.nav-menu-list a {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  text-decoration: none;
}
.nav-menu-list a:hover {
  background: var(--brand-soft);
}
.nav-menu-code {
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--brand);
  min-width: 3.2rem;
}
.nav {
  overflow: visible;
}
.tree-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.tree-fold,
.tree-fold-space {
  width: 1.6rem;
  height: 1.6rem;
  flex: none;
}
.tree-fold {
  font: inherit;
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
}
.tree-fold:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.tree-children > .tree-node::before {
  top: 1.1rem;
}
@media (max-width: 30rem) {
  .nav-menu-btn {
    padding-inline: var(--space-1);
  }
}
@media (max-width: 40rem) {
  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mode-tile {
    padding: var(--space-3);
  }
}

/* ---------- On this page + folding ---------- */
.mode-layout {
  display: grid;
  gap: var(--space-5);
}
.mode-aside:empty {
  display: none;
}
@media (min-width: 60rem) {
  .mode-layout:has(.mode-aside:not(:empty)) {
    grid-template-columns: 15rem minmax(0, 1fr);
    align-items: start;
  }
  .mode-aside {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
    max-height: calc(100vh - var(--header-h) - var(--space-6));
    overflow-y: auto;
  }
}
.page-nav {
  padding: var(--space-3) var(--space-4);
  display: grid;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.page-nav summary {
  cursor: pointer;
}
.page-nav-tools {
  gap: var(--space-1);
}
.page-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.page-nav a {
  display: block;
  padding: 3px var(--space-2);
  color: var(--text-muted);
  text-decoration: none;
  border-inline-start: 2px solid var(--border);
}
.page-nav a:hover {
  color: var(--text);
  border-inline-start-color: var(--brand);
}
.page-nav-group {
  display: grid;
  gap: 2px;
  margin-top: var(--space-2);
}
.page-nav-topic {
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
}
.section-fold {
  font: inherit;
  font-size: var(--text-base);
  line-height: 1;
  width: 1.6rem;
  height: 1.6rem;
  flex: none;
  color: var(--text-muted);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  margin-inline-end: var(--space-2);
  vertical-align: middle;
}
.section-fold:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
header.fold-keep {
  position: relative;
}
.is-folded > :not(.fold-keep) {
  display: none !important;
}
.is-folded {
  padding-block: var(--space-3);
}
.fold-keep h2,
.fold-keep h3,
h2.fold-keep {
  display: flex;
  align-items: center;
}
.flash {
  animation: flash 1.2s var(--ease);
}
@keyframes flash {
  0% {
    box-shadow: 0 0 0 3px var(--brand-border);
  }
  100% {
    box-shadow: 0 0 0 3px transparent;
  }
}
@media (prefers-reduced-motion: reduce) {
  .flash {
    animation: none;
  }
}

/* Way2Excellence mark: rising bars in MIT red, one in MIT gray (in the spirit of MIT's bar logo, not a copy). */
.logo-red {
  fill: var(--brand);
}
.logo-gray {
  fill: var(--mit-gray);
}
.brand-logo {
  width: 1.6rem;
  height: 1.6rem;
}

/* "In plain words": the tutor's easier wording. Deliberately quiet: a soft tint, a small label, no alarm colour. */
.plain {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-size: 0.97em;
  line-height: 1.55;
  max-width: 46rem;
}
.plain-label {
  display: inline-block;
  margin-inline-end: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}
.worked-answer .plain {
  margin-top: var(--space-2);
  background: transparent;
  padding: 0;
}

/* ---------- inbox: Canvas check ---------- */
.canvas-check .h-section {
  margin: 0;
}
.cc-ok {
  color: var(--success);
}
.cc-course summary {
  cursor: pointer;
  padding: var(--space-2) 0;
}
.cc-list {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  display: grid;
  gap: var(--space-1);
}
.cc-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
}
.cc-state {
  flex: none;
  color: var(--text-muted);
}

/* ---------- next class prep ---------- */
.prep {
  display: grid;
  gap: var(--space-3);
  border-inline-start: 4px solid var(--series-1);
}
.prep h2 {
  margin: 0;
}
.prep-classes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}
.prep-class {
  display: grid;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.prep-class:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.prep-class-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: baseline;
}
.prep-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-inline-end: var(--space-1);
}
.prep-do {
  margin: 0;
}
.prep-recap {
  display: grid;
  gap: var(--space-1);
}
.chip-link {
  text-decoration: none;
  color: var(--text);
}
.chip-link:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.prep-due {
  margin: 0;
  padding-inline-start: 1.1rem;
}
.material-note {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: baseline;
  padding: var(--space-3) var(--space-4);
  background: var(--sky-soft);
  border-inline-start: 3px solid var(--sky);
}

/* ---------- explain it back ---------- */
.tb {
  max-width: 46rem;
}
.tb-score {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.tb-list ul {
  margin: var(--space-1) 0 0;
  padding-inline-start: 1.2rem;
  display: grid;
  gap: var(--space-1);
}
.tb-list {
  padding: var(--space-3) var(--space-4);
  border-inline-start: 3px solid var(--border-strong);
  background: var(--surface-2);
}
.tb-right {
  border-color: var(--success);
}
.tb-missing {
  border-color: var(--gold);
}
.tb-wrong {
  border-color: var(--warning);
}
.tb-model summary {
  cursor: pointer;
  font-weight: 600;
}

/* ---------- phone polish ---------- */
@media (max-width: 40rem) {
  .page-head {
    flex-wrap: wrap;
    gap: var(--space-3);
  }
  .tree-link {
    flex-wrap: wrap;
    min-width: 0;
    row-gap: var(--space-1);
  }
  .tree-title {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .tree-fold,
  .tree-fold-space,
  .section-fold {
    width: 2.25rem;
    height: 2.25rem;
  }
  .guide-nav .btn-lg {
    padding-inline: var(--space-4);
  }
  .cal-head h2 {
    font-size: var(--text-lg);
  }
}
/* Keep the Ask bubble clear of the guided tutor's Back/Next bar. */
body:has(.guide-nav) .bubble-host {
  bottom: calc(var(--space-4) + 4.5rem);
}

/* ---------- teacher demos ---------- */
.demo-frame {
  width: 100%;
  height: min(80vh, 56rem);
  border: 1px solid var(--border-strong);
  background: var(--surface);
}
.demo-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-3);
}
.demo-link {
  align-self: flex-start;
  font-weight: 650;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--brand-border);
  background: var(--brand-soft);
  color: var(--text);
  text-decoration: none;
}
.demo-link:hover {
  border-color: var(--brand);
  color: var(--brand);
}
