:root {
  color-scheme: light dark;
  --paper: #F2F5F4;
  --ink: #14212B;
  --soft: #55656F;
  --rule: #D5DCDB;
  --line: #2B5B6B;
  --backdrop: #C5D0D8;
  --interface: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --reading: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101A21;
    --ink: #E7EDF0;
    --soft: #9FB0BA;
    --rule: #2A3944;
    --line: #93C5D6;
    --backdrop: #263843;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1.125rem/1.6 var(--reading); }
.page { max-width: 80rem; margin-inline: auto; padding: 3.25rem 1.5rem 5rem; }
.lesson-header { padding-bottom: 2.5rem; }
h1, h2, h3, .course-label, button, dt, .round-count, .note span, .result, summary { font-family: var(--interface); }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
h1 { max-width: 19ch; font-size: clamp(2.5rem, 6vw, 4.25rem); line-height: 1.04; letter-spacing: -0.025em; }
h2 { font-size: 1.625rem; line-height: 1.2; letter-spacing: -0.015em; }
h3 { font-size: 1.1875rem; line-height: 1.3; }
.course-label { margin-bottom: 0.625rem; color: var(--soft); font-size: 0.9375rem; font-weight: 600; }
.course-label span { margin-inline: 0.3em; }
.course-label a { display: inline-flex; align-items: center; min-height: 2.75rem; }
a, summary { color: var(--line); text-decoration: underline; text-decoration-thickness: 1px; }
a:hover, summary:hover { text-decoration-thickness: 2px; }
.lede { max-width: 38rem; margin-top: 1rem; font-size: 1.25rem; }

.experiment { border-block: 1px solid var(--rule); padding-block: 1.5rem 1rem; }
.experiment-header p { margin-top: 0.375rem; }
.exercise-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(13rem, 0.8fr); margin-top: 1.5rem; border-top: 2px solid var(--line); }
.exercise-grid:has(.decision[hidden]) { grid-template-columns: minmax(0, 1fr); }
.scenario, .decision { min-width: 0; padding: 1rem clamp(0.75rem, 2.2vw, 1.75rem) 1.25rem; }
.decision { border-inline-start: 1px solid var(--rule); }

.round-count { color: var(--soft); font-size: 0.875rem; font-weight: 600; }
.note {
  display: grid;
  gap: 0.15rem;
  margin-block: 0.65rem 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px dashed var(--line);
  background: color-mix(in srgb, var(--backdrop) 24%, var(--paper));
}
.note span { color: var(--soft); font-size: 0.875rem; font-weight: 600; }
code { font: 1rem/1.6 var(--mono); overflow-wrap: anywhere; }
.round + .round { margin-top: 1.5rem; }
.round dl { margin-top: 0.75rem; }
.round dl > div { border-top: 1px solid var(--rule); padding-block: 0.55rem; }
dt { font-size: 0.875rem; font-weight: 650; }
.solution { margin-top: 0.75rem; }

.choices { display: grid; gap: 0.5rem; margin-block: 0.875rem; }
button {
  min-height: 2.75rem;
  max-width: 100%;
  border: 1px solid var(--soft);
  border-radius: 0.4rem;
  padding: 0.5rem 0.85rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
}
button:not(:disabled) { cursor: pointer; }
button:not(:disabled):hover { text-decoration: underline; }
button:disabled { opacity: 0.55; }
button.primary:not(:disabled) { border-color: var(--line); background: var(--line); color: var(--paper); }
.choices button { text-align: left; }
.choices button[aria-pressed="true"] {
  border-color: var(--line);
  box-shadow: inset 0 0 0 1px var(--line);
  background: color-mix(in srgb, var(--backdrop) 35%, var(--paper));
}
.result { min-height: 4.5em; margin-bottom: 0.85rem; color: var(--line); font-size: 0.9375rem; }
:focus-visible { outline: 2px solid var(--line); outline-offset: 3px; }

.reading { max-width: 40rem; margin-top: 3.25rem; }
.reading p { margin-top: 1rem; }
.recap { padding-inline-start: 1.4rem; }
.recap li + li { margin-top: 0.5rem; }
.check { margin-top: 3.25rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
details { margin-top: 0.35rem; }
summary { min-height: 2.75rem; width: fit-content; padding-block: 0.5rem; cursor: pointer; font-size: 0.9375rem; font-weight: 600; }

@media (max-width: 47rem) {
  .page { padding-top: 2rem; }
  .exercise-grid { grid-template-columns: minmax(0, 1fr); }
  .scenario, .decision { padding-inline: 0.25rem; }
  .decision { border-inline-start: 0; border-top: 1px solid var(--rule); }
}

@media print {
  :root { --paper: #fff; --ink: #000; --soft: #000; --rule: #999; --line: #000; }
  .page { padding: 0; }
  .exercise-grid { display: block; }
  .decision, .round-count, #decision-prompt, .check details { display: none; }
  .experiment .round[hidden], .experiment .solution[hidden] { display: block !important; }
  .round { break-inside: avoid; }
}
