/* ============================================================
   Tutor Platform — "Ledger"

   The site is a workbook, not a dashboard. Everything follows from
   that: content sits directly on paper, sections are divided by
   hairline rules instead of floating cards, and the orientation cues
   a student needs (which unit, how long, how far in) live in a margin
   rail the way they do in a textbook.

   Progress is drawn as THE MEASURE — one tick per problem, inked as
   they are solved. It is the one shape this site owns, it states the
   real count rather than a percentage, and it needs no JavaScript.

   Light + dark, mobile first, tuned for a student reading on a phone
   at 10pm.
   ============================================================ */

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

:root {
  color-scheme: light dark;

  /* Warm paper rather than the blue-grey every admin template ships
     with. #f6f4ef against near-black ink reads as printed stock. */
  --paper: #f6f4ef;
  --card: #fffdf9;
  --ink: #16161a;
  --ink-soft: #4a4a52;
  /* Carries the orientation cues ("Unit 1 of 12", "6 / 23 solved"), so
     it must clear WCAG AA against --paper, not just against --card.
     Measured 5.03:1 on --paper. */
  --ink-faint: #66666f;
  --line: #ddd8cd;
  --line-soft: #ece8df;
  --code-bg: #efece3;

  /* chrome — the one genuinely dark surface, used only for the top bar */
  --chrome: #16161a;
  --chrome-2: #212128;
  --on-chrome: #f6f4ef;
  --on-chrome-soft: rgba(246, 244, 239, .62);

  /* semantic */
  --ok: #0f7040;
  --ok-bg: #e6f3ea;
  --ok-line: #9ccfb2;
  --bad: #b32820;
  --bad-bg: #fbeae7;
  --bad-line: #eeb2ab;
  --warn: #8a5a00;
  --warn-bg: #f7eeda;

  /* brand-derived — the tutor's two picks are the ONLY colour that
     varies between sites, and they are used for ink, not decoration */
  --primary-tint: color-mix(in srgb, var(--primary) 8%, var(--card));
  --primary-tint-2: color-mix(in srgb, var(--primary) 15%, var(--card));
  --primary-line: color-mix(in srgb, var(--primary) 34%, var(--paper));
  /* --primary-strong, --mark and --mark-accent are emitted per brand by
     render.mjs, solved against this mode's paper. Not defined here: no fixed
     color-mix can make a near-white brand pick readable. */
  --primary-hi: color-mix(in srgb, var(--primary) 86%, white);
  --accent-tint: color-mix(in srgb, var(--accent) 20%, var(--card));

  /* Containers are ruled, not rounded. Radius survives only where it
     carries an affordance: buttons, inputs, chips. */
  --radius: 3px;
  --radius-sm: 3px;
  --radius-ctl: 7px;

  --display: "Bricolage Grotesque", "Space Grotesk", system-ui, sans-serif;
  --body-font: "Public Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --wrap: 1000px;
  --read: 66ch;
  --rail: 108px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121215;
    --card: #191920;
    --ink: #edece8;
    --ink-soft: #a9a8a3;
    /* 4.83:1 on --paper. */
    --ink-faint: #85848c;
    --line: #2c2c34;
    --line-soft: #212128;
    --code-bg: #24242c;

    --chrome: #0b0b0e;
    --chrome-2: #17171d;

    --ok: #4cc98a;
    --ok-bg: color-mix(in srgb, #17a765 15%, var(--card));
    --ok-line: color-mix(in srgb, #17a765 44%, var(--card));
    --bad: #ff7b74;
    --bad-bg: color-mix(in srgb, #e5484d 14%, var(--card));
    --bad-line: color-mix(in srgb, #e5484d 44%, var(--card));
    --warn: #e8b45a;
    --warn-bg: color-mix(in srgb, #c98a1e 12%, var(--card));

    --primary-tint: color-mix(in srgb, var(--primary) 16%, var(--card));
    --primary-tint-2: color-mix(in srgb, var(--primary) 25%, var(--card));
    --primary-line: color-mix(in srgb, var(--primary) 44%, var(--paper));
  }
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--body-font);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--display); line-height: 1.1; margin: 0 0 .5em; letter-spacing: -.022em; font-weight: 700; }
h1 { font-size: clamp(1.9rem, 6vw, 2.4rem); font-weight: 800; letter-spacing: -.032em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.06rem; }
p { margin: .4em 0 .9em; }
a { color: var(--primary-strong); text-underline-offset: 2px; }
.mono, code { font-family: var(--mono); font-size: .93em; }
img, svg { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* Focus must clear 3:1 against BOTH the paper it sits on and whatever
   brand colour the tutor picked, including a pale one. Mixing the
   primary toward the ink guarantees it. */
:root { --focus-ring: color-mix(in srgb, var(--primary) 55%, var(--ink)); }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- top bar ----------
   A single ink band. No blur, no translucency, no floating. */
.topbar {
  background: var(--chrome); color: var(--on-chrome);
  border-bottom: 1px solid var(--chrome-2);
}
.topbar-inner {
  max-width: var(--wrap); margin: 0 auto; padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.topbar a { color: var(--on-chrome); text-decoration: none; }
.topbar .site-name {
  font-family: var(--display); font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; gap: 9px; letter-spacing: -.015em;
}
/* A small square of the tutor's colour — a printer's register mark,
   not a logo bubble. */
.site-name::before {
  content: ""; width: 9px; height: 9px; background: var(--accent); flex: none;
}
.topbar .logo { height: 26px; width: auto; }
.topbar nav { display: flex; gap: 16px; align-items: center; font-size: .9rem; }
.topbar nav a { color: var(--on-chrome-soft); }
.topbar nav a:hover { color: var(--on-chrome); }
.whoami {
  display: flex; align-items: center; gap: 8px;
  font-size: .86rem; color: var(--on-chrome-soft);
}
.avatar {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--mono); font-size: .7rem; font-weight: 600;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 30px 18px 90px; }
.wrap-narrow { max-width: 460px; }

/* ---------- the ledger grid ----------
   A margin rail carries numbers, times and marks; the wide column
   carries the words. This is what a textbook does and what no
   dashboard template does. Below 760px the rail folds into the row. */
.ledger { border-top: 1px solid var(--ink); }
.ledger-row {
  display: block; position: relative;
  padding: 20px 0; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
a.ledger-row { transition: background .12s ease; }
a.ledger-row:hover { background: var(--line-soft); }
a.ledger-row:hover .lr-title { color: var(--primary-strong); }
.lr-rail {
  font-family: var(--mono); color: var(--ink-faint);
  font-size: .74rem; letter-spacing: .1em; text-transform: uppercase;
  display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px;
}
/* The oversized hanging figure. Quiet in weight, loud in size — it is
   the thing your eye uses to find unit 7 without reading. */
.lr-num {
  font-family: var(--mono); font-size: 1.5rem; line-height: 1;
  font-weight: 400; color: var(--ink-faint); letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.ledger-row.is-done .lr-num { color: var(--ok); }
.ledger-row.is-here .lr-num { color: var(--ink); font-weight: 600; }
.lr-title { font-family: var(--display); font-weight: 700; font-size: 1.12rem; line-height: 1.25; letter-spacing: -.015em; }
.lr-sum { color: var(--ink-soft); font-size: .92rem; margin-top: 3px; max-width: 62ch; }
.lr-meta { margin-top: 11px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lr-count { font-family: var(--mono); font-size: .76rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (min-width: 760px) {
  .ledger-row { display: grid; grid-template-columns: var(--rail) 1fr; gap: 26px; padding: 22px 0; }
  .lr-rail {
    display: block; margin: 0; text-align: right;
    border-right: 1px solid var(--line); padding-right: 26px; margin-right: -26px;
  }
  .lr-num { display: block; font-size: 2.1rem; margin-bottom: 5px; }
  .lr-when { display: block; }
}

/* A tutor's row carries reorder controls in a third column. Below 760px the
   controls sit under the text rather than squeezing it. */
.tutor-row .lr-title { display: inline-block; color: inherit; text-decoration: none; }
.tutor-row:hover .lr-title, .tutor-row .lr-title:hover { color: var(--primary-strong); }
.lr-order { display: flex; gap: 5px; margin-top: 10px; }
@media (min-width: 760px) {
  .ledger-row.tutor-row { grid-template-columns: var(--rail) 1fr auto; }
  .lr-order { margin-top: 0; align-self: start; }
}

/* ---------- the measure ----------
   One tick per problem, inked as they are solved. States the real
   count instead of a percentage, works with JavaScript off, and gives
   the site a shape of its own. Over --measure-max problems the ticks
   would smear together, so .measure-rule takes over. */
.measure { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
/* Solved and unsolved differ in HEIGHT first and colour second. Colour alone
   measured 1.74:1 between the two states — below the 3:1 WCAG asks of a
   graphic that carries meaning, and invisible in greyscale. A solved tick now
   stands three times as tall as an unsolved one, so the reading survives both.
   Every fifth tick starts a new group, which is what makes them countable. */
.measure i {
  display: block; width: 3px; height: 4px; flex: none;
  background: var(--line);
}
.measure i:nth-child(5n+1):not(:first-child) { margin-left: 5px; }
/* --mark, not --primary. A tutor who picks a dark green renders their own
   progress at 2.35:1 on dark paper — technically drawn, practically invisible;
   a near-white pick measured 1.22:1. --mark is solved per brand in render.mjs
   against this mode's paper, so the measure stays legible either way. */
.measure i.on { height: 14px; background: var(--mark); }
.measure i.here { height: 14px; background: var(--mark-accent); }
.measure.is-done i.on { background: var(--ok); }

.measure-rule { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 90px; }
.measure-rule .track { flex: 1; height: 3px; background: var(--line); position: relative; }
.measure-rule .fill { position: absolute; inset: 0 auto 0 0; background: var(--mark); }
.measure-rule.is-done .fill { background: var(--ok); }

/* ---------- section rules ----------
   A drafting label sitting on the line, rather than a heading floating
   above a stack of cards. */
.section-label {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: .7rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-faint);
  margin: 44px 0 4px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- panels ----------
   `.card` survives as a name because it is used in dozens of places,
   but it is no longer a card: a hairline box on paper, square corners,
   no shadow. */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin: 16px 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.card-head h1, .card-head h2, .card-head h3 { margin: 0; }
/* Was a spotlight-follows-cursor effect. Now it just means "this box
   responds when you point at it". */
.spot { transition: border-color .12s ease, background .12s ease; }
a:hover > .spot, .spot:hover { border-color: var(--primary-line); }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; }
.list-row .sub { color: var(--ink-soft); font-size: .88rem; }
a.list-row { transition: background .12s ease; }
a.list-row:hover { background: var(--line-soft); }
a.list-row:hover .title { color: var(--primary-strong); }
.chev { flex: none; color: var(--ink-faint); font-size: 1.15rem; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin: 16px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=color], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius-ctl); padding: 11px 13px; min-height: 46px;
  transition: border-color .12s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline-offset: 1px; }
textarea { min-height: 130px; resize: vertical; line-height: 1.55; }
input[type=color] { padding: 4px; height: 46px; cursor: pointer; }
.field-hint { color: var(--ink-faint); font-size: .83rem; margin-top: 4px; }

/* ---------- buttons ----------
   Flat ink. No gradient, no glow, no shimmer sweep. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--on-primary);
  border: 1.5px solid var(--primary); border-radius: var(--radius-ctl);
  padding: 11px 20px; min-height: 46px;
  transition: filter .12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn-quiet { background: transparent; color: var(--primary-strong); border-color: var(--line); }
.btn-quiet:hover { border-color: var(--primary); background: var(--primary-tint); filter: none; }
.btn-small { padding: 7px 13px; min-height: 0; font-size: .88rem; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-bg); filter: none; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.btn[disabled] { opacity: .55; cursor: default; pointer-events: none; }

.pill, .badge-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: .68rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--radius-sm); white-space: nowrap;
  background: var(--line-soft); color: var(--ink-soft);
}
.pill-live { background: var(--ok-bg); color: var(--ok); }
.pill-draft { background: var(--line-soft); color: var(--ink-soft); }
.pill-warn { background: var(--bad-bg); color: var(--bad); }
.pill-info { background: var(--primary-tint-2); color: var(--primary-strong); }
.badge-tag.ai { background: var(--accent-tint); color: var(--ink); }
.chip { font-family: var(--mono); font-size: .72rem; padding: 3px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink-soft); }
.chip-primary { border-color: var(--primary-line); color: var(--primary-strong); }
.chip-ok { border-color: var(--ok-line); color: var(--ok); }
.chip-bad { border-color: var(--bad-line); color: var(--bad); }

.notice {
  border-left: 3px solid var(--primary); background: var(--primary-tint);
  padding: 12px 15px; margin: 16px 0; border-radius: 0 var(--radius) var(--radius) 0;
}
.error-box {
  border-left: 3px solid var(--bad); background: var(--bad-bg); color: var(--bad);
  padding: 12px 15px; margin: 16px 0; font-weight: 600; border-radius: 0 var(--radius) var(--radius) 0;
}

/* Kept for the few places measuring something other than problems. */
.progress-track { height: 3px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); }
.progress-fill.is-done { background: var(--ok); }
.progress-row { display: flex; align-items: center; gap: 10px; }
.progress-row .progress-track { flex: 1; }
.progress-pct { font-family: var(--mono); font-size: .77rem; color: var(--ink-faint); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- course masthead ----------
   Type on paper. The course title is the largest thing on the page and
   the only thing competing for attention. */
.masthead { padding: 12px 0 26px; border-bottom: 1px solid var(--ink); margin-bottom: 0; }
.masthead .kicker {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 12px;
}
.masthead h1 { font-size: clamp(2.2rem, 8vw, 3.6rem); margin: 0 0 14px; letter-spacing: -.035em; }
.masthead .standfirst { color: var(--ink-soft); font-size: 1.02rem; max-width: 52ch; margin: 0; }

/* The three orientation figures, set as a ruled strip rather than
   stat tiles. Mono figures, hairline dividers, no boxes. */
.figures { display: flex; flex-wrap: wrap; margin-top: 24px; border-top: 1px solid var(--line); }
.figure { padding: 14px 22px 12px 0; margin-right: 22px; border-right: 1px solid var(--line); }
.figure:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.figure .n {
  font-family: var(--mono); font-size: 1.7rem; font-weight: 600; line-height: 1;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.figure .l { font-size: .76rem; color: var(--ink-faint); margin-top: 6px; letter-spacing: .06em; text-transform: uppercase; font-family: var(--mono); }
.figure.wide { flex: 1; min-width: 160px; border-right: 0; padding-right: 0; margin-right: 0; }
.figure .measure { margin-top: 9px; }
/* Vertical dividers only survive while the strip is one line. Once it wraps,
   the last figure on a row leaves its rule hanging in empty space, so narrow
   screens separate by spacing alone. */
@media (max-width: 700px) {
  .figures, .stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
  .figure, .stat { border-right: 0; margin-right: 0; padding-right: 0; }
}

/* ---------- resume ----------
   Not a card with an arrow button. A ruled block with the accent bar
   down its left edge — the "you are here" mark from the margin. */
.resume {
  display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  padding: 18px 16px; color: inherit; text-decoration: none;
  transition: background .12s ease;
}
.resume:hover { background: var(--line-soft); }
.resume .grow { flex: 1; min-width: 0; }
.resume .eyebrow {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-faint);
}
.resume .title { font-family: var(--display); font-weight: 700; font-size: 1.16rem; margin-top: 4px; letter-spacing: -.018em; }
.resume:hover .title { color: var(--primary-strong); }
.resume .sub { color: var(--ink-soft); font-size: .89rem; margin-top: 2px; }
.resume .go { flex: none; font-size: 1.3rem; color: var(--ink-faint); }
.resume:hover .go { color: var(--primary-strong); }

/* ---------- reading a unit ---------- */
.read-progress { position: fixed; top: 0; left: 0; height: 2px; background: var(--accent); z-index: 50; }
.crumb {
  display: inline-block; font-family: var(--mono); font-size: .74rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint);
  text-decoration: none; margin-bottom: 18px;
}
.crumb:hover { color: var(--primary-strong); }

/* The unit's margin rail. Narrow screens get the facts as a strip above the
   heading; wide screens get them hanging in the margin, sticky, so "unit 3 of
   12, 6 of 23 solved" stays answerable without scrolling back up. */
.unit-rail {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint);
  padding-bottom: 12px; margin-bottom: 4px;
}
.unit-rail .ur-num { font-size: 1.5rem; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.unit-rail .ur-facts { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.unit-rail .ur-measure { display: block; }

@media (min-width: 1000px) {
  /* Wider than the ledger's rail: this one has to hold "40 min read" on one
     line and a measure up to MEASURE_MAX ticks wide. */
  .unit-page { display: grid; grid-template-columns: 132px 1fr; gap: 38px; align-items: start; }
  .unit-rail {
    display: block; position: sticky; top: 26px;
    text-align: right; border-right: 1px solid var(--line);
    padding: 4px 20px 0 0; margin: 0;
  }
  .unit-rail .ur-num { display: block; font-size: 2.6rem; line-height: 1; margin-bottom: 2px; }
  .unit-rail .ur-of { display: block; margin-bottom: 16px; }
  .unit-rail .ur-facts { display: block; }
  .unit-rail .ur-facts > div { margin-bottom: 7px; }
  .unit-rail .measure { justify-content: flex-end; margin-top: 10px; }
  .unit-main { min-width: 0; }
}

.lesson-head { padding-bottom: 20px; border-bottom: 1px solid var(--ink); margin-bottom: 30px; }
.lesson-head h1 { margin: 6px 0 10px; font-size: clamp(1.9rem, 6.5vw, 2.7rem); }
.lesson-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-family: var(--mono); font-size: .76rem; color: var(--ink-faint);
  letter-spacing: .06em; text-transform: uppercase;
}
.lesson-meta .dot { width: 3px; height: 3px; background: currentColor; }

.lesson-body { font-size: 17.5px; line-height: 1.72; max-width: var(--read); }
/* The opening paragraph is the unit's thesis. Set larger, with the
   brand rule beside it — the only place a summary gets that weight. */
.lesson-body > p:first-child {
  font-size: 1.1em; color: var(--ink-soft); line-height: 1.6;
  border-left: 3px solid var(--primary); padding-left: 18px; margin-bottom: 30px;
}
.lesson-section { margin: 36px 0; }
.lesson-section > h2 {
  font-size: 1.3rem; margin-bottom: .6em; padding-bottom: 8px;
  border-bottom: 1px solid var(--ink);
}
.lesson-body h3 { margin-top: 1.5em; font-size: 1.04rem; }
.lesson-body strong { font-weight: 700; }
.lesson-body svg { display: block; margin: 22px auto; }
.lesson-body .mono, .lesson-body code {
  background: var(--code-bg); color: var(--primary-strong);
  padding: 2px 6px; border-radius: var(--radius-sm); font-weight: 500;
}
.lesson-body ul, .lesson-body ol { padding-left: 1.35em; }
.lesson-body li { margin: .38em 0; }
.lesson-body li::marker { color: var(--ink-faint); }

/* ---- unit diagrams ----
   Theme-safe SVG: everything is driven by class + CSS variable so a
   diagram stays legible in both light and dark. */
.dia { display: block; margin: 22px auto; max-width: 100%; overflow: visible; }
.dia text { font-family: var(--mono); font-size: 11px; fill: var(--ink-soft); }
.dia text.lbl { fill: var(--ink); font-weight: 600; }
.dia text.big { font-size: 13px; fill: var(--ink); font-weight: 600; }
.dia .ink { stroke: var(--ink); fill: none; stroke-width: 2; stroke-linecap: round; }
.dia .ink-f { fill: var(--ink); stroke: none; }
.dia .thin { stroke: var(--line); fill: none; stroke-width: 1.5; }
.dia .a { stroke: var(--primary); fill: none; stroke-width: 2.5; stroke-linecap: round; }
.dia .a-f { fill: var(--primary); stroke: none; }
.dia .a-soft { fill: var(--primary-tint); stroke: var(--primary-line); stroke-width: 1.5; }
.dia .b { stroke: var(--accent); fill: none; stroke-width: 2.5; stroke-linecap: round; }
.dia .b-f { fill: var(--accent); stroke: none; }
.dia .b-soft { fill: var(--accent-tint); stroke: color-mix(in srgb, var(--accent) 45%, var(--card)); stroke-width: 1.5; }
.dia .ok-f { fill: var(--ok); stroke: none; }
.dia .ok-soft { fill: var(--ok-bg); stroke: var(--ok-line); stroke-width: 1.5; }
.dia .bad-f { fill: var(--bad); stroke: none; }
.dia .bad-soft { fill: var(--bad-bg); stroke: var(--bad-line); stroke-width: 1.5; }
.dia .card-f { fill: var(--card); }
.dia .dash { stroke-dasharray: 5 4; }

/* Legacy diagrams (the imported geometry course) hardcode their own
   palette instead of using the .dia classes. Remap by value in EVERY
   colour scheme, not just dark: the variables already flip for dark
   mode, and doing it here means these diagrams follow the tutor's
   colours rather than staying blue-and-navy on an orange-and-green
   site.

   fill and stroke must stay separate rules. A combined selector sets
   fill on `fill="none"` construction lines — and CSS beats
   presentation attributes, so the dashed auxiliary lines in the proof
   diagrams fill in solid. */
.lesson-body svg [stroke="#0D1B33"] { stroke: var(--ink); }
.lesson-body svg [fill="#0D1B33"]   { fill: var(--ink); }
.lesson-body svg [stroke="#5B6B87"] { stroke: var(--ink-faint); }
.lesson-body svg [fill="#5B6B87"]   { fill: var(--ink-faint); }
.lesson-body svg [stroke="#3B7DE0"] { stroke: var(--primary); }
.lesson-body svg [fill="#3B7DE0"]   { fill: var(--primary); }
.lesson-body svg [stroke="#DDE6F4"] { stroke: var(--line); }
.lesson-body svg [fill="#DDE6F4"]   { fill: var(--primary-tint-2); }
.lesson-body svg [stroke="#2E9E63"] { stroke: var(--ok); }
.lesson-body svg [fill="#2E9E63"]   { fill: var(--ok); }
.lesson-body svg [stroke="#E5484D"] { stroke: var(--bad); }
.lesson-body svg [fill="#E5484D"]   { fill: var(--bad); }
.lesson-body svg [stroke="#FFD84D"] { stroke: var(--accent); }
.lesson-body svg [fill="#FFD84D"]   { fill: var(--accent); }

/* Definitions set as a ruled table, the way a glossary is printed. */
.deflist { margin: 20px 0; border-top: 1px solid var(--ink); }
.deflist .def {
  display: grid; grid-template-columns: minmax(120px, 28%) 1fr; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.deflist dt { font-weight: 700; font-size: .95rem; }
.deflist dd { margin: 0; color: var(--ink-soft); font-size: .95rem; }
@media (max-width: 560px) { .deflist .def { grid-template-columns: 1fr; gap: 2px; } }

.callout { padding: 16px 0 16px 20px; margin: 30px 0; border-left: 3px solid var(--line); }
.callout > h2 {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .16em;
  border: 0; padding: 0; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 600;
}
.callout > *:last-child { margin-bottom: 0; }
.callout-example { border-left-color: var(--primary); }
.callout-example > h2 { color: var(--primary-strong); }
.callout-example .mono, .callout-example code { background: var(--code-bg); }
.callout-example ol { counter-reset: step; list-style: none; padding-left: 0; }
.callout-example ol > li { counter-increment: step; position: relative; padding-left: 30px; margin: .55em 0; }
.callout-example ol > li::before {
  content: counter(step) "."; position: absolute; left: 0; top: 0;
  font-family: var(--mono); font-size: .85rem; font-weight: 600; color: var(--primary-strong);
}
.callout-warn { border-left-color: var(--warn); }
.callout-warn > h2 { color: var(--warn); }

.table-wrap { overflow-x: auto; margin: 22px 0; }
.table-wrap table { margin: 0; border: 0; }
table.plain { border-collapse: collapse; width: 100%; font-size: .94rem; }
table.plain th {
  text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-faint); padding: 9px 12px 9px 0; border-bottom: 1px solid var(--ink);
  font-family: var(--mono); font-weight: 600;
}
table.plain td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); }
table.plain tbody tr:hover { background: var(--line-soft); }

.lesson-nav { display: flex; gap: 0; margin-top: 50px; border-top: 1px solid var(--ink); }
.lesson-nav a {
  flex: 1; display: block; text-decoration: none; color: inherit;
  padding: 18px 16px 18px 0; transition: background .12s ease;
}
.lesson-nav a + a { border-left: 1px solid var(--line); padding-left: 16px; padding-right: 0; }
.lesson-nav a:hover { background: var(--line-soft); }
.lesson-nav .dir { font-family: var(--mono); font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); }
.lesson-nav .name { font-weight: 600; margin-top: 4px; font-size: .96rem; }
.lesson-nav a:hover .name { color: var(--primary-strong); }
.lesson-nav .next { text-align: right; }

/* ---------- problems ---------- */
.practice-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; margin: 54px 0 0; padding-bottom: 10px;
  border-bottom: 1px solid var(--ink); flex-wrap: wrap;
}
.practice-head h2 { margin: 0; font-size: 1.4rem; }
.practice-head .tally { font-family: var(--mono); font-size: .8rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.problem-screen {
  max-width: 680px; scroll-margin-top: 70px;
  border-bottom: 1px solid var(--line);
  padding: 24px 0; margin: 0;
  border-left: 3px solid transparent; padding-left: 0;
  transition: border-color .2s ease, padding-left .2s ease;
}
.problem-screen:focus-within { border-left-color: var(--primary-line); padding-left: 17px; }
.problem-screen[data-state="right"] { border-left-color: var(--ok); padding-left: 17px; }
.problem-screen[data-state="wrong"] { border-left-color: var(--bad); padding-left: 17px; }

.problem-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.problem-count { font-family: var(--mono); font-size: .72rem; color: var(--ink-faint); letter-spacing: .14em; text-transform: uppercase; }
.diff-dots { display: flex; gap: 3px; margin-left: auto; }
.diff-dots i { width: 5px; height: 12px; background: var(--line); display: block; }
.diff-dots i.on { background: var(--accent); }
.solved-check {
  width: 19px; height: 19px; background: var(--ok); color: #fff;
  display: none; place-items: center; font-size: .7rem; flex: none;
}
.problem-screen[data-solved] .solved-check { display: grid; }

.problem-prompt { font-size: 1.13rem; line-height: 1.55; margin: 0 0 20px; }
.problem-prompt p:last-child { margin-bottom: 0; }
.problem-prompt .mono, .problem-prompt code {
  background: var(--code-bg); color: var(--primary-strong);
  padding: 2px 7px; border-radius: var(--radius-sm); font-weight: 500;
}

.answer-form input[type=text] {
  font-size: 1.2rem; font-family: var(--mono); padding: 14px;
  border-width: 2px; text-align: center;
}
.choice-list { display: grid; gap: 0; margin: 2px 0 6px; border-top: 1px solid var(--line); }
.choice-list button {
  font: inherit; color: var(--ink); text-align: left; cursor: pointer; position: relative;
  background: transparent; border: 0; border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  padding: 14px 14px 14px 44px; min-height: 52px; width: 100%;
  transition: background .12s ease, border-color .12s ease;
}
.choice-list button::before {
  content: attr(data-key); position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: .84rem; font-weight: 600; color: var(--ink-faint);
  transition: color .12s ease;
}
.choice-list button:hover { background: var(--primary-tint); border-left-color: var(--primary-line); }
.choice-list button:hover::before { color: var(--primary-strong); }
.choice-list button[data-picked] { background: var(--primary-tint); border-left-color: var(--primary); }
.choice-list button[data-picked]::before { color: var(--primary-strong); }
.choice-list button[data-right] { background: var(--ok-bg); border-left-color: var(--ok); }
.choice-list button[data-right]::before { color: var(--ok); content: "✓"; }
.choice-list button[data-wrong] { background: var(--bad-bg); border-left-color: var(--bad); }
.choice-list button[data-wrong]::before { color: var(--bad); content: "✕"; }
.choice-list button:disabled { cursor: default; }

.verdict {
  padding: 13px 0 13px 15px; margin: 16px 0 0;
  font-weight: 600; display: flex; gap: 11px; align-items: flex-start;
  border-left: 3px solid currentColor;
  animation: pop .22s cubic-bezier(.34,1.4,.64,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.verdict .vicon { flex: none; width: 20px; height: 20px; display: grid; place-items: center; font-size: .8rem; color: #fff; }
.verdict-right { background: var(--ok-bg); color: var(--ok); }
.verdict-right .vicon { background: var(--ok); }
.verdict-wrong { background: var(--bad-bg); color: var(--bad); }
.verdict-wrong .vicon { background: var(--bad); }
.verdict small { display: block; font-weight: 400; margin-top: 4px; line-height: 1.5; color: var(--ink); }

.hint-box, .solution-box {
  padding: 14px 0 14px 16px; margin: 14px 0 0;
  border-left: 3px solid var(--line);
  animation: pop .22s cubic-bezier(.34,1.4,.64,1);
}
.hint-box { border-left-color: var(--accent); background: var(--warn-bg); }
.solution-box { border-left-color: var(--primary); background: var(--primary-tint); }
.hint-box h4, .solution-box h4 {
  margin: 0 0 7px; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .16em; color: var(--ink-faint); font-family: var(--mono);
}
.hint-box p:last-child, .solution-box p:last-child, .solution-box ol:last-child { margin-bottom: 0; }
.solution-box ol { counter-reset: sstep; list-style: none; padding-left: 0; margin: 0; }
.solution-box ol > li { counter-increment: sstep; position: relative; padding-left: 28px; margin: .5em 0; }
.solution-box ol > li::before {
  content: counter(sstep) "."; position: absolute; left: 0; top: 0;
  font-family: var(--mono); font-size: .82rem; font-weight: 600; color: var(--primary-strong);
}
.solution-box .mono, .solution-box code, .hint-box .mono { background: var(--card); padding: 1px 5px; border-radius: var(--radius-sm); }
.hint-box, .solution-box, .verdict { padding-right: 15px; }

/* ---------- helper chat ---------- */
#tutor-chat { max-width: 680px; }
.chat-bubble {
  padding: 10px 14px; margin: 7px 0; max-width: 86%;
  white-space: pre-wrap; line-height: 1.5; font-size: .95rem;
  border-radius: var(--radius-ctl); animation: pop .2s ease;
}
.chat-bubble.me { background: var(--primary); color: var(--on-primary); margin-left: auto; }
.chat-bubble.bot { background: var(--line-soft); color: var(--ink); }

/* ---------- tutor dashboard ---------- */
.stat-grid { display: flex; flex-wrap: wrap; margin: 4px 0 26px; border-top: 1px solid var(--line); }
.stat { padding: 14px 22px 12px 0; margin-right: 22px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .n { font-family: var(--mono); font-size: 1.7rem; font-weight: 600; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--ink-faint); font-size: .74rem; margin-top: 6px; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.stat.alert .n { color: var(--bad); }
.miss-bar { display: flex; align-items: center; gap: 9px; }
.miss-bar .track { flex: 1; height: 3px; background: var(--line); }
.miss-bar .fill { height: 100%; background: var(--bad); }
.talk-item {
  display: block; color: inherit; text-decoration: none;
  border-left: 3px solid var(--accent); padding: 13px 15px; margin: 0;
  border-bottom: 1px solid var(--line);
  transition: background .12s ease;
}
.talk-item:hover { background: var(--line-soft); }
.talk-item .who { font-weight: 700; font-family: var(--display); }
.talk-item .what { color: var(--ink-soft); font-size: .89rem; }
.talk-item .ans { font-family: var(--mono); font-size: .85rem; background: var(--bad-bg); color: var(--bad); padding: 2px 7px; border-radius: var(--radius-sm); }
.status-list, .status-row { display: block; }
.status-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }

/* ---------- join ---------- */
.join-wrap { max-width: 420px; margin: 0 auto; padding: 9dvh 18px 60px; }
.join-brand { text-align: center; margin-bottom: 30px; }
.join-brand .mark {
  width: 52px; height: 52px; margin: 0 auto 18px;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-size: 1.5rem;
}
.code-input {
  font-family: var(--mono) !important; font-size: 1.65rem !important;
  text-align: center; letter-spacing: .32em; text-transform: uppercase;
  padding: 15px 8px 15px calc(8px + .32em) !important;
}
.join-code {
  font-family: var(--mono); font-size: 2rem; font-weight: 600; letter-spacing: .35em;
  text-align: center; padding: 20px 8px 20px calc(8px + .35em);
  background: var(--card); border: 1px dashed var(--primary-line);
  color: var(--primary-strong);
}

/* ---------- onboarding ---------- */
.steps { display: flex; gap: 7px; margin: 0 0 26px; padding: 0; list-style: none; font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.steps li { flex: 1; padding-top: 8px; border-top: 2px solid var(--line); }
.steps li.done { border-top-color: var(--ink-faint); }
.steps li.on { border-top-color: var(--primary); color: var(--ink); font-weight: 600; }

.start-choice { display: grid; gap: 0; border-top: 1px solid var(--ink); }
.start-choice a { text-decoration: none; color: inherit; display: block; }
.start-choice .card { margin: 0; border: 0; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; padding: 20px 18px; height: 100%; background: transparent; }
.start-choice a:hover .card { border-left-color: var(--primary); background: var(--line-soft); }
.start-choice h3 { margin-bottom: 5px; }
.start-choice a:hover h3 { color: var(--primary-strong); }
.start-choice p { margin: 0; color: var(--ink-soft); font-size: .92rem; }

/* ---------- AI authoring progress ---------- */
.gen-panel { border-left: 3px solid var(--primary); border-top: 0; border-right: 0; border-bottom: 1px solid var(--line); background: transparent; padding-left: 18px; }
.gen-status { font-family: var(--mono); font-size: .8rem; color: var(--ink-soft); margin-top: 10px; min-height: 1.4em; }

/* ---------- landing ---------- */
.landing-hero { padding: 30px 0 40px; border-bottom: 1px solid var(--ink); margin-bottom: 0; }
/* Capped so "Your name on the door." sets on two lines inside the hero's
   narrower column instead of orphaning "door." onto a third. */
.landing-hero h1 { font-size: clamp(2.3rem, 5.4vw, 3.4rem); line-height: 1.02; margin-bottom: 18px; letter-spacing: -.04em; }
.landing-hero .lede { font-size: 1.12rem; color: var(--ink-soft); max-width: 40ch; }
.landing-hero .btn-row { margin-top: 26px; }

/* A worked problem, set as it appears in the product — proof of what
   the thing actually is, rather than a screenshot in a browser frame. */
.mock-problem {
  margin-top: 34px; padding-left: 18px; border-left: 3px solid var(--ok); max-width: 340px;
}
.mock-problem .mock-chip { font-family: var(--mono); font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 8px; }
.mock-problem .mock-q { font-size: 1.02rem; font-weight: 600; margin-bottom: 12px; }
.mock-problem .mock-q code { background: var(--code-bg); color: var(--primary-strong); padding: 2px 7px; border-radius: var(--radius-sm); }
.mock-problem .mock-a {
  font-family: var(--mono); text-align: center; font-size: 1.05rem;
  border: 1px solid var(--ok-line); background: var(--ok-bg); color: var(--ok);
  padding: 10px; margin-bottom: 10px;
}
.mock-problem .mock-verdict { display: flex; gap: 8px; align-items: center; color: var(--ok); font-weight: 700; font-size: .94rem; }

/* The old bento grid of glowing tiles is now a numbered ruled list —
   the same four claims, read as a table of contents. */
.bento, .feature-grid { display: grid; gap: 0; margin-top: 34px; border-top: 1px solid var(--ink); }
.bento-tile, .feature { padding: 22px 0; border-bottom: 1px solid var(--line); background: transparent; border-left: 0; border-right: 0; border-top: 0; }
.bento-tile h3, .feature h3 { font-size: 1.1rem; margin-bottom: 6px; letter-spacing: -.018em; }
.bento-tile p, .feature p { margin: 0; color: var(--ink-soft); font-size: .95rem; max-width: 54ch; }
.feature .fnum, .bento-tile .fnum {
  font-family: var(--mono); font-weight: 600; font-size: .8rem;
  color: var(--ink-faint); margin-bottom: 10px; letter-spacing: .14em;
}

.empty-state { text-align: center; padding: 44px 20px; color: var(--ink-soft); border: 1px dashed var(--line); }
.empty-state .big { font-size: 1.8rem; margin-bottom: 10px; opacity: .45; }

/* ---------- labs ---------- */
.lab { border-left: 3px solid var(--line); padding: 4px 0 4px 18px; margin: 28px 0; }
.lab-label {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 10px; display: block;
}

.pager { display: flex; gap: 8px; align-items: center; font-family: var(--mono); font-size: .8rem; }

@media (min-width: 700px) {
  .wrap { padding: 40px 30px 110px; }
  .card { padding: 22px 24px; }
  .start-choice { grid-template-columns: repeat(2, 1fr); }
  .start-choice .card { border-bottom: 1px solid var(--line); }
  .bento, .feature-grid { grid-template-columns: repeat(2, 1fr); column-gap: 34px; }
  .bento-tile.wide { grid-column: span 2; }
  .landing-hero { padding: 44px 0 52px; display: grid; grid-template-columns: 1.25fr .75fr; gap: 40px; align-items: center; }
  .mock-problem { margin-top: 0; justify-self: end; }
}
