:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f7fafc;
  --bg-tertiary: #edf2f7;
  --bg-code: #1e293b;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --accent: #b7791f;
  --accent-light: #d69e2e;
  --accent-glow: rgba(214, 158, 46, 0.08);
  --navy: #1a365d;
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --content-width: 760px;
  --code-width: 900px;
  --sidebar-width: 260px;
}

/* ─── 1. Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 2rem; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

/* ─── 2. Scroll Progress Bar ────────────────────────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 1000;
  transition: width 50ms linear;
}

/* ─── 3. Layout Grid ─────────────────────────────────────────────────────────  */
.page-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
}
.sidebar-brand { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.25rem; }
.sidebar-sub { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2rem; }
.sidebar-nav { list-style: none; }
.sidebar-nav li { margin-bottom: 0.25rem; }
.sidebar-nav a {
  display: block;
  padding: 0.4rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}
.sidebar-nav a:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.sidebar-nav a.active {
  color: var(--accent-light);
  border-left-color: var(--accent);
  background: var(--accent-glow);
  font-weight: 500;
}
.sidebar-progress {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.main-content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}
.mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1001;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.25rem;
}
@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -100%;
    width: 280px;
    z-index: 1000;
    transition: left 0.25s ease;
  }
  .sidebar.open { left: 0; }
  .mobile-toggle { display: block; }
  .main-content { padding: 4rem 1.25rem 4rem; }
}

/* ─── 4. Typography ──────────────────────────────────────────────────────────  */
h1 { font-size: 2.75rem; font-weight: 800; line-height: 1.15; margin-bottom: 1rem; letter-spacing: -0.02em; }
h1 .accent { color: var(--accent-light); }
h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
h3 { font-size: 1.2rem; font-weight: 600; margin-top: 2.5rem; margin-bottom: 0.75rem; color: var(--text-primary); }
p { margin-bottom: 1rem; color: var(--text-secondary); }
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { color: var(--text-primary); font-weight: 600; }
ul, ol { margin-bottom: 1rem; padding-left: 1.5rem; color: var(--text-secondary); }
li { margin-bottom: 0.4rem; }

/* ─── 5. Code Blocks ─────────────────────────────────────────────────────────  */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: #f1f5f9;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: #b45309;
}
pre {
  position: relative;
  background: var(--bg-code);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem -70px 1.25rem -70px;
  max-width: var(--code-width);
  overflow-x: auto;
  line-height: 1.5;
}
pre code {
  background: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.85rem;
}
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.5rem;
  margin: 1.25rem -70px 0 -70px;
  max-width: var(--code-width);
  background: #0f172a;
  border: 1px solid #334155;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
}
.code-header + pre {
  margin-top: 0;
  border-radius: 0 0 8px 8px;
}
.copy-btn {
  background: none;
  border: 1px solid #475569;
  color: #94a3b8;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.copy-btn:hover { color: #e2e8f0; border-color: #94a3b8; }
.copy-btn.copied { color: var(--accent-light); border-color: var(--accent); }
@media (max-width: 900px) {
  pre, .code-header { margin-left: -1.25rem; margin-right: -1.25rem; border-radius: 0; }
  .code-header + pre { border-radius: 0; }
}

/* ─── 6. Callouts ────────────────────────────────────────────────────────────  */
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-glow);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
}
.callout.tip { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.08); }
.callout.warning { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.08); }
.callout.failure { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.callout.adapter { border-left-color: #8b5cf6; background: rgba(139, 92, 246, 0.08); }
.callout.adapter strong { color: #7c3aed; }
.callout p { margin-bottom: 0; color: var(--text-secondary); }
.callout strong { display: block; margin-bottom: 0.25rem; color: var(--text-primary); }

/* ─── 7. File Trees ──────────────────────────────────────────────────────────  */
.file-tree {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  line-height: 1.6;
  color: var(--text-secondary);
}
.file-tree summary { cursor: pointer; color: var(--text-primary); font-weight: 500; }
.file-tree summary:hover { color: var(--accent-light); }
.file-tree details { padding-left: 1.25rem; }
.file-tree .highlight { color: var(--accent-light); }
.file-tree .comment { color: var(--text-muted); font-style: italic; }

/* ─── 8. Hero ────────────────────────────────────────────────────────────────  */
.hero {
  text-align: center;
  padding: 3rem 0 4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}
.hero-badge {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--accent-light);
  border: 1px solid rgba(214, 158, 46, 0.4);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ─── 9. Section Numbers ─────────────────────────────────────────────────────  */
.section-num {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  line-height: 2rem;
  text-align: center;
  background: var(--accent-glow);
  color: var(--accent-light);
  border: 1px solid rgba(214, 158, 46, 0.3);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-right: 0.75rem;
  vertical-align: middle;
}

/* ─── 10. Before/After Diffs ─────────────────────────────────────────────────  */
.diff-container { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.5rem 0; }
.diff-container pre { margin: 0; }
.diff-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.diff-before .diff-label { color: #f87171; }
.diff-after .diff-label { color: #4ade80; }
@media (max-width: 900px) { .diff-container { grid-template-columns: 1fr; } }

/* ─── 11. Sidebar Logo ───────────────────────────────────────────────────────  */
.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  display: block;
}

/* ─── 12. Footer ─────────────────────────────────────────────────────────────  */
.site-footer {
  text-align: center;
  padding: 3rem 0;
  margin-top: 4rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--text-secondary); }
.site-footer a:hover { color: var(--accent-light); }
