:root {
  --ink: #14222b;
  --ink-soft: #334651;
  --muted: #687883;
  --paper: #f4f1e9;
  --paper-deep: #ebe6da;
  --surface: #fffdf8;
  --surface-blue: #edf5f4;
  --navy: #0b2938;
  --navy-2: #12394a;
  --teal: #087d7d;
  --cyan: #68d7d0;
  --amber: #d99a3d;
  --line: #dce3e2;
  --line-strong: #bdcac9;
  --shadow: 0 18px 50px rgba(11, 41, 56, 0.09);
  --radius: 18px;
  --sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Georgia, serif;
}

* {
  box-sizing: border-box;
}

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

html.chapter-document {
  scroll-behavior: auto;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -5%, rgba(104, 215, 208, 0.2), transparent 28rem),
    radial-gradient(circle at 96% 8%, rgba(217, 154, 61, 0.14), transparent 23rem),
    var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(11, 41, 56, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 41, 56, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

a {
  color: var(--teal);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: #045d61;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(8, 125, 125, 0.35);
  outline-offset: 3px;
}

img {
  max-width: 100%;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  padding: 10px 14px;
  color: #fff;
  background: var(--navy);
  border-radius: 8px;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

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

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 120;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--cyan), var(--amber));
}

.reader-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(220, 227, 226, 0.82);
  background: rgba(244, 241, 233, 0.9);
  backdrop-filter: blur(16px);
}

.reader-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 70px;
  padding: 0 24px;
  gap: 20px;
}

.back-to-study {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 11px;
  gap: 8px;
  color: var(--ink-soft);
  font: 600 13px/1.2 var(--sans);
  text-decoration: none;
  border-radius: 8px;
}

.back-to-study:hover {
  color: var(--navy);
  background: rgba(11, 41, 56, 0.06);
}

.back-to-study svg {
  width: 16px;
  height: 16px;
}

.reader-language-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reader-language-control {
  display: flex;
  align-items: center;
  gap: 7px;
}

.reader-control-label {
  color: var(--muted);
  font: 700 11px/1 var(--sans);
  letter-spacing: 0.04em;
}

.body-language-control .reader-control-label {
  padding: 5px 7px;
  color: var(--navy);
  font-size: 12px;
  background: rgba(104, 215, 208, 0.17);
  border-radius: 6px;
}

.panel-language-control .reader-control-label {
  color: var(--muted);
}

.reader-language-toggle {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  min-width: 98px;
  height: 38px;
  padding: 4px;
  color: var(--ink);
  font: 700 12px/1 var(--sans);
  background: rgba(255, 253, 249, 0.96);
  border: 1.5px solid var(--navy);
  border-radius: 999px;
  box-shadow: 0 5px 14px rgba(11, 41, 56, 0.13);
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.body-language-toggle {
  border-width: 2px;
  border-color: var(--teal);
}

.panel-language-toggle {
  color: var(--muted);
  background: rgba(255, 252, 246, 0.58);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.language-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  border-radius: 999px;
  transition: color 160ms ease, background-color 160ms ease;
}

.language-choice.is-active {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 2px 7px rgba(8, 125, 125, 0.28);
}

.language-divider {
  width: 1px;
  height: 12px;
  background: var(--line-strong);
}

.reader-language-toggle:hover {
  color: var(--ink);
  background: rgba(255, 253, 249, 0.95);
  border-color: var(--line-strong);
}

.reader-language-toggle:focus-visible {
  outline: 3px solid rgba(8, 125, 125, 0.23);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(220, 227, 226, 0.82);
  background: rgba(244, 241, 233, 0.88);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1240px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--cyan);
  background: var(--navy);
  border-radius: 50%;
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

.brand-text small {
  display: block;
  margin-top: -2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav a,
.text-button {
  padding: 8px 12px;
  color: var(--ink-soft);
  font: 600 13px/1.2 var(--sans);
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.site-nav a:hover,
.text-button:hover {
  color: var(--navy);
  background: rgba(11, 41, 56, 0.06);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  gap: 8px;
  color: #fff;
  font: 700 14px/1.2 var(--sans);
  text-decoration: none;
  background: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 150ms ease, transform 150ms ease;
}

.button:hover {
  color: #fff;
  background: var(--navy-2);
  transform: translateY(-1px);
}

.button.secondary {
  color: var(--navy);
  background: transparent;
  border-color: var(--line-strong);
}

.button.secondary:hover {
  background: var(--surface);
}

.button.small {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 12px;
}

.button svg {
  width: 16px;
  height: 16px;
}

.page-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  align-items: center;
  min-height: 660px;
  padding: 78px 0 70px;
  gap: clamp(40px, 7vw, 90px);
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--teal);
  font: 750 12px/1.4 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-title {
  max-width: 760px;
  margin: 0;
  font: 600 clamp(42px, 6.5vw, 78px)/0.99 var(--serif);
  letter-spacing: -0.045em;
}

.hero-title .accent {
  color: var(--teal);
}

.hero-summary {
  max-width: 680px;
  margin: 28px 0 0;
  color: var(--ink-soft);
  font: 18px/1.72 var(--serif);
}

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

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  margin-top: 34px;
  gap: 10px 22px;
  color: var(--muted);
  font-size: 13px;
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.hero-meta span::before {
  width: 6px;
  height: 6px;
  content: "";
  background: var(--amber);
  border-radius: 50%;
}

.photon-panel {
  position: relative;
  min-height: 470px;
  overflow: hidden;
  color: #eefbfa;
  background:
    radial-gradient(circle at 50% 48%, rgba(104, 215, 208, 0.24), transparent 38%),
    linear-gradient(145deg, #0b2938 5%, #103e4b 58%, #092431);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.photon-panel::after {
  position: absolute;
  inset: 18px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 22px;
}

.panel-label {
  position: absolute;
  top: 34px;
  left: 38px;
  z-index: 2;
  color: rgba(255, 255, 255, 0.62);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.chapter-number {
  position: absolute;
  right: 34px;
  bottom: 20px;
  z-index: 1;
  color: rgba(255, 255, 255, 0.08);
  font: 600 170px/0.8 var(--serif);
  letter-spacing: -0.08em;
}

.circuit {
  position: absolute;
  inset: 72px 36px 76px;
  width: calc(100% - 72px);
  height: calc(100% - 148px);
}

.circuit .track {
  fill: none;
  stroke: rgba(104, 215, 208, 0.5);
  stroke-width: 1.4;
}

.circuit .track-spark {
  fill: none;
  stroke: #f0b45b;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 18 150;
  animation: travel 4.5s linear infinite;
}

.circuit .node {
  fill: #ddfbf7;
  stroke: #68d7d0;
  stroke-width: 1.5;
}

.circuit .node-core {
  fill: #f0b45b;
}

.circuit text {
  fill: rgba(255, 255, 255, 0.74);
  font: 600 10px var(--sans);
  letter-spacing: 0.06em;
}

.panel-caption {
  position: absolute;
  right: 38px;
  bottom: 32px;
  left: 38px;
  z-index: 2;
  color: rgba(255, 255, 255, 0.7);
  font: 12px/1.5 var(--sans);
}

@keyframes travel {
  from {
    stroke-dashoffset: 168;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.section {
  padding: 72px 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 30px;
  gap: 30px;
}

.section-heading h2 {
  max-width: 720px;
  margin: 0;
  font: 600 clamp(30px, 4vw, 48px)/1.08 var(--serif);
  letter-spacing: -0.035em;
}

.section-heading p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 28px;
  background: var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat {
  padding: 27px 28px;
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.stat:last-child {
  border-right: 0;
}

.stat strong {
  display: block;
  color: var(--cyan);
  font: 600 34px/1 var(--serif);
  letter-spacing: -0.04em;
}

.stat span {
  display: block;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.chapter-card {
  grid-column: span 4;
  display: flex;
  flex-direction: column;
  min-height: 238px;
  padding: 26px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 253, 248, 0.84);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.chapter-card:nth-child(1),
.chapter-card:nth-child(5) {
  grid-column: span 6;
}

.chapter-card:hover {
  color: var(--ink);
  border-color: var(--teal);
  box-shadow: 0 16px 34px rgba(11, 41, 56, 0.08);
  transform: translateY(-3px);
}

.card-index {
  color: var(--teal);
  font: 700 12px/1 var(--sans);
  letter-spacing: 0.08em;
}

.chapter-card h3 {
  margin: 28px 0 10px;
  font: 600 24px/1.16 var(--serif);
  letter-spacing: -0.025em;
}

.chapter-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.chapter-card .card-arrow {
  margin-top: auto;
  padding-top: 25px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

.abstract-band {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  padding: clamp(30px, 5vw, 58px);
  gap: 36px;
  background: var(--surface-blue);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.abstract-band h2 {
  margin: 0;
  font: 600 28px/1.1 var(--serif);
}

.abstract-band blockquote {
  margin: 0;
  color: var(--ink-soft);
  font: clamp(19px, 2.3vw, 25px)/1.55 var(--serif);
}

.source-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 28px 30px;
  gap: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.source-panel strong {
  display: block;
  margin-bottom: 4px;
}

.source-panel p {
  max-width: 840px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.site-footer {
  padding: 42px 0 54px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
}

.footer-inner p {
  max-width: 720px;
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
}

/* Chapter reader */

.chapter-layout {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  justify-content: stretch;
  align-items: start;
  width: 100%;
  margin: 0;
  padding: 34px clamp(24px, 4vw, 64px) 90px clamp(16px, 2vw, 32px);
  gap: clamp(34px, 5vw, 72px);
}

.chapter-sidebar {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.book-tree {
  padding-top: 4px;
}

.book-tree-title {
  margin: 0;
  padding: 0 10px 16px;
  color: var(--ink);
  font: 600 clamp(20px, 1.6vw, 23px)/1.35 var(--serif);
  letter-spacing: -0.015em;
  border-bottom: 1px solid var(--line-strong);
}

.book-chapters {
  display: grid;
  padding: 11px 10px 13px;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}

.book-chapter-link {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr);
  padding: 6px 8px;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-decoration: none;
  border-radius: 7px;
}

.book-chapter-link:hover {
  color: var(--navy);
  background: rgba(255, 253, 248, 0.8);
}

.book-chapter-link.is-current {
  color: var(--ink);
  font-weight: 650;
  background: rgba(104, 215, 208, 0.13);
}

.book-chapter-index {
  color: var(--teal);
  font-weight: 750;
}

.chapter-tree {
  position: relative;
  margin-top: 12px;
  padding-left: 12px;
}

.chapter-tree::before {
  position: absolute;
  top: 17px;
  bottom: 10px;
  left: 0;
  width: 1px;
  content: "";
  background: var(--line);
}

.chapter-tree-title {
  margin: 0;
  padding: 0;
  color: var(--teal);
  font: 700 14px/1.3 var(--sans);
  letter-spacing: 0.03em;
}

.chapter-tree-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 5px 10px 12px;
  color: inherit;
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.chapter-tree-toggle:hover {
  color: var(--navy);
}

.chapter-tree-toggle:focus-visible {
  outline: 3px solid rgba(8, 125, 125, 0.2);
  outline-offset: 2px;
  border-radius: 5px;
}

.chapter-tree-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 160ms ease;
}

.chapter-tree-toggle[aria-expanded="false"] svg {
  transform: rotate(-90deg);
}

.sidebar-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-list[hidden] {
  display: none;
}

.toc-link {
  display: block;
  padding: 7px 10px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 7px 7px 0;
}

.toc-link:hover {
  color: var(--navy);
  background: rgba(255, 253, 248, 0.8);
}

.toc-link.level-3 {
  padding-left: 22px;
  color: var(--muted);
}

.toc-link.level-4 {
  padding-left: 34px;
  color: var(--muted);
  font-size: 11.5px;
}

.toc-link.is-active {
  color: var(--teal);
  font-weight: 700;
  background: rgba(255, 253, 248, 0.85);
  border-left-color: var(--teal);
}

.toc-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-meta {
  margin-top: 24px;
  padding: 16px;
  background: rgba(255, 253, 248, 0.64);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.sidebar-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.sidebar-meta strong {
  color: var(--ink);
}

.chapter-content {
  min-width: 0;
}

.chapter-content {
  width: 100%;
  max-width: 920px;
  justify-self: center;
}

.chapter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  gap: 18px;
  border-bottom: 1px solid var(--line-strong);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--teal);
}

.chapter-body {
  padding-top: 4px;
}

.chapter-language-version[hidden] {
  display: none !important;
}

.chapter-language-version {
  font: 18px/1.72 var(--serif);
}

.inline-math {
  font-family: "Cambria Math", Cambria, serif;
  font-style: italic;
  white-space: nowrap;
}

.chapter-body math {
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", serif;
  font-size: 1.08em;
}

.math-inline {
  display: inline;
}

.math-display {
  display: block;
  margin: 1.15em 0;
  padding: 12px 16px;
  overflow-x: auto;
  text-align: center;
  background: rgba(255, 253, 248, 0.68);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.math-display math {
  min-width: max-content;
}

.md-numbered {
  padding-left: 1.1em;
  text-indent: -1.1em;
}

.md-number {
  color: var(--teal);
}

.reference-note {
  margin: 0 0 1em;
  color: var(--muted);
  font: 12px/1.6 var(--sans);
}

.chapter-head {
  padding: 6px 0 36px;
  border-bottom: 2px solid var(--ink);
}

.chapter-head .eyebrow {
  margin-bottom: 14px;
  font-size: clamp(15px, 1.45vw, 18px);
  line-height: 1.4;
  letter-spacing: 0.025em;
  text-transform: none;
}

.chapter-head h1 {
  max-width: 800px;
  margin: 0.22em 0 0.38em;
  font: 600 clamp(32px, 4.5vw, 50px)/1.04 var(--serif);
  letter-spacing: -0.04em;
}

.chapter-head .meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.chapter-body .body {
  color: var(--ink);
  font: 18px/1.72 var(--serif);
}

.chapter-body h2,
.chapter-body h3,
.chapter-body h4 {
  color: var(--ink);
  scroll-margin-top: 96px;
}

.chapter-body h2 {
  margin: 2.2em 0 0.7em;
  padding-top: 0.55em;
  font: 600 clamp(25px, 3vw, 34px)/1.18 var(--serif);
  letter-spacing: -0.025em;
  border-top: 1px solid var(--line);
}

.chapter-body h3 {
  margin: 1.75em 0 0.55em;
  font: 650 clamp(19px, 2.4vw, 24px)/1.28 var(--sans);
  letter-spacing: -0.015em;
}

.chapter-body h4 {
  margin: 1.5em 0 0.4em;
  font: 700 18px/1.35 var(--sans);
}

.chapter-body p,
.chapter-body .u-margin-s-bottom {
  margin: 0.9em 0;
}

.chapter-body pre {
  margin: 1.2em 0;
  padding: 14px 16px;
  overflow-x: auto;
  color: #263d46;
  font: 12px/1.6 "Cascadia Code", "Consolas", monospace;
  background: #f5efe3;
  border: 1px solid #d9d0bf;
  border-radius: 10px;
  box-shadow: inset 4px 0 0 rgba(16, 105, 112, 0.28);
}

.chapter-body pre code {
  color: inherit;
  font: inherit;
  text-shadow: none;
}

.chapter-body pre .token.comment {
  color: #728077;
  font-style: italic;
}

.chapter-body pre .token.string {
  color: #9a5a28;
}

.chapter-body pre .token.number {
  color: #b34f3c;
}

.chapter-body pre .token.keyword {
  color: #6a4c93;
  font-weight: 650;
}

.chapter-body pre .token.boolean {
  color: #b05b17;
  font-weight: 650;
}

.chapter-body pre .token.function {
  color: #0d6f77;
  font-weight: 650;
}

.chapter-body pre .token.variable {
  color: #205a75;
}

.chapter-body pre .token.operator {
  color: #75507b;
}

.chapter-body pre .token.punctuation {
  color: #6d685f;
}

.chapter-body :not(pre) > code {
  padding: 0.12em 0.35em;
  color: var(--navy);
  font: 0.9em/1.4 "Cascadia Code", "Consolas", monospace;
  background: rgba(11, 41, 56, 0.06);
  border-radius: 4px;
}

.chapter-body .chapter-code-listings {
  margin-top: 3.5em;
  padding-top: 1.4em;
  border-top: 2px solid var(--ink);
}

.chapter-body .chapter-code-listings h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.code-listings-intro {
  max-width: 760px;
  color: var(--ink-soft);
}

.code-listing-index {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 6px;
  margin: 1.2em 0 2em;
  padding: 14px;
  font-family: var(--sans);
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.code-listing-index a {
  display: block;
  padding: 7px 9px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
  text-decoration: none;
  border-radius: 6px;
}

.code-listing-index a:hover,
.code-listing-index a:focus-visible {
  color: var(--navy);
  background: rgba(16, 105, 112, 0.08);
}

.chapter-body .code-listing-card {
  margin: 1.6em 0 2.4em;
  padding: 16px;
  scroll-margin-top: 96px;
  background: rgba(255, 253, 248, 0.5);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.code-listing-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.chapter-body .code-listing-title {
  margin: 0;
  font: 700 17px/1.35 var(--sans);
  letter-spacing: -0.01em;
}

.code-listing-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px 12px;
  margin: 0;
  color: var(--muted);
  font: 11px/1.55 var(--sans);
  white-space: nowrap;
}

.code-listing-meta code {
  color: var(--navy);
}

.code-listing-meta a {
  color: var(--teal);
}

.chapter-body .code-listing-code {
  margin: 0;
  padding: 16px 18px;
  tab-size: 2;
}

.chapter-body .code-listing-code code {
  display: block;
  min-width: max-content;
  white-space: pre;
}

.chapter-body .listing-link {
  color: var(--teal);
  font-weight: 600;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

.chapter-body .listing-link:hover,
.chapter-body .listing-link:focus-visible {
  color: var(--navy);
}

.chapter-body ul,
.chapter-body ol {
  margin: 1em 0;
  padding-left: 1.65em;
}

.chapter-body li {
  margin: 0.45em 0;
}

.chapter-body .list {
  padding-left: 0;
  list-style: none;
}

.chapter-body .list > li {
  margin: 0.65em 0;
}

.chapter-body .figure {
  margin: 2.3em 0;
  padding: clamp(14px, 2.5vw, 24px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 25px rgba(11, 41, 56, 0.035);
}

.chapter-body .figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto 16px;
  cursor: zoom-in;
}

.chapter-body .figure img:focus-visible {
  outline: 3px solid rgba(8, 125, 125, 0.32);
  outline-offset: 5px;
  border-radius: 4px;
}

.has-figure-lightbox {
  overflow: hidden;
}

.figure-lightbox {
  width: min(1120px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.figure-lightbox::backdrop {
  background: rgba(11, 25, 31, 0.82);
  backdrop-filter: blur(4px);
}

.figure-lightbox-panel {
  position: relative;
  display: grid;
  justify-items: center;
  max-height: calc(100vh - 32px);
  padding: clamp(36px, 5vw, 52px) clamp(16px, 4vw, 40px) 20px;
  overflow: auto;
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.figure-lightbox-image {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
}

.figure-lightbox-caption {
  width: min(100%, 940px);
  margin: 18px auto 0;
  color: var(--muted);
  font: 13px/1.65 var(--sans);
  text-align: center;
}

.figure-lightbox-close {
  position: absolute;
  top: 10px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  color: var(--ink-soft);
  font: 400 25px/1 var(--sans);
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.figure-lightbox-close:hover {
  color: var(--navy);
  border-color: var(--line-strong);
}

.figure-lightbox-close:focus-visible {
  outline: 3px solid rgba(8, 125, 125, 0.3);
  outline-offset: 3px;
}

.chapter-body .captions,
.chapter-body .legend,
.ReferenceLinks {
  color: var(--muted);
  font: 12px/1.55 var(--sans);
}

.chapter-body .captions .label {
  color: var(--teal);
  font-weight: 750;
}

.chapter-body .tables,
.chapter-body .chapter-table-wrap {
  margin: 2.2em 0;
  padding: 18px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.chapter-body .tables .captions {
  margin-bottom: 14px;
  font-size: 13px;
}

.chapter-body table {
  width: 100%;
  border-collapse: collapse;
  font: 12px/1.5 var(--sans);
}

.chapter-body th,
.chapter-body td {
  padding: 8px 10px;
  vertical-align: top;
  border: 1px solid var(--line);
}

.chapter-body th {
  color: var(--ink);
  background: var(--surface-blue);
}

.chapter-body td {
  color: var(--ink-soft);
}

.chapter-body .screen-reader-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chapter-body .u-display-none {
  display: none !important;
}

.chapter-body button,
.chapter-body .download-link {
  display: none !important;
}

.chapter-body .bibliography {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 2px solid var(--ink);
}

.chapter-body .references {
  padding-left: 0;
  list-style: none;
}

.chapter-body .references > li {
  margin: 1.15em 0;
  padding-bottom: 1.15em;
  font-size: 13px;
  line-height: 1.55;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 92px;
}

.chapter-body .references > li.is-reference-target {
  background: #fff6d9;
  outline: 1px solid rgba(217, 154, 61, 0.35);
  outline-offset: 5px;
  border-radius: 5px;
}

.chapter-body .references > li:target {
  background: #fff6d9;
  outline: 1px solid rgba(217, 154, 61, 0.35);
  outline-offset: 5px;
  border-radius: 5px;
}

.chapter-body .references a:target {
  color: var(--navy);
  background: #fff0b8;
  border-radius: 3px;
}

.chapter-body .references .label {
  float: left;
  margin-right: 10px;
  color: var(--teal);
  font-weight: 700;
}

.chapter-body .ReferenceLinks {
  clear: both;
  padding-top: 7px;
}

.chapter-body .ReferenceLinks a {
  margin-right: 9px;
}

.chapter-body .footnotes {
  margin: 14px 0 0;
  padding-top: 10px;
  color: var(--muted);
  font: 11px/1.55 var(--sans);
  border-top: 1px solid var(--line);
}

.chapter-body .footnotes dt {
  float: left;
  margin-right: 7px;
  color: var(--teal);
  font-weight: 750;
}

.chapter-body .footnotes dd {
  margin-left: 18px;
}

.chapter-body .source-note {
  margin-top: 3.5em;
  padding-top: 18px;
  color: var(--muted);
  font: 12px/1.6 var(--sans);
  border-top: 1px solid var(--line);
}

.citation-link {
  color: var(--teal);
  white-space: nowrap;
}

.citation-link:hover {
  color: var(--navy);
  background: rgba(104, 215, 208, 0.15);
  border-radius: 3px;
}

.citation-tooltip {
  position: fixed;
  z-index: 300;
  display: none;
  max-height: min(180px, calc(100vh - 28px));
  padding: 11px 13px;
  overflow: auto;
  color: #111;
  font: 13px/1.55 var(--sans);
  background: #fff;
  border: 1px solid #b9bcc0;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(20, 34, 43, 0.18);
  pointer-events: none;
}

.citation-tooltip.is-visible {
  display: block;
}

.chapter-body .mtx-container {
  max-width: 100%;
  overflow-x: auto;
}

.mobile-toc-toggle {
  display: none;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(11, 41, 56, 0.22);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top svg {
  width: 18px;
  height: 18px;
}

.return-jump {
  position: fixed;
  top: 46%;
  right: clamp(18px, calc((100vw - 1480px) / 2 + 24px), 42px);
  z-index: 90;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  gap: 8px;
  color: var(--navy);
  font: 700 12px/1 var(--sans);
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid rgba(16, 105, 112, 0.28);
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(11, 41, 56, 0.18);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(10px, -50%);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.return-jump.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.return-jump:hover {
  color: var(--teal);
  background: #fffdf8;
}

.return-jump:focus-visible {
  outline: 3px solid rgba(8, 125, 125, 0.22);
  outline-offset: 3px;
}

.return-jump svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.return-jump-label {
  white-space: nowrap;
}

.return-jump::after {
  position: absolute;
  top: 50%;
  right: calc(100% + 10px);
  width: max-content;
  max-width: 210px;
  padding: 7px 10px;
  color: #fff;
  font: 600 11px/1.35 var(--sans);
  content: attr(data-tooltip);
  background: var(--navy);
  border-radius: 7px;
  display: none;
  opacity: 0;
  pointer-events: none;
  transform: translate(4px, -50%);
  transition: opacity 140ms ease, transform 140ms ease;
}

.return-jump:hover::after,
.return-jump:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.not-found {
  display: grid;
  min-height: calc(100vh - 144px);
  place-items: center;
  text-align: center;
}

.not-found .code {
  margin: 0;
  color: var(--teal);
  font: 600 clamp(90px, 18vw, 190px)/0.85 var(--serif);
  letter-spacing: -0.07em;
}

.not-found h1 {
  margin: 28px 0 12px;
  font: 600 clamp(30px, 5vw, 52px)/1.1 var(--serif);
}

.not-found p {
  max-width: 520px;
  margin: 0 auto 28px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .home-hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 62px 0;
  }

  .photon-panel {
    min-height: 400px;
  }

  .chapter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chapter-card,
  .chapter-card:nth-child(1),
  .chapter-card:nth-child(5) {
    grid-column: auto;
  }

  .chapter-layout {
    grid-template-columns: minmax(0, 920px);
    justify-content: center;
    padding: 24px 20px 70px;
  }

  .chapter-sidebar {
    position: static;
    display: block;
    max-height: 46vh;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
  }

  .book-tree-title {
    padding-right: 8px;
    padding-left: 8px;
  }
}

@media (max-width: 700px) {
  html {
    scroll-padding-top: 116px;
  }

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

  .reader-header-inner {
    min-height: 64px;
    flex-wrap: wrap;
    padding: 9px 16px;
    row-gap: 8px;
  }

  .reader-language-controls {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
  }

  .reader-language-control {
    gap: 4px;
  }

  .reader-control-label {
    font-size: 10px;
  }

  .body-language-control .reader-control-label {
    font-size: 11px;
  }

  .reader-language-toggle {
    min-width: 84px;
    height: 34px;
  }

  .back-to-study {
    padding-left: 7px;
  }

  .header-inner {
    min-height: 64px;
  }

  .brand-text {
    font-size: 14px;
  }

  .brand-text small,
  .site-nav .nav-secondary {
    display: none;
  }

  .site-nav a,
  .text-button {
    padding: 7px 9px;
    font-size: 12px;
  }

  .home-hero {
    padding: 46px 0 56px;
    gap: 38px;
  }

  .hero-title {
    font-size: clamp(40px, 13vw, 62px);
  }

  .hero-summary {
    font-size: 17px;
  }

  .photon-panel {
    min-height: 340px;
    border-radius: 22px;
  }

  .chapter-number {
    font-size: 120px;
  }

  .section {
    padding: 54px 0;
  }

  .section-heading {
    display: block;
  }

  .section-heading p {
    margin-top: 14px;
  }

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

  .stat:nth-child(2) {
    border-right: 0;
  }

  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .chapter-grid {
    grid-template-columns: 1fr;
  }

  .chapter-card {
    min-height: 200px;
  }

  .abstract-band,
  .source-panel,
  .footer-inner {
    grid-template-columns: 1fr;
  }

  .abstract-band {
    display: block;
  }

  .abstract-band blockquote {
    margin-top: 20px;
  }

  .source-panel {
    display: block;
  }

  .source-panel .button {
    margin-top: 18px;
  }

  .footer-inner {
    display: block;
  }

  .footer-links {
    margin-top: 18px;
  }

  .chapter-body .body {
    font-size: 17px;
    line-height: 1.68;
  }

  .chapter-head h1 {
    font-size: clamp(30px, 9.2vw, 42px);
  }

  .chapter-body .figure,
  .chapter-body .tables,
  .chapter-body .chapter-table-wrap {
    margin-right: -8px;
    margin-left: -8px;
    border-radius: 10px;
  }

  .chapter-body .figure {
    padding: 10px;
  }

  .chapter-body table {
    min-width: 590px;
  }

  .code-listing-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .code-listing-meta {
    justify-content: flex-start;
    white-space: normal;
  }

  .chapter-body .code-listing-card {
    padding: 12px;
  }

  .chapter-body .code-listing-code {
    padding: 14px;
  }

  .citation-tooltip {
    font-size: 12px;
  }
}

@media (max-width: 1500px) {
  .return-jump {
    top: auto;
    right: 22px;
    bottom: 78px;
    width: 46px;
    height: 46px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    transform: translateX(10px);
  }

  .return-jump.is-visible {
    transform: translateX(0);
  }

  .return-jump-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .return-jump::after {
    display: block;
  }
}

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

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

@media print {
  :root {
    --ink: #000;
    --muted: #333;
    --line: #bbb;
  }

  body {
    background: #fff;
    font-size: 10.5pt;
  }

  body::before,
  .reader-header,
  .site-header,
  .chapter-sidebar,
  .chapter-toolbar,
  .site-footer,
  .return-jump,
  .reading-progress,
  .back-to-top {
    display: none !important;
  }

  .chapter-layout {
    display: block;
    width: 100%;
    padding: 0;
  }

  .chapter-content,
  .chapter-body {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .chapter-body .figure,
  .chapter-body .tables,
  .chapter-body .chapter-table-wrap {
    break-inside: avoid;
    box-shadow: none;
  }

  .chapter-body a {
    color: inherit;
  }
}
