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

/* The palette is the logo's: navy with an orange sweep. Orange is the accent
   and never an alarm — a student halfway through a chapter is making progress,
   not in trouble, and the old scheme painted that bar the same brown it used
   for "needs attention". */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #161c28;
  --ink-2: #3d4657;
  --muted: #6b7385;
  --brand: #1f3a93;
  --brand-dark: #16296b;
  --brand-soft: #e8edf9;
  --accent: #f29b1d;
  --accent-ink: #92400e;
  --accent-soft: #fdf0dc;
  --good: #1f7a45;
  --good-bg: #e6f4ec;
  --warn: #b7791f;
  --warn-swatch: #d9a13a;
  --warn-bg: #fdf1dc;
  --bad: #b3342c;
  --bad-bg: #fbeae8;
  --border: #e1e6f0;
  --subtle: #eef1f8;          /* secondary buttons, code, quiet fills */
  --subtle-2: #e2e7f3;        /* the same, hovered */
  --tint: #f7f9fd;            /* an answer, an option under the cursor */
  --track: #e9edf6;           /* the unfilled part of a meter */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,28,40,.05), 0 6px 18px rgba(20,28,40,.05);
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

/* ---------------- chrome ---------------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 12px 24px; position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--brand); }
.topbar-right { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: .9rem; }
.container { max-width: 1040px; margin: 24px auto; padding: 0 16px; }

h1 { font-size: 1.5rem; margin-bottom: 4px; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin-bottom: 10px; }
h3 { font-size: .98rem; margin-bottom: 6px; }
.sub { color: var(--muted); font-size: .9rem; margin-bottom: 16px; }
.muted { color: var(--muted); font-size: .88rem; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.card.tight { padding: 14px 16px; }

/* ---------------- controls ---------------- */
button, .btn {
  background: var(--brand); color: #fff; border: none; cursor: pointer;
  padding: 9px 16px; border-radius: 8px; font-size: .92rem; font-weight: 600;
  font-family: inherit;
}
button:hover:not(:disabled) { background: var(--brand-dark); }
button.secondary, a.btn.secondary { background: var(--subtle); color: var(--ink); }
button.secondary:hover:not(:disabled), a.btn.secondary:hover { background: var(--subtle-2); }
a.btn { display: inline-block; text-decoration: none; white-space: nowrap; }
button.danger { background: var(--bad); }
button.small { padding: 5px 10px; font-size: .82rem; }
button.link { background: none; color: var(--brand); padding: 2px 4px; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* 16px, not 14.7px: a mobile browser zooms the whole page when a field under
   16px takes focus, and the page never zooms back. */
input, select, textarea {
  width: 100%; padding: 10px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 1rem; margin-bottom: 12px;
  background: var(--card); font-family: inherit; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > button { flex: 0 0 auto; margin-bottom: 12px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.auth-wrap { max-width: 400px; margin: 48px auto; }

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: var(--subtle); color: var(--ink); }
.tabs button.active { background: var(--brand); color: #fff; }
/* A filter, not a place: smaller and quieter than the tabs that change screen. */
.tabs.subtle { margin-bottom: 0; }
.tabs.subtle button { padding: 5px 12px; font-size: .84rem; border-radius: 999px; }

/* ---------------- tables whose rows open something ---------------- */
table.rows tbody tr { cursor: pointer; }
table.rows tbody tr:hover { background: var(--subtle); }
table.rows tbody tr:focus-visible {
  outline: 2px solid var(--brand); outline-offset: -2px; background: var(--subtle);
}

/* Label and value, for a detail screen rather than a list. */
table.plain td { border-bottom: 1px solid var(--border); padding: 9px 0; vertical-align: middle; }
table.plain tr:last-child td { border-bottom: none; }
table.plain td:first-child { width: 170px; font-size: .84rem; }

/* ---------------- badges / meters ---------------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad); }
.badge.gray { background: var(--subtle); color: var(--muted); }
.badge.brand{ background: var(--brand-soft); color: var(--brand-dark); }

.meter { background: var(--track); border-radius: 999px; height: 7px; overflow: hidden; }
.meter > div { height: 100%; background: var(--brand); transition: width .35s; }
.meter.progress > div { background: var(--accent); }
.meter.good > div { background: var(--good); }
.meter.warn > div { background: var(--warn); }
.meter.bad  > div { background: var(--bad); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
/* Counts read as a row, never a tower: four stacked numbers push the content
   a parent came for off the bottom of the screen. Two across keeps the card
   one glance tall. .grid2 is prose side-by-side, so it still collapses. */
@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
.stat { text-align: center; padding: 10px; }
.stat .num { font-size: 1.9rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .82rem; }

/* ---------------- tables ---------------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
.scroll { overflow-x: auto; }

/* ---------------- lessons ---------------- */
.lesson {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.lesson:last-child { border-bottom: none; }
.lesson .info { flex: 1; min-width: 0; }
.lesson .title { font-weight: 600; }
.lesson .where { font-size: .8rem; color: var(--muted); }
.lesson .state { min-width: 120px; }

/* ---------------- video player ---------------- */
.player-wrap { background: #0d1017; border-radius: var(--radius); overflow: hidden; }
.player-wrap video { width: 100%; display: block; max-height: 460px; background: #000; }
.player-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; background: #151a24; color: #dfe4ee; font-size: .84rem;
}
.player-bar .grow { flex: 1; min-width: 160px; }
.player-bar .meter { background: #2a3140; }
.watch-note { font-size: .8rem; color: var(--muted); margin-top: 8px; }

/* ---------------- quiz ---------------- */
.question { padding: 16px 0; border-bottom: 1px solid var(--border); }
.question:last-of-type { border-bottom: none; }
.question .qnum { font-size: .76rem; color: var(--muted); font-weight: 700; letter-spacing: .05em; }
.question .prompt { font-weight: 600; margin: 4px 0 10px; }
.option {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; cursor: pointer;
}
.option:hover { background: var(--tint); }
.option input { width: auto; margin: 3px 0 0; }
.option.correct { border-color: var(--good); background: var(--good-bg); }
.option.chosen-wrong { border-color: var(--bad); background: var(--bad-bg); }

/* ---------------- alerts ---------------- */
.alert { padding: 11px 15px; border-radius: 8px; margin-bottom: 12px; font-size: .9rem; }
.alert.error   { background: var(--bad-bg);  color: var(--bad); }
.alert.success { background: var(--good-bg); color: var(--good); }
.alert.info    { background: var(--brand-soft); color: var(--brand-dark); }
.alert.warn    { background: var(--warn-bg); color: var(--warn); }

/* ---------------- modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,22,34,.55);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
.modal {
  background: var(--card); border-radius: var(--radius); max-width: 720px; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 22px 24px; box-shadow: var(--shadow);
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ---------------- admin tree ---------------- */
.tree { font-size: .92rem; }
.tree-node { padding: 5px 0; }
.tree-node .caret { cursor: pointer; user-select: none; display: inline-flex; gap: 6px; align-items: center; }
.tree-children { margin-left: 18px; border-left: 1px solid var(--border); padding-left: 14px; }
.node-actions { display: inline-flex; gap: 6px; margin-left: 8px; }
.node-actions button { padding: 2px 8px; font-size: .76rem; }

.q-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.q-card.picked { border-color: var(--brand); background: var(--brand-soft); }
.q-card .meta { font-size: .78rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }

.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

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

/* ---------------- student journey ---------------- */

.continue {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--brand-soft), var(--card));
  border-color: var(--brand);
}
.continue-body { flex: 1; min-width: 220px; }
.continue-body h2 { margin: 2px 0 4px; }
.continue .eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--brand-dark);
}

.reaction-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.reaction-bar button { display: inline-flex; align-items: center; gap: 8px; }
/* Liking a lesson is a good thing; in the error red it read as a warning. */
.reaction-bar button.liked { background: var(--accent-soft); color: var(--accent-ink); }
.reaction-bar button.liked:hover:not(:disabled) { background: #fbe5c2; }
.reaction-bar #likeIcon { font-size: 1.05rem; line-height: 1; }

/* test taking */
.test-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.test-head h1 { margin: 0; }
.test-progress { min-width: 190px; font-size: .84rem; color: var(--muted); }
.test-progress .meter { margin-top: 6px; }
.test-foot { display: flex; justify-content: flex-end; gap: 10px; }
.card.question { padding: 18px 20px; }
.card.question .prompt { margin-bottom: 12px; }

/* result */
.result-hero { text-align: center; padding: 30px 20px; }
.result-hero h1 { margin: 6px 0 4px; }
.result-hero p { color: var(--muted); margin: 0; }
.result-score { font-size: 3rem; font-weight: 700; line-height: 1; }
.result-hero.good { background: var(--good-bg); border-color: var(--good); }
.result-hero.good .result-score, .result-hero.good h1 { color: var(--good); }
.result-hero.warn { background: var(--warn-bg); border-color: var(--warn); }
.result-hero.warn .result-score, .result-hero.warn h1 { color: var(--warn); }
.result-hero.neutral .result-score { color: var(--muted); }

.option .muted { margin-left: auto; font-size: .78rem; }
.explain {
  margin-top: 10px; padding: 10px 12px; background: var(--brand-soft);
  border-radius: 8px; font-size: .9rem; color: var(--brand-dark);
}

/* progress */
.area { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.area:last-child { border-bottom: none; }
.area .info { flex: 1; min-width: 0; }
.area .title { font-weight: 600; font-size: .94rem; }
td .where { font-size: .78rem; color: var(--muted); font-weight: 400; }

@media (max-width: 640px) {
  .continue, .test-head, .test-foot { flex-direction: column; align-items: stretch; }
  .test-foot button, .continue button { width: 100%; }
  .result-score { font-size: 2.4rem; }
}

/* ---------------- dashboards ---------------- */

.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 860px) { .grid4 { grid-template-columns: repeat(2, 1fr); } }


.stat .num.alarm { color: var(--bad); }
td.alarm { color: var(--bad); font-weight: 700; }
tr.row-alarm { background: var(--bad-bg); }

/* heat map swatch — the red/amber/green the teacher actually scans */
.heat {
  display: inline-block; width: 14px; height: 14px; border-radius: 4px;
  vertical-align: middle;
}
.heat.strong      { background: var(--good); }
.heat.attention   { background: var(--warn-swatch); }
.heat.weak        { background: var(--bad); }
.heat.not-started { background: #cfd6e4; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; font-size: .82rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }

/* a percentage that reads as a bar and a number together */
.pct-cell { display: flex; align-items: center; gap: 8px; }
.pct-cell .meter { flex: 1; min-width: 60px; }
.pct-num { font-variant-numeric: tabular-nums; font-size: .84rem; min-width: 38px; text-align: right; }

.link-like { color: var(--brand); cursor: pointer; }
.link-like:hover { text-decoration: underline; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 5px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
ul.plain li:last-child { border-bottom: none; }
ul.plain .muted { font-size: .8rem; }

/* ---------------- school administration ---------------- */

/* A row that needs fixing before an import can proceed. Tinted rather than
   outlined so a long list reads as "these ones" at a glance. */
tr.row-error > td { background: var(--bad-bg); }

.right { text-align: right; }

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: inherit;
  resize: vertical;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: var(--subtle);
  padding: 2px 6px;
  border-radius: 5px;
}

/* ---------------- weekly reports ---------------- */

.week-block {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 14px;
}
.week-block:first-of-type { border-top: 0; }

.week-headline {
  font-size: 16px;
  font-weight: 600;
  margin: 8px 0 0;
}

.week-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}
.week-figures b { color: var(--ink); font-size: 15px; }

@media (max-width: 640px) {
  .week-figures { gap: 4px 14px; }
}

/* ---------------- header identity ---------------- */

/* Three columns rather than space-between, so the school name is centred on
   the page and does not drift as the name or role picker beside it changes
   width. */
/* fit-content caps the middle track: a short school name sizes to itself and
   stays centred, a long one stops at 34ch instead of sizing the track to its
   full width and squeezing the brand and the person's name into two lines
   each. A max-width on the element alone cannot do this — the track is sized
   from the content's max-content contribution, not from the used width. */
.topbar { display: grid; grid-template-columns: 1fr fit-content(34ch) 1fr; gap: 12px; }
/* justify-self sizes these to their content rather than to the track, so
   without the max-width a long name overflows its column and slides under the
   bell instead of being trimmed. */
.topbar .brand { justify-self: start; max-width: 100%; }
.topbar-right { justify-self: end; max-width: 100%; }

.topbar-school {
  justify-self: center;
  /* Lets the ellipsis below fire: without it the element is sized to the
     school's full name rather than to the column it sits in. */
  max-width: 100%;
  text-align: center;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-school .year { display: block; font-weight: 400; font-size: .72rem; color: var(--muted); }

.who { display: flex; flex-direction: column; line-height: 1.25; text-align: right; }
.who .who-name { color: var(--ink-2); font-weight: 600; }
.who .who-class { font-size: .78rem; color: var(--muted); }

/* On a phone the school name would squeeze the name and the Log out button
   into nothing, so it drops to its own line underneath. */
@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto;
    row-gap: 6px;
    padding: 10px 14px;
  }
  /* The school now lives in the account sheet; on a phone its own row cost
     more than it told anyone. */
  .topbar-school { display: none; }
}

/* ---------------- chapter grouping ---------------- */

.chapter { margin-top: 18px; }
.chapter:first-of-type { margin-top: 8px; }

.chapter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; margin-bottom: 6px;
}
.chapter-head h3 { margin: 0; }
.chapter .meter { margin-bottom: 4px; }

/* A lesson row is three columns of fixed-ish width, which leaves the title a
   sliver on a phone — "Rational and Irrational Numbers" wrapped to four lines.
   Below the breakpoint the title takes the full width and the status and
   button sit under it. */
@media (max-width: 640px) {
  .lesson {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 12px;
  }
  .lesson .info { grid-column: 1 / -1; }
  .lesson .state { min-width: 0; }
  .lesson button { justify-self: end; }
}

/* ---------------- platform portal ---------------- */

/* A whole row is the target, so it has to look like one. */
tr.clickable { cursor: pointer; }
tr.clickable:hover > td { background: var(--brand-soft); }

/* The onboarding wizard's progress. Steps already done are ticked rather than
   numbered, so the eye can find "where am I" without counting. */
.steps {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  margin: 8px 0 18px; font-size: .88rem; color: var(--muted);
}
.step { display: flex; align-items: center; gap: 8px; }
.step .dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--border); color: var(--ink-2); font-size: .78rem; font-weight: 700;
}
.step.now { color: var(--ink); font-weight: 600; }
.step.now .dot { background: var(--brand); color: #fff; }
.step.done .dot { background: var(--good); color: #fff; }

@media (max-width: 640px) {
  .steps { gap: 6px 14px; font-size: .8rem; }
}

/* A priced line on the billing screen: the amount, with what it multiplies by
   stated under it rather than left to be inferred from the label. */
.charge { margin-bottom: 10px; }
.charge > div { max-width: 260px; }
.charge .muted { margin-top: 2px; }

/* ---------------- timed tests ---------------- */

/* The clock is the one thing on a timed paper that must be seen without
   looking for it, so it sits where the eye already goes for progress. */
.countdown {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem;
  color: var(--ink); margin-bottom: 4px;
}
.countdown.low  { color: var(--bad); }
.countdown.over { color: var(--bad); text-transform: uppercase; letter-spacing: .02em; }

/* ---------------- notifications ---------------- */

.bell {
  position: relative; background: none; border: 1px solid var(--border);
  border-radius: 999px; width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2); cursor: pointer;
}
.bell:hover { background: var(--brand-soft); }
.bell-count {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: var(--bad); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center;
}

.inbox {
  position: fixed; top: 58px; right: 16px; width: min(380px, calc(100vw - 32px));
  max-height: 70vh; overflow: auto; z-index: 30;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.inbox-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card);
}
.inbox-item { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.inbox-item:hover { background: var(--brand-soft); }
.inbox-item.unread { background: var(--brand-soft); }
.inbox-item.unread .inbox-title::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); margin-right: 7px; vertical-align: middle;
}
/* What has been read stays — the inbox is the record of what the school
   said — but recedes: quieter type, no tint, and a rule between the new
   and the old so the eye lands on what still needs attention. */
.inbox-item.read { opacity: .72; }
.inbox-item.read .inbox-title { font-weight: 500; color: var(--ink-2); }
.inbox-sep {
  padding: 8px 14px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border);
}
.inbox-title { font-weight: 600; }
.inbox-more { display: block; width: 100%; text-align: center; padding: 11px; border: 0; border-top: 1px solid var(--border); }
.inbox-body  { font-size: .86rem; color: var(--ink-2); margin-top: 2px; }
.inbox-when  { font-size: .76rem; color: var(--muted); margin-top: 4px; }

button.link { background: none; border: 0; color: var(--brand); padding: 0; cursor: pointer; font: inherit; }
button.small { padding: 5px 10px; font-size: .82rem; }

/* ---------------- lesson tree ---------------- */

/* Three levels need to be told apart at a glance, so each one steps down in
   weight and size rather than relying on indentation alone. */
/* The staff heat map folds chapters with these same rows, so .chapter-block
   is listed alongside .tree — without it those buttons kept the primary
   button's blue fill, which read as "selected". */
.tree .tree-row, .chapter-block .tree-row {
  display: flex; align-items: baseline; gap: 10px; width: 100%;
  background: none; border: 0; padding: 10px 0; cursor: pointer; text-align: left;
  color: inherit; font: inherit;
}
.tree .tree-row:hover, .chapter-block .tree-row:hover { background: none; }
.tree .caret, .chapter-block .caret { color: var(--muted); font-size: .8rem; width: 12px; flex: none; }
.tree .tree-label, .chapter-block .tree-label { flex: 1; min-width: 0; }
.tree .tree-meta, .chapter-block .tree-meta {
  color: var(--muted); font-size: .8rem; font-weight: 400; flex: none;
}

.tree-row.subject .tree-label {
  font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink);
}
.tree-row.chapter .tree-label {
  font-size: .95rem; font-weight: 600; color: var(--ink-2);
}
.tree-row.chapter { padding: 8px 0; }

.tree-branch { border-top: 1px solid var(--border); }
.tree-children { padding-left: 22px; }
.tree-row.subject + .tree-children > .tree-branch:first-child { border-top: 0; }
.tree-children .lesson .title { font-weight: 500; font-size: .93rem; }
.tree-children > .meter { margin: 2px 0 6px; }

/* ---------------- a paper on the lesson page ---------------- */
.lesson.paper .title { font-weight: 600; }
.lesson.paper button[disabled] { opacity: .5; }

/* ---------------- per-subject continue card ---------------- */
.continue-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.continue-progress .meter { flex: 1; max-width: 220px; }

/* The picker needs to scroll without the dialog growing past the screen. */
.pick-list { max-height: 34vh; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; }
#pbPicked { max-height: 26vh; overflow-y: auto; }
#pbPicked .lesson { padding: 8px 0; }

/* ---------------- brand ---------------- */

/* The name carries a tagline under it, so the mark is a stacked block rather
   than a single line of text. */
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-weight: 700; font-size: 1.1rem; color: var(--brand); letter-spacing: -.01em;
}
.brand-tagline {
  font-size: .64rem; font-weight: 500; color: var(--muted);
  letter-spacing: .02em; white-space: nowrap;
}

/* On a narrow screen the tagline is the first thing that can go: the name
   still identifies the product, and the row has a name and a button to fit. */
@media (max-width: 560px) {
  .brand-tagline { display: none; }
  body.signed-out .brand-tagline { display: block; }
}

/* A consent tick is a record of what someone agreed to, so it reads as a
   statement rather than a setting. */
.wa-consent { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 0; }
.send-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.send-out { font-size: .82rem; }
.wa-consent input { width: auto; margin: 0; }

/* ---------------------------------------- staff heat map, grouped by chapter */

/* A chapter is a fold, not a card: nesting cards inside a card made the page
   look like a stack of unrelated panels rather than one syllabus. */
.chapter-block { border-top: 1px solid var(--border); }
.chapter-block:first-of-type { border-top: 0; }
.chapter-block .tree-children { padding-bottom: 10px; }
.chapter-block table { margin: 0; }

/* Who is accountable, directly under the class name. */
.teacher-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.teacher-strip .alert { margin: 0; }

/* Inside a dense table the default input sizing pushed the row height out. */
.taught-box { width: auto; margin: 0; }

/* ---------------- maths in question text ---------------- */

/* KaTeX sets its own font size relative to the surrounding text; left alone it
   renders noticeably larger than the sentence it sits inside. */
.katex { font-size: 1.05em; }
.katex-display { margin: 10px 0; }

/* A formula KaTeX could not parse, or that it never saw because the renderer
   failed to load. Showing the author's own source beats showing nothing. */
.math-raw {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .88em; background: var(--subtle); padding: 1px 5px; border-radius: 4px;
}
.math-bad { background: var(--bad-bg); color: var(--bad); }

/* The symbol palette under an authoring field. */
.math-palette {
  border: 1px solid var(--border); border-radius: 8px;
  margin: -6px 0 12px; background: var(--tint);
}
.math-palette-tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  padding: 6px 6px 0; border-bottom: 1px solid var(--border);
}
.math-tab {
  background: none; color: var(--muted); font-size: .78rem; font-weight: 600;
  padding: 5px 10px; border-radius: 6px 6px 0 0;
}
.math-tab:hover:not(:disabled) { background: var(--subtle); color: var(--ink); }
.math-tab.active { background: var(--card); color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }

.math-keys { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
/* An author style beats the browser's own [hidden] rule, so say it here. */
.math-keys[hidden] { display: none; }
.math-key {
  background: var(--card); border: 1px solid var(--border); color: var(--ink);
  min-width: 36px; padding: 5px 8px; font-size: .95rem; font-weight: 500;
  border-radius: 6px; line-height: 1.2;
}
.math-key:hover:not(:disabled) { background: var(--brand-soft); border-color: var(--brand); }

.math-hint { font-size: .76rem; color: var(--muted); padding: 0 8px 8px; margin: 0; }
.math-hint code { background: var(--subtle); padding: 0 3px; border-radius: 3px; }

/* What the student will see, shown while the author types. */
.math-preview {
  border: 1px dashed var(--border); border-radius: 8px;
  padding: 10px 12px; margin: -6px 0 12px; background: var(--card);
  font-size: .95rem; min-height: 40px; overflow-x: auto;
}
.math-preview-label {
  font-size: .76rem; font-weight: 600; color: var(--muted); margin-bottom: 4px;
}

/* ---------------- class test builder: topics to cover ---------------- */
.topic-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 720px) { .topic-pick { grid-template-columns: 1fr; } }
.topic-chapter { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.topic-chapter-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.topic-chapter-head .link { padding: 0 4px; font-size: .8rem; }
.topic-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer;
  font-size: .92rem; font-weight: 400; color: var(--ink); margin: 0;
}
.topic-row input { width: auto; margin: 0; }
.topic-row .topic-title { flex: 1; }
/* A topic with nothing in the bank is shown but cannot be ticked: the gap is
   the information, and hiding it would make the syllabus look shorter. */
.topic-row.empty { color: var(--muted); cursor: not-allowed; }

/* ---------------- teacher rankings ---------------- */
.trend { font-weight: 700; font-size: .85rem; }
.trend.up { color: var(--good); }
.trend.down { color: var(--bad); }

/* ---------------- a teacher's own row in the standings ---------------- */
tr.row-own > td { background: var(--brand-soft); }

/* ---------------- print ----------------
   A student's report is handed across a desk at a parents' evening, so what
   prints is the report and nothing else: no navigation, no buttons, no
   back links, and no page-break through the middle of a table row. */
.print-only { display: none; }


/* ======================================================================
   Dark
   Follows the phone rather than offering a switch: a student opening this
   at nine at night has already told their phone what they want, and a
   setting nobody finds is a setting nobody uses.

   Only the tokens move. Every screen is built from them, so the work here
   is choosing colours that keep the same meanings — green still means
   mastered, red still means weak, and the accent is still the one warm
   thing on the page.
   ====================================================================== */
/* Dark is a choice, not only a media query: the account menu offers Light,
   Dark and Auto, and the <head> script resolves Auto to one of the two before
   the first paint. So the tokens are keyed on data-theme, never on
   prefers-color-scheme directly. */
:root[data-theme="dark"] {
    --bg: #11151c;
    --card: #171c26;
    --ink: #e8ecf4;
    --ink-2: #c4cbd9;
    --muted: #949db0;

    /* The navy is lifted until it still carries white text on a dark card. */
    --brand: #4c6ef5;
    --brand-dark: #3b5bd9;
    --brand-soft: #1d2642;

    --accent: #f29b1d;
    --accent-ink: #f5c177;
    --accent-soft: #3a2a12;

    --good: #34d399;
    --good-bg: #112a21;
    --warn: #e0a942;
    --warn-swatch: #d9a13a;
    --warn-bg: #2d2413;
    --bad: #f87171;
    --bad-bg: #2e1a1a;

    --border: #273041;
    --subtle: #212937;
    --subtle-2: #2a3444;
    --tint: #1b212c;
    --track: #2a3242;

    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 18px rgba(0,0,0,.4);
  }

/* Subject tints are backgrounds here, not washes of colour. */
[data-theme="dark"] .tone-1 { --tone: #8da2fb; --tone-soft: #1b2440; }
[data-theme="dark"] .tone-2 { --tone: #5eead4; --tone-soft: #0f2a27; }
[data-theme="dark"] .tone-3 { --tone: #c4b5fd; --tone-soft: #231c3d; }
[data-theme="dark"] .tone-4 { --tone: #fdba74; --tone-soft: #33210f; }
[data-theme="dark"] .tone-5 { --tone: #f9a8d4; --tone-soft: #331426; }

/* The mark is drawn on white; a white tile beats a grey halo. */
[data-theme="dark"] .brand-mark { background: #fff; padding: 1px; }

/* A heat swatch that means "nothing here yet" has to read as absent
   against a dark card rather than as another colour. */
[data-theme="dark"] .heat.not-started { background: #39435a; }

/* The browser's own controls follow suit — otherwise a date field and a
   video player arrive as two bright rectangles. */
:root[data-theme="dark"] { color-scheme: dark; }

@media print {
  .topbar, .tabs, button, .legend, #modalRoot,
  .child-switch, .action-row, .listen-row, .listen-slot, .empty,
  .sheet, .sheet-backdrop, .inbox { display: none !important; }
  /* A fold on screen is a section on paper: a parents' evening should not
     hand over a report with half of it collapsed. */
  details.fold > summary::before { display: none; }
  details.fold[open] > summary, details.fold > summary { font-weight: 700; }
  details.fold > *:not(summary) { display: block !important; }
  .print-only { display: block; }
  .print-head {
    margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid #000;
    font-size: .95rem;
  }
  body { background: #fff; color: #000; }
  /* Printing follows the paper, never the phone's night setting. */
  :root {
    --card: #fff; --bg: #fff; --ink: #000; --ink-2: #222; --muted: #555;
    --border: #bbb; --subtle: #f1f1f1; --subtle-2: #e8e8e8; --tint: #fafafa;
  }
  .container { max-width: none; margin: 0; padding: 0; }
  .card {
    border: 1px solid #999; box-shadow: none; margin-bottom: 10px;
    break-inside: avoid; page-break-inside: avoid;
  }
  tr, .lesson, .area { break-inside: avoid; page-break-inside: avoid; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.05rem; }
  /* Meters are colour; on a mono printer they are an empty box, so the
     number beside them carries the meaning. */
  .meter { border: 1px solid #bbb; }
  .meter > div { background: #555 !important; }
  a[href]::after { content: ''; }
}

/* ---- marking written answers (teacher) and seeing them back (student) ---- */
.answer-text { white-space: pre-wrap; background: #f7f9fd; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 4px 0; line-height: 1.5; }
.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photo { position: relative; width: 120px; height: 120px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #f7f9fd; display: flex; align-items: center; justify-content: center; font-size: .8rem; color: var(--muted); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .remove { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 22px; height: 22px; line-height: 20px; padding: 0; font-size: .9rem; cursor: pointer; }
.photo.uploading::after { content: 'Uploading…'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.75); font-size: .78rem; }
.ai-box { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--brand-soft); border: 1px solid transparent; font-size: .92rem; }
.ai-box.warn { background: var(--warn-bg); }
.ai-box.bad  { background: var(--bad-bg); }
.ai-box .points { margin: 8px 0 0; padding: 0; list-style: none; }
.ai-box .points li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }
.ai-box .points .mk { white-space: nowrap; color: var(--muted); margin-left: auto; }
input.invalid { border-color: var(--bad); }
.add-photo { display: inline-flex; align-items: center; gap: 6px; }

/* ======================================================================
   Phones
   The app is used on a 375px screen by the two people it is really for: a
   student between classes and a parent on the way home. Everything below
   exists because that screen showed something the desktop never did.
   ====================================================================== */

/* ---------------- a table on a phone ----------------
   A table is columns, and a phone has room for about two. Every table here
   had a column carrying the meaning — the mastery figure, the score — and
   that is the one that fell off the right-hand edge.

   Below this width a row becomes a small card: the row's name, then each
   figure on its own line behind the column it came from. The labels are
   stamped onto the cells from the table's own header by UI.stackTables, so a
   table gets this by existing rather than by being rewritten. */
@media (max-width: 640px) {
  .scroll { overflow-x: visible; }

  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }

  table.stack tr {
    border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; margin-bottom: 8px; background: var(--card);
  }
  table.stack tr:last-child { margin-bottom: 0; }

  table.stack td {
    border: 0; padding: 3px 0;
    display: flex; gap: 10px; align-items: center;
  }
  table.stack td::before {
    content: attr(data-label);
    flex: 0 0 40%; color: var(--muted);
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
  }
  /* What the row is called takes the top line and the full width, with any
     swatch that came before it sitting on the same line. */
  table.stack td[data-name] {
    display: inline; font-weight: 600; font-size: .96rem; padding: 0;
  }
  table.stack td[data-lead] {
    display: inline-block; width: auto; padding: 0 7px 0 0; vertical-align: middle;
  }
  table.stack tr > td[data-name] + td { margin-top: 6px; }
  table.stack td[data-name]::before,
  table.stack td[data-lead]::before,
  table.stack td[data-label='']::before { display: none; }
  table.stack td:empty { display: none; }
  /* A meter is an empty div, so as a flex item it measures nothing and
     vanished. It takes the room left after the label. */
  table.stack .pct-cell { flex: 1; min-width: 0; }
  table.stack td > .meter { flex: 1 1 auto; min-width: 70px; }

  /* A row that was tinted to mean "look here" stays tinted as a card. */
  table.stack tr.row-alarm, table.stack tr.row-error { background: var(--bad-bg); }
  table.stack tr.row-error > td, table.stack tr.row-own > td { background: transparent; }
  table.stack tr.row-own { background: var(--brand-soft); }
}

/* ---------------- a topic beside its bar ----------------
   "Rational and Irrational Numbers" in a flex column next to a meter wrapped
   to four lines against a bar two fingers wide. The name takes the row and
   the bar goes under it. */
@media (max-width: 640px) {
  .area { flex-wrap: wrap; gap: 0 10px; padding: 10px 0; }
  .area .info { flex: 1 0 100%; margin-bottom: 6px; }
  .area .meter { flex: 1; }
}

/* ---------------- a chapter row ----------------
   The name and its summary shared one line, and at 375px they overlapped:
   "Numbermastery · 2 of 2 taught". The summary drops under the name. */
@media (max-width: 640px) {
  .tree .tree-row, .chapter-block .tree-row { flex-wrap: wrap; }
  .tree .tree-meta, .chapter-block .tree-meta { flex-basis: 100%; padding-left: 22px; }
}

/* ---------------- navigation ----------------
   A row of pills at the top of a long page is gone the moment it is scrolled,
   which is the moment a student wants it. For the two roles that live on a
   phone, their sections sit where a phone keeps navigation. Staff keep the
   pills: their .tabs rows are actions rather than sections, and they are
   mostly at a desk. */
@media (max-width: 640px) {
  body.nav-bottom { padding-bottom: 68px; }
  body.nav-bottom .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    margin: 0; gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    background: var(--card); border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(20, 28, 40, .07);
  }
  body.nav-bottom .tabs button {
    flex: 1 1 0; min-width: 0; background: none; color: var(--muted);
    padding: 9px 2px 7px; font-size: .76rem; font-weight: 600; border-radius: 0;
    border-top: 3px solid transparent;
  }
  body.nav-bottom .tabs button.active {
    background: none; color: var(--brand); border-top-color: var(--brand);
  }
}

/* ---------------- the header ----------------
   The most expensive strip on a phone: it was 90px of brand, bell, name, a
   Log out button and the school, before any content. The school and the way
   out moved into the sheet behind the name. */
@media (max-width: 720px) {
  .topbar { padding: 9px 12px; }
  .brand-name { font-size: 1rem; white-space: nowrap; }
  .who { max-width: 44vw; }
  .who .who-name, .who .who-class { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* A 25px-tall button is a fingernail target. These are secondary actions in
     a dense list, so they stay small — but not smaller than a fingertip. */
  button.small { min-height: 36px; padding: 7px 12px; }
}

/* The name in the header is a button now, not a label. */
.who-btn {
  background: none; border: 1px solid transparent; color: inherit;
  padding: 3px 6px; border-radius: 8px; font: inherit; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.who-btn:hover:not(:disabled) { background: var(--brand-soft); }
.who-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .76rem; font-weight: 700; letter-spacing: .02em;
}

/* The sheet itself: a menu on a desktop, a sheet from the bottom on a phone. */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: transparent; }
.sheet {
  position: fixed; top: 56px; right: 16px; z-index: 51; width: min(280px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.sheet-head { padding: 13px 15px; border-bottom: 1px solid var(--border); }
.sheet-head .nm { font-weight: 700; }
.sheet-head .sub2 { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.sheet button {
  display: block; width: 100%; text-align: left; background: none; color: var(--ink);
  border: 0; border-top: 1px solid var(--border); border-radius: 0;
  padding: 12px 15px; font-size: .92rem; font-weight: 500;
}
.sheet button:first-of-type { border-top: 0; }
.sheet button:hover:not(:disabled) { background: var(--brand-soft); }
.sheet button.danger-text { color: var(--bad); }
/* Light / Dark / Auto, as one segmented row: three equal choices, the
   current one filled. A toggle switch would have no place for "Auto". */
.sheet .sheet-row { padding: 11px 15px 13px; border-top: 1px solid var(--border); }
.sheet .sheet-row .lbl { font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 3px; background: var(--subtle); }
.sheet .seg button {
  flex: 1; border: 0; border-radius: 999px; padding: 7px 0; text-align: center;
  font-size: .86rem; font-weight: 600; color: var(--ink-2); background: none; width: auto;
}
.sheet .seg button:hover:not(:disabled) { background: var(--subtle-2); }
.sheet .seg button[aria-pressed="true"] { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }
/* The view picker: a pill in the header, the same height as the bell. A real
   <select>, so a phone opens its own picker and a keyboard just works. */
.view-pick { margin: 0; display: inline-flex; }
.view-pick select {
  width: auto; max-width: 22ch; height: 36px; margin: 0; padding: 0 30px 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background-color: var(--card); color: var(--ink-2);
  font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
  text-overflow: ellipsis;
}
.view-pick select:hover { background-color: var(--brand-soft); }
@media (max-width: 720px) { .view-pick select { max-width: 30vw; padding-left: 10px; font-size: 1rem; } }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 640px) {
  .sheet-backdrop { background: rgba(16, 22, 34, .35); }
  .sheet {
    top: auto; right: 0; left: 0; bottom: 0; width: auto;
    border-radius: 14px 14px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* ======================================================================
   Phase two and three: the app's own face
   ====================================================================== */

/* ---------------- the mark ---------------- */
.brand { flex-direction: row; align-items: center; gap: 9px; }
.brand-mark { border-radius: 7px; flex: none; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
body.signed-out .brand-mark { width: 36px; height: 36px; }

/* A grid column defaults to min-content, so a nowrap tagline inside it pushes
   the header wider than the screen instead of being trimmed. These let the
   brand shrink, and the tagline end in an ellipsis rather than off the edge. */
.brand, .brand-text { min-width: 0; }
.brand-name, .brand-tagline { overflow: hidden; text-overflow: ellipsis; }

/* On a phone the strip also has to hold the bell and whose account this is,
   and there is not room for the wordmark as well. Signed in, the mark alone
   says which app this is, so the word is what goes — a truncated "Aakar
   Lea..." is worse than no word at all. Signed out there is nothing to the
   right of it, so the full name and its tagline stay. */
@media (max-width: 560px) {
  body:not(.signed-out) .brand-name { display: none; }
}

/* ---------------- subjects have colours ----------------
   Not decoration: on a screen holding two subjects at once, the colour is
   what tells them apart before either label is read. Derived from the name
   by UI.subjectTone, so it is the same everywhere without being stored. */
.tone-1 { --tone: #1f3a93; --tone-soft: #e8edf9; }   /* navy   */
.tone-2 { --tone: #0f766e; --tone-soft: #dff0ee; }   /* teal   */
.tone-3 { --tone: #6d28d9; --tone-soft: #ece4fb; }   /* violet */
.tone-4 { --tone: #b45309; --tone-soft: #fbead8; }   /* rust   */
.tone-5 { --tone: #be185d; --tone-soft: #fbe2ec; }   /* rose   */

.card.continue.tone-1, .card.continue.tone-2, .card.continue.tone-3,
.card.continue.tone-4, .card.continue.tone-5 {
  background: linear-gradient(180deg, var(--tone-soft), var(--card));
  border-color: var(--tone);
}
.card.continue .eyebrow { color: var(--tone, var(--brand-dark)); }
.card.tree { border-left: 3px solid var(--tone, var(--border)); }
.card.tree .tree-row.subject .tree-label { color: var(--tone, var(--ink)); }

/* ---------------- a list that folds ----------------
   Sixteen topics, three of which need doing. The three are open; the rest
   are a number you can open. */
details.fold { border-top: 1px solid var(--border); padding: 4px 0; }
details.fold:first-of-type { border-top: 0; }
details.fold > summary {
  cursor: pointer; padding: 9px 2px; font-weight: 600; font-size: .95rem;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: '▸'; color: var(--muted); font-size: .8rem; transition: transform .15s;
}
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary .muted { margin-left: auto; font-weight: 600; }

/* ---------------- a pass is worth a moment ----------------
   The only animation in the product, on the one screen a student has worked
   for. It runs once and respects a phone told to stop moving things. */
.result-tick {
  width: 54px; height: 54px; margin: 0 auto 6px; border-radius: 50%;
  background: var(--good); color: #fff; font-size: 1.7rem; line-height: 54px;
  animation: pop .45s cubic-bezier(.2, 1.3, .4, 1) both;
}
.result-hero.celebrate .result-score { animation: rise .5s .1s ease-out both; }
@keyframes pop  { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(7px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .result-tick, .result-hero.celebrate .result-score { animation: none; }
}

/* ---------------- the parent's card ---------------- */
.child-card { scroll-margin-top: 72px; }
.child-head { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.child-head .grow { flex: 1; min-width: 0; }
.child-head .who-avatar { width: 38px; height: 38px; font-size: .84rem; }
.child-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* On a phone the button leaves the name about a hundred pixels, which breaks
   "Aarav Kumar" across two lines beside a centred avatar. The child's name is
   the heading of their card, so the button goes below it instead. */
@media (max-width: 560px) {
  .child-head { flex-wrap: wrap; }
  .child-head > button { flex: 1 0 100%; order: 3; margin-top: 2px; }
}

/* The week, read aloud. */
.listen-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.listen-slot:not(:empty) { margin-top: 10px; }
.listen-slot audio { width: 100%; height: 38px; }

/* ---------------- staff actions ----------------
   Buttons, not a tab row they had failed to choose from. */
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .action-row { width: 100%; }
  .action-row button { flex: 1 1 calc(50% - 4px); }
}

/* Where the principal should look, before the table that also says it. */
.card.attention { border-left: 3px solid var(--warn-swatch); }
.card.attention ul.plain li { padding: 7px 0; }
.card.attention .link { padding: 0 4px; }

/* ---------------- a screen with nothing on it yet ----------------
   "Nothing set yet." alone in a card reads as a failure to load. */
.empty { text-align: center; padding: 26px 18px; }
.empty .empty-mark {
  width: 42px; height: 42px; margin: 0 auto 10px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand); font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center;
}
.empty h3 { margin-bottom: 4px; }
.empty p { color: var(--muted); font-size: .9rem; margin: 0 auto 14px; max-width: 42ch; }
.empty .inline { justify-content: center; }

/* ---------------- the action stays in reach ----------------
   A long paper on a phone put Submit two screens below the last question. */
@media (max-width: 640px) {
  .card.test-foot, .card.sticky-foot {
    position: sticky; bottom: 0; z-index: 12; margin-bottom: 0;
    padding: 11px 14px calc(11px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(20, 28, 40, .08);
  }
  body.nav-bottom .card.test-foot, body.nav-bottom .card.sticky-foot { bottom: 60px; }
}
