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

:root {
  --sidebar-w: 272px;
  --topbar-h: 52px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-code: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-hover: #1e293b;
  --sidebar-active: rgba(99,102,241,0.15);
  --sidebar-heading: #64748b;

  --accent: #6366f1;
  --accent-light: #e0e7ff;

  --c-purple: #8b5cf6;
  --c-green: #10b981;
  --c-blue: #3b82f6;
  --c-orange: #f59e0b;
  --c-rose: #f43f5e;
  --c-slate: #64748b;
  --c-teal: #14b8a6;
  --c-cyan: #06b6d4;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid #1e293b;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 20px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.topbar-logo {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--c-purple), var(--accent));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.topbar-title {
  color: #f1f5f9;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-env {
  font-size: 11px;
  color: var(--text-muted);
  background: #1e293b;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* ── Layout ── */
.shell {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--sidebar-bg);
  overflow-y: auto;
  padding: 16px 0;
  border-right: 1px solid #1e293b;
  z-index: 90;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

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

.sidebar-project {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.sidebar-project:hover { background: var(--sidebar-hover); }

.sidebar-project-icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.sidebar-project-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  flex: 1;
}

.sidebar-project-arrow {
  font-size: 10px;
  color: var(--sidebar-heading);
  transition: transform 0.2s;
}

.sidebar-project.is-expanded .sidebar-project-arrow { transform: rotate(90deg); }

.sidebar-pages {
  display: none;
  padding: 2px 0;
}

.sidebar-project.is-expanded + .sidebar-pages { display: block; }

.sidebar-link {
  display: block;
  padding: 5px 20px 5px 50px;
  font-size: 13px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  cursor: pointer;
}

.sidebar-link:hover {
  color: #f1f5f9;
  background: var(--sidebar-hover);
}

.sidebar-link.is-active {
  color: #fff;
  background: var(--sidebar-active);
  border-left-color: var(--accent);
  font-weight: 500;
}

.sidebar-heading {
  padding: 20px 20px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-heading);
}

/* ── Content ── */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}

.page[hidden] { display: none; }

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--text);
}

.page-lead {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 24px;
}

.page-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* ── Section headings ── */
.page h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.page h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--text);
}

.page p {
  margin-bottom: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
}

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

/* ── Tables ── */
.table-wrap { overflow-x: auto; margin: 16px 0 24px; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tbl th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border);
}

.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: top;
}

.tbl tr:hover td { background: var(--bg-alt); }
.tbl td strong { color: var(--text); }
.tbl code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--c-purple);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge--production { background: #dcfce7; color: #166534; }
.badge--pilot { background: #fef3c7; color: #92400e; }
.badge--planned { background: #e0e7ff; color: #3730a3; }
.badge--deprecated { background: #fee2e2; color: #991b1b; }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Mermaid ── */
.diagram-wrap {
  margin: 20px 0 28px;
  padding: 24px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

.diagram-wrap .mermaid {
  display: flex;
  justify-content: center;
}

/* ── Flow list ── */
.flow-list {
  list-style: none;
  counter-reset: flow;
  margin: 16px 0 24px;
}

.flow-list li {
  counter-increment: flow;
  position: relative;
  padding: 12px 16px 12px 52px;
  margin-bottom: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.flow-list li::before {
  content: counter(flow);
  position: absolute;
  left: 14px;
  top: 12px;
  width: 26px; height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.flow-list li strong { color: var(--text); }

/* ── Cards grid ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 16px 0 28px;
}

.card {
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.card-icon {
  font-size: 24px;
  margin-bottom: 10px;
}

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

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-meta {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Project cards (home) ── */
.project-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin: 24px 0 40px;
}

.project-card {
  padding: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.project-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.project-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.project-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.project-card-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.project-card-type {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.project-card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.project-card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Callout ── */
.callout {
  padding: 16px 20px;
  border-radius: 10px;
  margin: 16px 0 24px;
  font-size: 14px;
  line-height: 1.6;
}

.callout--info {
  background: #eff6ff;
  border-left: 4px solid var(--c-blue);
  color: #1e40af;
}

.callout--warn {
  background: #fffbeb;
  border-left: 4px solid var(--c-orange);
  color: #92400e;
}

.callout--tip {
  background: #ecfdf5;
  border-left: 4px solid var(--c-green);
  color: #065f46;
}

/* ── Code block ── */
.code-block {
  margin: 16px 0 24px;
  background: #1e293b;
  border-radius: 10px;
  overflow: hidden;
}

.code-block-header {
  padding: 8px 16px;
  background: #0f172a;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.code-block pre {
  padding: 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
  margin: 0;
}

/* ── KV pairs ── */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.kv-item {
  padding: 14px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
  border-radius: 10px;
}

.kv-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kv-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ── UL/OL inside page ── */
.page ul, .page ol {
  margin: 8px 0 20px 20px;
  color: var(--text-secondary);
}

.page li {
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.65;
}

.page li strong { color: var(--text); }

/* ── Responsive ── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .page { padding: 24px 20px 60px; }
}
