:root {
  --bg: #0a0e14;
  --surface: #12161e;
  --surface-raised: #181d27;
  --border: #252d3a;
  --border-accent: #2a4a7f;
  --text: #e6edf3;
  --text-secondary: #c5cdd8;
  --text-muted: #7d8a9a;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-dim: #1a3a5c;
  --code-bg: #0f1319;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.4);
}

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

html { scroll-behavior: smooth; }

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

/* ── Sidebar ── */
nav {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

nav .logo {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  display: block;
  margin-bottom: 0.15rem;
  letter-spacing: -0.02em;
}

nav .tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

nav .version {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  margin-bottom: 2rem;
}

nav .section-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1.25rem 0.75rem 0.4rem;
}

nav a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.88rem;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}

nav a:hover {
  color: var(--text);
  background: rgba(88,166,255,0.06);
}

nav a.active {
  color: var(--accent);
  background: rgba(88,166,255,0.08);
  border-left-color: var(--accent);
}

nav .spacer { flex: 1; }

nav .nav-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

nav .nav-footer a {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
}

/* ── Main Content ── */
main {
  flex: 1;
  max-width: 860px;
  padding: 3.5rem 4.5rem 6rem;
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
  color: var(--text);
}

.page-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 1rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  color: var(--text-secondary);
}

p { margin-bottom: 1rem; color: var(--text-secondary); }

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

strong { color: var(--text); font-weight: 600; }

/* ── Code ── */
code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--code-bg);
  padding: 0.2em 0.45em;
  border-radius: 4px;
  color: var(--green);
  border: 1px solid var(--border);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.6;
  border: none;
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

th, td {
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-raised);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td { color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }

/* ── Lists ── */
ul, ol { margin-bottom: 1rem; padding-left: 1.5rem; }
li { margin-bottom: 0.4rem; color: var(--text-secondary); }

/* ── Diagram Container ── */
.diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 1.5rem 0 2rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.diagram svg { max-width: 100%; height: auto; }

/* ── Cards ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow);
}

.card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.5;
}

.card .card-icon {
  font-size: 1.5rem;
  margin-bottom: 0.6rem;
  display: block;
}

/* ── Callouts ── */
.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.callout.warning { border-left-color: var(--orange); }
.callout.success { border-left-color: var(--green); }

.callout strong { display: block; margin-bottom: 0.3rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.callout.warning strong { color: var(--orange); }
.callout.success strong { color: var(--green); }
.callout strong { color: var(--accent); }

/* ── Badge ── */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: middle;
  margin-left: 0.4rem;
}

/* ── Hero Section ── */
.hero {
  text-align: center;
  padding: 1rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}

.hero .hero-sub {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

.hero .hero-badges {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero .hero-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.8rem;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Link Buttons ── */
.link-row {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.55rem 1.2rem;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #0a0e14;
}

.btn-primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: #0a0e14;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text);
  text-decoration: none;
}

/* ── Footer ── */
.page-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.page-footer a {
  color: var(--text-muted);
}

.page-footer a:hover { color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 900px) {
  body { flex-direction: column; }
  nav {
    width: 100%;
    min-width: unset;
    height: auto;
    position: relative;
    padding: 1rem 1.25rem;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.2rem;
    align-items: center;
  }
  nav .logo { margin-right: 1rem; margin-bottom: 0; }
  nav .tagline, nav .version, nav .section-label, nav .spacer, nav .nav-footer { display: none; }
  main { padding: 2rem 1.5rem 4rem; }
  .hero h1 { font-size: 2rem; }
  .card-grid { grid-template-columns: 1fr; }
}

/* ── Additions for generated documentation pages ── */

main { min-width: 0; overflow-wrap: break-word; }

pre[data-lang] { padding-top: 2rem; }

pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.55rem;
  right: 1rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  pointer-events: none;
}

.table-scroll {
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
}

.table-scroll table { margin-bottom: 0; }

blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-left: 3px solid var(--border-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

blockquote > :last-child { margin-bottom: 0; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

h2, h3, h4 { scroll-margin-top: 1.5rem; }

@media (max-width: 900px) {
  main { padding-left: 1.25rem; padding-right: 1.25rem; }
  table { font-size: 0.82rem; }
}
