@font-face {
  font-family: DM;
  src: url("../assets/fonts/dm-sans-latin.woff2");
}
@font-face {
  font-family: Newsreader;
  src: url("../assets/fonts/newsreader-latin.woff2");
}
* {
  box-sizing: border-box;
}
:root {
  color-scheme: dark;
  --bg: #0c1422;
  --panel: #141f30;
  --line: #2a374b;
  --muted: #acb9cc;
  --text: #edf2f8;
  --blue: #79baff;
  --gold: #f4ca75;
  --teal: #70dcc7;
  --coral: #fc9e99;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.55 DM,
    system-ui,
    sans-serif;
}
button,
input,
select {
  font: inherit;
}
button,
select {
  border: 1px solid var(--line);
  background: #1b293d;
  color: var(--text);
  border-radius: 7px;
  padding: 9px 12px;
}
button {
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  min-height: 40px;
}
button:hover {
  background: #293b53;
  border-color: #60718a;
}
button:disabled {
  opacity: 0.38;
  cursor: default;
}
button.primary {
  background: var(--gold);
  color: #172033;
  border-color: var(--gold);
  font-weight: 650;
}
button.primary:hover {
  background: #ffdc96;
}
button.quiet {
  background: transparent;
  padding: 6px 10px;
}
button[aria-pressed="true"] {
  border-color: var(--teal);
  color: var(--teal);
}
a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}
.shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  max-width: 1800px;
  margin: auto;
}
.rail {
  padding: 27px 18px;
  border-right: 1px solid var(--line);
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  font-size: 13px;
}
.brand-mark {
  font:
    italic 30px Newsreader,
    serif;
  color: var(--gold);
}
small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.course {
  display: flex;
  gap: 13px;
  align-items: center;
  margin: 37px 8px 24px;
  font-size: 21px;
}
.course small {
  font-size: 12px;
}
.course-symbol {
  font: 48px Georgia;
  color: var(--gold);
}
.rail-caption {
  font-size: 12px;
  color: var(--muted);
  margin: 0 10px 12px;
}
#lessons {
  display: grid;
  gap: 5px;
}
#lessons button {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-size: 13px;
  background: transparent;
  border: 1px solid transparent;
  padding: 10px 9px;
  width: 100%;
  line-height: 1.35;
}
#lessons button .num {
  font-size: 11px;
  color: #a5b2c6;
  width: 20px;
  flex-shrink: 0;
}
#lessons button.active {
  background: #203044;
  border-color: #3d526e;
  color: var(--gold);
}
#lessons button.done .num {
  color: var(--teal);
}
.rail-bottom {
  margin-top: auto;
  padding: 24px 8px 0;
  font-size: 11px;
  color: var(--muted);
}
.rail-bottom a {
  display: block;
  margin-top: 9px;
}
.rail-bottom p {
  font:
    italic 18px/1.4 Newsreader,
    serif;
}
main {
  min-width: 0;
  padding: 0 32px 20px;
}
.topbar {
  min-height: 75px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.top-actions select {
  font-size: 12px;
}
.intro {
  padding: 28px 0 22px;
}
.intro h1 {
  font:
    normal clamp(32px, 3.3vw, 48px)/1.12 Newsreader,
    Georgia,
    serif;
  letter-spacing: -0.6px;
  margin: 0 0 12px;
}
.intro p {
  color: var(--muted);
  max-width: 760px;
  margin: 0;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.stage {
  min-width: 0;
  background: #0b1320;
  display: flex;
  flex-direction: column;
}
.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 12px;
  color: var(--muted);
  gap: 10px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0 20px;
  font-size: 11px;
}
.legend span {
  display: flex;
  gap: 6px;
  align-items: center;
}
.legend i {
  width: 20px;
  height: 2px;
  display: inline-block;
  background: currentColor;
}
.plot {
  min-width: 0;
  padding: 0 5px;
}
.plot svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: pan-y;
  overflow: hidden;
}
.plot svg text,
.companion svg text,
#error-plot svg text {
  font-family: DM, system-ui, sans-serif;
  font-size: 13px;
}
.plot svg .math-label {
  font-family: Georgia, serif;
  font-size: 19px;
  font-style: italic;
}
.plot .curve {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.readouts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 20px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.readouts div {
  font-size: 11px;
  color: var(--muted);
}
.readouts strong {
  display: block;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.plot-options {
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  padding: 0 20px;
  font-size: 11px;
  color: var(--muted);
}
input[type="checkbox"] {
  accent-color: var(--teal);
}
.plot-options label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.plot-note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  padding: 10px 20px 13px;
  margin: 0;
}
#error-plot svg {
  width: 100%;
  display: block;
}
.experiment {
  background: var(--panel);
  padding: 22px;
  border-left: 1px solid var(--line);
}
.step-label {
  color: var(--gold);
  font-size: 11px;
  margin-bottom: 9px;
}
.experiment h2 {
  font-size: 19px;
  line-height: 1.35;
  font-weight: 500;
  margin: 0 0 10px;
}
.experiment p {
  font-size: 12px;
  color: var(--muted);
}
.experiment #prompt {
  margin-bottom: 14px;
}
.predictions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.predictions button {
  font-size: 11px;
  padding: 6px 9px;
  min-height: 34px;
}
.predictions button.selected {
  color: var(--gold);
  border-color: var(--gold);
}
.feedback {
  min-height: 0;
  margin: 10px 0;
  color: var(--teal) !important;
}
.feedback:empty {
  display: none;
}
.control {
  margin-top: 14px;
}
.control-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.control-top output {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.control input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
  margin: 9px 0 0;
  cursor: pointer;
}
.control input[type="text"],
.control input[type="number"] {
  width: 96px;
  padding: 5px 7px;
  background: #0c1422;
  border: 1px solid #53617a;
  color: var(--text);
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.control small {
  font-size: 10px;
  margin-top: 2px;
}
.presets {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.presets button {
  font-size: 11px;
  min-height: 30px;
  padding: 4px 8px;
}
.hint-actions {
  display: flex;
  gap: 7px;
  margin-top: 19px;
}
.hint-actions button {
  font-size: 11px;
  flex: 1;
  padding: 7px;
}
.hint {
  padding-left: 10px;
  border-left: 2px solid var(--teal);
}
#reveal {
  width: 100%;
  margin-top: 12px;
  font-size: 12px;
}
.step-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}
.step-actions button {
  flex: 1;
  font-size: 11px;
  background: transparent;
  padding: 5px;
}
.understage {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 26px;
  margin-top: 26px;
}
.explanation,
.companion {
  min-width: 0;
}
.section-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 15px;
  gap: 10px;
}
.section-line h2 {
  font-weight: 500;
  font-size: 14px;
  margin: 0;
}
.section-line span {
  color: var(--muted);
  font-size: 11px;
}
.locked {
  display: flex;
  gap: 13px;
  padding: 18px 0;
  color: var(--muted);
  font-size: 13px;
}
.locked .lock-symbol {
  font: 32px Georgia;
  color: var(--gold);
}
.derivation-row {
  padding: 7px 0 12px;
  border-bottom: 1px solid #202c3f;
}
.derivation-row p {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 0;
}
.math {
  font-size: 15px;
  overflow-x: auto;
  padding: 4px 0;
}
.katex {
  font-size: 1.16em;
}
#inspector {
  margin-top: 13px;
}
.inspector-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}
#inspect-n {
  max-width: 90px;
  padding: 5px;
  font-size: 11px;
}
.term-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
}
.term-details span {
  color: var(--muted);
}
.term-details strong {
  display: block;
  font-size: 15px;
  font-weight: 500;
  margin: 2px 0;
}
.companion svg {
  display: block;
  width: 100%;
  height: auto;
}
.companion p {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0;
}
.matching {
  display: grid;
  gap: 7px;
}
.match-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 7px 9px;
  background: #131f30;
  border-radius: 5px;
  font-size: 12px;
}
.match-row.header {
  color: var(--muted);
  font-size: 10px;
  background: none;
}
.match-row .good {
  color: var(--teal);
}
.match-row .bad {
  color: var(--coral);
}
.factor-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 17px;
}
.factor-tile {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  font: 20px Georgia;
  color: var(--muted);
}
.factor-tile.used {
  border-color: var(--gold);
  color: var(--gold);
}
.checkpoint {
  margin-top: 24px;
  padding: 16px 20px;
  border-left: 2px solid var(--teal);
  background: #13252c;
  font-size: 13px;
}
.checkpoint p {
  margin: 0 0 10px;
}
.checkpoint button {
  font-size: 12px;
  background: transparent;
  margin-right: 6px;
}
.checkpoint .answer {
  margin: 10px 0 0;
  color: var(--teal);
}
.lesson-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 28px;
}
.lesson-footer button {
  font-size: 12px;
}
.lesson-footer span,
.fineprint {
  font-size: 11px;
  color: var(--muted);
}
.fineprint {
  text-align: center;
  margin-top: 22px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.skip {
  position: fixed;
  top: -100px;
  left: 10px;
  background: var(--gold);
  color: #142033;
  padding: 10px;
  z-index: 100;
}
.skip:focus {
  top: 10px;
}
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #152033;
  padding: 10px 20px;
  border-radius: 6px;
  z-index: 10;
  display: none;
  max-width: 90vw;
}
.focus .rail {
  display: none;
}
.focus .shell {
  grid-template-columns: 1fr;
  max-width: 1500px;
}
.classroom .intro h1 {
  font-size: 48px;
}
.classroom .math {
  font-size: 20px;
}
.classroom .experiment p {
  font-size: 15px;
}
.classroom .plot svg text {
  font-size: 15px;
}
.classroom .understage {
  grid-template-columns: 1fr 1fr;
}
.stat-strip {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}
.stat-strip b {
  color: var(--gold);
  font-weight: 500;
}
.motion-controls {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.motion-controls button {
  flex: 1;
  font-size: 11px;
}
.tolerance-band {
  fill: #70dcc7;
  opacity: 0.09;
}
.domain-band {
  fill: #70dcc7;
  opacity: 0.06;
}
.animation-enter {
  animation: enter 0.25s ease-out;
}
@keyframes enter {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
@media (min-width: 1500px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
  .experiment {
    padding: 26px;
  }
  .plot {
    padding: 0 20px;
  }
}
@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 195px minmax(0, 1fr);
  }
  main {
    padding: 0 20px 20px;
  }
  .rail {
    padding: 23px 10px;
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr) 275px;
  }
  .experiment {
    padding: 17px;
  }
  .top-actions {
    gap: 4px;
  }
  .topbar {
    font-size: 11px;
  }
  .plot-options {
    gap: 8px;
  }
  .readouts strong {
    font-size: 15px;
  }
}
@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .rail {
    position: relative;
    height: auto;
    min-height: 0;
    padding: 16px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: block;
  }
  .brand {
    float: left;
  }
  .course,
  .rail-caption,
  .rail-bottom {
    display: none;
  }
  #lessons {
    display: flex;
    overflow: auto;
    clear: both;
    padding-top: 12px;
    gap: 6px;
  }
  #lessons button {
    width: auto;
    white-space: nowrap;
    padding: 8px 10px;
    flex-shrink: 0;
  }
  .topbar {
    min-height: 65px;
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr) 285px;
  }
  .intro {
    padding-top: 22px;
  }
}
@media (max-width: 700px) {
  main {
    padding: 0 14px 20px;
  }
  .rail {
    padding: 12px 14px;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
  }
  .top-actions {
    gap: 5px;
  }
  .top-actions button {
    font-size: 11px;
    min-height: 35px;
  }
  .top-actions select {
    max-width: 155px;
    padding: 7px;
  }
  .intro h1 {
    font-size: 34px;
  }
  .intro p {
    font-size: 13px;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .experiment {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 20px;
  }
  .stage-top {
    padding: 10px 14px;
  }
  .legend {
    padding: 0 14px;
    font-size: 10px;
    gap: 10px;
  }
  .readouts {
    margin: 0 14px 12px;
  }
  .plot-options {
    padding: 0 14px;
    font-size: 10px;
  }
  .plot-note {
    padding: 10px 14px;
  }
  .understage,
  .classroom .understage {
    grid-template-columns: 1fr;
    gap: 23px;
  }
  .control-top {
    font-size: 13px;
  }
  .experiment p {
    font-size: 13px;
  }
  .predictions button {
    min-height: 40px;
  }
  .hint-actions button,
  .step-actions button,
  #reveal {
    font-size: 13px;
  }
  .lesson-footer span {
    display: none;
  }
  .classroom .intro h1 {
    font-size: 36px;
  }
  .math {
    font-size: 14px;
  }
  .checkpoint {
    padding: 14px;
  }
  .plot svg text {
    font-size: 15px;
  }
}

#title:focus {
  outline: none;
}

@media (max-width: 700px) {
  .companion svg text {
    font-size: 17px;
  }
  .plot svg text {
    font-size: 12px;
  }
  .stage-top .katex {
    font-size: 1.2em;
  }
}
