/* ─────────────────────────────────────────────────────────────────────────
   Versine — an arcade HUD, not a worksheet.
   Deep navy field, hairline grid, one hot accent per meaning:
   coral = first term, cyan = second, violet = third, gold = the answer.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg:          #080f1c;
  --bg-2:        #0c1526;
  --surface:     #101c31;
  --surface-2:   #17263f;
  --line:        #223550;
  --line-soft:   #1a2b45;

  --text:        #eaf2ff;
  --muted:       #7d92b4;
  --dim:         #55688a;

  --hot:         #ff5f6d;
  --cool:        #35d6ff;
  --gold:        #ffd93d;
  --grow:        #4ade80;
  --violet:      #c084fc;

  --vec-1: var(--hot);
  --vec-2: var(--cool);
  --vec-3: var(--violet);
  --result: var(--gold);

  --axis:        #2b4062;
  --axis-major:  #47628d;
  --axis-zero:   #7d92b4;

  --radius:      3px 18px 3px 18px;
  --radius-sm:   2px 10px 2px 10px;

  --display: 'Chakra Petch', 'Nunito', system-ui, sans-serif;
  --body:    'Nunito', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Atmosphere: two cold glows and a hairline grid. */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 15% 0%,   rgba(53,214,255,.10), transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(255,95,109,.09), transparent 60%);
}
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image:
    repeating-linear-gradient(0deg,   var(--line-soft) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg,  var(--line-soft) 0 1px, transparent 1px 44px);
  mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, #000 20%, transparent 80%);
}

.app {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: clamp(12px, 3vw, 28px);
  padding-bottom: max(env(safe-area-inset-bottom), 16px);
  gap: 18px;
}

/* ── Typography ───────────────────────────────────────────────────────── */
h1, h2, h3, .display { font-family: var(--display); font-weight: 700; letter-spacing: .01em; }

.wordmark {
  font-family: var(--display);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: .5ch;
}
.wordmark b { color: var(--cool); font-weight: 700; }
.wordmark .slash { color: var(--hot); }

.eyebrow {
  font-family: var(--display);
  font-size: .7rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  /* --dim is 3:1 on the cards, too faint for text this small. */
  color: var(--muted);
}

.muted { color: var(--muted); }
.tiny  { font-size: .8rem; }

/* ── Shell ────────────────────────────────────────────────────────────── */
.shell { width: 100%; max-width: 860px; display: flex; flex-direction: column; gap: 18px; }
.shell--wide { max-width: 1100px; }

.topbar {
  width: 100%; max-width: 860px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar--wide { max-width: 1100px; }

.whoami { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 1rem;
  color: var(--bg); background: var(--accent, var(--cool));
}
.avatar--lg { width: 56px; height: 56px; flex-basis: 56px; font-size: 1.6rem; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 24px);
}
.card--flush { padding: 0; overflow: hidden; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--display);
  font-size: .95rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 12px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, color .15s;
}
.btn:hover  { border-color: var(--cool); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--cool), #1aa9d8);
  border-color: transparent; color: #04121d;
  box-shadow: 0 0 0 1px rgba(53,214,255,.4), 0 6px 24px -8px rgba(53,214,255,.6);
}
.btn--primary:hover { color: #04121d; filter: brightness(1.08); }

.btn--go {
  background: linear-gradient(135deg, var(--grow), #22b35f);
  border-color: transparent; color: #04180d;
  box-shadow: 0 0 0 1px rgba(74,222,128,.4), 0 6px 24px -8px rgba(74,222,128,.6);
}
.btn--go:hover { color: #04180d; filter: brightness(1.08); }

.btn--ghost { background: transparent; }
.btn--sm { padding: 8px 14px; font-size: .78rem; }
.btn--block { width: 100%; }
.btn--danger:hover { border-color: var(--hot); color: var(--hot); }

/* ── HUD ──────────────────────────────────────────────────────────────── */
.hud { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.stat {
  flex: 1 1 84px; min-width: 84px; max-width: 168px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  text-align: center;
}
.stat__label {
  font-family: var(--display);
  font-size: .62rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--dim);
}
.stat__value {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.3rem, 4vw, 1.7rem); line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat--time  .stat__value { color: var(--gold); }
.stat--score .stat__value { color: var(--grow); }
.stat--streak .stat__value { color: var(--cool); }
.stat--lives .stat__value { color: var(--hot); letter-spacing: .1em; }
.stat.is-urgent .stat__value { color: var(--hot); animation: throb .6s ease-in-out infinite alternate; }

@keyframes throb { from { transform: scale(1); } to { transform: scale(1.09); } }

.timebar { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.timebar__fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--grow), var(--gold));
  transition: width 1s linear;
}
.timebar__fill.is-urgent { background: linear-gradient(90deg, var(--hot), var(--gold)); }

/* ── The problem ──────────────────────────────────────────────────────── */
.problem {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(2rem, 9vw, 3.4rem);
  line-height: 1.1;
  text-align: center;
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: .28em;
  min-height: 1.4em;
  font-variant-numeric: tabular-nums;
}
/* An unbreakable piece too wide for the card: see renderPrompt. */
.problem.is-long { font-size: clamp(1.6rem, 6.5vw, 2.5rem); }
.problem.is-longer { font-size: clamp(1.3rem, 5vw, 1.95rem); }
.problem .t1 { color: var(--vec-1); }
.problem .t2 { color: var(--vec-2); }
.problem .t3 { color: var(--vec-3); }
.problem .op { color: var(--dim); }
.problem .q  { color: var(--result); }
.problem .a  { color: var(--result); animation: pop .3s ease-out; }

@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.retry-flag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--display); font-size: .66rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--violet); border: 1px solid rgba(192,132,252,.35);
  border-radius: 99px; padding: 3px 10px; align-self: center;
}

/* ── Number line ──────────────────────────────────────────────────────── */
.nl { width: 100%; height: auto; display: block; overflow: visible; }
.nl-label  { font-family: var(--body); font-size: 13px; font-weight: 700; fill: var(--axis-major); }
.nl-label--zero { fill: var(--axis-zero); }
.nl-vec    { font-family: var(--display); font-size: 15px; font-weight: 700; }
.nl-answer { font-family: var(--display); font-size: 15px; font-weight: 700; fill: var(--result); }

@keyframes nl-draw { to { stroke-dashoffset: 0; } }
.nl-pop { animation: pop .3s .1s backwards ease-out; }

/* ── Answer input ─────────────────────────────────────────────────────── */
.answer-row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
/* A list of choices takes the whole row, with Check and Why? beneath it.
   Short labels ("Part A") otherwise left room for the buttons to wrap up
   beside the list, half-way down it. */
.answer-slot:has(.choices) { flex-basis: 100%; display: flex; justify-content: center; }

.answer {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  width: 5ch; text-align: center;
  padding: 8px 10px;
  color: var(--text);
  background: #050b16;
  border: 2px solid var(--line);
  border-bottom-color: var(--cool);
  border-radius: var(--radius-sm);
  outline: none;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.5);
  transition: border-color .15s, box-shadow .15s;
}
.answer::placeholder { color: var(--dim); opacity: .6; }
.answer:focus { border-color: var(--cool); box-shadow: 0 0 0 3px rgba(53,214,255,.15); }
.answer.is-wrong { border-color: var(--hot); animation: shake .34s ease; }
.answer.is-right { border-color: var(--grow); box-shadow: 0 0 0 3px rgba(74,222,128,.18); }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-7px); } 75% { transform: translateX(7px); }
}

.feedback {
  text-align: center; min-height: 1.6em;
  font-family: var(--display); font-weight: 600; font-size: 1rem;
  letter-spacing: .04em;
}
.feedback.is-correct { color: var(--grow); }
.feedback.is-wrong   { color: var(--hot); }
.feedback.is-info    { color: var(--muted); }


/* ── Grids and lists ──────────────────────────────────────────────────── */
.grid { display: grid; gap: 12px; }
.grid--skills { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid--modes  { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--people { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.tile {
  text-align: left; width: 100%;
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer; color: var(--text);
  font-family: var(--body);
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s, transform .12s, background .15s;
}
.tile:hover { border-color: var(--cool); transform: translateY(-2px); }
.tile:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.tile__head { display: flex; align-items: center; gap: 10px; }
.tile__glyph {
  width: 38px; height: 38px; flex: 0 0 38px;
  display: grid; place-items: center;
  font-family: var(--display); font-size: 1.3rem; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--cool);
}
.tile__name { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.tile__blurb { color: var(--muted); font-size: .86rem; line-height: 1.45; }

.tile--locked .tile__glyph { color: var(--dim); }

/* Tier pips */
.pips { display: flex; gap: 4px; }
.pip {
  height: 5px; flex: 1; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.pip.is-open     { background: var(--line); }
.pip.is-mastered { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 8px -2px var(--gold); }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: none; border-left: 0; border-right: 0; border-top: 0;
  color: var(--text); font-family: var(--body); font-size: .95rem;
  width: 100%; text-align: left; cursor: pointer;
  transition: background .12s;
}
.row:last-child { border-bottom: 0; }
.row:hover:not(:disabled) { background: var(--surface-2); }
.row:disabled { opacity: .4; cursor: not-allowed; }
.row__n {
  width: 26px; height: 26px; flex: 0 0 26px;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: .82rem;
  border-radius: 50%; border: 1px solid var(--line); color: var(--muted);
}
.row.is-mastered .row__n { border-color: var(--gold); color: var(--gold); }
.row__main { flex: 1; min-width: 0; }
.row__title { font-family: var(--display); font-weight: 600; }
.row__sub { color: var(--muted); font-size: .82rem; }
.row__right { font-family: var(--display); font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── XP bar ───────────────────────────────────────────────────────────── */
.xp { display: flex; align-items: center; gap: 10px; }
.xp__level {
  font-family: var(--display); font-weight: 700; font-size: .8rem;
  letter-spacing: .1em; color: var(--gold);
}
.xp__track { flex: 1; height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.xp__fill { height: 100%; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width .6s ease-out; }

/* ── Summary ──────────────────────────────────────────────────────────── */
.summary { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.summary__verdict { font-family: var(--display); font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 700; }
.summary__verdict.is-pass { color: var(--grow); }
.summary__verdict.is-fail { color: var(--hot); }
.summary__score { font-family: var(--display); font-size: clamp(3rem, 12vw, 4.5rem); font-weight: 700; line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; }
.summary__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; width: 100%; }

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-family: var(--display); font-weight: 600; font-size: .9rem;
  letter-spacing: .04em;
}
.banner--gold   { background: rgba(255,217,61,.1);  border: 1px solid rgba(255,217,61,.4);  color: var(--gold); }
.banner--violet { background: rgba(192,132,252,.1); border: 1px solid rgba(192,132,252,.4); color: var(--violet); }
.banner--cool   { background: rgba(53,214,255,.1);  border: 1px solid rgba(53,214,255,.4);  color: var(--cool); }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-family: var(--display); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.input {
  font-family: var(--body); font-size: 1rem;
  padding: 11px 14px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); outline: none;
}
.input:focus { border-color: var(--cool); }

/* PIN entry */
.pin-input {
  width: 5ch; letter-spacing: .3em; text-align: center;
  font-size: clamp(1.5rem, 5vw, 2rem);
}
.pin-input.is-wrong { border-color: var(--hot); animation: shake .34s ease; }

/* ── Teacher console ──────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  font-family: var(--display); font-size: .66rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--display); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.meter__fill { height: 100%; border-radius: 99px; }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 34px; }
.spark__bar { flex: 1; min-width: 3px; background: var(--cool); border-radius: 1px 1px 0 0; opacity: .8; }


/* ── Utility ──────────────────────────────────────────────────────────── */
.stack   { display: flex; flex-direction: column; gap: 14px; }
.stack--sm { gap: 8px; }
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.center { text-align: center; }
.grow { flex: 1; }
.hidden { display: none !important; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--display); font-size: .74rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 6px 13px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--cool); color: var(--text); }
.chip.is-active { background: var(--cool); border-color: var(--cool); color: #04121d; }

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

/* Touch devices get larger hit areas than a mouse needs. */
@media (hover: none) and (pointer: coarse) {
  .btn--sm { padding: 13px 18px; }
  .row { padding: 16px; }
  .chip { padding: 10px 16px; }
}

/* ── Profile creation ─────────────────────────────────────────────────── */
.avatar { font-size: 1.1rem; }
.avatar--lg { font-size: 1.9rem; }
.avatar--ghost {
  background: transparent;
  border: 2px dashed var(--line);
  color: var(--muted);
  font-family: var(--display); font-weight: 700;
}
.tile--new { border-style: dashed; }
.tile--new:hover .avatar--ghost { border-color: var(--cool); color: var(--cool); }

.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.icon-opt {
  aspect-ratio: 1; font-size: 1.35rem; line-height: 1;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .12s, transform .1s, background .12s;
}
.icon-opt:hover { border-color: var(--cool); transform: translateY(-1px); }
.icon-opt.is-active { border-color: var(--cool); background: rgba(53,214,255,.16); }

.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-opt {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.color-opt:hover { transform: scale(1.08); }
.color-opt.is-active { border-color: var(--text); transform: scale(1.12); }

.pin-field { width: 9rem; letter-spacing: .28em; text-align: center; }
/* The wide tracking is for the digits, not the label -- it truncated it. */
.pin-field::placeholder { letter-spacing: normal; }

/* Block-level avatars need real centering; text-align won't move a grid box. */
.center > .avatar { margin-inline: auto; }
.identity-preview { width: 72px; height: 72px; flex-basis: 72px; font-size: 2.4rem; }

.btn--danger.is-armed { border-color: var(--hot); color: var(--hot); background: rgba(255,95,109,.12); }

/* ── Tier selection ───────────────────────────────────────────────────── */
.row.is-selected {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--cool);
}
.row.is-selected .row__n { border-color: var(--cool); color: var(--cool); }
.row.is-selected .row__title { color: #fff; }

/* ── Streak strip ─────────────────────────────────────────────────────── */
.streak-headline {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
}

.days { display: grid; grid-template-columns: repeat(28, 1fr); gap: 3px; }
.day {
  aspect-ratio: 1; border-radius: 2px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.day.is-on { border-color: transparent; }

/* The goal counter in a Time Trial. */
.stat--goal .stat__value { color: var(--violet); }

/* ── Breadcrumbs ──────────────────────────────────────────────────────── */
.crumbs {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-family: var(--display); font-size: .72rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
}
.crumb {
  /* The way back to the map mid-run: tall enough to hit with a thumb, the
     padding taken back out of the margin so the line does not grow. */
  background: none; border: 0; padding: 14px 0; margin: -14px 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--muted); cursor: pointer;
  transition: color .12s;
}
.crumb:hover { color: var(--cool); text-decoration: underline; }
.crumb.is-here { color: var(--text); cursor: default; }
.crumb-sep { color: var(--line); }

/* ── Daily completion ─────────────────────────────────────────────────── */
.tile--done { border-color: rgba(255,217,61,.45); }
.done-tick {
  flex: 0 0 26px; width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255,217,61,.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: var(--display); font-weight: 700; font-size: .85rem;
}

/* The last level is the finish line, so it reads differently to the rest. */
.row.is-last-level { border-top: 1px solid var(--line); }
.row.is-last-level .row__title { color: var(--gold); }
.row.is-last-level .row__n { border-color: var(--gold); color: var(--gold); }
.row.is-last-level .row__right { color: var(--gold); font-size: .78rem; }

.day.is-done {
  background: var(--gold);
  box-shadow: 0 0 6px -1px var(--gold);
  opacity: 1;
}

.banner span:first-child { font-size: 1rem; }

/* ── Visual slot ──────────────────────────────────────────────────────── */
.visual { width: 100%; }

/* ── Sign & size model (multiply / divide) ────────────────────────────── */
.signmodel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .signmodel { grid-template-columns: 1fr; } }

.sm-panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 12px 16px;
  text-align: center;
}
.sm-label {
  font-family: var(--display); font-size: .64rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
  margin-bottom: 10px;
}
.sm-row {
  display: flex; align-items: center; justify-content: center; gap: .3em;
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.3rem, 4.5vw, 1.8rem);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.sm-sign {
  display: inline-grid; place-items: center;
  min-width: 1.5em; height: 1.5em; padding: 0 .18em;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  line-height: 1;
}
.sm-sign.is-neg { color: var(--hot);  background: rgba(255,95,109,.12); }
.sm-sign.is-pos { color: var(--cool); background: rgba(53,214,255,.12); }
.sm-abs { color: var(--text); }
.sm-op, .sm-eq { color: var(--dim); }
.sm-out { min-width: 1.4em; }
.sm-out.is-open { color: var(--dim); }
.sm-out.is-neg  { color: var(--hot); }
.sm-out.is-pos  { color: var(--grow); }
.sm-out.is-size { color: var(--gold); }

.sm-result {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 14px;
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  animation: pop .3s ease-out;
}
.sm-result__value.is-neg { color: var(--hot); }
.sm-result__value.is-pos { color: var(--grow); }
.sm-verdict {
  display: inline-grid; place-items: center;
  width: 1.3em; height: 1.3em; border-radius: 50%;
  font-size: .7em; color: var(--bg);
}
.sm-verdict.is-ok  { background: var(--grow); }
.sm-verdict.is-bad { background: var(--hot); }

/* ── Page header with back button ─────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; gap: 14px; }
.page-head__text { min-width: 0; }
.btn--back { flex: 0 0 auto; margin-top: 4px; }
.btn--back:hover { border-color: var(--cool); }

/* A row that leads somewhere gets a chevron. */
.row__go { color: var(--dim); font-size: 1.4rem; line-height: 1; flex: 0 0 auto; }
.row:hover:not(:disabled) .row__go { color: var(--cool); transform: translateX(2px); }
.row__go { transition: color .12s, transform .12s; }

/* ── Mode cards (their own page now) ──────────────────────────────────── */
.tile--mode { gap: 10px; }
.tile__cta {
  margin-top: auto; align-self: flex-start;
  font-family: var(--display); font-size: .75rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--cool);
}
.tile--mode:hover .tile__cta { color: #fff; }

/* ── Countdown ────────────────────────────────────────────────────────── */
.card { position: relative; }
.countdown {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  background: linear-gradient(160deg, rgba(16,28,49,.97), rgba(8,15,28,.99));
  border-radius: var(--radius);
}
.countdown__label {
  font-family: var(--display); font-size: .72rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--dim);
}
.countdown__num {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(4rem, 18vw, 7rem); line-height: 1;
  color: var(--cool);
  font-variant-numeric: tabular-nums;
}
.countdown__num.is-pulse { animation: count-pop .8s ease-out; }
.countdown__num.is-go { color: var(--grow); animation: count-go .45s ease-out; }
.countdown__hint { font-size: .85rem; color: var(--muted); }

@keyframes count-pop {
  0%   { transform: scale(1.5); opacity: 0; }
  35%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(.92); opacity: .65; }
}
@keyframes count-go {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.btn--ok { min-width: 180px; }

/* A failed trial gets two ways on: straight back in, or out to the levels. */
.summary__actions { display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* ── Pace by level (calibration instrument) ───────────────────────────── */
.levels { display: flex; flex-direction: column; gap: 8px; }

.level-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.6fr) repeat(3, minmax(78px, .8fr)) minmax(110px, 1.2fr) auto;
  gap: 14px; align-items: center;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
@media (max-width: 900px) {
  .level-row { grid-template-columns: 1fr 1fr 1fr; }
  .level-row__name { grid-column: 1 / -1; }
  .level-row__trend { grid-column: 1 / -1; }
}

.metric__label {
  font-family: var(--display); font-size: .58rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
}
.metric__value {
  font-family: var(--display); font-weight: 700; font-size: 1.05rem;
  font-variant-numeric: tabular-nums; line-height: 1.3;
}
.metric__sub { font-size: .7rem; color: var(--dim); font-variant-numeric: tabular-nums; }

/* Bars are median solve time per day; the dashed line is the required pace. */
.pace-spark {
  position: relative;
  display: flex; align-items: flex-end; gap: 2px;
  height: 38px; margin-top: 4px;
  border-bottom: 1px solid var(--line);
}
.pace-spark__bar { flex: 1; min-width: 3px; border-radius: 1px 1px 0 0; opacity: .85; }
.pace-spark__line {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 1px dashed var(--cool); opacity: .75; pointer-events: none;
}

.verdict {
  font-family: var(--display); font-size: .64rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 99px; white-space: nowrap;
  border: 1px solid currentColor;
}
.verdict--good { color: var(--grow);   background: rgba(74,222,128,.1); }
.verdict--ok   { color: var(--cool);   background: rgba(53,214,255,.1); }
.verdict--warn { color: var(--gold);   background: rgba(255,217,61,.1); }
.verdict--bad  { color: var(--hot);    background: rgba(255,95,109,.1); }
.verdict--idle { color: var(--dim);    background: transparent; }


/* ── Dependency hints (soft, never a gate) ────────────────────────────── */
.builds-on { display: flex; align-items: center; gap: 8px; }
.builds-on__label {
  font-family: var(--display); font-size: .58rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
  border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px;
}
.row__leans {
  font-size: .72rem; color: var(--violet); opacity: .75; margin-top: 3px;
}

/* ── Level breakdown ──────────────────────────────────────────────────── */
.contribs { display: flex; flex-direction: column; gap: 6px; }
.contrib {
  display: grid;
  grid-template-columns: minmax(130px, 1.4fr) minmax(60px, 1fr) 62px minmax(120px, 1.2fr);
  gap: 12px; align-items: center;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
@media (max-width: 640px) {
  .contrib { grid-template-columns: 1fr auto; }
  .contrib__bar { grid-column: 1 / -1; }
  .contrib__why { grid-column: 1 / -1; }
}
.contrib__bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.contrib__fill { height: 100%; border-radius: 99px; transition: width .4s ease-out; }
.contrib__value {
  font-family: var(--display); font-weight: 700; font-size: .95rem;
  color: var(--grow); text-align: right; font-variant-numeric: tabular-nums;
}
.contrib__why { font-size: .74rem; color: var(--dim); }

/* Review — a finished skill due for another pass. Advisory only: it never
   lowers the Level and never closes anything. Violet, the color every
   review prompt already used, so it reads as an invitation, not a warning. */
.badge-review {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--violet);
  border: 1px solid currentColor;
}
.review-offer { border-color: rgba(192,132,252,.4); background: rgba(192,132,252,.08); }
.review-offer .eyebrow { color: var(--violet); }
.review-offer__name { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.review-offer__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
/* The teacher's review summary: label over value, wrapping on a phone. */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 18px; margin-top: 8px; }
.fact__value { font-size: .9rem; margin-top: 2px; }

/* Where a Time Trial clock came from. */
.clock-note { font-size: .72rem; color: var(--dim); line-height: 1.45; }
.tile--locked { opacity: .55; cursor: not-allowed; }

/* "New" — a skill that is open but has not had every level cleared yet. It
   marks what is worth starting, so it never appears on a locked tile. */
.badge-new {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--bg);
  background: var(--gold);
}
.tile--locked .tile__cta { color: var(--muted); }
/* What a skill is worth to the Level, in Level units. */
.tile__worth { margin-top: 8px; font-size: .74rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.tile__worth b { color: var(--gold); font-weight: 700; }
.tile__best { color: var(--muted); }

/* ── Fractions in the problem line ────────────────────────────────────── */
.frac-term {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; line-height: 1; margin: 0 .06em;
}
.frac-term .fn, .frac-term .fd { font-size: .62em; }
.frac-term .fl {
  display: block; width: 100%; min-width: 1.1em; height: 2px;
  background: currentColor; margin: .1em 0; border-radius: 2px;
}

/* ── Bar model ────────────────────────────────────────────────────────── */
.bar__line { display: block; width: 22px; height: 2px; background: var(--muted); margin: 3px 0; }
.bar__num, .bar__den { color: var(--text); }

.bar-verdict {
  display: inline-grid; place-items: center;
  width: 1.5em; height: 1.5em; border-radius: 50%;
  font-size: .8em; color: var(--bg);
}
.bar-verdict.is-ok { background: var(--grow); }
.bar-verdict.is-bad { background: var(--hot); }

.bar-hint { font-size: .8rem; color: var(--dim); text-align: center; margin-top: 4px; }

@media (max-width: 560px) {
  .bar__label { flex-basis: 38px; font-size: .9rem; }
  .bar { height: 28px; gap: 1px; }
  .bar-row { gap: 10px; }
}

/* ── Numerator over denominator input ─────────────────────────────────── */
.frac-input {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
}
.frac-box {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.2rem, 4.5vw, 1.6rem);
  width: 3.2ch; text-align: center;
  padding: 4px 6px;
  color: var(--text);
  background: #050b16;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
}
.frac-box:focus { border-color: var(--cool); box-shadow: 0 0 0 3px rgba(53,214,255,.15); }
.frac-box::placeholder { color: var(--dim); opacity: .5; }
.frac-box.is-right { border-color: var(--grow); }
.frac-box.is-wrong { border-color: var(--hot); animation: shake .34s ease; }
.frac-bar { align-self: stretch; height: 3px; background: var(--cool); border-radius: 2px; }

/* ── Ordered pair input ───────────────────────────────────────────────── */
.pair-input { display: inline-flex; align-items: center; gap: 4px; }
.pair-mark {
  font-family: var(--display); font-weight: 700; color: var(--muted);
  font-size: clamp(1.3rem, 5vw, 1.8rem);
}
.pair-box {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.2rem, 4.5vw, 1.6rem);
  width: 4.2ch; text-align: center; padding: 4px 6px;
  color: var(--text); background: #050b16;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  outline: none; font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
}
.pair-box:focus { border-color: var(--cool); box-shadow: 0 0 0 3px rgba(53,214,255,.15); }
.pair-box::placeholder { color: var(--dim); opacity: .5; }
.pair-box.is-right { border-color: var(--grow); }
.pair-box.is-wrong { border-color: var(--hot); animation: shake .34s ease; }

/* Sound toggle: an icon button, sized like the others but square. */
.sound-toggle { padding: 8px 12px; font-size: 1rem; line-height: 1; }

/* ── Area model (multiplying fractions) ───────────────────────────────── */
.area-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.area {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  width: min(280px, 62vw);
  aspect-ratio: 1;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.area__cell { transition: background .25s ease-out, box-shadow .25s; }
/* No grid lines while the question is open: the strips read as strips, and
   working out the overlap means imposing the grid yourself. */
.area__cell.is-a    { background: color-mix(in srgb, var(--vec-1) 34%, transparent); }
.area__cell.is-b    { background: color-mix(in srgb, var(--vec-2) 34%, transparent); }
.area__cell.is-both { background: color-mix(in srgb, var(--vec-1) 40%, var(--vec-2)); }

.area.is-revealed .area__cell { box-shadow: inset 0 0 0 1px rgba(255,255,255,.10); }
.area.is-revealed .area__cell.is-both {
  background: var(--result);
  box-shadow: inset 0 0 0 1px var(--bg);
}

.area-legend {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center;
  font-family: var(--display); font-size: .74rem; font-weight: 600;
  letter-spacing: .04em;
}
.area-key { display: inline-flex; align-items: center; gap: 6px; }
.area-key::before {
  content: ''; width: 12px; height: 12px; border-radius: 3px; background: currentColor;
}
.area-key.is-a { color: var(--vec-1); }
.area-key.is-b { color: var(--vec-2); }
.area-key.is-both { color: var(--result); }

/* ── Fits model (dividing fractions) ──────────────────────────────────── */

/* Mixed number input: a whole number beside a stacked fraction. */
.mixed-input { display: inline-flex; align-items: center; gap: 10px; }
.mixed-whole {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  width: 3ch; text-align: center; padding: 6px 8px;
  color: var(--text); background: #050b16;
  border: 2px solid var(--line); border-bottom-color: var(--cool);
  border-radius: var(--radius-sm); outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
}
.mixed-whole:focus { border-color: var(--cool); box-shadow: 0 0 0 3px rgba(53,214,255,.15); }
.mixed-whole::placeholder { color: var(--dim); opacity: .5; }
.mixed-whole.is-right { border-color: var(--grow); }
.mixed-whole.is-wrong { border-color: var(--hot); animation: shake .34s ease; }

/* A mixed number written inline in the problem line. */
.mixed-term { display: inline-flex; align-items: center; gap: .16em; }

/* ── Wholes model (improper fractions and mixed numbers) ──────────────── */
.wt {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(4, 9, 18, .82);
  backdrop-filter: blur(3px);
  animation: wt-in .18s ease-out;
}
@keyframes wt-in { from { opacity: 0; } to { opacity: 1; } }

.wt__panel {
  width: 100%; max-width: 640px;
  max-height: 92dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  padding: 22px;
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.8);
}

.problem--lesson { font-size: clamp(1.5rem, 6vw, 2.2rem); min-height: 0; }

.wt__caption {
  font-size: .98rem; line-height: 1.6; text-align: center;
  color: var(--text); min-height: 3.2em;
  display: flex; align-items: center; justify-content: center;
}

.wt__dots { display: flex; gap: 6px; justify-content: center; }
.wt__dot {
  width: 26px; height: 4px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background .2s;
}
.wt__dot.is-done { background: var(--line); }
.wt__dot.is-here { background: var(--cool); border-color: var(--cool); }

.lesson-prompt { align-items: center; }

/* ── Working, line by line (order of operations) ──────────────────────── */
.eval { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.eval-row {
  display: flex; align-items: baseline; gap: 14px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  animation: eval-in .22s ease-out;
}
@keyframes eval-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.eval-line {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.2rem, 4.5vw, 1.7rem);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.eval-rule {
  font-family: var(--display); font-size: .62rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--dim);
}
.eval-row.is-latest { border-color: var(--line); background: var(--bg-2); }
.eval-row.is-latest .eval-line { color: var(--text); }
.eval-row.is-answer .eval-line { color: var(--result); }

/* ── Table of values ─────────────────────────────────────────────────── */
.vtable { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.vtable table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
/* Headers are letters as often as words -- x, y, n, aₙ -- and a capital
   is a different letter, so they keep the case they were written in. */
.vtable th {
  font-family: var(--display); font-size: .74rem; font-weight: 600;
  letter-spacing: .06em; color: var(--dim);
  padding: 6px 18px; border-bottom: 1px solid var(--line);
}
.vtable td {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.05rem, 4vw, 1.4rem);
  text-align: center; padding: 6px 18px; color: var(--text);
}
.vtable tbody tr + tr td { border-top: 1px solid var(--line); }
.vtable td.is-blank { color: var(--gold); }
.vtable td.is-answer, .vtable th.is-answer { color: var(--result); }
.vtable-note { margin: 0; font-size: .85rem; color: var(--muted); text-align: center; }

/* ── Choice input (judgment questions) ───────────────────────────────── */
.choices { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 460px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--body); font-size: .95rem;
  cursor: pointer; outline: none;
  transition: border-color .15s, background .15s;
}
.choice:hover, .choice:focus { border-color: var(--cool); }
.choice.is-picked { border-color: var(--cool); background: rgba(53,214,255,.10); }
.choice.is-right  { border-color: var(--grow); background: rgba(74,222,128,.12); }
.choice.is-wrong  { border-color: var(--hot);  background: rgba(255,95,109,.12); animation: shake .34s ease; }
.choice__key {
  flex: 0 0 22px; height: 22px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 5px;
  font-family: var(--display); font-size: .72rem; font-weight: 700; color: var(--muted);
}
.choice.is-picked .choice__key { border-color: var(--cool); color: var(--cool); }
.choice__body { display: flex; flex-direction: column; gap: 2px; }
.choice__label { font-weight: 600; }
.choice__note { font-size: .78rem; color: var(--dim); line-height: 1.45; }

/* Strategy levels: about choosing a method, not running one. */
.row.is-strategy .row__n { border-color: var(--cool); color: var(--cool); }
.row__kind {
  margin-left: 8px; padding: 1px 7px;
  border: 1px solid var(--cool); border-radius: 99px;
  font-family: var(--body); font-size: .64rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--cool); vertical-align: 2px;
}
/* Situations are prose, not expressions — they should not be set in the
   oversized display face the math prompts use. */
.t1.situation {
  font-family: var(--body); font-size: 1.1rem; font-weight: 600;
  line-height: 1.5; max-width: 30ch; text-align: center;
}
/* In the text color, not the first term's red: a question set in the red
   of "Not quite" reads as an error before it has been answered. */
.problem .t1.situation { color: var(--text); }

/* A level whose library will not load — deliberately not a silent fallback. */
.load-failed { display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; padding: 24px 16px; }
.load-failed__title { font-family: var(--display); font-size: 1.1rem; color: var(--hot); }
.load-failed__body { font-size: .9rem; color: var(--muted); max-width: 34ch; line-height: 1.5; }
.load-failed__detail { font-family: ui-monospace, monospace; font-size: .72rem; color: var(--dim); }

/* A blank inside a fraction — "1/2 = ?/6" asks for one part, not the whole. */
.frac-term .is-blank { color: var(--gold); }
/* A term rendered by the prompt vocabulary that nothing knows how to draw.
   Visible on purpose: a silent gap would be found by a student, not by us. */
.is-unknown { color: var(--hot); }

/* ── Segments: a length cut into pieces, with some emphasized ─────────────
   One family replacing four. `.bar__cell` and `.equiv-cell` were identical
   rules under different names and `.whole-cell` was the same without the
   border; only the fine bars genuinely needed different drawing. The three
   skins carry the differences that are real -- how densely a bar is divided
   changes how wide its label needs to be and whether per-cell borders help or
   drown it. */
/* One row gap for every skin. Equivalence bars used to sit 10px apart and
   addition bars 8px, for no reason anyone recorded; two stacks of bars should
   breathe the same. */
.seg { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.seg__row { display: flex; align-items: center; gap: 14px; }
.seg__label {
  flex: 0 0 46px;
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--display); font-weight: 700; font-size: 1rem;
  line-height: 1.05; font-variant-numeric: tabular-nums;
}
.seg__tag {
  font-family: var(--display); font-weight: 400;
  font-size: .56rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim); margin-top: 3px;
}
.seg__stack { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.seg__stack .seg__bar { width: 100%; flex: none; }
.seg__bar {
  flex: 1; display: grid; height: 34px;
  grid-template-columns: repeat(var(--segments, 1), 1fr);
}
.seg__sep {
  font-family: var(--display); font-weight: 700; font-size: 1.2rem;
  color: var(--dim); padding-left: 18px;
  display: flex; align-items: center; gap: 10px;
}
.seg__sep.is-note {
  padding-left: 60px; font-weight: 600; font-size: .85rem; color: var(--cool);
}
.seg__answer {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--display); font-weight: 600; font-size: .95rem;
  color: var(--result); margin-top: 4px;
}
/* An answer whose value is picked out: the sentence recedes, the number does not. */
.seg__answer.has-value { color: var(--muted); }
.seg__value { color: var(--result); font-size: 1.3rem; }

/* Ruled: bordered cells. The default, readable to about twenty pieces. */
.seg--ruled .seg__bar { gap: 2px; }
.seg--ruled .seg__cell {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: background .25s ease-out;
}
.seg--ruled .seg__cell.is-filled { background: var(--tone); border-color: var(--tone); }
/* What subtraction takes away: outlined, not solid. */
.seg--ruled .seg__cell.is-ghost {
  background: transparent; border-color: var(--tone); border-style: dashed;
}

/* Plain: whole bars, where how many wholes there are matters more than how
   each one is divided, so the cells lose their borders and the bar gains one. */
.seg--plain .seg__label { flex-basis: 84px; text-align: right; align-items: flex-end;
  font-weight: 600; font-size: .78rem; color: var(--muted); }
.seg--plain .seg__bar {
  gap: 2px; height: 30px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 2px;
}
.seg--plain .seg__bar.is-solid {
  display: block; background: var(--tone); border-color: var(--tone);
}
.seg--plain .seg__cell { background: var(--surface-2); border-radius: 2px; transition: background .25s; }
.seg--plain .seg__cell.is-filled { background: var(--tone); }
.seg--plain .seg__answer { margin-top: 6px; }

/* Fine: up to forty pieces, where a border on each would be all you could see.
   Hairline dividers, and copies in alternating bands so they can be counted at
   a glance. */
.seg--fine .seg__label { flex-basis: 74px; }
.seg--fine .seg__bar {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
}
.seg--fine .seg__bar.is-slim { height: 24px; opacity: .9; }
.seg--fine .seg__cell { border-right: 1px solid rgba(255,255,255,.05); }
.seg--fine .seg__cell:last-child { border-right: 0; }
.seg--fine .seg__cell.is-filled { background: color-mix(in srgb, var(--vec-1) 70%, transparent); }
.seg--fine .seg__cell.is-unit   { background: color-mix(in srgb, var(--vec-2) 70%, transparent); }
.seg--fine .seg__cell.copy-0 { background: var(--vec-1); }
.seg--fine .seg__cell.copy-1 { background: color-mix(in srgb, var(--vec-1) 55%, var(--bg)); }
.seg--fine .seg__cell.starts-copy { border-left: 2px solid var(--bg); }

/* Narrow screens: the fine bars give up label width before bar width, since
   forty segments in less than a phone's width is already the tight case. */
@media (max-width: 560px) {
  .seg--fine .seg__label { flex-basis: 58px; font-size: .88rem; }
  .seg--fine .seg__bar { height: 28px; }
}

/* Powers and roots. The exponent is small and raised; the radical needs a bar
   over its body so where the root ends is unambiguous — √50 + 2 is not √52. */
.pow-term sup { font-size: .55em; vertical-align: super; margin-left: .04em; }
.pow-term sup.is-blank { color: var(--gold); }
.root-term { display: inline-flex; align-items: flex-start; }
.root-term__sign { font-size: 1.05em; line-height: 1; }
.root-term__body {
  border-top: 2px solid currentColor;
  padding: .04em .12em 0 .06em; margin-top: .08em;
}
.root-term .is-blank { color: var(--gold); }
/* A sum: the sign with its limits stacked, then what is added. */
.sigma-term { display: inline-flex; align-items: center; }
.sigma-term__op {
  display: inline-flex; flex-direction: column; align-items: center;
  line-height: 1; margin-right: .12em;
}
.sigma-term__sign { font-size: 1.5em; line-height: .95; }
.sigma-term__hi, .sigma-term__lo { font-size: .55em; white-space: nowrap; }

/* ── The x/y plane ────────────────────────────────────────────────────── */
.pl { display: block; max-width: 100%; height: auto; margin-inline: auto; overflow: visible; }
.pl__grid line { stroke: var(--line); stroke-width: 1; opacity: .45; }
.pl__polar circle { stroke: var(--line); stroke-width: 1; opacity: .45; }
.pl__polar line { opacity: .3; }
.pl__polar line.is-major { opacity: .6; }
.pl__axes line { stroke: var(--muted); stroke-width: 1.5; }
.pl__title { fill: var(--muted); font-size: 11px; font-weight: 600; }
.pl__ticks text {
  fill: var(--dim); font-family: var(--display); font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.pl__mark { --tone: var(--vec-1); }
.pl__mark circle { fill: var(--tone); stroke: var(--tone); stroke-width: 2; }
.pl__mark circle.is-open { fill: var(--bg); }
.pl__mark line, .pl__mark polyline { stroke: var(--tone); stroke-width: 2.5; stroke-linecap: round; }
.pl__mark line.is-dashed, .pl__mark polyline.is-dashed { stroke-dasharray: 7 6; stroke-linecap: butt; }
.pl__mark polygon.pl__region { fill: var(--tone); fill-opacity: .2; stroke: none; }
.pl__label { fill: var(--tone); font-family: var(--display); font-size: 11px; font-weight: 700; }
/* An angle's size, written inside the angle on a figure. */
.pl__text { font-size: 12.5px; }
/* Whatever arrives with the answer is drawn in the result color, so it reads
   as the reply rather than as more of the question. */
.pl__mark.is-answer { --tone: var(--result); }
.pl__mark.is-answer circle { animation: pop .3s ease-out; }
.pl__verdict { font-size: 13px; font-weight: 700; }
.pl__verdict.is-ok { fill: var(--grow); }
.pl__verdict.is-bad { fill: var(--hot); }

/* ── Sets on a number line ────────────────────────────────────────────── */
.iv { display: block; width: 100%; height: auto; overflow: visible; }
.iv__axis { stroke: var(--muted); stroke-width: 1.5; }
.iv__tick { stroke: var(--muted); stroke-width: 1; }
.iv__num {
  fill: var(--dim); font-family: var(--display); font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.iv__run { stroke-width: 5; stroke-linecap: butt; opacity: .9; }
.iv__dot { stroke-width: 2.5; }
.iv__label { font-family: var(--display); font-size: 12px; font-weight: 700; }
.iv__row.is-answer .iv__run, .iv__row.is-answer .iv__dot { animation: pop .3s ease-out; }
.iv__verdict { font-size: 13px; font-weight: 700; }
.iv__verdict.is-ok { fill: var(--grow); }
.iv__verdict.is-bad { fill: var(--hot); }

/* Variables are italic, as every mathematical typesetter has done since
   the eighteenth century — and it is what tells 2x from 2·x at a glance. */
.var-term { font-style: italic; }
/* Brackets drawn as their own spans so they can grow with what they hold. */
.group-term__b { color: var(--muted); }
/* What a bracket holds is spaced like the line around it, and stays on one line. */
.group-term { display: inline-flex; align-items: center; white-space: nowrap; }
.group-term > span:not(.group-term__b) { display: inline-flex; align-items: center; gap: .28em; }
/* The small index of a root that is not a square one. */
.root-term__index { font-size: .5em; align-self: flex-start; margin-right: -.24em; }

/* ── Free entry, with the input rendered back above the box ──────────────
   The strip sits above rather than below: the screen runs prompt, visual,
   input, keyboard, so anything under the box can end up under the keyboard. */
.free { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.free__preview {
  min-height: 34px; display: flex; align-items: center; justify-content: center;
  gap: .1em; padding: 2px 12px;
  font-family: var(--display); font-size: 1.3rem; color: var(--cool);
  border-bottom: 1px dashed var(--line);
  transition: opacity .15s;
}
.free__preview:empty { border-bottom-color: transparent; }
/* Mid-keystroke: what is shown is the last thing that parsed, so it is dimmed
   rather than removed. Nothing goes red until an answer is committed. */
.free__preview.is-stale { opacity: .45; }
.free__hint { font-size: .74rem; color: var(--hot); min-height: 1em; }
.free__keys { display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem .8rem; font-size: .74rem; color: var(--muted); margin-bottom: .35rem; }
.free__key { white-space: nowrap; }
.free__key kbd { font: inherit; font-family: ui-monospace, monospace; padding: 0 .3em; border: 1px solid var(--line); border-radius: .25em; color: var(--text); }
.answer--decimal { width: 9ch; max-width: 100%; }
.answer--free { width: 16ch; max-width: 100%; font-size: clamp(1.2rem, 4.5vw, 1.6rem); }

/* A product written without a sign is set without a gap. */
.juxt-term { display: inline-flex; align-items: center; gap: .06em; }
/* An equation inside a sentence: wraps around it, never through it. */
.math-term { display: inline-flex; align-items: center; gap: .28em; white-space: nowrap; }
.situation .tail, .math-term .tail { margin-left: -.18em; }

/* An expression answer is drawn from terms, and each term carries its own
   color — so the answer highlight has to reach inside it, or the reply is
   set in the same ink as the question. */
.problem .a, .problem .a * { color: var(--result); }

/* One accent per category, so a card says where it belongs before it is read. */
.tile.cat-number      { border-left: 3px solid color-mix(in srgb, var(--cool) 55%, transparent); }
.tile.cat-parts       { border-left: 3px solid color-mix(in srgb, var(--violet) 55%, transparent); }
.tile.cat-powers      { border-left: 3px solid color-mix(in srgb, var(--gold) 55%, transparent); }
.tile.cat-expressions { border-left: 3px solid color-mix(in srgb, var(--grow) 55%, transparent); }
.tile.cat-equations   { border-left: 3px solid color-mix(in srgb, var(--hot) 55%, transparent); }
.tile.cat-graphs      { border-left: 3px solid color-mix(in srgb, #5eead4 55%, transparent); }
.tile.cat-shape       { border-left: 3px solid color-mix(in srgb, #fb923c 55%, transparent); }
.tile.cat-trig        { border-left: 3px solid color-mix(in srgb, #f472b6 55%, transparent); }
.tile.cat-functions   { border-left: 3px solid color-mix(in srgb, #a3e635 55%, transparent); }
.tile.cat-chance      { border-left: 3px solid color-mix(in srgb, #94a3b8 55%, transparent); }

/* Finer categories, one accent each. Shared hues within a subject, so the
   territory reads before the group does. */
.tile.cat-integers    { border-left: 3px solid color-mix(in srgb, var(--cool) 55%, transparent); }
.tile.cat-fractions   { border-left: 3px solid color-mix(in srgb, var(--violet) 55%, transparent); }
.tile.cat-decimals    { border-left: 3px solid color-mix(in srgb, #a78bfa 55%, transparent); }
.tile.cat-factors     { border-left: 3px solid color-mix(in srgb, #38bdf8 55%, transparent); }
.tile.cat-expressions { border-left: 3px solid color-mix(in srgb, var(--grow) 55%, transparent); }
.tile.cat-equations   { border-left: 3px solid color-mix(in srgb, var(--hot) 55%, transparent); }
.tile.cat-sequences   { border-left: 3px solid color-mix(in srgb, #a3e635 55%, transparent); }
.tile.cat-coordinates { border-left: 3px solid color-mix(in srgb, #5eead4 55%, transparent); }
.tile.cat-angles      { border-left: 3px solid color-mix(in srgb, #2dd4bf 55%, transparent); }
.tile.cat-shapes      { border-left: 3px solid color-mix(in srgb, #fb923c 55%, transparent); }
.tile.cat-measure     { border-left: 3px solid color-mix(in srgb, #f59e0b 55%, transparent); }
.tile.cat-right-triangles { border-left: 3px solid color-mix(in srgb, #f472b6 55%, transparent); }
.tile.cat-unit-circle { border-left: 3px solid color-mix(in srgb, #ec4899 55%, transparent); }
.tile.cat-identities  { border-left: 3px solid color-mix(in srgb, #d946ef 55%, transparent); }
.tile.cat-probability { border-left: 3px solid color-mix(in srgb, #94a3b8 55%, transparent); }
.tile.cat-statistics  { border-left: 3px solid color-mix(in srgb, #cbd5e1 55%, transparent); }

/* On a touchscreen the small boxes are tapped, not tabbed between -- iOS's
   number pad has no / or comma -- so each is a full thumb's height. */
@media (pointer: coarse) {
  .frac-box, .pair-box, .mixed-whole { min-height: 44px; }
}

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

/* After a third miss, the way to the walkthrough is lit up. */
.btn.is-nudged { border-color: var(--cool); color: var(--cool); box-shadow: 0 0 0 3px rgba(53,214,255,.15); }
.keep-together { display: inline-flex; align-items: center; gap: .28em; white-space: nowrap; }
/* Four figures sit two by two on a phone, not three and one. */
@media (max-width: 480px) { .summary__grid { grid-template-columns: 1fr 1fr; } }
