:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-raised: #1e2430;
  --border: #30363d;
  --border-light: #21262d;
  --text: #c9d1d9;
  --text-bright: #f0f6fc;
  --text-muted: #8b949e;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.15);
  --link: #818cf8;
  --link-hover: #a5b4fc;
  --code-bg: #0d1117;
  --code-border: #30363d;
  --green: #3fb950;
  --orange: #e3b341;
  --red: #f85149;
  --cyan: #58d8f5;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Menlo', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  min-height: 100vh;
}

/* ── NAV ───────────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 52px;
  flex-wrap: wrap;
  overflow: hidden;
}
.nav-logo {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-light);
  text-decoration: none;
  white-space: nowrap;
  margin-right: 0.5rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-logo svg { flex-shrink: 0; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-wrap: wrap;
  list-style: none;
}
.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text-bright);
  background: var(--surface-raised);
}
.nav-links a.active { color: var(--accent-light); }

/* ── LAYOUT ────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ── HERO ──────────────────────────────────────────────────── */
.hero {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2rem;
}
.hero-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 0.5rem;
}
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
.hero-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 620px;
}
.hero-meta {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.hero-meta a {
  color: var(--link);
  text-decoration: none;
  font-family: var(--font-mono);
}
.hero-meta a:hover { color: var(--link-hover); text-decoration: underline; }

/* ── SECTIONS ──────────────────────────────────────────────── */
.section { margin-bottom: 1.5rem; }

details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}
details + details { margin-top: 1rem; }

summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-bright);
  list-style: none;
  transition: background 0.15s;
}
summary::-webkit-details-marker { display: none; }
summary:hover { background: var(--surface-raised); }

.summary-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s;
  margin-left: auto;
}
details[open] .summary-chevron { transform: rotate(180deg); }

.summary-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.section-body {
  padding: 1.1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border-light);
}

/* ── PROSE ─────────────────────────────────────────────────── */
h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-bright);
  margin: 1.2rem 0 0.5rem;
}
h3:first-child { margin-top: 0; }
p {
  margin-bottom: 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
}
p:last-child { margin-bottom: 0; }
ul, ol {
  padding-left: 1.3rem;
  margin-bottom: 0.75rem;
}
li {
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: var(--text);
}
strong { color: var(--text-bright); font-weight: 600; }
em { color: var(--accent-light); font-style: normal; }

/* ── CODE REFS ─────────────────────────────────────────────── */
.code-ref {
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem 0;
  background: var(--code-bg);
}
.code-ref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
  flex-wrap: wrap;
}
.code-ref-path {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.code-ref-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent-light);
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(167,139,250,0.3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.code-ref-link:hover {
  background: rgba(167,139,250,0.1);
  border-color: rgba(167,139,250,0.6);
}
.code-ref pre {
  overflow-x: auto;
  padding: 1rem 1.1rem;
}
.code-ref pre code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--text);
  white-space: pre;
  display: block;
}
/* Inline code */
code:not(.code-ref pre code) {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: rgba(48,54,61,0.6);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--cyan);
}

/* ── PIPELINE DIAGRAM ──────────────────────────────────────── */
.pipeline {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.pipeline pre {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre;
  padding: 1.25rem;
  background: var(--code-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-width: 560px;
}

/* ── CARDS GRID ────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.card {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.card:hover {
  border-color: var(--accent);
  background: var(--surface-raised);
  transform: translateY(-1px);
}
.card-icon {
  font-size: 1.3rem;
  margin-bottom: 0.4rem;
  display: block;
}
.card-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-bright);
  margin-bottom: 0.2rem;
}
.card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── STEP LIST ─────────────────────────────────────────────── */
.steps {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  counter-reset: step;
}
.steps > li {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0;
  counter-increment: step;
  position: relative;
}
.steps > li::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 50%;
  margin-top: 0.2rem;
}
.steps > li + li {
  border-top: 1px solid var(--border-light);
}

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.badge-purple { background: rgba(124,58,237,0.2); color: var(--accent-light); }
.badge-green  { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-orange { background: rgba(227,179,65,0.15); color: var(--orange); }

/* ── TABLE ─────────────────────────────────────────────────── */
.ref-table-wrap { overflow-x: auto; }
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.ref-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: var(--surface-raised);
  color: var(--text-bright);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ref-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
.ref-table tr:last-child td { border-bottom: none; }
.ref-table td code { font-size: 0.78em; }
.ref-table a { color: var(--link); text-decoration: none; font-size: 0.78em; }
.ref-table a:hover { text-decoration: underline; }

/* ── DIVIDER ───────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.5rem 0;
}

/* ── CALLOUT ───────────────────────────────────────────────── */
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-glow);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  margin: 0.75rem 0;
}
.callout p { margin-bottom: 0; }
.callout.green { border-color: var(--green); background: rgba(63,185,80,0.08); }
.callout.orange { border-color: var(--orange); background: rgba(227,179,65,0.08); }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-wrap { padding: 1.25rem 0.9rem 3rem; }
  .hero { padding: 1.5rem 0 1.25rem; }
  .cards { grid-template-columns: 1fr 1fr; }
  .nav-inner { height: auto; padding: 0.5rem 0; }
  .section-body { padding: 0.9rem 1rem 1rem; }
  .code-ref-path { max-width: 180px; }
}
@media (max-width: 400px) {
  .cards { grid-template-columns: 1fr; }
}
