[hidden] { display: none !important; }
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #5b6676;
  --border: #dde2e8;
  --accent: #0b6e8a;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1f5;
  --ok: #1f7a4d;
  --ok-soft: #e3f4ea;
  --warn: #9a5b00;
  --danger: #b3261e;
  --hot: #d1495b;
  --cold: #2d7dd2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  /* chart series, in this order (charts.js uses them for series without a colour) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  /* fluids in schematics */
  --fluid-water: #4f9fe0;
  --fluid-seawater: #2a7fa8;
  --fluid-oil: #e0a84a;
  --fluid-ethanol: #e0a84a;
  --fluid-glycerin: #b9a3e3;
  --fluid-mercury: #9aa3ad;
  --on-fill: #ffffff; /* text on a coloured bar or segment */
  /* instruments (apps/_lib/instruments.js): meter bodies, dial rims, LCD displays */
  --ins-body: #3b4654;
  --ins-body-ink: #f2f5f8;
  --ins-rim: #8d97a3;
  --lcd-bg: #dce6d3;
  --lcd-ink: #1c2b1e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not(.force-light) { /* .force-light: the printed book (print.html) and its snapshots stay light */
    --bg: #11151b;
    --surface: #1a2029;
    --text: #e6ebf1;
    --muted: #9aa6b5;
    --border: #2c3542;
    --accent: #4fb3cf;
    --accent-ink: #0b1a20;
    --accent-soft: #16323b;
    --ok: #5fcf95;
    --ok-soft: #173326;
    --warn: #e0a64a;
    --danger: #ef7b72;
    --hot: #ef6f80;
    --cold: #6aa9f0;
    --shadow: none;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --fluid-water: #3d8bd0;
    --fluid-seawater: #2f8fbd;
    --fluid-oil: #c99238;
    --fluid-ethanol: #c99238;
    --fluid-glycerin: #9f88d0;
    --fluid-mercury: #8a939e;
    --on-fill: #11151b;
    --ins-body: #2b333f;
    --ins-body-ink: #e6ebf1;
    --ins-rim: #5d6876;
    --lcd-bg: #15241a;
    --lcd-ink: #a8e8b4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.8em; }
code { font-size: 0.92em; }
.muted { color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.logo {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; letter-spacing: 0.5px;
}
.topbar nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; }
.who { color: var(--muted); font-size: 0.9em; overflow-wrap: anywhere; }

/* controls */
.btn, button {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn.small, button.small { padding: 4px 10px; font-size: 0.9em; }
.btn.ghost, button.ghost { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button:disabled { opacity: 0.55; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 0.9em; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 180px; }

/* panels & cards */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.card .meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.85em; color: var(--muted); margin-top: auto; padding-top: 6px; }
.card.done { border-color: var(--ok); }
button.role-card { font: inherit; color: inherit; text-align: left; cursor: pointer; align-items: flex-start; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 0.78em; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge { font-size: 0.8em; padding: 2px 9px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); font-weight: 600; white-space: nowrap; }
.badge.todo { background: transparent; color: var(--muted); border: 1px solid var(--border); font-weight: 400; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: 0.9em; }
.hero { padding: 28px 0 8px; }
.hero p { max-width: 640px; color: var(--muted); font-size: 1.05em; }
.progressbar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.progressbar > div { height: 100%; background: var(--ok); }
.msg { font-size: 0.92em; min-height: 1.3em; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 28px 0 12px; }
.course { margin-top: 36px; }
.topic { margin: 18px 0 8px; }
.topic h3 { font-size: 1rem; margin-bottom: 10px; }
.code { font: 600 1.35em ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 2px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.92em; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-weight: 600; color: var(--muted); background: var(--bg); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.c, th.c { text-align: center; }
td.tick { color: var(--ok); font-weight: 700; }
td.cross { color: var(--border); }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
th.sticky-col { background: var(--bg); }

/* app pages */
.app-layout { display: grid; gap: 16px; grid-template-columns: 340px 1fr; max-width: 1280px; margin: 0 auto; padding: 16px; }
.app-layout > .full { grid-column: 1 / -1; }
@media (max-width: 860px) { .app-layout { grid-template-columns: 1fr; } }
.slider { margin-bottom: 14px; }
.slider .lbl { display: flex; justify-content: space-between; font-size: 0.9em; }
.slider .lbl output { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.slider input[type=range] { width: 100%; accent-color: var(--accent); padding: 0; border: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.kpi .v { font-size: 1.3em; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 0.8em; color: var(--muted); overflow-wrap: break-word; } /* a long label such as η_II = COP_R/COP_R,Carnot wraps rather than spilling out of a narrow tile */
.pz-side .kpi .k { overflow-wrap: normal; } /* Present mode widens the columns instead (layoutKpis) */
.chart-box { position: relative; height: 420px; }
@media (max-width: 600px) { .chart-box { height: 300px; } }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border-color: var(--border); padding: 5px 12px; }
.tabs button[aria-selected=true] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.task { border-left: 4px solid var(--accent); }
.task.done { border-left-color: var(--ok); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.streams input { width: 72px; padding: 4px 6px; }
.streams input.name { width: 52px; }
.streams td, .streams th { padding: 4px; }
/* shared by app pages: state tables, sliders turned off, checkboxes, sum rows, numeric cells */
table.states { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.9em; }
table.states th, table.states td { padding: 4px 10px; text-align: right; border-bottom: 1px solid var(--border); }
table.states th:first-child, table.states td:first-child { text-align: left; }
.slider.off { opacity: 0.45; }
.check input { width: auto; }
tr.sum td { font-weight: 700; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
select.full { width: 100%; margin: 4px 0 12px; }
/* colour key: <div class="swatches"><span style="--swatch: var(--hot)">label</span>…</div> */
.swatches span::before {
  content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px;
  background: var(--swatch, var(--muted));
}
/* utilities (in place of inline styles) */
.fs-sm { font-size: 0.85em !important; }
.fs-90 { font-size: 0.9em !important; }
.mt-6 { margin-top: 6px !important; }
.mt-8 { margin-top: 8px !important; }
.mt-10 { margin-top: 10px !important; }
.mt-12 { margin-top: 12px !important; }
.mb-8 { margin-bottom: 8px !important; }
.mb-10 { margin-bottom: 10px !important; }
.mb-12 { margin-bottom: 12px !important; }
.mb-14 { margin-bottom: 14px !important; }
.math { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-style: italic; }
form.panel input, form.panel select { width: 100%; }
form.panel input[type=radio], form.panel input[type=checkbox] { width: auto; }
select { max-width: 100%; }
/* keep grid/flex children from growing past narrow screens */
.app-layout > *, .grid > *, .kpis > * { min-width: 0; }
@media (max-width: 860px) { .app-layout { grid-template-columns: minmax(0, 1fr); } }
.panel select { max-width: 100%; }
.concept-head { display: flex; gap: 8px; align-items: baseline; }
.concept-head h3 { margin: 0; }
.concept-head .num { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.card.pending { border-style: dashed; box-shadow: none; background: transparent; }
.card.pending:hover { border-color: var(--border); }
.card.pending .num { color: var(--muted); }
th.c { white-space: normal; min-width: 110px; max-width: 160px; font-size: 0.85em; vertical-align: bottom; }

/* ---- Learn / Explore / Apply steps ---- */
.stepper {
  position: sticky; top: 49px; z-index: 9; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  padding: 6px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.stepper a {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px;
  color: var(--muted); text-decoration: none; font-size: 0.92em; border: 1px solid transparent;
}
.stepper a .n, .step-title .n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--border); color: var(--text); font-size: 0.8em; font-weight: 700;
}
.stepper a.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.stepper a.active .n { background: var(--accent); color: var(--accent-ink); }
.step { max-width: 1280px; margin: 0 auto; padding: 20px 16px 8px; scroll-margin-top: 100px; }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; margin: 0 0 14px; }
.step-title .n { width: 28px; height: 28px; background: var(--accent); color: var(--accent-ink); font-size: 0.85em; }
/* the standard openings of Learn ("Concept: …" + one sentence) and Explore (a question + tries), from catalog.json */
.lead-box { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); padding: 10px 16px; margin: 0 0 14px; }
.lead-box p { margin: 0 0 4px; }
.lead-box p:last-child { margin-bottom: 0; }
.lead-box .lead-k { color: var(--muted); }
.lead-box .lead-k strong { color: var(--text); }
.lead-box .lead-q { font-size: 1.05em; margin-bottom: 6px; }
.lead-box ul { margin: 2px 0 0; padding-left: 1.3em; }
.lead-box li { margin: 1px 0; }
.step .app-layout { padding: 0; max-width: none; }
#learn .panel, #learn .concept-lead { max-width: 860px; }
#learn .panel p, #learn .panel li { max-width: 75ch; }
.eq {
  font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-size: 1.1em; padding: 10px 14px; margin: 8px 0 12px;
  background: var(--accent-soft); border-radius: 8px; overflow-x: auto;
}
.questions { display: grid; gap: 14px; }
.question { border-left: 4px solid var(--border); }
.question.solved { border-left-color: var(--ok); }
.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.qnum { font-weight: 700; color: var(--accent); }
.qtick { color: var(--ok); font-weight: 700; visibility: hidden; }
.question.solved .qtick { visibility: visible; }
.choices { display: grid; gap: 6px; justify-items: start; }
/* Apply: "Practise with new numbers" (exploratory.js) */
.apply-mode { display: grid; gap: 8px; justify-items: start; margin-bottom: 12px; }
.apply-mode:empty { display: none; }
.apply-mode .row { align-items: center; }
.practice-note { color: var(--text); padding: 8px 12px; border-radius: 8px; border-left: 4px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent); }
.practising .question { border-left-style: dashed; }
.practising .question.solved { border-left-color: var(--warn); }
.practising .qtick { color: var(--warn); }
.choice { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 1em; margin: 0; cursor: pointer; }
.choice input { margin-top: 4px; }
#apply.done .step-title .n { background: var(--ok); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 0.95em; margin: 6px 0; cursor: pointer; }

/* class app picker (teacher dashboard) */
.pick-tree { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.pick-topic summary { cursor: pointer; padding: 4px 0; }
.pick-topic summary label.check { display: inline-flex; margin: 0; font-weight: 600; }
.pick-apps { display: grid; gap: 2px; padding: 2px 0 8px 22px; }
.pick-apps label.check { margin: 0; font-size: 0.9em; }
.share { border-left: 4px solid var(--accent); }
.share-text { white-space: pre-wrap; margin: 0; font: 0.9em/1.5 ui-monospace, Menlo, monospace; background: var(--bg); padding: 10px 12px; border-radius: 8px; }

/* Class discussion board */
.q-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.q-card.open { border-left: 4px solid var(--warn); }
.q-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; align-items: center; font-size: .9em; }
.q-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.q-reply { border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; padding: 8px 12px; }
.q-answer-form textarea, #questions textarea { width: 100%; box-sizing: border-box; font: inherit; }
.notice { border-left: 4px solid var(--ok); }

/* Home page filters */
.filters { gap: 8px; }
.filter-row { display: flex; gap: 10px; align-items: baseline; }
.filter-label { min-width: 64px; font-size: .9em; }
.tabs.chips { margin-bottom: 0; }
.tabs button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
@media (max-width: 600px) { .filter-row { flex-direction: column; gap: 4px; } }

/* Super admin viewing as another role */
.chip.viewing-as { border-color: var(--warn); color: var(--warn); text-decoration: none; }
/* Super admins' role dropdown in the top bar; amber while viewing as another role. */
.role-switch { width: auto; padding: 3px 8px; font-size: 0.9em; border-radius: 99px; }
.role-switch.viewing { border-color: var(--warn); color: var(--warn); }

/* ---- Signed-out landing page ---- */
.landing { display: flex; flex-direction: column; gap: 28px; padding: 24px 0 8px; }
.landing-hero {
  position: relative; overflow: hidden; border-radius: 18px; border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 100%);
  padding: 56px 40px; min-height: 380px; display: flex; align-items: center;
}
.landing-map { position: absolute; inset: 0; pointer-events: none; }
.landing-map svg { width: 100%; height: 100%; display: block; }
.landing-map .contours path { stroke: var(--accent); stroke-width: 1.2; opacity: 0.18; }
.landing-map .route { stroke: var(--hot); stroke-width: 2.5; stroke-dasharray: 2 9; stroke-linecap: round; opacity: 0.7; }
.landing-map .route-points circle { fill: var(--surface); stroke: var(--hot); stroke-width: 2.5; opacity: 0.85; }
.landing-copy { position: relative; max-width: 560px; }
.landing-eyebrow { margin: 0 0 10px; color: var(--accent); font-weight: 600; letter-spacing: 0.02em; font-size: 0.92em; }
.landing-copy h1 { font-size: clamp(1.9em, 4.5vw, 2.8em); letter-spacing: -0.01em; margin-bottom: 14px; }
.landing-message { font-size: 1.1em; color: var(--text); margin: 0 0 22px; }
.landing-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.landing-signin { padding: 10px 18px; font-size: 1.02em; }
.landing-hint { margin: 14px 0 0; color: var(--muted); font-size: 0.9em; }
.landing-route { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; position: relative; }
.landing-route::before {
  content: ''; position: absolute; left: 8%; right: 8%; top: 0;
  border-top: 2px dashed var(--border);
}
.waypoint { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 44px 18px 16px; }
.waypoint h2 { font-size: 1.1em; margin-bottom: 4px; }
.waypoint p { margin: 0; color: var(--muted); }
.waypoint-pin {
  position: absolute; top: -20px; left: 18px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); border: 4px solid var(--bg);
  display: grid; place-items: center; font-weight: 700;
}
.landing-contact { text-align: center; padding: 8px 0; }
.landing-contact h2 { font-size: 1.25em; }
.landing-contact p { color: var(--muted); margin: 0 0 6px; }
.landing-contact a { font-weight: 600; font-size: 1.05em; }
.landing-footer { text-align: center; color: var(--muted); font-size: 0.85em; padding: 8px 0 24px; }
@media (max-width: 700px) {
  .landing-hero { padding: 36px 20px; min-height: 0; }
  .landing-route { grid-template-columns: 1fr; gap: 26px; }
  .landing-route::before { display: none; }
}

/* App header breadcrumb: brand / course code / app */
.topbar a.crumb { color: var(--muted); font-weight: 600; text-decoration: none; }
.topbar a.crumb:hover { color: var(--accent); text-decoration: underline; }

/* Started but not finished: some Apply questions correct, app not yet completed */
.badge.attention { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); border: 1px solid var(--warn); font-weight: 600; }
td.attention { color: var(--warn); font-weight: 700; }
.card.attention { border-color: var(--warn); }

/* Landing: student / teacher switch above the waypoints */
.landing-how { display: flex; flex-direction: column; gap: 26px; }
.landing-tabs { justify-content: center; margin: 0; }

/* Signed-in dashboard: overall progress, up next, course cards */
.dash-overall { max-width: 420px; }
.dash-courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.course-card .kpis { margin: 0; }
.card-reason { margin: 0; font-size: .85em; font-weight: 600; color: var(--accent); }
.card.attention .card-reason { color: var(--warn); }
.topic-progress { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .9em; }
.topic-progress li { display: grid; grid-template-columns: minmax(0, 1fr) 90px 52px; gap: 10px; align-items: center; }
.topic-progress .tp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-progress .tp-bar { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.topic-progress .tp-bar > span { display: block; height: 100%; background: var(--ok); }
.topic-progress .tp-count { text-align: right; white-space: nowrap; }
.tp-attention { color: var(--warn); font-weight: 700; }
@media (max-width: 480px) { .dash-courses { grid-template-columns: 1fr; } .topic-progress li { grid-template-columns: minmax(0, 1fr) 60px 46px; } }
/* Space between dashboard sections (Up next, Your courses, Classes you teach, …) */
.dash-section { margin-top: 32px; }
#classes { margin-top: 32px; }
/* Student dashboard: course chips and enrol form */
.course-chips { margin: 0; }
.course-chips .enrol-chip { border-style: dashed; }
.enrol-form { align-items: end; }
#courses .course-card { max-width: 640px; }
/* First-sign-in details form: name, then university, then buttons */
.details-form { max-width: 420px; gap: 14px; }
.details-form input, .details-form select { width: 100%; }
/* Admin: a fixed role (Admin) lines up with the text inside the role dropdowns (border + padding) */
.role-fixed { display: inline-block; padding-left: 11px; }

/* Week planner (teacher: class schedule) */
/* Topics tray on the left; weeks three across (12 teaching weeks = 4 rows), one across on phones. */
.planner .week-board { display: grid; grid-template-columns: 240px 1fr; gap: 10px; align-items: start; }
.planner .week-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) {
  .planner .week-board { grid-template-columns: 1fr; }
  .planner .week-grid { grid-template-columns: 1fr; }
  .planner .week-col.tray { position: static; max-height: none; }
}
.planner .week-col { min-height: 110px; background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.planner .week-col.tray { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; background: var(--surface); border-style: solid; }
.planner .week-col.tray.drop { background: var(--accent-soft); }
.planner .week-topic.placed > summary { opacity: 0.7; }
.planner .week-col.drop { border-color: var(--accent); background: var(--accent-soft); }
.planner .week-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 0.9em; }
.planner .week-topic { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: grab; }
.planner .week-topic > summary { display: flex; gap: 6px; align-items: center; padding: 6px 8px; font-size: 0.88em; list-style: none; }
.planner .week-topic > summary::-webkit-details-marker { display: none; }
.planner .week-apps { display: flex; flex-direction: column; gap: 4px; padding: 0 6px 6px; }
.planner .week-app { display: flex; gap: 6px; align-items: center; font-size: 0.82em; padding: 3px 4px; border-radius: 6px; cursor: grab; }
.planner .week-app:hover { background: var(--accent-soft); }
.planner .week-move { font-size: 0.85em; padding: 2px 4px; max-width: 110px; }
.planner .grip { color: var(--muted); cursor: grab; }
.planner .grow { flex: 1; min-width: 0; }
.planner .week-empty { font-size: 0.85em; margin: 8px 0; text-align: center; }
.planner .link-x { background: none; border: none; color: inherit; padding: 0 2px; cursor: pointer; }
/* Student: weekly plan */
.week-plan .week-row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.week-plan .week-row.now { font-weight: 600; }
.late { color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.week-plan { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--bg); }
.week-apps-list { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
/* The new-class form spans the full width while its advanced section (week planner) is open. */
form.panel:has(> details.advanced[open]) { grid-column: 1 / -1; }
details.advanced > summary { cursor: pointer; }
.planner .break-col { background: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--muted) 10%, transparent) 8px 16px); border-style: solid; cursor: grab; min-height: 0; }
.planner .break-item { border-style: dashed; }
.planner .summary-like { display: flex; gap: 6px; align-items: center; padding: 6px 8px; font-size: 0.88em; }
.planner .break-col .week-head { flex-direction: column; align-items: flex-start; gap: 2px; }
/* Header traffic light: is the apps' Python runtime stored on this device? */
.labs-light { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; cursor: help;
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 22%, transparent); background: currentColor; }
.labs-light[data-state="green"] { color: #22a559; }
.labs-light[data-state="amber"] { color: #e8a317; animation: labs-pulse 1.2s ease-in-out infinite; }
.labs-light[data-state="red"] { color: #d64545; }
@keyframes labs-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .labs-light[data-state="amber"] { animation: none; } }
/* Merged apps (parts A, B…) and digital labs (timed stages): a list of links to the parts at the top of a section,
   and a heading per part with its suggested time. */
.part-list { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.part-list a { display: inline-flex; gap: 6px; align-items: baseline; padding: 3px 10px; border: 1px solid var(--border);
  border-radius: 999px; text-decoration: none; color: var(--text); font-size: 0.9em; background: var(--surface); }
.part-list a:hover { border-color: var(--accent); }
.part-list .min, .part-head .min { color: var(--muted); font-size: 0.85em; font-weight: 400; }
.part-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; margin-top: 0; }

/* Previous / next app arrows in an app's top bar */
.app-prevnext { display: inline-flex; gap: 4px; margin-left: 4px; }
.app-prevnext .btn { padding: 2px 10px; line-height: 1.4; }
.app-prevnext [aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

/* App stepper: unanswered questions count on the Discuss step (teachers and tutors) */
.stepper .n.waiting { background: var(--warn); color: #fff; }

/* Icon-only buttons (copy to clipboard) */
button.icon-btn, button.small.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 3px 5px; line-height: 0; vertical-align: middle; }

/* ---- Present mode (/apps/_lib/present.js): a 1280 × 720 slide zoomed to the screen; 21px ≈ 16pt, the floor ---- */
body.presenting { overflow: hidden; }
.present { position: fixed; inset: 0; z-index: 1000; background: #000; display: grid; place-items: center; }
.pz-stage { position: relative; width: 1280px; height: 720px; background: var(--bg); color: var(--text); display: grid; grid-template-rows: 40px 1fr; grid-template-columns: minmax(0, 1fr); overflow: hidden; font-size: 21px; line-height: 1.35; }
.pz-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 12px 0 36px; border-bottom: 1px solid var(--border); }
.pz-title { flex: 1 1000 auto; min-width: 120px; font-size: 21px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz-nav { display: flex; align-items: center; gap: 6px; font-size: 21px; color: var(--muted); flex: none; }
.pz-dots { display: flex; gap: 8px; }
.pz-dot { width: 14px; height: 14px; padding: 0; border-radius: 50%; border: 2px solid var(--muted); background: transparent; cursor: pointer; }
.pz-dot.on { background: var(--accent); border-color: var(--accent); }
.pz-btn { font-size: 21px; line-height: 1; padding: 2px 8px; background: transparent; color: var(--text); border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.pz-btn:hover { border-color: var(--accent); }
.pz-flag { font-size: 21px; padding: 2px 8px; border-radius: 6px; background: var(--warn-soft, #fde68a); color: #713f12; }
.pz-body { display: grid; grid-template-columns: 40% 60%; min-height: 0; }
.present.wide .pz-body { grid-template-columns: 1fr; }
.pz-text { display: flex; flex-direction: column; padding: 20px 28px 16px 36px; overflow: hidden; border-right: 1px solid var(--border); }
.pz-text > * { margin: 0 0 18px; flex: none; }
/* Vertically centred; auto margins (not justify-content) keep overflow at the bottom, where the fit check sees it. */
.pz-text > :first-child { margin-top: auto; }
.pz-text > :last-child { margin-bottom: auto; }
.pz-h2 { font-size: 36px; line-height: 1.15; color: var(--accent); }
.pz-h1 { font-size: 34px; line-height: 1.15; }
.pz-k { font-size: 21px; color: var(--muted); }
.pz-lead { font-size: 23px; }
.pz-q { font-size: 23px; padding: 14px 18px; border-left: 6px solid var(--accent); background: var(--accent-soft); border-radius: 6px; }
.pz-list { padding-left: 1.1em; }
.pz-list li { margin: 0 0 10px; }
.pz-tries li.hidden { visibility: hidden; }
.pz-tries li.shown { animation: pz-in .25s ease-out; }
@keyframes pz-in { from { opacity: 0; transform: translateY(6px); } }
.pz-eq { font-size: 24px; text-align: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.pz-eq-line { white-space: nowrap; overflow: hidden; line-height: 1.5; text-wrap-style: balance; } /* not the text-wrap shorthand: it would turn wrapping back on */
.pz-live { display: flex; flex-direction: column; padding: 12px 16px; overflow: hidden; min-width: 0; }
.present:not(.graph) .pz-live > :not(.pz-side) { margin-block: auto; flex: none; width: 100%; }
.present.wide .pz-live { padding: 16px 28px; }
/* Slide 5: scene and metrics only. Slide 6 (apps with a chart): the chart with its heading and result line. */
.present.wide:not(.graph) .pz-live .panel > :not(.kpis):not(:has(.sc)) { display: none !important; }
.present.graph .pz-live { display: flex; flex-direction: column; }
.present.graph .pz-live .app-layout { display: flex; flex-direction: column; align-items: stretch; flex: 1 1 0; min-height: 0; width: 100%; }
.present.graph .pz-live .panel { display: flex !important; flex-direction: column; align-items: stretch !important; flex: 1 1 0; min-height: 0; width: 100%; }
.present.graph .pz-live .panel > :not(h3):not(.chart-box):not(:has(canvas)):not(.msg) { display: none !important; }
.present.graph .pz-live .chart-box { flex: 1 1 0; min-height: 0; height: auto; }
.present.graph .pz-live h3 { font-size: 26px; margin: 0 0 8px; }
.present.graph .pz-live .msg { font-size: 21px; margin: 8px 0 0; }
.pz-live .panel { border: 0; background: transparent; padding: 0; box-shadow: none; }
.pz-live .app-layout { padding: 0; max-width: none; }
.pz-live :is(p.muted, .fs-sm) { display: none; } /* the teacher explains; the app's small print stays in the app */
/* Slides 1–4: only the scene; readings, results and charts wait for slide 5. (These hiding rules are !important:
   an app's own style, such as #schem { display: block }, would otherwise keep its extra drawing on the slide.) */
.present:not(.wide) .pz-live .panel > :not(:has(.sc)) { display: none !important; }
/* The scenes' Run / Reset bars sit in the slide's top bar. */
.pz-dock { display: flex; gap: 8px; flex: 0 1 auto; min-width: 0; } /* gives way before the navigation does */
.pz-dock .sc-bar { flex: none; margin: 0; padding: 0; border: 0; background: none; max-width: none !important; gap: 6px; }
.pz-dock .sc-bar > button { font-size: 17px; min-height: 0; padding: 2px 10px; } /* 80 % of the 16 pt bar text, as asked */
.pz-dock .sc-bar > .sc-reset { margin-left: 0; }
.pz-dock .tabs { margin: 0; flex-wrap: nowrap; gap: 4px; flex: 0 1 auto; min-width: 0; } /* the app's scene tabs, docked */
.pz-dock .pz-off { display: none; }
/* scene tabs carry a letter: "(A) Hot-water tank" on the page, just "A" in Present's top bar */
.tabs .tab-key::before { content: "("; }
.tabs .tab-key::after { content: ") "; white-space: pre; }
.pz-dock .tabs .tab-name { display: none; }
.pz-dock .tabs .tab-key::before, .pz-dock .tabs .tab-key::after { content: none; }
.pz-dock .tabs button:has(.tab-key) { min-width: 2.2em; padding: 2px 10px; font-weight: 700; }
.pz-dock .tabs button { font-size: 14px; min-height: 0; padding: 2px 8px; white-space: nowrap; flex: 0 1 auto; min-width: 3.5em; overflow: hidden; text-overflow: ellipsis; display: block; }
/* Slide 5: all the app's summary metrics in one side column (or several) left of the scene. */
.pz-side { display: none; }
.present.wide:not(.graph) .pz-live { flex-direction: row; gap: 20px; align-items: center; }
.present.wide:not(.graph) .pz-live > :not(.pz-side) { flex: 1 1 0; min-width: 0; }
.present.wide:not(.graph) .pz-side:has(.kpi) { display: grid; flex: none; width: calc(var(--kpi-cols, 1) * var(--kpi-w, 250px) + (var(--kpi-cols, 1) - 1) * 8px);
  grid-template-columns: repeat(var(--kpi-cols, 1), minmax(0, 1fr)); align-content: start; gap: 8px; }
.pz-side .kpis { display: contents; }
.pz-side .kpi { padding: 6px 12px; min-width: 0; overflow: hidden; margin: 0; }
.pz-side .v { font-size: 28px; line-height: 1.1; }
.pz-side .k { font-size: 21px; line-height: 1.2; }
.pz-blank { position: fixed; inset: 0; background: #000; z-index: 1001; cursor: pointer; }
.present.full .pz-body { grid-template-columns: 1fr; }
.present.full .pz-live { display: none; }
.present.full .pz-text { border-right: 0; padding: 28px 72px; }
.pz-next-row { margin-top: 28px !important; }
.pz-next { display: inline-flex; flex-direction: column; gap: 2px; padding: 14px 22px; border: 2px solid var(--accent); border-radius: 12px; text-decoration: none; color: var(--text); font-size: 24px; }
.pz-next:hover { background: var(--accent-soft); }
.present.full .pz-dock { visibility: hidden; }
.pz-live .part[hidden] { display: none !important; }
/* A full slide: everything at the 16 pt floor (21 px) before anything is dropped. */
.pz-compact > * { margin-bottom: 12px; }
.pz-compact .pz-h2 { font-size: 30px; }
.pz-compact .pz-h1 { font-size: 28px; }
.pz-compact :is(.pz-lead, .pz-q, .pz-k) { font-size: 21px; }
.pz-compact .pz-q { padding: 10px 14px; }
.pz-compact .pz-eq { font-size: 21px; padding: 6px 10px; }
.pz-compact .pz-list li { margin-bottom: 6px; }
.pz-prev { display: none; position: absolute; left: 36px; bottom: 16px; flex-direction: column; gap: 0; padding: 8px 16px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); font-size: 21px; max-width: 420px; }
.pz-prev .pz-k { font-size: 18px; }
.pz-prev:hover { border-color: var(--accent); }
.present.first .pz-prev { display: inline-flex; }
.present.first .pz-text { padding-bottom: 96px; }
.topic h3 .print-link { font-size: .8em; font-weight: 400; margin-left: 12px; }
/* Student progress grid (teacher.html): a bar per student per topic; + opens a topic into its apps. */
.progress-grid .topic-th { text-align: left; border-left: 1px solid var(--border); vertical-align: bottom; min-width: 130px; max-width: 190px; white-space: normal; font-weight: 600; }
.progress-grid .topic-th.open { max-width: none; white-space: nowrap; }
.progress-grid .topic-th small { display: block; font-weight: 400; }
.progress-grid .first-app, .progress-grid .topic-td { border-left: 1px solid var(--border); }
.progress-grid .grid-toggle { min-width: 1.9em; padding: 0 6px; line-height: 1.4; font-weight: 700; }
.progress-grid .topic-td { min-width: 120px; vertical-align: middle; }
.tbar { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; margin-bottom: 3px; }
.tbar > span { display: block; height: 100%; background: var(--accent); }
.tbar.full > span { background: var(--ok); }
.tbar-att { color: var(--warn); font-weight: 600; }
.tbar-late { color: var(--danger); }

/* "Report a problem" (top bar) and its dialog (/assets/feedback.js) */
.feedback-dialog { width: min(560px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface); }
.feedback-dialog::backdrop { background: rgba(10, 20, 30, .45); }
.feedback-dialog textarea { width: 100%; box-sizing: border-box; }
.feedback-dialog h2 { margin: 0; }
.feedback-btn { display: inline-flex; align-items: center; justify-content: center; padding: 4px 7px; line-height: 0; }
@media print { .feedback-btn, .feedback-dialog { display: none !important; } }

/* "Excel formulas for this view" (apps with property lookups; /apps/_lib/exploratory.js) */
.fx-panel > summary { cursor: pointer; font-weight: 600; }
.fx-state { margin: 10px 0 0; }
.fx-given { font-size: .92em; margin-bottom: 4px; }
.fx-table { width: 100%; border-collapse: collapse; font-size: .86em; }
.fx-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fx-table td.fx-k { width: 3.5em; color: var(--muted); }
.fx-table td.fx-v { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.fx-table code { cursor: copy; overflow-wrap: anywhere; font-size: .95em; }
.fx-table code.copied { background: var(--ok-soft, #d8f0dc); }
@media print { .fx-panel { display: none !important; } }
.fx-answer { width: min(420px, 100%); font-family: Menlo, Consolas, monospace; font-size: .9em; }
.fx-value { align-self: center; }
.fx-badge { margin-left: 6px; background: #1d6f42; color: #fff; font-size: .72em; padding: 1px 6px; border-radius: 4px; vertical-align: middle; }
.fx-notes { margin: 6px 0 0; padding-left: 18px; font-size: .92em; }
.pz-fx { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.pz-fx code { font-size: 18px; background: var(--accent-soft); padding: 4px 10px; border-radius: 6px; overflow-wrap: anywhere; }
.pz-steps li { margin: 4px 0; }
