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

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #161c28;
  --ink-2: #3d4657;
  --muted: #6b7385;
  --brand: #2f4bcd;
  --brand-dark: #263ea8;
  --brand-soft: #eaeefc;
  --good: #1f7a45;
  --good-bg: #e6f4ec;
  --warn: #8a5a12;
  --warn-bg: #fdf1dc;
  --bad: #b3342c;
  --bad-bg: #fbeae8;
  --border: #e1e6f0;
  --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 { background: #eef1f8; color: var(--ink); }
button.secondary:hover:not(:disabled) { background: #e2e7f3; }
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; }

input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: .92rem; margin-bottom: 12px;
  background: #fff; 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: #eef1f8; color: var(--ink); }
.tabs button.active { background: var(--brand); color: #fff; }

/* ---------------- 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: #eef1f8; color: var(--muted); }
.badge.brand{ background: var(--brand-soft); color: var(--brand-dark); }

.meter { background: #e9edf6; border-radius: 999px; height: 7px; overflow: hidden; }
.meter > div { height: 100%; background: var(--brand); transition: width .35s; }
.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; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 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: #f7f9fd; }
.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: #fff; 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; }
.reaction-bar button.liked { background: var(--bad-bg); color: var(--bad); }
.reaction-bar button.liked:hover:not(:disabled) { background: #f8dcd9; }
.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); } }
@media (max-width: 460px) { .grid4 { grid-template-columns: 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: #d9a13a; }
.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: #fff5f5; }

.right { text-align: right; }

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: #f1f4fa;
  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. */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; }
.topbar .brand { justify-self: start; }
.topbar-right { justify-self: end; }

.topbar-school {
  justify-self: center;
  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;
  }
  .topbar-school { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .topbar-school .year { display: inline; margin-left: 6px; }
}

/* ---------------- 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: #f3f6ff; }
.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;
}
.inbox-title { font-weight: 600; }
.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; }
.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: #eef1f8; 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: #fbfcfe;
}
.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: #eef1f8; color: var(--ink); }
.math-tab.active { background: #fff; 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: #fff; 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: #eef1f8; 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: #fff;
  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; }

@media print {
  .topbar, .tabs, button, .legend, #modalRoot { display: none !important; }
  .print-only { display: block; }
  .print-head {
    margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid #000;
    font-size: .95rem;
  }
  body { background: #fff; }
  .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; }
