: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, label, select, .interface-note, .readout, caption, th, summary { font-family: var(--interface); }
h1, h2, h3, p, figure { margin: 0; }
h1 { max-width: 21ch; 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; }
.activity-intro { margin-top: 0.375rem; max-width: 40rem; }
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1rem clamp(1.25rem, 3vw, 2rem);
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--line);
}
.machine { display: block; width: min(100%, 28rem); overflow: visible; margin-inline: auto; }
.machine text { text-anchor: middle; fill: var(--ink); }
.machine .diagram-label { fill: var(--soft); font: 650 16px var(--interface); }
.machine .terminal-letter, .machine .contact-letter { dominant-baseline: central; font: 650 15px var(--mono); }
.machine .terminal, .machine .rotor-plate { fill: var(--paper); stroke: var(--line); stroke-width: 1.5; }
.machine .rotor-guide { fill: none; stroke: var(--rule); stroke-width: 2; }
.machine #contacts { transform-box: view-box; transform-origin: 170px 112px; }
.machine #contacts circle { fill: var(--paper); stroke: var(--soft); stroke-opacity: 0.55; stroke-width: 1.5; }
.machine .contact-letter.picked { fill: var(--line); font-weight: 750; }
.machine .pickup { fill: none; stroke: var(--line); stroke-width: 2; }
.machine .signal { fill: none; stroke: var(--soft); stroke-width: 1.5; stroke-dasharray: 4 4; }
.machine .signal.active { stroke: var(--line); stroke-width: 2.5; stroke-dasharray: none; }
.machine marker path { fill: var(--line); }
.machine .lamp-light { fill: none; }
.machine .lit { fill: var(--line); }
.machine .lit + text { fill: var(--paper); }

label { font-size: 0.9375rem; font-weight: 650; }
select, button {
  min-height: 2.75rem;
  border: 1px solid var(--soft);
  border-radius: 0.4rem;
  padding: 0.45rem 0.65rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
select { margin-inline-start: 0.4rem; }
button:hover { text-decoration: underline; }
button.press { border-color: var(--line); background: var(--line); color: var(--paper); }
:focus-visible { outline: 2px solid var(--line); outline-offset: 3px; }
.interface-note { margin-top: 0.4rem; color: var(--soft); font-size: 0.875rem; }
.controls { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.85rem; }
.readout { min-height: 3.2em; margin-top: 0.8rem; color: var(--ink); font-size: 0.9375rem; }
.previous-run { margin-top: 0.75rem; }

.steps { width: 100%; max-width: 27rem; margin-top: 1.25rem; border-collapse: collapse; }
.steps caption { margin-bottom: 0.35rem; color: var(--soft); font-size: 0.9375rem; text-align: left; }
.steps th, .steps td { border-bottom: 1px solid var(--rule); padding: 0.35rem 0.25rem; text-align: left; }
.steps th { color: var(--soft); font-size: 0.8125rem; }
.steps td { font: 0.9375rem/1.5 var(--mono); }
.fallback { border-block: 1px solid var(--rule); padding-block: 1rem; }

.reading { max-width: 40rem; margin-top: 3.25rem; }
.reading p { margin-top: 1rem; }
.reading h2:not(:first-child) { margin-top: 3.25rem; }
code { font: 1em/1.6 var(--mono); }
.worked { margin-block: 1.25rem; }
.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: 43rem) {
  .page { padding-top: 2rem; }
  .workbench { grid-template-columns: 1fr; }
}

@media (forced-colors: active) {
  .machine {
    --paper: Canvas;
    --ink: CanvasText;
    --soft: CanvasText;
    --rule: GrayText;
    --line: CanvasText;
  }
  .machine .signal.active, .machine .pickup { stroke: Highlight; }
  .machine .lit { fill: Highlight; stroke: Highlight; }
  .machine .lit + text { fill: HighlightText; }
  .machine marker path { fill: Highlight; }
}

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