:root {
  color-scheme: light dark;
  --paper: #F2F5F4;
  --ink: #14212B;
  --soft: #55656F;
  --rule: #D5DCDB;
  --line: #2B5B6B;
  --decrypt-fill: #A5472D;
  --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;
    --decrypt-fill: #DF9A7C;
    --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, label, .hint, .result, .artifacts dt, .signature, th, caption, summary, .reference { 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; }
.stations { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); margin-top: 1.5rem; }
.station { min-width: 0; border-top: 2px solid var(--line); padding: 1rem clamp(0.75rem, 2.2vw, 1.75rem) 1.25rem; }
.station + .station { border-inline-start: 1px solid var(--rule); }
.hint { margin-block: 0.325rem 0.85rem; color: var(--soft); font-size: 0.875rem; }
label, .artifacts dt { display: block; font-size: 0.875rem; font-weight: 650; }
.artifacts dd { margin-bottom: 0.65rem; }
code { font: 1rem/1.6 var(--mono); overflow-wrap: anywhere; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.field { margin-bottom: 0.85rem; }
.field .hint { margin-bottom: 0; }

button, select, input {
  min-height: 2.75rem;
  max-width: 100%;
  border: 1px solid var(--soft);
  border-radius: 0.4rem;
  background: var(--paper);
  color: var(--ink);
}

input, select { display: block; width: 100%; margin-top: 0.25rem; padding: 0.4rem 0.6rem; font: 1rem/1.5 var(--interface); }
input { font-family: var(--mono); }
button { padding: 0.5rem 0.85rem; font-size: 0.875rem; font-weight: 600; }
button:not(:disabled) { cursor: pointer; }
button:not(:disabled):hover { text-decoration: underline; }
button:disabled, input:disabled, select:disabled { opacity: 0.55; }
button.primary:not(:disabled) { border-color: var(--decrypt-fill); background: var(--decrypt-fill); color: var(--paper); }
.field button { margin-top: 0.35rem; }
:focus-visible { outline: 2px solid var(--line); outline-offset: 3px; }
.result { min-height: 1.6em; margin-top: 0.85rem; border-top: 1px solid var(--rule); padding-top: 0.75rem; color: var(--line); font-size: 0.9375rem; font-weight: 650; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.signature { margin-top: 0.75rem; border: 1px dashed var(--line); padding: 0.65rem; font-size: 0.875rem; }
.signature code { display: block; font-size: 0.875rem; }
.fallback { border-block: 1px solid var(--rule); padding-block: 1rem; }

.reading { max-width: 40rem; margin-top: 3.25rem; }
.reading p { margin-top: 1rem; }
.walkthrough { margin-block: 1.65rem 2.5rem; }
.walkthrough table { border-collapse: collapse; width: 100%; }
.walkthrough caption { margin-bottom: 0.5rem; color: var(--soft); text-align: left; font-size: 0.9375rem; }
.walkthrough th, .walkthrough td { border-block: 1px solid var(--rule); padding: 0.5rem 0.6rem 0.5rem 0; text-align: left; font-size: 0.9375rem; overflow-wrap: anywhere; }
.walkthrough th:last-child, .walkthrough td:last-child { padding-inline-end: 0; }
.reference { font-size: 0.9375rem; }
.reading .reference { margin: -1.5rem 0 2.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; }
  .stations { grid-template-columns: 1fr; }
  .station { padding-inline: 0.25rem; }
  .station + .station { border-inline-start: 0; }
}

@media print {
  :root { --paper: #fff; --ink: #000; --soft: #000; --rule: #999; --line: #000; }
  .page { padding: 0; }
  .experiment, .fallback { display: none; }
  .reading { margin-top: 0; }
  .walkthrough { break-inside: avoid; }
}
