:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #5b6370;
  --border: #dcd9d2;
  --accent: #1d5fa8;
  --accent-text: #ffffff;
  --right: #1f7a3d;
  --right-bg: #e7f4ea;
  --wrong: #a5301f;
  --wrong-bg: #fbeae6;
  --instr-bg: #fff6dc;
  --instr-border: #d9a520;
  --verify: #ffe08a;
  --code-bg: #f0eee8;
  --measure: 46rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1c1f24;
    --text: #e8e6e1;
    --muted: #a3a9b3;
    --border: #353a42;
    --accent: #7fb2ec;
    --accent-text: #0d1117;
    --right: #7fd39a;
    --right-bg: #173323;
    --wrong: #f19a8a;
    --wrong-bg: #3a1d18;
    --instr-bg: #2e2714;
    --instr-border: #a07a1a;
    --verify: #6b5413;
    --code-bg: #252930;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1c1f24;
  --text: #e8e6e1;
  --muted: #a3a9b3;
  --border: #353a42;
  --accent: #7fb2ec;
  --accent-text: #0d1117;
  --right: #7fd39a;
  --right-bg: #173323;
  --wrong: #f19a8a;
  --wrong-bg: #3a1d18;
  --instr-bg: #2e2714;
  --instr-border: #a07a1a;
  --verify: #6b5413;
  --code-bg: #252930;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.2; }
code { background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 4px; font-size: 0.92em; overflow-wrap: anywhere; }
mark.verify { background: var(--verify); color: inherit; padding: 0 0.2em; font-weight: 600; }
.small { font-size: 0.85rem; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.78rem; color: var(--muted); margin: 0 0 0.3rem; }

.site-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem;
  padding: 0.75rem 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.site-header nav a { text-decoration: none; }
.badge { background: var(--instr-border); color: #000; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.85rem; }
.tools { margin-left: auto; display: flex; gap: 0.5rem; }

main { max-width: var(--measure); margin: 0 auto; padding: 1rem 16px 3rem; }
.site-footer { max-width: var(--measure); margin: 0 auto; padding: 1rem 16px 2rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); }

button {
  font: inherit; cursor: pointer; border-radius: 6px; padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
}
button.secondary, .tools button { background: transparent; color: var(--accent); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: 0.5rem 0 1rem; font-size: 0.95rem; }
th, td { text-align: left; vertical-align: top; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; }

/* Lessons in article mode */
.slide { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.slide h2 { margin-top: 0; }
.title-slide h1 { margin: 0.2rem 0; }
.block { color: var(--muted); }
.big { font-size: 1.1rem; }
.where { color: var(--muted); }
.report { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
p.report code { display: block; padding: 0.6rem; font-size: 1.05rem; white-space: pre-wrap; }
textarea.report { width: 100%; font-size: 1rem; padding: 0.6rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.options { list-style: none; padding-left: 0; }
.checks li { margin-bottom: 0.75rem; }
.checks p { margin: 0 0 0.25rem; }

details.reveal { margin: 0.75rem 0; }
details.reveal summary { cursor: pointer; color: var(--accent); font-weight: 600; width: max-content; }
details.reveal .answer { margin-top: 0.5rem; padding: 0.6rem 0.9rem; border-left: 4px solid var(--accent); background: var(--surface); }
.verdict { font-weight: 700; margin: 0 0 0.3rem; }
.verdict.right { color: var(--right); }
.verdict.wrong { color: var(--wrong); }
dl.key { margin: 0; }
dl.key dt { font-weight: 600; margin-top: 0.5rem; }
dl.key dd { margin: 0; }

.bins { border: 1px solid var(--border); border-radius: 6px; display: grid; gap: 0.3rem; }
.bins label { display: flex; gap: 0.5rem; align-items: baseline; }
.card.right .bins { border-color: var(--right); background: var(--right-bg); }
.card.wrong .bins { border-color: var(--wrong); background: var(--wrong-bg); }

/* Instructor material: always visibly marked */
.instr-note, .instr { background: var(--instr-bg); border-left: 4px solid var(--instr-border); padding: 0.6rem 1rem; margin: 0.75rem 0; border-radius: 0 6px 6px 0; }
.instr-notes > h2 { margin-top: 2rem; }
.instr h3 { margin-top: 0.25rem; }
.verify-box { border-left-color: var(--wrong); }

.pager { display: flex; justify-content: space-between; gap: 1rem; padding-top: 1.5rem; }

/* Home */
.lede { font-size: 1.1rem; color: var(--muted); }
.lesson-list li { margin: 0.2rem 0; }

/* Quizzes */
.quiz { padding-left: 1.4rem; }
.q { margin: 0 0 1.5rem; }
.q p { margin: 0 0 0.4rem; }
label.opt { display: flex; gap: 0.45rem; align-items: baseline; padding: 0.35rem 0.5rem; border-radius: 6px; cursor: pointer; }
label.opt:hover { background: var(--surface); }
.q.right .feedback { border-left: 4px solid var(--right); background: var(--right-bg); }
.q.wrong .feedback { border-left: 4px solid var(--wrong); background: var(--wrong-bg); }
.feedback { padding: 0.5rem 0.9rem; margin-top: 0.4rem; border-radius: 0 6px 6px 0; }
.cite { font-size: 0.85rem; color: var(--muted); }
.timer { position: sticky; top: 0; background: var(--bg); padding: 0.4rem 0; font-weight: 700; font-variant-numeric: tabular-nums; z-index: 1; }
.timer.low { color: var(--wrong); }
.mode-buttons { display: grid; gap: 0.5rem; }
.mode-buttons button { text-align: left; background: var(--surface); color: var(--text); border-color: var(--border); }
.mode-buttons button:hover { border-color: var(--accent); }
.run-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.result { margin-bottom: 1.5rem; }
.steps li { margin-bottom: 0.5rem; }
.steps h3 { margin-bottom: 0.25rem; }
.links li { margin: 0.3rem 0; }

/* Present mode: one full-viewport section at a time, readable from the back of a room */
body.presenting { overflow: hidden; }
body.presenting .site-header,
body.presenting .site-footer,
body.presenting .instr,
body.presenting .instr-notes,
body.presenting .instr-note,
body.presenting .pager { display: none; }
body.presenting main { max-width: none; padding: 0; }
body.presenting .slide { display: none; }
body.presenting .slide.current {
  display: flex; flex-direction: column; justify-content: center;
  height: 100vh; overflow-y: auto; padding: 4vh 6vw 8vh; border: 0;
  font-size: clamp(1.4rem, 2.6vw + 0.4rem, 3rem);
}
body.presenting .slide.current h1 { font-size: 2em; }
body.presenting .slide.current h2, body.presenting .slide.current h3 { font-size: 1.5em; margin-bottom: 0.5em; }
body.presenting .slide.current li { margin: 0.25em 0; }
body.presenting .slide.current .big { font-size: 1.1em; }
body.presenting .slide.current .eyebrow { font-size: 0.5em; }
body.presenting .slide.current table { font-size: 0.6em; }
body.presenting .slide.current p.report code { font-size: 1em; }
body.presenting .slide.current textarea.report { font-size: 0.7em; }
#present-bar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between;
  padding: 0.4rem 1rem; font-size: 1rem; color: var(--muted); background: var(--bg);
}
#present-bar[hidden] { display: none; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .tools { margin-left: 0; }
}

/* Print: drills come out as clean handouts, answers stay hidden unless revealed */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --border: #999; }
  .site-header, .site-footer, .pager, #present-bar, button, details.reveal:not([open]), .tools, textarea { display: none !important; }
  main { max-width: none; padding: 0; }
  .slide { break-inside: avoid; border-bottom: 1px solid #ccc; padding: 0.6rem 0; }
  a { color: #000; text-decoration: none; }
  .instr, .instr-note, .instr-notes { background: none; border: 1px solid #999; }
}
