:root {
  color-scheme: light dark;
  --bg: #f5f1e9;
  --surface: #fffdf8;
  --surface-2: #f0ebe1;
  --text: #2e2924;
  --muted: #746b61;
  --line: #d8ccbd;
  --accent: #b46042;
  --accent-soft: #f0d9cf;
  --blue: #3b6f8f;
  --blue-soft: #dbeaf2;
  --green: #49795b;
  --green-soft: #dfece3;
  --purple: #725a8e;
  --purple-soft: #e8e0f0;
  --gold: #8a6a2d;
  --gold-soft: #f0e5c9;
  --shadow: 0 16px 45px rgba(72, 49, 32, .09);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513;
    --surface: #211e1b;
    --surface-2: #2b2723;
    --text: #f2ece4;
    --muted: #b9aea2;
    --line: #4b423a;
    --accent: #e39070;
    --accent-soft: #493027;
    --blue: #79b2d2;
    --blue-soft: #243d4a;
    --green: #87bd95;
    --green-soft: #293f30;
    --purple: #b49ace;
    --purple-soft: #3c3049;
    --gold: #d3ae61;
    --gold-soft: #493d25;
    --shadow: 0 16px 45px rgba(0, 0, 0, .28);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, color-mix(in srgb, var(--accent-soft) 78%, transparent), transparent 27rem),
    radial-gradient(circle at 92% 22%, color-mix(in srgb, var(--blue-soft) 65%, transparent), transparent 25rem),
    var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Text", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a { color: inherit; }
code, .mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .92em;
}

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  max-width: 1480px;
  min-height: 100vh;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 32px 22px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
}

.brand { margin-bottom: 26px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 750;
}
.brand strong { display: block; font-size: 1.05rem; }
.brand span { color: var(--muted); font-size: .8rem; }

.language {
  display: flex;
  gap: 7px;
  margin-bottom: 24px;
}
.language a {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .75rem;
  text-decoration: none;
}
.language a[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

nav { display: grid; gap: 7px; }
nav a {
  padding: 9px 11px;
  border-radius: 10px;
  color: var(--muted);
  font-size: .88rem;
  text-decoration: none;
}
nav a:hover, nav a:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.main { min-width: 0; padding: 58px clamp(24px, 5vw, 76px) 90px; }
.hero { max-width: 1020px; margin-bottom: 42px; }
.eyebrow {
  color: var(--accent);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 {
  max-width: 960px;
  margin: 14px 0 14px;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  letter-spacing: -.045em;
  line-height: 1.02;
}
.hero > p { max-width: 850px; color: var(--muted); font-size: 1.06rem; }
.tagline { margin-top: 18px; color: var(--muted); font-size: .84rem; }

section { margin-top: 66px; scroll-margin-top: 28px; }
.section-head { max-width: 900px; margin-bottom: 22px; }
h2 { margin: 0 0 8px; font-size: clamp(1.5rem, 2.8vw, 2.35rem); letter-spacing: -.025em; }
h3 { margin: 0; font-size: 1rem; }
.section-head p { margin: 0; color: var(--muted); }

.principles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}
.principle {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.principle strong { display: block; margin-bottom: 4px; font-size: 1.02rem; }
.principle span { color: var(--muted); font-size: .82rem; }

.diagram { overflow-x: auto; padding: 26px 4px 12px; }
.flow {
  display: grid;
  min-width: 860px;
  grid-template-columns: 1fr 52px 1.1fr 52px 1.08fr 52px 1fr;
  align-items: center;
}
.node {
  min-height: 158px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.node.source { border-top: 5px solid var(--gold); }
.node.index { border-top: 5px solid var(--green); }
.node.resolve { border-top: 5px solid var(--blue); }
.node.answer { border-top: 5px solid var(--accent); }
.node-title { margin-bottom: 9px; font-weight: 700; }
.node ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: .86rem; }
.arrow { color: var(--muted); font-size: 1.45rem; text-align: center; }
.arrow small { display: block; margin-top: 4px; font-size: .6rem; }

.cold-lane {
  margin-top: 22px;
  padding: 20px;
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--gold-soft) 42%, var(--surface));
}
.cold-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.cold-label strong { color: var(--gold); }
.cold-label span { color: var(--muted); font-size: .8rem; }
.cold-grid {
  display: grid;
  grid-template-columns: 1fr 44px 1fr 44px 1fr;
  align-items: center;
}
.cold-step {
  min-height: 108px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.cold-step strong { display: block; margin-bottom: 5px; font-size: .9rem; }
.cold-step span { color: var(--muted); font-size: .8rem; }
.cold-arrow { color: var(--gold); font-size: 1.25rem; text-align: center; }

.layer-grid, .revival-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.layer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  padding: 23px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 8px; font-size: 1.06rem; }
.card p { margin: 0; color: var(--muted); font-size: .88rem; }
.card .tag {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.revival-card .number {
  display: grid;
  width: 31px;
  height: 31px;
  margin-bottom: 14px;
  place-items: center;
  border-radius: 10px;
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 750;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
td { font-size: .89rem; }
td:first-child { color: var(--accent); font-family: "SFMono-Regular", Consolas, monospace; }

.tree-wrap {
  padding: 10px 22px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
details { border-top: 1px solid var(--line); }
details:first-child { border-top: 0; }
summary { padding: 14px 2px; cursor: pointer; font-weight: 700; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { display: inline-block; width: 20px; color: var(--accent); content: "▸"; }
details[open] > summary::before { content: "▾"; }
.tree {
  margin: 0 0 18px 10px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .84rem;
  line-height: 1.82;
}
.tree b { color: var(--text); }
.tree em { color: var(--accent); font-style: normal; }

.ladder {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.rung {
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
}
.rung strong { display: block; font-size: .82rem; }
.rung span { color: var(--muted); font-size: .72rem; }

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  margin-top: 26px;
  padding: 18px 20px;
  border-left: 4px solid var(--accent);
  border-radius: 0 14px 14px 0;
  background: var(--accent-soft);
}
.callout p { margin: 0; }
.footer {
  margin-top: 80px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
}

.landing {
  display: grid;
  min-height: 100vh;
  padding: 48px 24px;
  place-items: center;
}
.landing-inner { width: min(920px, 100%); }
.landing h1 { max-width: 820px; }
.landing-inner > p { max-width: 760px; color: var(--muted); font-size: 1.04rem; }
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 30px;
}
.choices.single { grid-template-columns: minmax(0, 1fr); margin-top: 16px; }
.choice {
  display: block;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.choice:hover, .choice:focus-visible { border-color: var(--accent); outline: none; }
.choice strong { display: block; margin-bottom: 5px; font-size: 1.12rem; }
.choice span { color: var(--muted); }
.resources { margin-top: 30px; color: var(--muted); font-size: .9rem; }
.resources a { color: var(--accent); }

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 18px 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
  .brand-mark { width: 36px; height: 36px; margin: 0; }
  .language { margin-bottom: 0; }
  nav { display: none; }
  .main { padding-top: 38px; }
  .principles { grid-template-columns: repeat(2, 1fr); }
  .layer-grid, .revival-grid { grid-template-columns: 1fr; }
  .ladder { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .main { padding-inline: 18px; }
  .principles, .choices { grid-template-columns: 1fr; }
  .cold-label { display: block; }
  .cold-grid { grid-template-columns: 1fr; gap: 8px; }
  .cold-arrow { transform: rotate(90deg); }
  .tree-wrap { padding-inline: 14px; }
}
