/* ── Design tokens ──────────────────────────────────────────────────────────── */
:root {
  --bg:          #0f172a;
  --surface:     #1e2a3a;
  --surface-2:   #243044;
  --border:      rgba(148,163,184,0.12);
  --border-2:    rgba(148,163,184,0.22);
  --text:        #e2e8f0;
  --muted:       #94a3b8;
  --accent:      #818cf8;
  --accent-dim:  #6366f1;
  --accent-bg:   rgba(99,102,241,0.10);
  --tip-bg:      rgba(16,185,129,0.08);
  --tip-border:  rgba(16,185,129,0.30);
  --tip-color:   #34d399;
  --info-bg:     rgba(99,102,241,0.08);
  --info-border: rgba(99,102,241,0.28);
  --info-color:  #818cf8;
  --code-bg:     rgba(148,163,184,0.10);
  --sidebar-w:   240px;
  --topbar-h:    52px;
  --shadow-card: 0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
}

[data-theme="light"] {
  --bg:          #f8fafc;
  --surface:     #ffffff;
  --surface-2:   #f1f5f9;
  --border:      rgba(15,23,42,0.10);
  --border-2:    rgba(15,23,42,0.18);
  --text:        #0f172a;
  --muted:       #64748b;
  --accent:      #4f46e5;
  --accent-dim:  #4338ca;
  --accent-bg:   rgba(99,102,241,0.08);
  --tip-bg:      rgba(16,185,129,0.06);
  --tip-border:  rgba(16,185,129,0.25);
  --tip-color:   #059669;
  --info-bg:     rgba(99,102,241,0.06);
  --info-border: rgba(99,102,241,0.22);
  --info-color:  #4f46e5;
  --code-bg:     rgba(15,23,42,0.07);
  --shadow-card: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.08);
}

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

html { scroll-behavior: smooth; font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.topbar-divider {
  color: var(--border-2);
  font-size: 1.1rem;
  user-select: none;
}

.topbar-section {
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 7px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent-dim);
  color: #fff;
  padding: 7px 14px;
  font-size: 0.85rem;
}
.btn-primary:hover { opacity: 0.88; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

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

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  padding: 20px 0 40px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  z-index: 90;
}

.sidebar-close {
  display: none;
}

.sidebar-section {
  padding: 8px 16px 4px;
}

.sidebar-heading {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 14px;
}

.sidebar-section:first-child .sidebar-heading {
  margin-top: 0;
}

.sidebar-link {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.875rem;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
}
.sidebar-link:hover {
  background: var(--accent-bg);
  color: var(--text);
}
.sidebar-link.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

/* ── Main content ───────────────────────────────────────────────────────────── */
.docs-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 48px 56px 80px;
  max-width: 820px;
}

.menu-btn {
  display: none;
}

/* ── Doc sections ───────────────────────────────────────────────────────────── */
.doc-section {
  padding-bottom: 64px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 64px;
}
.doc-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.section-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.doc-h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 14px;
}

.doc-h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.doc-lead {
  font-size: 1.05rem;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.7;
}

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

.doc-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.doc-link:hover { border-color: var(--accent); }

.doc-code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--accent);
}

.doc-kbd {
  font-family: 'SFMono-Regular', 'Consolas', monospace;
  font-size: 0.82em;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 2px 6px;
  box-shadow: 0 1px 0 var(--border-2);
}

.doc-list {
  padding-left: 20px;
  margin-bottom: 12px;
  color: var(--text);
}
.doc-list li { margin-bottom: 6px; }
.doc-list-numbered { list-style-type: decimal; }

/* ── Definition list ────────────────────────────────────────────────────────── */
.doc-dl { display: grid; grid-template-columns: auto 1fr; gap: 0; margin-bottom: 12px; }
.doc-dl dt {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  padding: 8px 16px 8px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  min-width: 160px;
}
.doc-dl dd {
  font-size: 0.9rem;
  color: var(--muted);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.doc-dl dt:last-of-type, .doc-dl dd:last-of-type { border-bottom: none; }

/* ── Callouts ───────────────────────────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 12px;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 20px 0;
  font-size: 0.9rem;
  line-height: 1.6;
}
.callout-icon {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  padding-top: 1px;
}
.callout-icon svg { width: 18px; height: 18px; }
.callout-info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--text);
}
.callout-info .callout-icon { color: var(--info-color); }
.callout-tip {
  background: var(--tip-bg);
  border: 1px solid var(--tip-border);
  color: var(--text);
}
.callout-tip .callout-icon { color: var(--tip-color); }

/* ── Pipeline steps ─────────────────────────────────────────────────────────── */
.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.pipeline-step {
  display: flex;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
}
.pipeline-step:last-child { border-bottom: none; }
.pipeline-step p { margin-bottom: 0; color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.pipeline-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* ── Option table ───────────────────────────────────────────────────────────── */
.option-table {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 16px 0;
  font-size: 0.875rem;
}
.option-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.option-row:last-child { border-bottom: none; }
.option-row > span {
  padding: 10px 14px;
  border-right: 1px solid var(--border);
  color: var(--text);
}
.option-row > span:last-child { border-right: none; }
.option-row-header {
  background: var(--surface-2);
}
.option-row-header > span {
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.option-row:not(.option-row-header) { background: var(--surface); }
.option-row:not(.option-row-header):nth-child(even) { background: var(--bg); }

/* ── Tag grid ───────────────────────────────────────────────────────────────── */
.tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.tag-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--info-border);
}
.tag-default {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-2);
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .docs-main {
    margin-left: 0;
    padding: 24px 20px 60px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
  }
  .sidebar-close:hover { color: var(--text); }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 24px;
    padding: 6px 12px;
    border: 1px solid var(--border-2);
    border-radius: 7px;
    background: none;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
  }
  .menu-btn svg { width: 14px; height: 14px; }

  .doc-h1 { font-size: 1.6rem; }

  .option-row {
    grid-template-columns: 1fr 1fr;
  }
  .option-row > span:last-child {
    grid-column: 1 / -1;
    border-right: none;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.83rem;
  }
  .option-row-header > span:last-child {
    display: none;
  }

  .doc-dl { grid-template-columns: 1fr; }
  .doc-dl dt { border-bottom: none; padding-bottom: 2px; }
  .doc-dl dd { padding-top: 0; color: var(--muted); }
}

@media (max-width: 520px) {
  .options-table { font-size: 0.82rem; }
  .topbar-inner { padding: 0 14px; }
}
