:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #17212b; --muted: #5b6876; --line: #d9e0e6;
  --brand: #0f4c5c; --brand-ink: #ffffff; --accent: #127a8a; --ok: #1d6b3a; --ok-bg: #e5f4e9;
  --err: #a12a2a; --err-bg: #fbe9e9; --warn: #8a5a00; --gap: #fff6e5;
  --radius: 10px; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; }
h2 { font-size: 1.2rem; margin: 1.25rem 0 .5rem; }
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex: none; background: var(--brand); color: var(--brand-ink); padding: 20px 16px; display: flex; flex-direction: column; gap: 24px; }
.sidebar a { color: var(--brand-ink); }
.brand .school { display: block; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.brand .course { display: block; font-weight: 700; font-size: 1.1rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { text-decoration: none; padding: 8px 10px; border-radius: 8px; }
.sidebar nav a.on, .sidebar nav a:hover { background: rgba(255,255,255,.14); }
.who { margin-top: auto; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
main { flex: 1; padding: 28px 32px; max-width: 1100px; min-width: 0; }
main.narrow { margin: 0 auto; max-width: 440px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.narrow-form { max-width: 420px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #b7c3cc; border-radius: 8px; background: #fff; color: var(--ink); }
button { font: inherit; cursor: pointer; padding: 8px 14px; border-radius: 8px; border: 1px solid #b7c3cc; background: #fff; color: var(--ink); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.small { padding: 4px 10px; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #f0b429; outline-offset: 2px; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .warn { color: var(--warn); }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; color: var(--muted); margin: 0; }
.login { padding-top: 10vh; }
.tabs { display: flex; gap: 4px; margin: 8px 0 12px; }
.tabs a { padding: 6px 14px; border-radius: 8px; text-decoration: none; border: 1px solid var(--line); background: var(--panel); }
.tabs a[aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; min-width: 140px; display: flex; flex-direction: column; }
.stat .num { font-size: 1.8rem; font-weight: 700; }
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.unit-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none; }
.unit-card:hover { border-color: var(--accent); }
.unit-code { font-size: .8rem; font-weight: 700; color: var(--accent); text-transform: uppercase; }
meter { width: 100%; height: 10px; }
.pill { font-size: .75rem; font-weight: 600; background: #e3eff2; color: var(--brand); padding: 2px 8px; border-radius: 99px; vertical-align: middle; margin-left: 6px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); }
tr.gap td { background: var(--gap); }
tr.inactive td { color: var(--muted); }
.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 2px 4px 2px 0; }
.actions { white-space: nowrap; }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; }
  main { padding: 18px 16px; }
  .roster, .roster tbody, .roster tr, .roster td { display: block; }
  .roster thead { display: none; }
}
/* lessons */
.prose pre, pre.code, pre.output, .code-editor, .trace-code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9rem; }
.prose pre, pre.code, pre.output { background: #f1f4f6; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; }
.prose table { margin: 8px 0; }
.code-editor { width: 100%; min-height: 360px; tab-size: 4; line-height: 1.45; background: #0f1b24; color: #e6edf3; border-color: #0f1b24; }
.run-box { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.run-box button { align-self: flex-start; }
pre.output.error { background: var(--err-bg); color: var(--err); }
.questions { padding-left: 1.4rem; }
.question { margin-bottom: 14px; }
.question p { margin: 0 0 6px; font-weight: 600; }
.choice { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; padding: 4px 0; }
.choice input { margin-top: 5px; }
.locked { background: var(--gap); padding: 10px 14px; border-radius: 8px; }
.evidence { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; }
.evidence .row-form label { flex: 1 1 240px; }
.evidence textarea, #reflection, #run-input { width: 100%; font-family: ui-monospace, Consolas, monospace; }
.breakdown tr.pass td:first-child { color: var(--ok); }
.breakdown tr.fail td:first-child { color: var(--err); }
.lesson-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.lesson-link { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; text-decoration: none; color: var(--ink); }
.lesson-link:hover { border-color: var(--accent); }
.pill.done { background: var(--ok-bg); color: var(--ok); }
.pill.todo { background: var(--gap); color: var(--warn); }
.state-visible, .state-open { color: var(--ok); font-weight: 600; }
.state-hidden, .state-locked { color: var(--muted); }
.state-scheduled { color: var(--warn); }
fieldset.gate, fieldset.topic-pick { border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.check { flex-direction: row; gap: 6px; font-weight: 400; width: 100%; }
ol.key li.right { font-weight: 700; color: var(--ok); }
.trace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; }
.trace-code { background: #0f1b24; color: #c9d4dc; border-radius: 8px; padding: 10px; overflow-x: auto; margin: 0; }
.trace-line { display: block; }
.trace-line.on { background: #f0b429; color: #111; }
.trace-out { background: #f1f4f6; border-radius: 8px; padding: 8px; min-height: 2em; }
@media (max-width: 760px) { .trace { grid-template-columns: 1fr; } }
.breakdown td:nth-child(2) { white-space: nowrap; }
/* grades */
.scroll-x { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.gradebook th, .gradebook td { white-space: nowrap; text-align: center; }
.gradebook th[scope="row"], .gradebook td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
.gradebook tr.avg td { background: #f1f4f6; font-weight: 600; }
.gradebook a.low { color: var(--err); font-weight: 600; }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.two-col > .card { margin: 0 0 16px; }
.grow { flex: 1 1 240px; }
.ok-text { color: var(--ok); } .err-text { color: var(--err); }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.stat .num.small { font-size: 1.1rem; padding: 10px 0; }
form.inline label { flex-direction: row; align-items: center; gap: 6px; }
/* exams */
.exam-bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 16px; }
.timer { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.timer.low { color: var(--err); }
.question-card .row-form { margin-top: 8px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
button.danger { color: var(--err); }
fieldset.rubric { border: 1px solid var(--line); border-radius: 8px; }
.option-row .check { width: auto; }
