:root {
  --bg: #f7f2e8;
  --paper: rgba(255, 251, 245, 0.82);
  --surface: rgba(255, 253, 248, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --ink: #1e2328;
  --muted: #66655f;
  --accent: #ab5d2b;
  --accent-soft: rgba(171, 93, 43, 0.1);
  --line: rgba(30, 35, 40, 0.12);
  --shadow-soft: 0 16px 40px rgba(57, 42, 26, 0.08);
  --shadow-card: 0 18px 38px rgba(57, 42, 26, 0.1);
  --radius-xl: 36px;
  --radius-lg: 26px;
  --radius-md: 18px;
  --max-width: 1280px;
  --nav-height: 74px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(171, 93, 43, 0.16), transparent 32%),
    radial-gradient(circle at top right, rgba(67, 114, 95, 0.12), transparent 28%),
    linear-gradient(180deg, #f8efe2 0%, #f7f2e8 42%, #f3ede3 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(30, 35, 40, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 35, 40, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.38), transparent 82%);
  content: "";
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

[id] {
  scroll-margin-top: calc(var(--nav-height) + 18px);
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
  background: rgba(247, 242, 232, 0.82);
  border-bottom: 1px solid rgba(30, 35, 40, 0.08);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(calc(100% - 40px), var(--max-width));
  min-height: var(--nav-height);
  margin: 0 auto;
}

.nav-brand,
.nav-link {
  text-decoration: none;
}

.nav-brand {
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.96rem;
  transition:
    color 180ms ease,
    background-color 180ms ease,
    transform 180ms ease;
}

.nav-link:hover,
.nav-link.is-current {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  transform: translateY(-1px);
}

.page-shell {
  width: min(calc(100% - 40px), var(--max-width));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(360px, 0.98fr);
  gap: 34px;
  padding: 44px 0 24px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.hero::after {
  content: none;
}

.hero-copy,
.hero-visual {
  position: relative;
  z-index: 1;
}

.hero-copy {
  display: grid;
  align-content: start;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1,
.section-heading h2 {
  margin: 0;
  font-family: "Source Serif 4", serif;
}

.hero h1 {
  line-height: 0.95;
}

.hero-brand {
  display: block;
  white-space: nowrap;
  font-size: clamp(2.65rem, 4.7vw, 3.85rem);
  letter-spacing: -0.07em;
}

.hero-title {
  display: block;
  max-width: none;
  margin-top: 18px;
  font-size: clamp(1.32rem, 1.85vw, 1.9rem);
  line-height: 1.14;
  letter-spacing: -0.03em;
  color: rgba(30, 35, 40, 0.8);
  text-wrap: pretty;
}

.hero-summary,
.intro-copy p,
.explorer-intro p,
.footer p,
.authors {
  font-size: 1.02rem;
  line-height: 1.74;
  color: var(--muted);
}

.hero-summary,
.intro-copy p,
.explorer-intro p,
.detail-list p,
.insight-band p {
  text-align: justify;
  text-align-last: left;
  text-wrap: pretty;
  hyphens: auto;
}

.hero-summary {
  max-width: 60ch;
  margin: 24px 0 16px;
}

.hero-course {
  margin: 0 0 18px;
  font-size: 0.98rem;
  line-height: 1.72;
  color: var(--muted);
}

.hero-course a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(171, 93, 43, 0.38);
  transition:
    color 180ms ease,
    border-color 180ms ease;
}

.hero-course a:hover {
  color: var(--ink);
  border-color: rgba(171, 93, 43, 0.72);
}

.authors {
  margin: 0 0 28px;
}

.authors a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(30, 35, 40, 0.3);
  transition:
    color 180ms ease,
    border-color 180ms ease;
}

.authors a:hover {
  color: var(--ink);
  border-color: rgba(30, 35, 40, 0.36);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-link,
.secondary-link,
.homework-pill {
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
}

.primary-link {
  background: var(--ink);
  color: #fff8f2;
}

.secondary-link {
  border-color: rgba(30, 35, 40, 0.12);
  background: rgba(255, 255, 255, 0.62);
}

.primary-link:hover,
.secondary-link:hover,
.homework-pill:hover,
.homework-pill.is-active {
  transform: translateY(-2px);
}

.hero-visual {
  display: grid;
  gap: 0;
  align-content: start;
  justify-items: center;
}

.hero-visual figure,
.split-figure {
  margin: 0;
}

.hero-visual figure {
  padding: 12px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-card);
}

.hero-carousel {
  display: grid;
  gap: 14px;
  width: min(100%, 520px);
}

.hero-carousel-frame {
  position: relative;
  min-height: 640px;
  border-radius: 20px;
  border: 1px solid rgba(30, 35, 40, 0.05);
  background: rgba(255, 255, 255, 0.99);
  overflow: hidden;
}

.hero-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  object-fit: contain;
  image-rendering: auto;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  opacity: 0;
  transform: scale(0.985);
  transition:
    opacity 420ms ease,
    transform 420ms ease;
}

.hero-slide.is-active {
  opacity: 1;
  transform: scale(1);
}

.hero-caption {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(30, 35, 40, 0.08);
  justify-items: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.99);
}

.hero-caption-kicker {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(30, 35, 40, 0.58);
}

.hero-caption-text {
  max-width: 48ch;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--muted);
  text-wrap: pretty;
}

.hero-carousel-controls {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
}

.hero-carousel-button {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(30, 35, 40, 0.2);
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease;
}

.hero-carousel-button:hover,
.hero-carousel-button.is-active {
  transform: scale(1.08);
  background: rgba(30, 35, 40, 0.72);
}

.hero-visual img,
.split-figure img {
  width: 100%;
  border-radius: 18px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  max-width: 680px;
  margin-top: 18px;
  margin-bottom: 26px;
}

.hero-metrics div {
  padding: 12px 4px 0;
  border-top: 1px solid rgba(30, 35, 40, 0.12);
}

.hero-metrics span {
  display: block;
  margin-bottom: 8px;
  font-family: "Source Serif 4", serif;
  font-size: 2.2rem;
  line-height: 1;
}

.hero-metrics p,
.detail-list p,
.insight-band p,
.example-meta p,
.panel-heading p,
.split-figure figcaption {
  margin: 0;
  line-height: 1.55;
  color: var(--muted);
}

.hero-metrics p,
.split-figure figcaption,
.example-meta p {
  text-wrap: balance;
}

.section {
  position: relative;
  padding: 56px 0 8px;
}

.section + .section {
  margin-top: 18px;
}

.section + .section::before {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(30, 35, 40, 0.14) 15%, rgba(30, 35, 40, 0.14) 85%, transparent);
  content: "";
}

.section-heading {
  max-width: none;
}

.section-heading h2 {
  max-width: none;
  font-size: clamp(1.9rem, 3vw, 2.95rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: pretty;
}

.section-heading.compact {
  max-width: 70ch;
}

.explorer-section .section-heading {
  max-width: none;
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
  gap: 34px;
  margin-top: 28px;
  align-items: start;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin-top: 28px;
}

.detail-list div,
.insight-band article {
  padding-top: 16px;
  border-top: 1px solid rgba(30, 35, 40, 0.12);
}

.detail-list h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.split-figure {
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow-soft);
}

.split-figure figcaption {
  margin-top: 14px;
  font-size: 0.95rem;
}

.insight-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px;
  margin-top: 28px;
}

.insight-band span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.explorer-intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-top: 24px;
}

.explorer-copy {
  display: grid;
  gap: 10px;
  max-width: 68ch;
}

.explorer-intro p {
  max-width: 66ch;
  margin: 0;
}

.control-cluster {
  min-width: 250px;
}

.select-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(30, 35, 40, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
  font: inherit;
}

.homework-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.homework-pill {
  padding: 10px 14px;
  border: 1px solid rgba(30, 35, 40, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.homework-pill.is-active {
  border-color: rgba(171, 93, 43, 0.3);
  background: var(--accent-soft);
  color: var(--ink);
}

.example-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
  padding: 16px 0;
  border-top: 1px solid rgba(30, 35, 40, 0.12);
  border-bottom: 1px solid rgba(30, 35, 40, 0.12);
}

.example-meta p {
  padding-right: 18px;
}

.example-meta p:not(:last-child) {
  border-right: 1px solid rgba(30, 35, 40, 0.08);
}

.example-meta strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.viewer-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}

.panel {
  min-height: 0;
}

.panel-heading {
  padding-bottom: 12px;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
}

.panel-heading p:not(.transcript-note) {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
}

.transcript-panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.transcript-note {
  margin: 6px 0 0;
  max-width: 54ch;
  font-size: 0.76rem;
  font-weight: 400;
  line-height: 1.62;
  letter-spacing: 0.01em;
  color: rgba(102, 101, 95, 0.92);
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.42rem;
  padding: 0.07rem 0.42rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  vertical-align: baseline;
}

.legend-chip-red {
  border-color: rgba(183, 36, 36, 0.35);
  background: rgba(183, 36, 36, 0.07);
  color: #9d2020;
}

.legend-chip-green {
  border-color: rgba(47, 143, 77, 0.36);
  background: rgba(47, 143, 77, 0.08);
  color: #246d39;
}

.transcript-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(30, 35, 40, 0.08);
}

.transcript-toggle-button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.transcript-toggle-button:hover,
.transcript-toggle-button.is-active {
  background: rgba(171, 93, 43, 0.12);
  color: var(--ink);
}

.image-frame,
.transcript-body {
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(244, 239, 230, 0.74));
  box-shadow: var(--shadow-card);
}

.image-frame {
  padding: 18px;
}

.image-frame img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(74vh, 980px);
  margin: 0 auto;
  border-radius: 16px;
  box-shadow: 0 18px 32px rgba(20, 24, 27, 0.12);
}

.transcript-body {
  min-height: 420px;
  max-height: min(74vh, 980px);
  overflow: auto;
  padding: 22px;
}

.transcript-body h3,
.transcript-body h4 {
  margin: 0 0 12px;
  font-family: "IBM Plex Sans", sans-serif;
}

.transcript-body p,
.transcript-body blockquote,
.transcript-body .equation {
  margin: 0 0 12px;
  animation: rise-in 340ms ease both;
}

.transcript-body p,
.transcript-body li {
  line-height: 1.72;
}

.transcript-body blockquote {
  padding: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

.transcript-body code {
  padding: 0.12rem 0.42rem;
  border-radius: 8px;
  background: rgba(30, 35, 40, 0.08);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.92em;
}

.transcript-body .equation {
  overflow-x: auto;
  padding: 2px 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.transcript-body .line-diff {
  padding: 4px 0;
  border-left: 3px solid rgba(183, 36, 36, 0.45);
}

.transcript-body .diff-token {
  padding: 0.05em 0.2em;
  border: 1.5px solid rgba(183, 36, 36, 0.55);
  border-radius: 6px;
  background: rgba(183, 36, 36, 0.05);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.transcript-body .rectified-token {
  padding: 0.05em 0.2em;
  border: 1.5px solid rgba(47, 143, 77, 0.48);
  border-radius: 6px;
  background: rgba(47, 143, 77, 0.07);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.transcript-body .equation.is-diff {
  padding-bottom: 2px;
  box-shadow: none;
}

.transcript-body .line-rectified {
  padding: 4px 0;
  border-left: 3px solid rgba(47, 143, 77, 0.4);
}

.loading-copy,
.empty-copy {
  color: var(--muted);
}

.footer {
  margin-top: 36px;
  padding: 22px 0 0;
  border-top: 1px solid rgba(30, 35, 40, 0.12);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .hero,
  .intro-grid,
  .viewer-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    gap: 32px;
  }

  .hero-carousel-frame {
    min-height: 520px;
  }

  .hero-brand {
    white-space: normal;
  }

  .hero-metrics,
  .detail-list,
  .insight-band,
  .example-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .example-meta p {
    padding-right: 0;
    border-right: none;
  }

  .explorer-intro {
    flex-direction: column;
    align-items: start;
  }

  .transcript-body {
    max-height: none;
  }

  .transcript-panel-heading {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 820px) {
  [id] {
    scroll-margin-top: 136px;
  }

  .nav-inner {
    width: min(calc(100% - 20px), var(--max-width));
    min-height: auto;
    padding: 12px 0;
    flex-direction: column;
    align-items: start;
  }

  .nav-links {
    gap: 4px;
  }

  .page-shell {
    width: min(calc(100% - 20px), var(--max-width));
    padding-top: 18px;
  }

  .hero-carousel-frame {
    min-height: 400px;
  }

  .hero {
    padding: 28px 0 20px;
  }

  .hero-brand {
    font-size: clamp(2.2rem, 12vw, 3.35rem);
  }

  .hero-title {
    font-size: 1.18rem;
  }

  .section {
    padding-top: 42px;
  }

  .section-heading h2,
  .explorer-section .section-heading h2 {
    max-width: 100%;
    font-size: clamp(1.72rem, 8vw, 2.45rem);
  }

  .hero-metrics,
  .detail-list,
  .insight-band,
  .example-meta {
    grid-template-columns: 1fr;
  }

  .control-cluster {
    width: 100%;
  }

  .example-meta p {
    border-right: none;
  }

  .homework-pills {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .image-frame,
  .transcript-body {
    border-radius: 22px;
  }

  .transcript-body {
    min-height: 360px;
  }

  .transcript-toggle {
    flex-wrap: wrap;
  }
}
