@font-face {
  font-family: "KaTeX_Main";
  src: url("./vendor/katex/fonts/KaTeX_Main-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-raised: #ffffff;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-muted: #f4f6f8;
  --ink: #081a31;
  --ink-soft: #21344a;
  --muted: #4d5d6e;
  --line: #d3d9e0;
  --line-strong: #8794a3;
  --navy: #082f5b;
  --navy-2: #124a7a;
  --gold: #9b6500;
  --gold-soft: #f2d393;
  --teal: #06736d;
  --teal-soft: #d4ece8;
  --coral: #b74634;
  --coral-soft: #f5d8d2;
  --violet: #5d4d95;
  --chart-navy: #0b4f79;
  --chart-teal: #067d75;
  --chart-gold: #9f6800;
  --chart-coral: #bd4d39;
  --chart-violet: #6653a0;
  --shadow: 0 18px 55px rgba(8, 26, 49, 0.1);
  --header-bg: rgba(255, 255, 255, 0.97);
  --focus-ring: #086da3;
  --control-track: #cdd4db;
  --control-thumb: #082f5b;
  --success: #1f6b4c;
  --error: #a93828;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-editorial: Iowan Old Style, Charter, "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111e;
  --bg-raised: #0a1726;
  --surface: #0d1b2b;
  --surface-strong: #112338;
  --surface-muted: #14263a;
  --ink: #f4f1e9;
  --ink-soft: #d6dde5;
  --muted: #9daaba;
  --line: #263a50;
  --line-strong: #53677c;
  --navy: #f2c36c;
  --navy-2: #f8d997;
  --gold: #f2be55;
  --gold-soft: #493816;
  --teal: #4dc0b6;
  --teal-soft: #153e3d;
  --coral: #f07b65;
  --coral-soft: #4a2928;
  --violet: #b3a1ec;
  --chart-navy: #78b8e2;
  --chart-teal: #58cabf;
  --chart-gold: #f1bf59;
  --chart-coral: #f27f69;
  --chart-violet: #b6a6ed;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  --header-bg: rgba(7, 17, 30, 0.92);
  --focus-ring: #7dc4f2;
  --control-track: #2d4157;
  --control-thumb: #f2c36c;
  --success: #72c99f;
  --error: #ff917c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 180ms ease, color 180ms ease;
}

body.has-focused-lab {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a,
button {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

::selection {
  background: var(--gold-soft);
  color: var(--ink);
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 500;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--surface);
  transform: translateY(-150%);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.page-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 120;
  height: 3px;
  background: transparent;
}

.page-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 80ms linear;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.course-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 13px;
  text-decoration: none;
}

.course-code {
  padding: 4px 8px 3px;
  background: var(--navy);
  color: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

html[data-theme="dark"] .course-code,
html[data-theme="dark"] .primary-action,
html[data-theme="dark"] .preset-button.is-active,
html[data-theme="dark"] .closing-section {
  color: #07111e;
}

.course-name {
  color: var(--ink-soft);
  font-family: var(--font-editorial);
  font-size: 1.04rem;
}

.header-actions,
.toolbar-actions,
.hero-actions,
.button-row,
.check-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle,
.focus-button,
.preset-button,
.control-button,
.secondary-button {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.theme-toggle {
  padding: 8px 11px;
  font-size: 0.82rem;
}

.theme-toggle:hover,
.focus-button:hover,
.preset-button:hover,
.control-button:hover,
.secondary-button:hover {
  border-color: var(--navy);
  color: var(--navy);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-dot {
  width: 8px;
  height: 8px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 18%, transparent);
}

.page-shell {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: clamp(22px, 2vw, 36px);
  width: min(1860px, calc(100% - 32px));
  margin: 0 auto;
}

.topic-rail {
  position: sticky;
  top: 106px;
  align-self: start;
  max-height: calc(100vh - 128px);
  padding: 24px 0;
}

.rail-heading {
  margin-bottom: 18px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topic-rail ol {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.topic-rail a {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  transition: all 120ms ease;
}

.topic-rail a span {
  font-family: var(--font-mono);
  font-size: 0.67rem;
}

.topic-rail a:hover,
.topic-rail a.is-active {
  border-left-color: var(--gold);
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  color: var(--ink);
}

.topic-rail a.is-active {
  font-weight: 650;
}

.rail-key {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px 7px;
  align-items: center;
  margin-top: 30px;
  padding: 16px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
}

.key-line {
  height: 2px;
}

.key-baseline {
  background: var(--chart-navy);
}

.key-comparison {
  background: repeating-linear-gradient(90deg, var(--chart-gold) 0 5px, transparent 5px 8px);
}

main {
  min-width: 0;
  padding-bottom: 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(440px, 1.1fr);
  gap: clamp(36px, 6vw, 90px);
  align-items: center;
  min-height: calc(100vh - 72px);
  padding: 78px 0 66px;
}

.eyebrow,
.plot-kicker,
.insight-label {
  margin: 0 0 12px;
  color: var(--teal);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--font-editorial);
  font-size: clamp(4rem, 7.4vw, 7.8rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.84;
}

.hero h1 em {
  color: var(--gold);
  font-weight: 400;
}

.hero-lede {
  max-width: 630px;
  margin: 32px 0 0;
  color: var(--ink-soft);
  font-family: var(--font-editorial);
  font-size: clamp(1.15rem, 1.8vw, 1.45rem);
  line-height: 1.55;
}

.hero-actions {
  margin-top: 32px;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid var(--navy);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.primary-action {
  background: var(--navy);
  color: var(--surface);
}


.primary-action:hover {
  transform: translateY(-1px);
}

.hero-facts {
  display: flex;
  gap: 30px;
  margin: 42px 0 0;
  padding: 20px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.hero-facts li {
  display: grid;
  gap: 2px;
}

.hero-facts strong {
  font-family: var(--font-editorial);
  font-size: 1.7rem;
  font-weight: 500;
}

.hero-facts span {
  color: var(--muted);
  font-size: 0.72rem;
}

.hero-visual {
  position: relative;
  min-height: 410px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.hero-visual::before {
  position: absolute;
  inset: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 66%, transparent);
  content: "";
  pointer-events: none;
}

.hero-visual svg {
  width: 100%;
  height: 410px;
}

.hero-axis {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 2;
}

.hero-line {
  fill: none;
  stroke: url(#line-gradient);
  stroke-width: 5;
}

.hero-change {
  fill: none;
  stroke: var(--chart-gold);
  stroke-width: 3;
  stroke-dasharray: 9 7;
}

.hero-point {
  fill: var(--chart-teal);
  stroke: var(--surface);
  stroke-width: 3;
}

.hero-point-gold {
  fill: var(--chart-gold);
}

.hero-formula {
  position: absolute;
  left: 34px;
  bottom: 30px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.hero-note {
  position: absolute;
  top: 25px;
  right: 28px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.orientation {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 140px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.orientation div {
  display: grid;
  gap: 8px;
  padding: 20px 24px;
  border-right: 1px solid var(--line);
}

.orientation div:last-child {
  border-right: 0;
}

.orientation span,
.section-number,
.closing-grid span {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.orientation strong {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
}

.lesson-section {
  margin-bottom: 140px;
}

.section-heading {
  display: grid;
  grid-template-columns: 58px minmax(0, 900px);
  gap: 28px;
  align-items: start;
  margin-bottom: 38px;
}

.section-number {
  padding-top: 8px;
  border-top: 2px solid var(--gold);
}

.section-heading h2,
.closing-section h2 {
  margin: 0;
  font-family: var(--font-editorial);
  font-size: clamp(2.45rem, 4vw, 4.6rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.section-heading p:last-child {
  max-width: 1100px;
  margin: 22px 0 0;
  color: var(--ink-soft);
  font-family: var(--font-editorial);
  font-size: clamp(1.22rem, 1.5vw, 1.62rem);
  line-height: 1.5;
}

.lab-card {
  position: relative;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lab-card.is-focused {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  max-width: none;
  border-color: var(--gold);
  box-shadow: 0 25px 90px rgba(0, 0, 0, 0.38);
}

.lab-card.is-focused .lab-toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 58px;
  padding-inline: 24px;
  font-size: 1rem;
}

.lab-card.is-focused .lab-layout {
  flex: 1;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: calc(100vh - 58px);
}

.lab-card.is-focused .control-panel {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  padding: 20px 30px;
}

.lab-card.is-focused .plot-panel,
.lab-card.is-focused .insight-panel {
  padding: 28px 34px;
}

.lab-card.is-focused .chart {
  min-height: clamp(430px, 58vh, 720px);
}

.lab-card.is-focused .dynamic-equation {
  min-height: 72px;
  font-size: clamp(1.2rem, 1.8vw, 1.8rem);
}

.lab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 8px 12px 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lab-toolbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-light {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 13%, transparent);
}

.focus-button,
.preset-button {
  padding: 5px 8px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: none;
}

.preset-button.is-active {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--surface);
}

.lab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(330px, 0.82fr);
  grid-template-areas:
    "controls controls"
    "plot insight";
  min-height: 0;
}

.lab-layout-wide {
  grid-template-columns: minmax(0, 1.72fr) minmax(330px, 0.8fr);
}

.control-panel,
.insight-panel,
.plot-panel {
  min-width: 0;
  padding: clamp(22px, 2vw, 32px);
}

.control-panel {
  grid-area: controls;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px 22px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-raised) 75%, var(--surface));
}

.control-panel > .panel-title {
  grid-column: 1 / -1;
}

.insight-panel {
  grid-area: insight;
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-muted) 42%, var(--surface));
}

.plot-panel {
  grid-area: plot;
  display: flex;
  flex-direction: column;
  min-height: 520px;
  background: var(--surface-strong);
}

.panel-title,
.parameter-heading,
.plot-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-title {
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 700;
}

.panel-title > span:last-child,
.parameter-heading > span:last-child {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 650;
}

.parameter {
  margin: 0;
}

.parameter-heading {
  align-items: center;
  margin-bottom: 8px;
}

.parameter-heading label,
.select-control label {
  color: var(--ink-soft);
  font-size: 0.94rem;
  font-weight: 650;
}

.parameter-inputs {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 88px;
  gap: 10px;
  align-items: center;
}

.select-control {
  display: grid;
  gap: 8px;
}

input[type="number"],
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface-strong);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

input[type="number"] {
  padding: 6px 7px;
  text-align: right;
}

select {
  padding: 6px 28px 6px 9px;
}

input[type="range"] {
  width: 100%;
  height: 28px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--control-track));
}

input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--control-thumb);
  box-shadow: 0 0 0 1px var(--control-thumb);
  appearance: none;
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 3px;
  background: var(--control-track);
}

input[type="range"]::-moz-range-progress {
  height: 3px;
  background: var(--teal);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--control-thumb);
  box-shadow: 0 0 0 1px var(--control-thumb);
}

.toggle-control {
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
}

.toggle-control input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--teal);
}

.control-button,
.secondary-button {
  min-height: 40px;
  padding: 8px 11px;
  font-size: 0.86rem;
}

.control-button-strong {
  border-color: var(--teal);
  color: var(--teal);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.button-row-three {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
}

.button-row .control-button {
  width: 100%;
}

.plot-heading {
  margin-bottom: 8px;
}

.plot-heading h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-editorial);
  font-size: clamp(1.15rem, 1.7vw, 1.48rem);
  font-weight: 500;
  line-height: 1.25;
}

.plot-kicker {
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 0.69rem;
}

.plot-unit {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  white-space: nowrap;
}

.chart {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 390px;
}

.line-hover-tooltip {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 30;
  display: grid;
  gap: 3px;
  width: max-content;
  max-width: min(280px, calc(100% - 16px));
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--teal);
  background: var(--surface-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  pointer-events: none;
  white-space: normal;
  will-change: transform;
}

.line-hover-tooltip[hidden] {
  display: none;
}

.line-hover-tooltip strong {
  color: var(--ink);
  font-size: 0.84rem;
}

.line-hover-tooltip span {
  display: block;
}

.lab-card.is-focused .line-hover-tooltip {
  padding: 11px 13px;
  font-size: 0.95rem;
}

.lab-card.is-focused .line-hover-tooltip strong {
  font-size: 1rem;
}

.chart-feature {
  min-height: 440px;
}

.chart-summary {
  min-height: 36px;
  margin: 8px 0 0;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.dynamic-equation {
  min-height: 58px;
  margin: 4px 0 22px;
  overflow-x: auto;
  color: var(--ink);
  font-size: clamp(1rem, 1.25vw, 1.22rem);
  scrollbar-width: thin;
}

.metric-grid,
.closing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.metric-grid > div,
.closing-grid > div {
  min-width: 0;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-grid dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-grid dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: var(--font-editorial);
  font-size: 1.06rem;
  font-weight: 650;
}

.interpretation {
  margin: 24px 0 0;
  padding: 17px 18px;
  border-left: 3px solid var(--gold);
  background: color-mix(in srgb, var(--gold-soft) 28%, var(--surface));
  color: var(--ink-soft);
  font-family: var(--font-editorial);
  font-size: 1.05rem;
  line-height: 1.56;
}

.knowledge-check {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.knowledge-check fieldset {
  min-width: 0;
  margin: 0;
  padding: 30px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.knowledge-check legend {
  display: block;
  width: 100%;
  margin-bottom: 20px;
  color: var(--ink);
  font-family: var(--font-editorial);
  font-size: 1.18rem;
  line-height: 1.5;
}

.knowledge-check legend > span:first-child {
  display: block;
  margin-bottom: 14px;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1;
}

.knowledge-check fieldset > label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 9px 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  color: var(--ink-soft);
  font-size: 0.94rem;
  cursor: pointer;
}

.knowledge-check fieldset > label:hover {
  border-color: var(--line);
  background: var(--bg-raised);
}

.knowledge-check input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.22em;
  flex: 0 0 auto;
  accent-color: var(--teal);
}

.question-feedback {
  min-height: 2.9em;
  margin: 16px 0 0;
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.5;
}

.question-feedback.is-correct {
  color: var(--success);
}

.question-feedback.is-incorrect {
  color: var(--error);
}

.check-actions {
  grid-column: 1 / -1;
  min-height: 74px;
  padding: 14px 20px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.check-actions .primary-action {
  border-radius: 0;
}

#check-score {
  margin-left: auto;
  color: var(--ink);
  font-family: var(--font-editorial);
  font-size: 1.18rem;
}

.closing-section {
  margin: 30px 0 100px;
  padding: clamp(34px, 5vw, 70px);
  border: 1px solid var(--line-strong);
  background: var(--navy);
  color: var(--surface);
}

.closing-section .eyebrow {
  color: var(--gold-soft);
}

.closing-section h2 {
  max-width: 1080px;
  font-size: clamp(2.1rem, 3.8vw, 4.25rem);
}

.closing-grid {
  margin-top: 42px;
  border-color: color-mix(in srgb, currentColor 30%, transparent);
}

.closing-grid > div {
  background: color-mix(in srgb, var(--surface) 8%, transparent);
  border-color: color-mix(in srgb, currentColor 24%, transparent);
}

.closing-grid span {
  color: var(--gold-soft);
}

.closing-grid strong {
  display: block;
  margin-top: 8px;
  color: inherit;
  font-size: 0.95rem;
}

.artifact-footer {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  padding: 30px 0 10px;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.72rem;
}

.artifact-footer strong {
  color: var(--ink);
  font-family: var(--font-editorial);
  font-size: 0.98rem;
}

.artifact-footer p {
  margin: 4px 0 0;
}


.noscript-message {
  position: fixed;
  z-index: 500;
  inset: auto 20px 20px;
  padding: 16px;
  border: 1px solid var(--error);
  background: var(--surface);
  color: var(--error);
}

.katex-display {
  margin: 0.3em 0;
  padding-block: 0.35em;
  overflow-x: auto;
  overflow-y: hidden;
}

@media (max-width: 1320px) {
  .page-shell {
    display: block;
    width: min(calc(100% - 24px), 1280px);
  }

  .topic-rail {
    display: none;
  }
}

@media (max-width: 1060px) {
  .page-shell {
    width: min(100% - 36px, 940px);
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 74px;
  }

  .hero-copy {
    max-width: 740px;
  }

  .hero-visual {
    width: min(100%, 760px);
  }
}

@media (max-width: 900px) {
  .lab-layout,
  .lab-layout-wide {
    grid-template-columns: 1fr;
    grid-template-areas:
      "controls"
      "plot"
      "insight";
  }

  .control-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 820px) {
  .site-header {
    height: 62px;
    padding: 0 16px;
  }

  .course-name,
  .quiet-link {
    display: none;
  }

  .page-shell {
    width: min(100% - 24px, 720px);
  }

  .hero {
    padding: 58px 0 54px;
  }

  .hero h1 {
    font-size: clamp(3.45rem, 15vw, 5.6rem);
  }

  .hero-visual {
    min-height: 0;
  }

  .orientation {
    grid-template-columns: 1fr;
    margin-bottom: 90px;
  }

  .orientation div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .orientation div:last-child {
    border-bottom: 0;
  }

  .lesson-section {
    margin-bottom: 100px;
  }

  .section-heading {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 15px;
  }

  .section-heading h2 {
    font-size: clamp(2.25rem, 11vw, 3.4rem);
  }

  .lab-toolbar {
    align-items: flex-start;
    gap: 10px;
  }

  .toolbar-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .plot-panel {
    min-height: 430px;
  }

  .knowledge-check {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 560px) {
  .header-actions {
    gap: 6px;
  }

  .theme-toggle {
    padding: 7px 8px;
  }

  .hero h1 {
    font-size: clamp(3rem, 17vw, 4.6rem);
  }

  .hero-actions,
  .hero-facts,
  .toolbar-actions {
    flex-wrap: wrap;
  }

  .hero-facts {
    gap: 18px;
  }

  .hero-formula {
    left: 18px;
    right: 18px;
    bottom: 18px;
    overflow-x: auto;
  }

  .section-heading {
    display: block;
  }

  .section-number {
    width: 38px;
    margin-bottom: 14px;
  }

  .button-row-three,
  .metric-grid,
  .closing-grid {
    grid-template-columns: 1fr;
  }

  .check-actions {
    align-items: stretch;
    flex-direction: column;
  }

  #check-score {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  .site-header,
  .topic-rail,
  .page-progress,
  .lab-toolbar,
  .control-panel,
  .hero-actions,
  .knowledge-check,
  .noscript-message {
    display: none !important;
  }

  .page-shell,
  .hero,
  .lab-layout {
    display: block;
    width: 100%;
  }

  .hero,
  .lesson-section {
    break-after: page;
  }

  .lab-card,
  .hero-visual,
  .knowledge-check {
    box-shadow: none;
  }
}


/* Chapter 2 interactive components */
.hero-frontier {
  fill: none;
  stroke-width: 5;
}

.hero-frontier-base {
  stroke: var(--chart-navy);
}

.hero-frontier-shift {
  stroke: url(#ppf-gradient);
  stroke-dasharray: 10 8;
}

.hero-shift-arrow {
  fill: none;
  stroke: var(--chart-gold);
  stroke-width: 3;
  marker-end: url(#hero-shift-marker);
}

.parameter-inputs-select {
  grid-template-columns: minmax(90px, 1fr) 88px;
}

.metric-grid-stack {
  grid-template-columns: 1fr;
}

.trade-rate-guide {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.trade-rate-guide strong {
  position: relative;
  display: block;
  padding-top: 12px;
  color: var(--teal);
  text-align: center;
}

.trade-rate-guide strong::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--chart-teal), var(--chart-gold));
  content: "";
}

.gain-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.gain-grid > div {
  display: grid;
  gap: 7px;
  padding: 18px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.gain-grid span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gain-grid strong {
  color: var(--ink);
  font-family: var(--font-editorial);
  font-size: 1.05rem;
}

.gain-grid small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.gain-grid small.is-positive {
  color: var(--success);
}

.gain-grid small.is-negative {
  color: var(--error);
}

.economy-slider {
  grid-column: span 2;
}

.allocation-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.allocation-strip > div {
  display: grid;
  gap: 5px;
  padding: 13px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.allocation-strip span {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.allocation-strip strong {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.institution-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 28px;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.institution-grid article {
  min-width: 0;
  padding: 24px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.institution-grid article > span {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.institution-grid h3 {
  margin: 12px 0 8px;
  color: var(--ink);
  font-family: var(--font-editorial);
  font-size: 1.35rem;
  font-weight: 600;
}

.institution-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.flow-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.7fr);
  min-height: 610px;
}

.flow-plot-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 26px;
  background: var(--surface-strong);
}

.flow-diagram {
  width: 100%;
  max-height: 610px;
}

.flow-node {
  fill: color-mix(in srgb, var(--surface-muted) 72%, var(--surface));
  stroke: var(--line-strong);
  stroke-width: 2;
}

.flow-node-main {
  fill: color-mix(in srgb, var(--teal-soft) 60%, var(--surface));
  stroke: var(--teal);
}

.flow-node-label {
  fill: var(--ink);
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 750;
  text-anchor: middle;
}

.flow-path {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  opacity: 0.12;
  transition: opacity 180ms ease, stroke-width 180ms ease;
}

.flow-real {
  stroke: var(--chart-navy);
  marker-end: url(#arrow-real);
}

.flow-money {
  stroke: var(--chart-coral);
  marker-end: url(#arrow-money);
}

#arrow-real path {
  fill: var(--chart-navy);
}

#arrow-money path {
  fill: var(--chart-coral);
}

.flow-route-label {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 650;
  text-anchor: middle;
  opacity: 0.14;
  transition: opacity 180ms ease;
}

.flow-real-label {
  fill: var(--chart-navy);
}

.flow-money-label {
  fill: var(--chart-coral);
}

.flow-diagram.show-real .flow-real,
.flow-diagram.show-money .flow-money,
.flow-diagram.show-both .flow-path {
  opacity: 1;
  stroke-dasharray: 14 8;
  animation: flow-dash 1.8s linear infinite;
}

.flow-diagram.show-real .flow-real-label,
.flow-diagram.show-money .flow-money-label,
.flow-diagram.show-both .flow-route-label {
  opacity: 1;
}

@keyframes flow-dash {
  to {
    stroke-dashoffset: -44;
  }
}

.flow-insight-panel {
  padding: clamp(26px, 3vw, 42px);
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-muted) 42%, var(--surface));
}

.flow-insight-panel h3 {
  margin: 0 0 18px;
  color: var(--ink);
  font-family: var(--font-editorial);
  font-size: clamp(1.7rem, 2.6vw, 2.5rem);
  font-weight: 550;
}

.flow-insight-panel > p:not(.insight-label) {
  color: var(--ink-soft);
  font-family: var(--font-editorial);
  font-size: 1.05rem;
  line-height: 1.6;
}

.flow-steps {
  display: grid;
  gap: 0;
  margin: 26px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
  counter-reset: flow-step;
}

.flow-steps li {
  position: relative;
  padding: 13px 8px 13px 34px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.88rem;
  counter-increment: flow-step;
}

.flow-steps li::before {
  position: absolute;
  left: 5px;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  content: counter(flow-step, decimal-leading-zero);
}

.flow-card.is-focused .flow-layout {
  flex: 1;
  min-height: calc(100vh - 58px);
}

.flow-card.is-focused .flow-diagram {
  min-height: calc(100vh - 110px);
}

@media (max-width: 1000px) {
  .institution-grid {
    grid-template-columns: 1fr 1fr;
  }

  .flow-layout {
    grid-template-columns: 1fr;
  }

  .flow-insight-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 820px) {
  .economy-slider {
    grid-column: auto;
  }

  .trade-rate-guide {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .allocation-strip {
    grid-template-columns: 1fr;
  }

  .flow-plot-panel {
    padding: 10px;
  }
}

@media (max-width: 560px) {
  .institution-grid,
  .gain-grid {
    grid-template-columns: 1fr;
  }

  .flow-node-label {
    font-size: 21px;
  }

  .flow-route-label {
    display: none;
  }
}