:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --accent: #0284c7;
  --accent-soft: #e0f2fe;
  --caution-bg: #fff7ed;
  --caution-line: #f59e0b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background: #fff;
  padding: 0.5rem;
  border: 1px solid var(--line);
}

.site-header, .site-footer {
  padding: 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.site-footer {
  border-top: 1px solid var(--line);
  border-bottom: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.container { width: min(100%, 46rem); margin: 0 auto; padding: 1rem; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}
.chapter-body {
  width: min(100%, 39rem);
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}
.chapter-body > * { margin: 0; }
.chapter-body h2 { margin-top: 0.2rem; }
.chapter-paragraph { line-height: 1.8; }
.chapter-paragraph + .chapter-paragraph { margin-top: 0.8rem; }
.refs {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}
.refs h2 { font-size: 1.05rem; }
.refs ol {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
}
.refs li {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.cite {
  color: #0c4a6e;
  text-decoration: none;
  font-size: 0.88em;
  white-space: nowrap;
}

h1 { margin: 0.2rem 0 0.6rem; font-size: 1.55rem; line-height: 1.3; }
h2, h3 { line-height: 1.35; margin-top: 0; }
.eyebrow { color: var(--muted); margin: 0; font-size: 0.85rem; }
.lede, .note { color: var(--muted); }
a { color: #0369a1; }

.thesis-block {
  border-left: 4px solid var(--accent);
  padding: 0.65rem 0.8rem;
  background: var(--accent-soft);
  border-radius: 0.3rem;
  margin-bottom: 1rem;
}
.figure-label {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.caution-box {
  border-left: 4px solid var(--caution-line);
  background: var(--caution-bg);
  padding: 0.7rem 0.85rem;
  border-radius: 0.35rem;
}
.meaning-box {
  border-left: 4px solid #14b8a6;
  background: #f0fdfa;
  padding: 0.7rem 0.85rem;
  border-radius: 0.35rem;
}

.technical-note {
  border: 1px solid #bfd9ee;
  border-radius: 0.6rem;
  background: #f8fbff;
  font-size: 0.94rem;
}
.technical-note > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.65rem 0.8rem;
  font-weight: 600;
  color: #0c4a6e;
}
.technical-note > summary::-webkit-details-marker { display: none; }
.technical-note > summary::before {
  content: '▸';
  margin-right: 0.45rem;
}
.technical-note[open] > summary::before { content: '▾'; }
.technical-note .note-body {
  border-top: 1px solid #d7e5f2;
  padding: 0.7rem 0.8rem 0.8rem;
}
.eq-block {
  margin: 0.55rem 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: #fff;
  overflow-x: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
}
.term-list {
  margin: 0.4rem 0 0;
  padding-left: 1rem;
}
.term-list li { margin-bottom: 0.3rem; }

.viz-frame { margin: 0; }
#overview-viz, .mini-viz svg {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #f8fbff;
}
figcaption { margin-top: 0.5rem; font-size: 0.88rem; color: var(--muted); }

.chapter-grid {
  display: grid;
  gap: 0.75rem;
}
.chapter-card {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.75rem;
  background: #fff;
}
.chapter-card h3 { margin-bottom: 0.3rem; font-size: 1rem; }
.chapter-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.compare-table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.compare-table th, .compare-table td {
  border: 1px solid var(--line);
  padding: 0.55rem;
  text-align: left;
  vertical-align: top;
}

.metric-grid, .scope-grid, .imp-grid {
  display: grid;
  gap: 0.7rem;
}
.metric-card, .scope-item {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.7rem;
  background: #fff;
}
.metric-card strong { font-size: 1.25rem; display: block; }

.pipeline-step {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.75rem;
  margin-bottom: 0.6rem;
  opacity: 0;
  transform: translateY(8px);
  animation: step-in 320ms ease forwards;
}

.prev-next { display: flex; justify-content: space-between; gap: 0.7rem; }
.prev-next a { flex: 1; border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.55rem; text-decoration: none; }

@keyframes step-in { to { opacity: 1; transform: translateY(0);} }
@keyframes pulse-arrow { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }
.state-arrow { animation: pulse-arrow 1600ms ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@media (min-width: 48rem) {
  h1 { font-size: 1.95rem; }
  .container { padding: 1.4rem; }
  .chapter-body { gap: 1.1rem; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scope-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.correct { color: #16a34a; font-weight: 600; }
.incorrect { color: #dc2626; font-weight: 600; }

.equation {
  font-family: "Times New Roman", serif;
  font-size: 1.05rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.5rem 0.7rem;
}
.fig-box { fill: #f8fafc; stroke: #94a3b8; }
.fig-sub { font-size: 12px; fill: #475569; }
.fig-arrow { stroke: #0ea5e9; stroke-width: 2; fill: none; }
.bridge-edge { stroke: #dc2626; stroke-width: 3; fill: none; }
.viz-frame svg { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 0.5rem; background: #fff; }
