:root {
  --bg: #0d0d0f;
  --bg-2: #141417;
  --bg-3: #1c1c21;
  --bg-4: #242429;
  --border: #2e2e36;
  --border-light: #3a3a44;
  --text: #e8e8ee;
  --text-muted: #8888a0;
  --text-dim: #5a5a6e;
  --accent: #6c63ff;
  --accent-2: #4ecdc4;
  --accent-3: #ff6b9d;
  --accent-4: #ffa94d;
  --green: #51cf66;
  --yellow: #ffd43b;
  --red: #ff6b6b;
  --blue: #74c0fc;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  --radius: 8px;
  --radius-lg: 12px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.6; }

/* NAV */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,13,15,0.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; gap: 24px;
}
.nav-brand { font-weight: 700; font-size: 15px; color: var(--text); text-decoration: none; letter-spacing: -0.3px; }
.nav-brand span { color: var(--accent); }
.nav-links { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav-links a {
  color: var(--text-muted); text-decoration: none; font-size: 13px; padding: 6px 10px;
  border-radius: 6px; transition: all 0.15s;
}
.nav-links a:hover { background: var(--bg-3); color: var(--text); }
.nav-links a.active { color: var(--accent); background: rgba(108,99,255,0.1); }

/* LAYOUT */
.page-layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 52px); }
@media (max-width: 800px) { .page-layout { grid-template-columns: 1fr; } }

/* SIDEBAR */
.sidebar {
  border-right: 1px solid var(--border); padding: 24px 0;
  position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto;
}
.sidebar-title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); padding: 0 20px 10px; }
.sidebar a {
  display: block; padding: 7px 20px; font-size: 13px; color: var(--text-muted);
  text-decoration: none; transition: all 0.1s; border-left: 2px solid transparent;
}
.sidebar a:hover { color: var(--text); background: var(--bg-2); }
.sidebar a.active { color: var(--accent); border-left-color: var(--accent); background: rgba(108,99,255,0.08); }
.sidebar-section { margin-top: 16px; }

/* CONTENT */
.content { padding: 40px 48px; max-width: 880px; }
@media (max-width: 800px) { .content { padding: 24px 20px; } }

/* HEADINGS */
.page-header { margin-bottom: 40px; }
.page-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 12px; }
.page-title { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin-bottom: 12px; }
.page-subtitle { font-size: 16px; color: var(--text-muted); line-height: 1.6; }

h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; color: var(--text); margin: 40px 0 16px; }
h3 { font-size: 15px; font-weight: 600; color: var(--text); margin: 28px 0 10px; }
h4 { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 20px 0 8px; }

p { color: var(--text-muted); margin-bottom: 16px; font-size: 14px; line-height: 1.7; }
p strong { color: var(--text); }
ul, ol { color: var(--text-muted); font-size: 14px; line-height: 1.7; padding-left: 20px; margin-bottom: 16px; }
li { margin-bottom: 4px; }
li strong { color: var(--text); }
a { color: var(--accent); }
code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-3); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 4px; color: var(--accent-2);
}
pre {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; overflow-x: auto; margin-bottom: 20px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6; color: var(--text);
}
pre code { background: none; border: none; padding: 0; font-size: inherit; color: inherit; }
hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* TABLES */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 24px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg-3); padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim); border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }
tbody td { padding: 9px 14px; vertical-align: top; color: var(--text-muted); }
tbody td strong { color: var(--text); }
tbody td code { font-size: 11px; }

/* CALLOUT */
.callout {
  background: rgba(108,99,255,0.08); border: 1px solid rgba(108,99,255,0.25);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px;
}
.callout.warn { background: rgba(255,212,59,0.06); border-color: rgba(255,212,59,0.25); }
.callout.danger { background: rgba(255,107,107,0.06); border-color: rgba(255,107,107,0.25); }
.callout.success { background: rgba(81,207,102,0.06); border-color: rgba(81,207,102,0.25); }
.callout-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.callout.warn .callout-title { color: var(--yellow); }
.callout.danger .callout-title { color: var(--red); }
.callout.success .callout-title { color: var(--green); }
.callout p { margin-bottom: 0; font-size: 13px; }

/* TAGS */
.tag {
  display: inline-block; background: rgba(108,99,255,0.15); border: 1px solid rgba(108,99,255,0.2);
  color: var(--accent); font-size: 11px; padding: 2px 7px; border-radius: 4px; font-weight: 600;
}
.tag-green { background: rgba(81,207,102,0.1); border-color: rgba(81,207,102,0.2); color: var(--green); }
.tag-yellow { background: rgba(255,212,59,0.1); border-color: rgba(255,212,59,0.2); color: var(--yellow); }
.tag-blue { background: rgba(116,192,252,0.1); border-color: rgba(116,192,252,0.2); color: var(--blue); }
.tag-red { background: rgba(255,107,107,0.1); border-color: rgba(255,107,107,0.2); color: var(--red); }

/* DIAGRAM WRAPPER */
.diagram-wrap {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px; overflow-x: auto; margin-bottom: 24px;
}
.diagram-wrap svg { width: 100%; }

/* RESEARCH LINK */
.research-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim); text-decoration: none; font-size: 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 6px; margin-top: 24px;
}
.research-link:hover { color: var(--text-muted); border-color: var(--border-light); }

footer {
  border-top: 1px solid var(--border); padding: 24px; text-align: center;
  color: var(--text-dim); font-size: 12px;
}
footer a { color: var(--text-muted); text-decoration: none; }
