/* ─── Reset & Base ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d0d16;
  --bg-surface: #12121e;
  --bg-card: #1a1a2b;
  --bg-hover: #1e1e30;
  --border: #252538;
  --border-light: #2e2e48;
  --text: #e2e2f0;
  --text-muted: #8888aa;
  --text-dim: #55556a;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-2: #10b981;
  --accent-3: #f59e0b;
  --accent-4: #ec4899;
  --code-bg: #0f0f1c;
  --sidebar-w: 260px;
  --content-max: 900px;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  font-size: 15px;
}

/* ─── Layout ────────────────────────────────────────────────────────────── */
.wiki-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-bottom: 6px;
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
}

.sidebar-version {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section {
  padding: 6px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  line-height: 1.4;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.nav-link.active {
  color: #a5b4fc;
  border-left-color: var(--accent);
  background: var(--accent-glow);
}

.nav-link .nav-icon {
  width: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-link.active .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-links a {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
}

.sidebar-links a:hover {
  color: var(--text);
}

/* ─── Main Content ──────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  padding: 48px 64px;
  display: grid;
  justify-content: center;
  align-content: start;
}

.main-content > * {
  width: min(100%, var(--content-max));
}

/* ─── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  margin-bottom: 56px;
  position: relative;
}

.hero::before {
  content: "";
  position: absolute;
  top: -80px;
  left: -80px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.hero-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.hero h1 {
  font-size: 48px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #e2e2f0 0%, #a5b4fc 50%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.hero-desc {
  font-size: 18px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 640px;
  margin-bottom: 28px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tech-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid;
}

.badge-node {
  background: rgba(51, 153, 51, 0.12);
  border-color: rgba(51, 153, 51, 0.3);
  color: #6dbf6d;
}
.badge-react {
  background: rgba(97, 218, 251, 0.1);
  border-color: rgba(97, 218, 251, 0.25);
  color: #61dafb;
}
.badge-ts {
  background: rgba(49, 120, 198, 0.12);
  border-color: rgba(49, 120, 198, 0.3);
  color: #5a9fd4;
}
.badge-sqlite {
  background: rgba(0, 59, 87, 0.2);
  border-color: rgba(0, 100, 150, 0.3);
  color: #5bb8e0;
}
.badge-ws {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
  color: #34d399;
}
.badge-vite {
  background: rgba(100, 108, 255, 0.12);
  border-color: rgba(100, 108, 255, 0.3);
  color: #9699ff;
}
.badge-python {
  background: rgba(55, 118, 171, 0.12);
  border-color: rgba(55, 118, 171, 0.3);
  color: #6aaddb;
}
.badge-mit {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

/* ─── Quick Start Cards ─────────────────────────────────────────────────── */
.quick-start-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.qs-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition:
    border-color 0.2s,
    transform 0.2s;
}

.qs-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.qs-step {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.qs-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.qs-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Section Styles ────────────────────────────────────────────────────── */
section {
  margin-bottom: 64px;
  scroll-margin-top: 32px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a5b4fc;
  margin-bottom: 12px;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

h2 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 12px;
}

h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 24px;
  margin-bottom: 8px;
}

p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

p:last-child {
  margin-bottom: 0;
}

/* ─── Mermaid diagrams ──────────────────────────────────────────────────── */
.diagram-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 20px 0;
  overflow-x: auto;
  text-align: center;
}

.diagram-wrap .mermaid {
  display: inline-block;
}

.diagram-label {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 10px;
  font-style: italic;
}

/* ─── Code blocks ───────────────────────────────────────────────────────── */
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 16px 0;
  position: relative;
}

code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: #c9d1ff;
}

:not(pre) > code {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12.5px;
  color: #a5b4fc;
}

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

.code-header + pre {
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: 0;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead {
  background: var(--bg-surface);
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}

td:first-child {
  color: var(--text);
  font-weight: 500;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-hover);
}

/* ─── Callouts ──────────────────────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid;
  margin: 20px 0;
}

.callout-icon {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1.7;
}

.callout-body {
  flex: 1;
}
.callout-body strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}
.callout-body p {
  font-size: 13.5px;
  margin: 0;
}

.callout-info {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.25);
}
.callout-info .callout-body strong {
  color: #a5b4fc;
}
.callout-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
}
.callout-success .callout-body strong {
  color: #34d399;
}
.callout-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
}
.callout-warning .callout-body strong {
  color: #fbbf24;
}

/* ─── Feature Grid ──────────────────────────────────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s;
}

.feature-card:hover {
  border-color: var(--border-light);
}

.feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}

.ic-indigo {
  background: rgba(99, 102, 241, 0.15);
}
.ic-emerald {
  background: rgba(16, 185, 129, 0.15);
}
.ic-amber {
  background: rgba(245, 158, 11, 0.15);
}
.ic-pink {
  background: rgba(236, 72, 153, 0.15);
}
.ic-violet {
  background: rgba(139, 92, 246, 0.15);
}
.ic-cyan {
  background: rgba(6, 182, 212, 0.15);
}
.ic-blue {
  background: rgba(59, 130, 246, 0.15);
}
.ic-rose {
  background: rgba(244, 63, 94, 0.15);
}

.feature-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}
.feature-card p {
  font-size: 13px;
  margin: 0;
}

/* ─── Status Chips ──────────────────────────────────────────────────────── */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.chip-idle {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(107, 114, 128, 0.2);
}
.chip-connected {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.chip-working {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.chip-completed {
  background: rgba(139, 92, 246, 0.12);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.2);
}
.chip-error {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.chip-active {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.chip-abandoned {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── Pipeline Stepper ──────────────────────────────────────────────────── */
.pipeline {
  display: flex;
  gap: 0;
  margin: 24px 0;
  overflow-x: auto;
}

.pipe-step {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.pipe-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 12px;
  text-align: center;
  min-width: 100px;
  transition: border-color 0.2s;
}

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

.pipe-box .pipe-num {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.pipe-box .pipe-name {
  color: var(--text);
  font-weight: 600;
}
.pipe-box .pipe-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.pipe-arrow {
  color: var(--text-dim);
  padding: 0 6px;
  font-size: 14px;
}

/* ─── Stat Highlights ───────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.stat-highlight {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

.stat-highlight .stat-val {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--text), #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-highlight .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Route List ────────────────────────────────────────────────────────── */
.route-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.route-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  transition: border-color 0.15s;
}

.route-item:hover {
  border-color: var(--border-light);
}

.method {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}

.method-get {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
.method-post {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}
.method-patch {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
.method-delete {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.route-path {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.route-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-left: auto;
}

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

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .main-content {
    display: block;
    margin-left: 0;
    width: auto;
    padding: 32px 24px;
  }
  .main-content > * {
    width: auto;
  }
  .hero h1 {
    font-size: 32px;
  }
}

/* ─── Anchor offset ─────────────────────────────────────────────────────── */
[id] {
  scroll-margin-top: 32px;
}

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

/* ─── Search bar ────────────────────────────────────────────────────────── */
.search-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px 6px 30px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238888aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px center;
}

.search-input::placeholder {
  color: var(--text-dim);
}
.search-input:focus {
  border-color: var(--accent);
}

/* ─── Footer ────────────────────────────────────────────────────────────── */
.wiki-footer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: gap;
  gap: 16px;
}

.wiki-footer p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

.wiki-footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.wiki-footer a:hover {
  color: var(--text);
}

/* ─── Mermaid theme overrides ───────────────────────────────────────────── */
.mermaid svg {
  max-width: 100%;
  height: auto;
}
