:root {
  color-scheme: light;
  --background: #fcfcfc;
  --surface: #ffffff;
  --text: #000000;
  --muted: #667085;
  --line: #d7deea;
  --primary: #2563eb;
  --primary-strong: #1746a2;
  --accent: #e53935;
  --accent-strong: #b71c1c;
  --soft: #eaf1ff;
  --yellow: #f9c74f;
  --plot-background: #ffffff;
  --plot-grid: #dce3ee;
  --plot-axis: #64748b;
  --plot-curve: #2563eb;
  --plot-tangent: #e53935;
  --point-ring: #ffffff;
  --shadow: 0 12px 30px rgba(31, 65, 135, 0.08);
  --lesson-nav-background: #dbe8fb;
  --lesson-nav-selected: #ffffff;
  --lesson-nav-text: #000000;
  --corner: 10px;
  --control-corner: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #222222;
  --surface: #111111;
  --text: #ffffff;
  --muted: #b4b4b4;
  --line: #303030;
  --primary: #64a0ff;
  --primary-strong: #8bb8ff;
  --accent: #ff625e;
  --accent-strong: #ff8b88;
  --soft: #151515;
  --yellow: #ffd166;
  --plot-background: #000000;
  --plot-grid: #292929;
  --plot-axis: #a0a0a0;
  --plot-curve: #64a0ff;
  --plot-tangent: #ff625e;
  --point-ring: #000000;
  --shadow: none;
  --lesson-nav-background: #29456f;
  --lesson-nav-selected: #4775b3;
  --lesson-nav-text: #ffffff;
  --callout-blue-background: #1a2d4c;
  --callout-red-background: #3b2025;
  --callout-yellow-background: #382f19;
  --callout-orange-background: #3b271a;
  --callout-neutral-background: #2c2d31;
}

.lesson .lede,
.lesson section > p,
.lesson .hint p,
.lesson .solution div,
.lesson .reflection p {
  color: var(--text);
}

* { box-sizing: border-box; }
html {
  overflow-anchor: none;
  scroll-behavior: smooth;
  background: #050505;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: #050505;
  color: var(--text);
  font-family: "Alegreya Sans", system-ui, sans-serif;
  font-size: 1.125rem;
  line-height: 1.62;
}

a { color: inherit; }

.site-header {
  width: 100%;
  min-height: 80px;
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid #242424;
  background: #000000;
  color: #ffffff;
}

.wordmark {
  width: 38px;
  display: grid;
  color: #ffffff;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: .9rem;
  line-height: .85;
}

.fraction-bar { height: 1.5px; margin: 4px 0; background: var(--accent); }
.site-header nav { display: flex; gap: 30px; grid-column: 2; }

nav a {
  color: var(--muted);
  font-size: 1.125rem;
  font-weight: 600;
  text-decoration: none;
}

.site-header nav a { color: #aeb4bf; }
.site-header nav a:hover,
.site-header nav a[aria-current="page"] { color: #ffffff; }
.site-header nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 7px; }

.theme-toggle {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: #d4d7dc;
  font: inherit;
  cursor: pointer;
}

.toggle-track {
  width: 38px;
  height: 22px;
  position: relative;
  flex: 0 0 auto;
  border: 1px solid #686b70;
  border-radius: 999px;
  background: #34363a;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.toggle-track::after {
  content: "";
  width: 16px;
  height: 16px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  transition: transform 160ms ease;
}

[data-theme="dark"] .toggle-track {
  border-color: var(--primary);
  background: var(--primary);
}

[data-theme="dark"] .toggle-track::after { transform: translateX(16px); }

.theme-label {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
}
.theme-toggle:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 3px; }

main {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  flex: 1 0 auto;
  background: var(--background);
  box-shadow: 0 0 0 100vmax var(--background);
  clip-path: inset(0 -100vmax);
}
.hero { max-width: 650px; padding: 52px 0 50px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 28px; font-size: clamp(3.1rem, 6.6vw, 5.7rem); line-height: .98; letter-spacing: -.035em; }
h2 { font-size: 1.85rem; line-height: 1.12; letter-spacing: -.018em; }
.lede { max-width: 720px; color: var(--muted); font-size: clamp(1.28rem, 2.2vw, 1.6rem); line-height: 1.48; }
.hero h1 { margin-bottom: 14px; font-size: 2.5rem; line-height: 1.12; letter-spacing: -.018em; }
.hero .lede { max-width: 620px; font-size: 1.08rem; line-height: 1.6; }

.home-section { padding: 54px 0 110px; border-top: 1px solid var(--line); }
.section-heading { max-width: 660px; padding: 54px 0 42px; }
.section-heading h2 { margin-bottom: 12px; font-size: 2.5rem; }
.section-heading p:last-child { color: var(--muted); }
.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.home-grid-two { grid-template-columns: repeat(2, 1fr); }

.card {
  min-height: 275px;
  padding: 4px 30px 8px 0;
  border-right: 1px solid var(--line);
}
.card + .card { padding-left: 30px; }
.card:last-child { padding-right: 0; border-right: 0; }
.card h2 { margin-bottom: 14px; }
.card p { color: var(--muted); }
.text-link { color: var(--primary); font-weight: 700; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.text-link:hover { color: var(--primary-strong); }

.listing-page { max-width: 1040px; padding: 56px 0 100px; }
.page-intro { max-width: 700px; margin-bottom: 52px; }
.page-intro h1 { margin-bottom: 16px; font-size: 2.5rem; line-height: 1.12; letter-spacing: -.018em; }
.page-intro .lede { max-width: 650px; font-size: 1.15rem; line-height: 1.58; }

.part-card-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 52px;
}
.part-card {
  aspect-ratio: 3 / 4;
  min-width: 0;
  position: relative;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--corner);
  background: #111111;
  color: #ffffff;
  box-shadow: var(--shadow);
  cursor: pointer;
  isolation: isolate;
}
.part-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to top, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .08) 62%, rgba(0, 0, 0, .18) 100%);
  transition: background-color 160ms ease;
}
.part-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 220ms ease, filter 220ms ease;
}
.part-card.is-planned img {
  filter: grayscale(1);
}
.part-card-label {
  position: absolute;
  right: 14px;
  bottom: 12px;
  left: 14px;
  z-index: 2;
  font: 700 clamp(1.3rem, 2.3vw, 1.8rem)/1 "Alegreya Sans", system-ui, sans-serif;
  letter-spacing: -.02em;
  text-align: left;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .65);
}
.part-card-status {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: start center;
  padding-top: 18px;
  background: rgba(6, 10, 16, .22);
  color: #ffffff;
  font: 700 clamp(.82rem, 1.4vw, 1rem)/1 "Alegreya Sans", system-ui, sans-serif;
  letter-spacing: .14em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .85);
  text-transform: uppercase;
}
.part-card:hover img { transform: scale(1.035); }
.part-card.is-selected {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
}
.part-card.is-selected:not(.is-planned) img { filter: saturate(1.08) contrast(1.04); }
.part-card:focus-visible {
  outline: 4px solid var(--primary);
  outline-offset: 3px;
}

.curriculum-list { border-top: 1px solid var(--line); }
[data-part-panel][hidden] { display: none; }
.curriculum-part {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 30px;
  padding: 34px 0 0;
}
.part-number { padding-top: 4px; color: var(--primary); font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.part-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.part-heading h2 { margin-bottom: 10px; }
.part-content > p { max-width: 670px; margin-bottom: 0; color: var(--muted); }
.status { flex: 0 0 auto; color: var(--primary); font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.status.planned { color: var(--muted); }
.chapter-list { margin-top: 30px; }
.chapter { margin-top: 30px; }
.chapter:first-child { margin-top: 0; }
.chapter h3 { margin: 0 0 8px; font-size: 1.15rem; line-height: 1.3; }
.chapter ol { margin: 0; padding: 0; list-style: none; }
.chapter li {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.chapter li span { color: var(--muted); font-variant-numeric: tabular-nums; }
.chapter li a { display: contents; color: var(--primary); font-weight: 700; }
.chapter li a span { color: var(--primary); }
.planned-section { color: var(--muted); }
.planned-section::after {
  content: "Planned";
  grid-column: 3;
  align-self: center;
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.capstone { margin: 30px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); }
.capstone strong { color: var(--text); }
.part-image-credit {
  grid-column: 1 / -1;
  margin: 34px 0 0;
  padding: 12px 0 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
  text-align: right;
}
.part-image-credit a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
  text-underline-offset: 3px;
}
.part-image-credit a:hover { color: var(--text); }
.part-outline { margin-top: 22px; }
.part-outline summary {
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.part-outline summary::-webkit-details-marker { display: none; }
.part-outline summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms ease;
}
.part-outline[open] summary::before { transform: rotate(45deg) translate(-2px, -2px); }
.part-outline summary:hover { color: var(--primary-strong); }
.part-outline summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent); outline-offset: 4px; }

.demo-list { border-top: 1px solid var(--line); }
.demo-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: end;
  padding: 34px 0 38px;
  border-bottom: 1px solid var(--line);
}
.demo-list-item h2 { margin-bottom: 10px; }
.demo-list-item p { max-width: 620px; margin-bottom: 0; color: var(--muted); }
.demo-list-item .text-link { white-space: nowrap; }

.reading-layout {
  max-width: none;
  width: calc(100% - clamp(230px, 23vw, 300px));
  margin: 0 0 0 clamp(230px, 23vw, 300px);
  padding: 28px 0 96px;
}
.lesson-index {
  width: clamp(230px, 23vw, 300px);
  height: calc(100dvh - 80px);
  position: fixed;
  top: 80px;
  left: 0;
  overflow-y: auto;
  padding: 32px 24px;
  background: var(--lesson-nav-background);
  color: var(--lesson-nav-text);
  font-size: 1.125rem;
}
.lesson { width: min(680px, calc(100% - 40px)); margin: 0 auto; }
.lesson-index a { color: var(--lesson-nav-text); font-weight: 700; }
.lesson-index h2 { margin-bottom: 18px; font-size: 1.55rem; line-height: 1.15; }
.chapter-label { margin-bottom: 4px; color: var(--lesson-nav-text); font-size: 1.35rem; line-height: 1.2; }
.lesson-index ol { margin: 0; padding: 0; list-style: none; }
.chapter-navigation li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 7px;
  margin: 2px -12px;
  padding: 7px 12px;
  line-height: 1.3;
}
.chapter-navigation li > span, .chapter-navigation a span { color: var(--lesson-nav-text); font-variant-numeric: tabular-nums; }
.chapter-navigation a { display: contents; }
.chapter-navigation .current-lesson {
  border-radius: 7px;
  background: var(--lesson-nav-selected);
}
.chapter-navigation .current-lesson a { color: var(--text); font-weight: 700; }
.chapter-navigation .planned-lesson { color: var(--lesson-nav-text); }
.chapter-navigation.reference-navigation li { grid-template-columns: minmax(0, 1fr); }
.reference-page-title { min-width: 0; overflow-wrap: anywhere; }
.status-label { text-transform: capitalize; }
.lesson-heading { margin-bottom: 30px; }
.lesson-heading h1 { margin-bottom: 16px; font-size: 2.5rem; line-height: 1.12; letter-spacing: -.018em; }
.lesson-heading .lede { max-width: 640px; font-size: 1.15rem; line-height: 1.58; }
.lesson-splash {
  margin: 0 0 34px;
  overflow: hidden;
  border-radius: var(--corner);
  background: var(--surface);
}
.lesson-splash img { display: block; width: 100%; height: auto; }
.lesson-media {
  width: 100%;
  margin: 30px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--corner);
  background: var(--surface);
}
.lesson-image-expand {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: zoom-in;
}
.lesson-image-expand img,
.lesson-video-frame video { display: block; width: 100%; height: auto; }
.lesson-video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.lesson-video-frame iframe,
.lesson-video-frame video { width: 100%; height: 100%; border: 0; }
.lesson-media figcaption { padding: 15px 18px; border-top: 1px solid var(--line); color: var(--muted); }
.lesson-media figcaption > :first-child { margin-top: 0; }
.lesson-media figcaption > :last-child { margin-bottom: 0; }
.media-credit,
.media-video-link { margin: 0; padding: 10px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.media-lightbox {
  width: min(76rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 2.75rem 1rem 1rem;
  border: 0;
  border-radius: var(--corner);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1rem 4rem #0008;
}
.media-lightbox::backdrop { background: #000b; }
.media-lightbox img { display: block; max-width: 100%; max-height: calc(100vh - 10rem); margin: 0 auto; object-fit: contain; }
.media-lightbox-close { position: absolute; top: .55rem; right: .65rem; border: 0; color: var(--text); background: transparent; font-size: 1.7rem; }
.photo-credit {
  margin: 38px 0 0;
  color: var(--muted) !important;
  font-size: .78rem;
  line-height: 1.4;
  text-align: right;
}
.photo-credit a { color: inherit; text-decoration: underline; text-underline-offset: .14em; }
.lesson-part.overview > p:not(.photo-credit) {
  max-width: 680px;
  font-size: 1.15rem;
  line-height: 1.65;
}
.lesson section { margin-bottom: 62px; }
.lesson section > p { color: var(--text); }

.objectives { margin: 28px 0 34px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.objectives h3 { margin: 0 0 10px; font-size: 1.15rem; }
.objectives ul { margin-bottom: 0; }
.lesson-phase-navigation {
  display: flex;
  align-items: stretch;
  gap: 34px;
  width: fit-content;
  min-height: 46px;
  position: sticky;
  top: 80px;
  z-index: 50;
  isolation: isolate;
  margin-top: -28px;
  margin-bottom: 46px;
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  scroll-margin-top: 98px;
}
.lesson-phase-navigation::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  left: calc((100vw - clamp(230px, 23vw, 300px) - min(680px, calc(100vw - clamp(230px, 23vw, 300px) - 40px))) / -2);
  width: calc(100vw - clamp(230px, 23vw, 300px));
  background: var(--background);
}
.lesson-phase-navigation a {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  padding: 0;
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 700;
}
.lesson-phase-navigation a[aria-current="page"] { color: var(--text); }
.lesson-phase-navigation a[aria-current="page"]::after {
  content: "";
  height: 2px;
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  background: var(--text);
}
.lesson-part { scroll-margin-top: 28px; }
.explore-settings {
  display: none;
  position: fixed;
  z-index: 70;
  top: 104px;
  right: 28px;
  color: var(--text);
}
[data-lesson-view="explore"] .explore-settings { display: block; }
.explore-settings summary {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  list-style: none;
}
.explore-settings summary::-webkit-details-marker { display: none; }
.explore-settings summary:hover { border-color: var(--primary); color: var(--primary); }
.explore-settings summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
  outline-offset: 3px;
}
.explore-settings summary svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.explore-settings-menu {
  width: max-content;
  min-width: 210px;
  position: absolute;
  top: 50px;
  right: 0;
  overflow: hidden;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--corner);
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(20, 32, 55, .18);
}
.explore-settings-menu button {
  width: 100%;
  display: block;
  padding: 9px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .94rem;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}
.explore-settings-menu button:hover,
.explore-settings-menu button:focus-visible {
  outline: none;
  background: var(--soft);
  color: var(--primary-strong);
}
.lesson-part.concepts > .guidance-callout:first-child { margin-top: 0; }
.lesson-part.apply > .exercise-set:first-child {
  padding-top: 0;
  border-top: 0;
}
.block-kind { color: var(--text); }
.content-list { margin: 20px 0; padding-left: 1.65rem; }
.content-list > li { padding-left: .25rem; }
.content-list > li + li { margin-top: .65rem; }
.content-list > li > p { margin: 0; }
.content-list > li > p + p { margin-top: .65rem; }
.content-list .content-list { margin: .65rem 0 0; }
.content-list > li > .content-list:first-child { margin-top: 0; }
.vocab { color: inherit; font-style: normal; font-weight: 700; text-decoration: none; }
dfn.vocab {
  font-weight: 700;
  text-decoration: none;
}
.lesson-interactive { margin: 30px 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--corner); background: var(--surface); }
.desmos-plot { width: 100%; height: 410px; background: var(--plot-background); }
.lesson-interactive figcaption { padding: 15px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .95rem; }
.exercise-activity { margin: 28px 0; padding: 26px 28px; border-radius: var(--corner); border-left: 3px solid var(--yellow); background: color-mix(in srgb, var(--yellow) 10%, var(--surface)); }
.prompt { font-weight: 600; }
.inline-exercise { padding-block: 20px; }
.inline-exercise .prompt p { margin: 0; line-height: 2.5; }
.inline-response {
  display: inline-flex;
  position: relative;
  align-items: center;
  gap: 6px;
  margin-inline: .18em;
  vertical-align: baseline;
}
.inline-response input[type="text"],
.inline-response select {
  width: auto;
  min-width: 4.5rem;
  height: 2.15rem;
  box-sizing: border-box;
  padding: 4px 30px 4px 9px;
  border: 2px solid var(--line);
  border-radius: var(--control-corner);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.2;
}
.inline-response input::placeholder { color: var(--muted); opacity: .7; text-align: center; }
.inline-response select {
  min-width: 8rem;
  appearance: none;
  -webkit-appearance: none;
}
.inline-response select.awaiting-answer { color: var(--muted); }
.inline-response input[readonly],
.inline-response select:disabled {
  opacity: 1;
  cursor: default;
  -webkit-text-fill-color: currentColor;
}
.inline-response .response-feedback {
  position: absolute;
  right: 9px;
  color: currentColor;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.inline-response.is-correct { color: var(--primary); }
.inline-response.is-correct input,
.inline-response.is-correct select {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
}
.inline-response.is-correct.is-revealed { color: color-mix(in srgb, var(--yellow) 72%, var(--text)); }
.inline-response.is-correct.is-revealed input,
.inline-response.is-correct.is-revealed select {
  border-color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 24%, var(--surface));
}
.inline-response.is-incorrect { color: #c73939; }
.inline-response.is-incorrect input,
.inline-response.is-incorrect select {
  border-color: #c73939;
  background: color-mix(in srgb, #c73939 8%, var(--surface));
}
.responses { display: grid; gap: 16px; margin: 22px 0; }
.response-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.response-row > * { flex: 1 1 12rem; }
.response-row label { display: grid; gap: 7px; color: var(--muted); font-size: .9rem; }
.response-row input[type="text"], .response-row select { width: 100%; }
.response-row select {
  height: 44px;
  padding: 9px 34px 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--control-corner);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.response-check { position: relative; }
.response-check .response-feedback {
  position: absolute;
  right: 10px;
  bottom: 11px;
  font-weight: 700;
  pointer-events: none;
}
.response-check.is-correct { color: var(--primary); }
.response-check.is-correct input,
.response-check.is-correct select { border-color: var(--primary); }
.response-check.is-incorrect { color: #c73939; }
.response-check.is-incorrect input,
.response-check.is-incorrect select { border-color: #c73939; }
input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--control-corner);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input[type="text"] { min-width: 0; padding: 9px 10px; }
textarea { margin-bottom: 16px; padding: 10px 12px; resize: vertical; }
.hint, .solution, .proof { margin-top: 14px; }
.hint summary, .solution summary, .proof summary { width: fit-content; color: var(--primary); font-weight: 700; cursor: pointer; }
.hint p, .solution div, .proof div { margin: 10px 0 0; color: var(--muted); }
.reflection { margin: 32px 0; padding: 22px 25px; border-radius: var(--corner); border-left: 3px solid var(--primary); background: var(--soft); }
.reflection p { margin: 5px 0 0; color: var(--muted); }
.subsection { margin-bottom: 52px !important; }
.subsection h3, .exercise-set h3 { margin-bottom: 16px; font-size: 1.55rem; line-height: 1.2; }
.formal-block { margin: 30px 0; padding: 25px 28px; border: 1px solid var(--line); border-radius: var(--corner); background: var(--surface); }
.formal-block.definition, .formal-block.fact { border-left: 4px solid var(--primary); }
.formal-block.example { border-left: 4px solid var(--accent); }
.formal-block.principle { border-left: 4px solid var(--yellow); }
.formal-block.theorem, .formal-block.proposition, .formal-block.lemma, .formal-block.corollary { border-left: 4px solid var(--primary); }
.block-kind { margin: 0 0 7px; color: var(--muted); font-size: .76rem; font-weight: 800; letter-spacing: .09em; line-height: 1.2; text-transform: uppercase; }
.formal-block h4 { margin: 0 0 12px; font-size: 1.28rem; }
.formal-block p:last-child, .statement { margin-bottom: 0; }
.guidance-callout, .you-try { margin: 30px 0; padding: 22px 25px; border: 1px solid var(--line); border-radius: var(--corner); background: var(--soft); }
.guidance-callout.tip { border-left: 4px solid var(--primary); }
.guidance-callout.warning { border-left: 4px solid #d96a24; }
.guidance-callout.note { border-left: 4px solid var(--muted); }
.guidance-callout.reflection { border-left: 4px solid var(--primary); }
.you-try { border-left: 4px solid var(--accent); background: var(--surface); }
.guidance-callout h4, .you-try h4 { margin: 0 0 10px; font-size: 1.28rem; }
.guidance-callout p:last-child, .you-try-prompt > :last-child { margin-bottom: 0; }
.exercise-set { margin-bottom: 54px !important; padding-top: 28px; border-top: 1px solid var(--line); }
.exercises { display: grid; gap: 28px; margin: 0; padding-left: 2rem; }
.exercise-item { padding-left: .35rem; }
.exercise-item::marker, .task-item::marker { color: var(--muted); font-weight: 700; }
.exercise-content > .exercise-activity { margin: 0; }
.tasks { display: grid; gap: 18px; margin: 20px 0; padding-left: 1.65rem; color: inherit; }
.task-item { padding-left: .25rem; }
.task-content > .exercise-activity { margin: 0; }
.exercise-set .exercise-activity { background: var(--surface); }
.choices { display: grid; gap: 10px; margin: 20px 0; padding: 0; border: 0; }
.choices legend { margin-bottom: 8px; color: var(--muted); font-size: .9rem; }
.choices label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: var(--control-corner);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.choices label:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--line)); }
.choices label:focus-within { outline: 2px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.choices input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.choices.is-correct label:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  color: var(--primary);
}
.choices.is-correct label:has(input:checked)::after {
  content: "✓";
  font-weight: 700;
}
.choices.is-incorrect label:has(input:checked) {
  border-color: #c73939;
  background: color-mix(in srgb, #c73939 8%, var(--surface));
  color: #c73939;
}
.choices.is-incorrect label:has(input:checked)::after {
  content: "×";
  font-weight: 700;
}
.choices label:has(input:disabled) { cursor: default; }
.phase-sequence-navigation { display: flex; justify-content: space-between; gap: 24px; margin-top: 54px; padding-top: 22px; border-top: 1px solid var(--line); }
.phase-sequence-navigation a { color: var(--primary); font-weight: 700; }
.phase-sequence-navigation .next-phase { margin-left: auto; text-align: right; }

.comparison, .readout { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin: 30px 0; overflow: hidden; border: 1px solid var(--line); background: var(--line); }
.comparison div, .readout div { display: grid; gap: 4px; padding: 20px; background: var(--surface); }
.comparison span, .readout span { color: var(--muted); font-size: .9rem; }
.callout { padding: 32px 34px; border-left: 3px solid var(--primary); background: var(--soft); }
.callout h2 { font-size: 2.2rem; }

:root[data-theme="dark"] .exercise-activity,
:root[data-theme="dark"] .formal-block.principle {
  background: var(--callout-yellow-background);
}
:root[data-theme="dark"] .reflection,
:root[data-theme="dark"] .formal-block.definition,
:root[data-theme="dark"] .formal-block.fact,
:root[data-theme="dark"] .formal-block.theorem,
:root[data-theme="dark"] .formal-block.proposition,
:root[data-theme="dark"] .formal-block.lemma,
:root[data-theme="dark"] .formal-block.corollary,
:root[data-theme="dark"] .guidance-callout.tip,
:root[data-theme="dark"] .guidance-callout.reflection,
:root[data-theme="dark"] .callout {
  background: var(--callout-blue-background);
}
:root[data-theme="dark"] .formal-block.example,
:root[data-theme="dark"] .you-try {
  background: var(--callout-red-background);
}
:root[data-theme="dark"] .guidance-callout.warning {
  background: var(--callout-orange-background);
}
:root[data-theme="dark"] .guidance-callout.note {
  background: var(--callout-neutral-background);
}

.lesson-nav { display: flex; justify-content: space-between; padding-top: 28px; border-top: 1px solid var(--line); }

.demo-page { padding: 56px 0 96px; }
.demo-intro { max-width: 700px; margin-bottom: 36px; }
.demo-intro h1 { margin-bottom: 16px; font-size: 2.5rem; line-height: 1.12; letter-spacing: -.018em; }
.demo-intro .lede { max-width: 650px; font-size: 1.15rem; line-height: 1.58; }
.interactive-card { overflow: hidden; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.plot-wrap { padding: 14px; background: var(--plot-background); }
#calculator, #calculator-3d { width: 100%; height: min(64vw, 580px); min-height: 420px; }
.desmos-message { height: 100%; display: grid; place-content: center; gap: 8px; padding: 28px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }
.desmos-message strong { color: var(--text); font-size: 1.3rem; }
.desmos-message code { color: var(--primary); }
.desmos-caption { margin: 0; padding: 17px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 1rem; }
.demo-controls { padding: 28px 34px 32px; border-top: 1px solid var(--line); }
.demo-controls label { display: block; font-size: 1.2rem; }
input[type="range"] { width: 100%; margin: 20px 0 10px; accent-color: var(--accent); }
.readout { grid-template-columns: repeat(3, 1fr); }
.hint { margin-bottom: 0; color: var(--muted); font-size: 1rem; }
.demo-explanation { max-width: 680px; padding-top: 68px; }
.demo-explanation p { color: var(--muted); }
.demo-links { display: flex; flex-wrap: wrap; gap: 12px 28px; }

footer {
  width: 100%;
  margin: 0;
  padding: 18px 20px;
  background: #050505;
  color: #f5f5f5;
  font-size: .9rem;
}
footer p { margin: 0; }

@media (max-width: 760px) {
  .site-header {
    width: 100%;
    min-height: 104px;
    padding: 12px 20px;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    row-gap: 8px;
  }
  .site-header nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; gap: 24px; }
  .theme-toggle { grid-column: 2; grid-row: 1; }
  .hero { padding: 40px 0 42px; }
  .home-grid, .reading-layout { grid-template-columns: 1fr; }
  .home-grid-two { grid-template-columns: 1fr; }
  .card, .card + .card { min-height: 0; padding: 28px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .card:last-child { border-bottom: 0; }
  .reading-layout { gap: 32px; padding-top: 42px; }
  .lesson-index, .lesson { grid-column: 1; }
  .lesson { padding: 0 20px; }
  .reading-layout { width: 100%; margin-left: 0; }
  .lesson-index {
    width: auto;
    height: auto;
    min-height: 0;
    position: static;
    overflow: visible;
    padding: 24px 20px;
    border-bottom: 1px solid var(--line);
  }
  .comparison, .readout { grid-template-columns: 1fr; }
  .response-row { display: grid; grid-template-columns: 1fr; }
  .exercise-activity, .formal-block { padding: 22px 20px; }
  .desmos-plot { height: 340px; }
  .demo-controls { padding: 24px 20px; }
  .plot-wrap { padding: 8px; }
  #calculator, #calculator-3d { height: 520px; min-height: 0; }
  .desmos-caption { padding: 17px 20px; }
  .lesson-nav { gap: 18px; }
  .listing-page { padding-top: 42px; }
  .page-intro { margin-bottom: 38px; }
  .part-card-list {
    width: calc(100% + 20px);
    grid-template-columns: repeat(5, 142px);
    gap: 10px;
    margin-bottom: 42px;
    padding: 4px 20px 8px 4px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }
  .part-card {
    scroll-snap-align: start;
    border-radius: 8px;
  }
  .part-card-label { font-size: 1.35rem; }
  .curriculum-part { grid-template-columns: 1fr; gap: 10px; }
  .part-heading { align-items: flex-start; }
  .chapter li { grid-template-columns: 38px 1fr; }
  .planned-section::after { display: none; }
  .demo-list-item { grid-template-columns: 1fr; gap: 18px; align-items: start; }
  .lesson-phase-navigation { top: 104px; margin-top: 0; }
  .lesson-phase-navigation::before { left: calc(50% - 50vw); width: 100vw; }
  .explore-settings { top: 92px; right: 18px; left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .part-card img { transition: none; }
}
