:root {
  --bg: #0f0e16;
  --surface: #1a1822;
  --text: #f4f1f6;
  --muted: #bbb7c4;
  --line: rgba(244, 241, 246, 0.12);
  --accent: #ed1e40;
  --accent-soft: rgba(237, 30, 64, 0.12);
}

[data-theme="light"] {
  --bg: #f5f2f4;
  --surface: #ebe6ea;
  --text: #19161f;
  --muted: #5f5968;
  --accent: #d9193b;
  --line: rgba(25, 22, 31, 0.14);
}

[data-theme="raf"] {
  --bg: #141311;
  --surface: #1b1a17;
  --text: #e8e2d4;
  --muted: #8e867a;
  --accent: #d78e7e;
  --accent-soft: rgba(215, 142, 126, 0.12);
}

[data-theme="kyle"] {
  --bg: #f5f0e8;
  --surface: #e5ddd2;
  --text: #111111;
  --muted: #666666;
  --accent: #9b4729;
  --accent-soft: rgba(155, 71, 41, 0.1);
}

[data-theme="nomad"] {
  --bg: #0f172a;
  --surface: #111827;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.11);
}

[data-theme="lime"] {
  --bg: #10110f;
  --surface: #191b18;
  --text: #f1f0e9;
  --muted: #aaa99f;
  --accent: #d2ff49;
  --accent-soft: rgba(210, 255, 73, 0.1);
}

[data-theme="electric"] {
  --bg: #160b27;
  --surface: #211334;
  --text: #fbf4ff;
  --muted: #c8b5da;
  --accent: #d76bff;
  --accent-soft: rgba(215, 107, 255, 0.14);
  --line: rgba(215, 107, 255, 0.24);
}

[data-theme="ember"] {
  --bg: #19130f;
  --surface: #251c16;
  --text: #f4ede4;
  --muted: #baaa99;
  --accent: #ff7139;
  --accent-soft: rgba(255, 113, 57, 0.11);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image: linear-gradient(color-mix(in srgb, var(--bg) 91%, transparent), color-mix(in srgb, var(--bg) 91%, transparent)), url("background-pattern.jpg");
  background-size: auto, 760px;
  font-family: var(--sans);
  line-height: 1.55;
  transition: color 220ms ease, background-color 220ms ease;
}

a { color: inherit; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 1rem;
  left: 1rem;
  padding: 0.7rem 1rem;
  color: var(--bg);
  background: var(--accent);
  font-weight: 750;
  transform: translateY(-180%);
}
.skip-link:focus { transform: none; }

.guide-hero, .guide-shell { width: min(1120px, 92vw); margin-inline: auto; }
.guide-hero { padding: clamp(5rem, 10vw, 9rem) 0 clamp(4rem, 7vw, 6.5rem); border-bottom: 1px solid var(--line); }

.kicker, .section-number, .meta-label {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.guide-hero h1 {
  max-width: 950px;
  margin: 1.25rem 0 1.4rem;
  font-family: var(--serif);
  font-size: clamp(3.6rem, 9.3vw, 8.6rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.86;
}
.guide-hero h1 em { color: var(--accent); font-weight: 400; }

.hero-lede { max-width: 760px; margin: 0; color: var(--muted); font-size: clamp(1.15rem, 2.25vw, 1.65rem); line-height: 1.45; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 2.25rem; }
.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.9rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 160ms ease;
}
.button-link:first-child { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.button-link:hover { transform: translateY(-2px); }

.guide-shell {
  display: grid;
  grid-template-columns: minmax(190px, 0.72fr) minmax(0, 2.3fr);
  gap: clamp(3rem, 8vw, 8rem);
  padding: clamp(4.5rem, 8vw, 8rem) 0;
}
.guide-index { align-self: start; position: sticky; top: 2rem; }
.guide-index ol { margin: 1.2rem 0 0; padding: 0; list-style: none; }
.guide-index li { border-top: 1px solid var(--line); }
.guide-index li:last-child { border-bottom: 1px solid var(--line); }
.guide-index a { display: flex; gap: 0.7rem; padding: 0.85rem 0; color: var(--muted); font-size: 0.82rem; text-decoration: none; }
.guide-index a span { color: var(--accent); font-variant-numeric: tabular-nums; }
.guide-index a:hover { color: var(--text); }

.guide-section { padding: 0 0 clamp(4.5rem, 9vw, 8rem); scroll-margin-top: 2rem; }
.guide-section + .guide-section { padding-top: clamp(4rem, 8vw, 7rem); border-top: 1px solid var(--line); }
.guide-section h2 {
  max-width: 770px;
  margin: 0.9rem 0 1.5rem;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 5vw, 4.6rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.98;
}
.guide-section > p, .guide-section li, .guide-section dd { color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.15rem); }

.canonical-summary {
  margin: 2.25rem 0 0;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.75vw, 2.25rem);
  line-height: 1.35;
}

.fact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 2.5rem 0 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.fact-grid > div { min-height: 8.5rem; padding: 1.25rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fact-grid dt { color: var(--accent); font-size: 0.7rem; font-weight: 780; letter-spacing: 0.14em; text-transform: uppercase; }
.fact-grid dd { margin: 1rem 0 0; color: var(--text); font-family: var(--serif); font-size: 1.35rem; line-height: 1.15; }

.rule-list, .capability-list, .work-list, .link-list { margin: 2rem 0 0; padding: 0; list-style: none; }
.rule-list li, .capability-list li, .work-list li, .link-list li { padding: 1.1rem 0; border-top: 1px solid var(--line); }
.rule-list li::before { content: "→"; margin-right: 0.85rem; color: var(--accent); }
.capability-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2.5rem; }
.capability-list strong, .work-list strong { display: block; color: var(--text); font-family: var(--serif); font-size: 1.3rem; font-weight: 500; }
.capability-list span, .work-list span { display: block; margin-top: 0.3rem; }

.work-list { counter-reset: work; }
.work-list li { display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: 1rem; counter-increment: work; }
.work-list li::before { content: counter(work, decimal-leading-zero); padding-top: 0.15rem; color: var(--accent); font-size: 0.72rem; font-weight: 760; letter-spacing: 0.1em; }

.link-list a { color: var(--text); text-decoration-color: var(--accent); text-underline-offset: 0.22em; }
.link-list small { display: block; margin-top: 0.25rem; color: var(--muted); }
.technical-note { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; }

@media (max-width: 760px) {
  .guide-shell { grid-template-columns: 1fr; }
  .guide-index { position: static; }
  .guide-index ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-index li:nth-child(even) { padding-left: 1rem; border-left: 1px solid var(--line); }
  .fact-grid, .capability-list { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .guide-hero, .guide-shell { width: min(90vw, 1120px); }
  .guide-hero h1 { font-size: clamp(3.35rem, 17vw, 5rem); }
  .site-nav { gap: 1rem; }
  .site-nav a { font-size: 0.66rem; }
  .guide-index ol { grid-template-columns: 1fr; }
  .guide-index li:nth-child(even) { padding-left: 0; border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
