:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111214;
  --bg-tertiary: #1a1b1e;
  --bg-card: #141518;
  --border: #2c2e33;
  --border-hover: #3c3e43;
  --text-primary: #f0f0f0;
  --text-secondary: #8b8d91;
  --text-muted: #56585c;
  --accent: #4da6ff;
  --accent-dim: rgba(77, 166, 255, 0.12);
  --accent-hover: #6db8ff;
  --emerald: #62e0b0;
  --emerald-dim: rgba(98, 224, 176, 0.12);
  --warning: #c2891b;
  --danger: #c75d4e;
  --success: #4da6ff;
  --code-bg: #0d0e11;
  --sidebar-width: 280px;
  --header-height: 64px;
  --font-sans: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.6;
}
::selection { background: rgba(77, 166, 255, 0.25); }
a { color: var(--accent); text-decoration: none; transition: color 0.18s; }
a:hover { color: var(--accent-hover); }

/* ── Header ── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logo svg { flex-shrink: 0; }
.logo-text {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.logo-text span { color: var(--accent); }
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-link {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  transition: color 0.18s;
}
.header-link:hover { color: var(--text-primary); }
.header-badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(77, 166, 255, 0.2);
}

/* ── Search ── */
.search-box {
  position: relative;
}
.search-input {
  width: 260px;
  padding: 8px 14px 8px 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.search-results.active { display: block; }
.search-result-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: background 0.15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-tertiary); }
.search-result-item .result-page {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 50;
  transition: transform 0.3s ease;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-title {
  padding: 0 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.sidebar-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-link svg {
  flex-shrink: 0;
  opacity: 0.6;
}
.sidebar-link.active svg { opacity: 1; }

/* ── Main Content ── */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}
.content {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}

/* ── Typography ── */
.content h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 16px;
}
.content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 48px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 32px 0 12px;
}
.content h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 24px 0 8px;
}
.content p {
  color: var(--text-secondary);
  margin: 0 0 16px;
  line-height: 1.7;
}
.content ul, .content ol {
  color: var(--text-secondary);
  padding-left: 24px;
  margin: 0 0 16px;
}
.content li { margin-bottom: 6px; line-height: 1.6; }
.content strong { color: var(--text-primary); font-weight: 600; }
.content em { color: var(--text-secondary); }
.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}
.content blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}
.content blockquote strong { color: var(--accent); }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.content th {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.content td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.content tr:last-child td { border-bottom: none; }
.content tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Code ── */
.content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--emerald);
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
  position: relative;
}
pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
.code-label {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Callouts ── */
.callout {
  padding: 14px 18px;
  border-radius: 10px;
  margin: 16px 0;
  font-size: 0.9rem;
  line-height: 1.6;
  display: flex;
  gap: 12px;
}
.callout-icon { flex-shrink: 0; margin-top: 2px; }
.callout-info {
  background: rgba(77, 166, 255, 0.08);
  border: 1px solid rgba(77, 166, 255, 0.2);
  color: var(--text-secondary);
}
.callout-warn {
  background: rgba(194, 137, 27, 0.08);
  border: 1px solid rgba(194, 137, 27, 0.2);
  color: var(--text-secondary);
}
.callout-success {
  background: rgba(98, 224, 176, 0.08);
  border: 1px solid rgba(98, 224, 176, 0.2);
  color: var(--text-secondary);
}

/* ── Steps ── */
.steps { counter-reset: step; padding-left: 0; list-style: none; }
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 48px;
  margin-bottom: 20px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid rgba(77, 166, 255, 0.3);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Feature Cards ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: border-color 0.2s, transform 0.2s;
}
.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}
.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.card-icon--blue { background: var(--accent-dim); color: var(--accent); }
.card-icon--green { background: var(--emerald-dim); color: var(--emerald); }
.card-icon--yellow { background: rgba(194,137,27,0.12); color: var(--warning); }
.card h3 {
  font-size: 1rem;
  margin: 0 0 8px;
}
.card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Page Navigation ── */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.page-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex: 1;
  max-width: 48%;
  transition: border-color 0.2s;
}
.page-nav a:hover { border-color: var(--accent); }
.page-nav .nav-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.page-nav .nav-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}
.page-nav .next { text-align: right; margin-left: auto; }

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 80px 0 48px;
}
.hero h1 {
  font-size: 3.2rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 16px auto 32px;
  line-height: 1.6;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: var(--accent-hover); color: #000; }
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* ── Architecture Diagram ── */
.arch-diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 24px 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-secondary);
}

/* ── Mobile ── */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.active { display: block; }
  .main { margin-left: 0; }
  .content { padding: 32px 20px 60px; }
  .mobile-menu-btn { display: flex; }
  .header-link { display: none; }
  .search-input { width: 160px; }
  .hero h1 { font-size: 2rem; }
  .hero-sub { font-size: 1rem; }
  .card-grid { grid-template-columns: 1fr; }
  .page-nav { flex-direction: column; }
  .page-nav a { max-width: 100%; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.content { animation: fadeIn 0.3s ease; }

/* ── Tags ── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
}
.tag-blue { background: var(--accent-dim); color: var(--accent); }
.tag-green { background: var(--emerald-dim); color: var(--emerald); }
.tag-yellow { background: rgba(194,137,27,0.12); color: var(--warning); }
.tag-red { background: rgba(199,93,78,0.12); color: var(--danger); }
