:root {
  --bg: #FBF8F1;
  --ink: #1a1a1a;
  --muted: #5b5b55;
  --accent: #5b7fd4;
  --accent-soft: #95BAFF;
  --rule: #e4ddc8;
  --code-bg: #f1ecdd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.65;
}

.banner {
  width: 100%;
  display: block;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

h1, h2, h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: normal;
  line-height: 1.25;
}

h1 {
  font-size: 2.6rem;
  margin: 2.5rem 0 0.5rem;
}

h1.page-title {
  font-size: 2.1rem;
  margin-top: 2.5rem;
}

.stage-kicker {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2.5rem;
  margin-bottom: 0.3rem;
}

.tagline {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 2.5rem;
}

.tagline a { color: var(--accent); }

h2 {
  font-size: 1.5rem;
  margin-top: 3.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent-soft);
}

h3 {
  font-size: 1.2rem;
  margin-top: 2.2rem;
  margin-bottom: 0.5rem;
}

h3 a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
}

h3 a:hover { border-bottom-color: var(--accent); }

p {
  margin: 0.9rem 0;
  color: #2b2b28;
}

code {
  background: var(--code-bg);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

a { color: var(--accent); }

footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}

footer a { color: var(--accent); }

.cta-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 1rem;
}

.cta-row a {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.95rem;
}

.cta-row a.primary {
  background: var(--ink);
  color: var(--bg);
}

.cta-row a.secondary {
  border: 1px solid var(--rule);
  color: var(--ink);
}

.intro-section {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1rem;
}

.replicate-steps {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin: 1.2rem 0;
}

.replicate-steps pre {
  margin: 0.6rem 0;
  overflow-x: auto;
  font-size: 0.85rem;
}

.replicate-steps pre code {
  background: none;
  padding: 0;
}

.mermaid {
  margin: 1.2rem 0;
  display: flex;
  justify-content: center;
}

/* Stage index list (on the home page) */
.stage-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.stage-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
}

.stage-list .n {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: 1.6rem;
  flex-shrink: 0;
}

.stage-list a {
  color: var(--ink);
  text-decoration: none;
  font-size: 1.02rem;
}

.stage-list a:hover { color: var(--accent); }

/* Prev/next nav on a stage page */
.stage-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}

.stage-nav a {
  text-decoration: none;
  color: var(--accent);
}

.stage-nav .spacer { flex: 1; }

/* Prev / all / next at the top of a stage page */
.stage-nav-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 1rem;
  margin: 1.5rem 0 0;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9rem;
}

.stage-nav-top a {
  color: var(--accent);
  text-decoration: none;
}

.stage-nav-top a:hover { text-decoration: underline; }

.stage-nav-top .all { color: var(--muted); }

.stage-nav-top > :last-child { text-align: right; }

.stage-nav-top .s { display: none; }

@media (max-width: 520px) {
  /* phones: "← Stage 6 · All stages · Stage 8 →" instead of full titles */
  .stage-nav-top .t { display: none; }
  .stage-nav-top .s { display: inline; }
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover { color: var(--accent); }

.code-link {
  display: inline-block;
  margin: 0.3rem 0 1.2rem;
  font-size: 0.85rem;
}

.task-list {
  margin: 0.8rem 0;
  padding-left: 1.3rem;
}

.task-list li {
  margin: 0.6rem 0;
}

.task-list code {
  font-size: 0.85em;
}

p.expect {
  background: var(--code-bg);
  border-left: 3px solid var(--accent-soft);
  padding: 0.7rem 1rem;
  border-radius: 0 6px 6px 0;
  margin: 1rem 0;
}

.refs-list {
  margin: 0.8rem 0;
  padding-left: 1.3rem;
}

.refs-list li {
  margin: 0.3rem 0;
}

/* The rabbit that walks the diagrams (rabbit.js) */
.diagram:has(svg .rabbit),
.mermaid:has(svg .rabbit) {
  cursor: pointer;
  padding-top: 28px; /* room for the rabbit's ears on the top row */
}

.lanes-note {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  margin-top: -0.4rem;
}

/* Landing: the recorded session */
.hero-stat {
  font-size: 1.15rem;
  margin: 1.6rem 0 0.8rem;
}

.hero-stat .loc { font-weight: 700; }

.terminal {
  background: #1f2126;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(31, 33, 38, 0.18);
  overflow: hidden;
}

.terminal .t-bar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: #2a2d33;
}

.terminal .t-bar span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4a4e57;
}

.terminal pre {
  margin: 0;
  padding: 14px 16px 16px;
  height: 22rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  color: #e9e6df;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal .t-first, .terminal .t-line { display: block; }
.terminal .t-line[hidden] { display: none; }
.terminal .t-prompt { color: #ffd23f; }
.terminal .t-log { color: #9aa3b2; }
.terminal .t-model { color: #ffd23f; }
.terminal .t-tool { color: #95BAFF; }
.terminal.typing .t-cmd::after {
  content: "▋";
  color: #ffd23f;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.t-caption {
  font-size: 0.88rem;
  color: var(--muted);
}

/* Stage pages: the diff */
.diff-intro .d-plus, .d-stat .d-plus { color: #2f7d3b; font-weight: 600; }
.diff-intro .d-minus, .d-stat .d-minus { color: #b4433b; font-weight: 600; }

details.diff {
  margin: 0.8rem 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fffdf7;
  overflow: hidden;
}

details.diff summary {
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  background: var(--code-bg);
  font-size: 0.9rem;
}

details.diff summary code { background: none; padding: 0; }

.diff-body {
  margin: 0;
  max-height: 30rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.5;
}

.diff-body span {
  display: block;
  padding: 0 0.8rem 0 1.6rem;
  white-space: pre;
  position: relative;
}

.diff-body .d-add { background: #e6f4e3; }
.diff-body .d-add::before { content: "+"; position: absolute; left: 0.6rem; color: #2f7d3b; }
.diff-body .d-del { background: #fbe7e4; }
.diff-body .d-del::before { content: "−"; position: absolute; left: 0.6rem; color: #b4433b; }
.diff-body .d-hunk { color: var(--muted); background: #f3eee1; font-style: italic; }

.map-intro { font-size: 0.92rem; color: var(--muted); }
.diagram.map svg a:hover rect { stroke: var(--accent); stroke-width: 2.4; }

/* Phones: keep diagrams legible; swipe sideways instead of shrinking the text */
.diagram { overflow-x: auto; }
@media (max-width: 600px) {
  .diagram svg { min-width: 560px; }
  .diagram.map svg { min-width: 640px; }
}

/* "Show the solution": the stage's diff stays folded until asked for */
details.solution > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  list-style: none;
  padding: 0.5rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fffdf7;
  font-size: 0.95rem;
}

details.solution > summary::-webkit-details-marker { display: none; }
details.solution > summary::before { content: "▸"; color: var(--accent); }
details.solution[open] > summary::before { content: "▾"; }
details.solution > summary .hide,
details.solution[open] > summary .show { display: none; }
details.solution[open] > summary .hide { display: inline; }
details.solution > summary:hover { border-color: var(--accent-soft); }
details.solution[open] > summary { margin-bottom: 0.4rem; }

/* Landing: top bar, compact banner, one headline */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
  padding: 0.7rem 24px;
  background: rgba(251, 248, 241, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
  font-size: 0.92rem;
}

.topbar a { color: var(--ink); text-decoration: none; }
.topbar a:hover { color: var(--accent); }
.topbar .brand { display: inline-flex; align-items: center; gap: 0.45rem; font-family: Georgia, serif; font-size: 1.05rem; }
.topbar-links { display: flex; gap: 1.2rem; }

main > .banner {
  width: 100%;
  max-width: 720px;
  margin: 1.2rem auto 0;
  border-radius: 10px;
}

h1.hero {
  font-size: 2.5rem;
  line-height: 1.15;
  margin: 1.6rem 0 0.8rem;
}

h1.hero .mark {
  background: linear-gradient(transparent 58%, #ffd23f 58%, #ffd23f 92%, transparent 92%);
  padding: 0 0.1em;
}

main > .hero-stat { font-size: 1.08rem; margin: 0 0 1.2rem; color: #2b2b28; }
main > .cta-row { margin: 0 0 2rem; }
.t-intro { color: var(--muted); font-size: 0.92rem; margin-bottom: 0.6rem; }

@media (max-width: 520px) {
  h1.hero { font-size: 1.9rem; }
  .topbar-links { gap: 0.9rem; }
}

h2[id] { scroll-margin-top: 4rem; } /* clear the sticky top bar when jumping to a section */

.topbar-links { align-items: center; }
.topbar .gh { display: inline-flex; }
.cta-row a.gh-btn { display: inline-flex; align-items: center; gap: 0.45rem; }

footer.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem 1.2rem;
}

.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.site-footer .footer-links { display: flex; gap: 1.2rem; align-items: center; }
.site-footer .gh { display: inline-flex; align-items: center; gap: 0.35rem; }
.site-footer .gh svg { display: block; margin-top: -2px; }

/* Landing: who it's for / what you'll learn */
.who {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
  margin: 1rem 0 1.6rem;
}

.who > div {
  background: #fffdf7;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.who strong { font-family: Georgia, serif; font-weight: normal; font-size: 1.05rem; }
.who p { margin: 0.4rem 0 0; font-size: 0.92rem; color: var(--muted); }
.learn-title { margin-top: 1.4rem; }
.learn { padding-left: 1.2rem; margin: 0.4rem 0; }
.learn li { margin: 0.35rem 0; }
.prereq { font-size: 0.92rem; color: var(--muted); }

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