:root {
  --bg:           #0f172a;
  --bg-card:      #1e293b;
  --bg-sidebar:   #080e1c;
  --bg-code:      #020817;
  --border:       #1e293b;
  --border-light: #334155;
  --text:         #e2e8f0;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;
  --accent:       #3b82f6;
  --accent-glow:  rgba(59,130,246,0.15);
  --green:        #22c55e;
  --green-bg:     rgba(34,197,94,0.1);
  --yellow:       #eab308;
  --yellow-bg:    rgba(234,179,8,0.1);
  --red:          #ef4444;
  --red-bg:       rgba(239,68,68,0.1);
  --purple:       #a855f7;
  --orange:       #f97316;
  --cyan:         #06b6d4;
  --sidebar-w:    260px;
  --header-h:     56px;
  --radius:       8px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* ── HEADER ─────────────────────────────────────────── */
.topbar {
  grid-column: 1 / -1;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.topbar-logo span { color: var(--accent); }

.topbar-tagline {
  color: var(--text-muted);
  font-size: 13px;
  border-left: 1px solid var(--border-light);
  padding-left: 16px;
  margin-left: 4px;
}

.topbar-nav {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.topbar-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 6px;
  transition: all 0.15s;
}
.topbar-nav a:hover,
.topbar-nav a.active { background: var(--accent-glow); color: var(--accent); }

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  overflow-y: auto;
  padding: 20px 12px;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 12px;
  margin-bottom: 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
  cursor: pointer;
}
.sidebar-link:hover { background: var(--bg-card); color: var(--text); }
.sidebar-link.active { background: var(--accent-glow); color: var(--accent); font-weight: 500; }

.sidebar-link .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-toc { margin-top: 8px; }
.sidebar-toc a {
  display: block;
  padding: 4px 12px 4px 32px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.sidebar-toc a:hover { color: var(--text-muted); border-left-color: var(--border-light); }
.sidebar-toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* ── MAIN CONTENT ───────────────────────────────────── */
.content {
  padding: 40px 48px;
  max-width: 900px;
  overflow-y: auto;
  height: calc(100vh - var(--header-h));
}

.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* ── HERO ────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #0c1a3a 0%, #0f172a 60%, #1a0a2e 100%);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 48px;
  margin-bottom: 40px;
  text-align: center;
}

.hero h1 { font-size: 36px; font-weight: 800; margin-bottom: 12px; }
.hero h1 span { color: var(--accent); }
.hero p { color: var(--text-muted); font-size: 17px; max-width: 560px; margin: 0 auto 28px; }

.hero-badges { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid;
}
.badge-blue   { color: var(--accent);  background: rgba(59,130,246,0.12);  border-color: rgba(59,130,246,0.3);  }
.badge-green  { color: var(--green);   background: rgba(34,197,94,0.12);   border-color: rgba(34,197,94,0.3);   }
.badge-orange { color: var(--orange);  background: rgba(249,115,22,0.12);  border-color: rgba(249,115,22,0.3);  }
.badge-purple { color: var(--purple);  background: rgba(168,85,247,0.12);  border-color: rgba(168,85,247,0.3);  }
.badge-cyan   { color: var(--cyan);    background: rgba(6,182,212,0.12);   border-color: rgba(6,182,212,0.3);   }
.badge-yellow { color: var(--yellow);  background: rgba(234,179,8,0.12);   border-color: rgba(234,179,8,0.3);   }

/* ── PAGE HEADER ─────────────────────────────────────── */
.page-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.page-header .topic-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  padding: 4px 12px;
  border-radius: 20px;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 10px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 16px;
}

/* ── TYPOGRAPHY ─────────────────────────────────────── */
h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 48px 0 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-left: 8px;
}

h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--text);
  scroll-margin-top: calc(var(--header-h) + 20px);
}

p { margin-bottom: 14px; color: var(--text); }
p:last-child { margin-bottom: 0; }

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

ul, ol { margin: 12px 0 16px 20px; }
li { margin-bottom: 6px; color: var(--text); }

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

/* ── CODE ────────────────────────────────────────────── */
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 13px;
  background: var(--bg-code);
  color: #93c5fd;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
}

.code-block {
  position: relative;
  margin: 16px 0 24px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.code-block-header {
  background: #0d1a30;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.copy-btn {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.copy-btn:hover { background: var(--border-light); color: var(--text); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

pre {
  background: var(--bg-code);
  padding: 20px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0;
}
pre::-webkit-scrollbar { height: 4px; }
pre::-webkit-scrollbar-thumb { background: var(--border-light); }

pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: inherit;
}

/* Syntax colors */
.kw  { color: #c792ea; } /* keywords */
.fn  { color: #82aaff; } /* functions */
.str { color: #c3e88d; } /* strings */
.cmt { color: #546e7a; font-style: italic; } /* comments */
.num { color: #f78c6c; } /* numbers */
.var { color: #eeffff; } /* variables */
.op  { color: #89ddff; } /* operators */
.flag{ color: #ffcb6b; } /* flags/options */

/* ── CALLOUTS ────────────────────────────────────────── */
.callout {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  border-left: 3px solid;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.callout-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.callout-body { flex: 1; }
.callout-body strong { display: block; margin-bottom: 4px; font-size: 14px; }
.callout-body p { font-size: 14px; color: var(--text-muted); margin: 0; }

.callout-tip    { background: var(--green-bg);  border-color: var(--green);  }
.callout-warn   { background: var(--yellow-bg); border-color: var(--yellow); }
.callout-danger { background: var(--red-bg);    border-color: var(--red);    }
.callout-info   { background: var(--accent-glow); border-color: var(--accent); }

/* ── CARDS ───────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-light); }

.card-icon { font-size: 28px; margin-bottom: 10px; }
.card h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.card p  { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.5; }

.card a {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

/* ── TABLES ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 20px 0; border-radius: var(--radius); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: #0d1a30;
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }
tbody td code { font-size: 12px; }

/* ── STEPS ───────────────────────────────────────────── */
.steps { margin: 20px 0; }
.step {
  display: flex;
  gap: 16px;
  padding-bottom: 28px;
  position: relative;
}
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 16px;
  top: 36px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.step-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.step-body { flex: 1; padding-top: 4px; }
.step-body h4 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.step-body p  { font-size: 14px; color: var(--text-muted); }

/* ── ARCH DIAGRAM ────────────────────────────────────── */
.arch-diagram {
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 13px;
  line-height: 1.8;
  color: #94a3b8;
  margin: 20px 0;
  overflow-x: auto;
  white-space: pre;
}
.arch-diagram .h { color: var(--accent); font-weight: 700; }
.arch-diagram .g { color: var(--green); }
.arch-diagram .y { color: var(--yellow); }
.arch-diagram .p { color: var(--purple); }
.arch-diagram .o { color: var(--orange); }

/* ── CMD TABLE ───────────────────────────────────────── */
.cmd-list { list-style: none; margin: 0 0 20px; }
.cmd-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.cmd-list li:last-child { border-bottom: none; }
.cmd-list .cmd-desc { font-size: 14px; color: var(--text-muted); padding-top: 2px; }

/* ── HOME GRID ───────────────────────────────────────── */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  display: block;
  transition: all 0.15s;
  cursor: pointer;
}
.topic-card:hover {
  border-color: var(--accent);
  background: #1a2640;
  text-decoration: none;
  transform: translateY(-2px);
}
.topic-card .tc-icon { font-size: 32px; margin-bottom: 12px; }
.topic-card .tc-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.topic-card .tc-desc  { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin: 0; }
.topic-card .tc-tags  { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.topic-card .tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-code);
  color: var(--text-dim);
  border: 1px solid var(--border-light);
}

/* ── DIVIDER ─────────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

/* ── MOBILE ──────────────────────────────────────────── */
.burger {
  display: none;
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
  }
  .sidebar {
    position: fixed;
    left: -100%;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    z-index: 200;
    transition: left 0.25s ease;
    width: var(--sidebar-w);
  }
  .sidebar.open { left: 0; }
  .content { padding: 24px 20px; max-width: 100%; }
  .burger { display: block; }
  .topbar-tagline { display: none; }
  .hero { padding: 28px 20px; }
  .hero h1 { font-size: 26px; }
  h2 { font-size: 19px; }
  .card-grid, .topic-grid { grid-template-columns: 1fr; }
}
