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

:root {
  --bg: #fafafa;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-code: #f4f4f5;
  --bg-code-block: #1e1e2e;
  --bg-header: rgba(255,255,255,0.92);

  --text: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --text-code: #e4e4e7;

  --border: #e4e4e7;
  --border-light: #f4f4f5;

  --accent: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-muted: #93c5fd;

  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;

  --radius: 8px;
  --radius-sm: 4px;

  --header-h: 56px;
  --sidebar-w: 260px;
  --toc-w: 220px;
  --content-max: 740px;

  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* === Base === */
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 24px); }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* === Header === */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.logo svg { color: var(--accent); flex-shrink: 0; }
.logo-text {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.logo-docs {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.header-nav { display: flex; align-items: center; gap: 16px; }
.version-badge {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.header-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.header-link:hover { color: var(--accent); }
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}

/* === Layout === */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
  max-width: 1400px;
  margin: 0 auto;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 0 24px 24px;
  border-right: 1px solid var(--border-light);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.nav-section { margin-bottom: 4px; }
.nav-section-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
  transition: all 0.15s;
}
.nav-section-title:hover { color: var(--text); background: var(--border-light); }
.nav-section-title.active { color: var(--accent); }
.nav-items { list-style: none; margin: 0 0 8px 0; }
.nav-link {
  display: block;
  font-size: 13.5px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 12px 5px 24px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.nav-link:hover { color: var(--text-secondary); background: var(--border-light); }
.nav-link.current {
  color: var(--accent);
  background: var(--accent-light);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* === Table of Contents === */
.toc {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 24px 24px 0;
  scrollbar-width: thin;
}
.toc-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.toc nav, .toc #TableOfContents { font-size: 13px; }
.toc ul { list-style: none; }
.toc li { margin-bottom: 2px; }
.toc a {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  padding: 3px 0 3px 12px;
  border-left: 1px solid var(--border-light);
  transition: all 0.15s;
}
.toc a:hover { color: var(--text-secondary); border-left-color: var(--border); }
.toc ul ul { margin-left: 0; }
.toc ul ul a { padding-left: 24px; }

/* === Content === */
.content {
  padding: 40px 48px;
  min-width: 0;
}

/* === Doc Page === */
.doc-header { margin-bottom: 32px; border-bottom: 1px solid var(--border-light); padding-bottom: 24px; }
.doc-header h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text);
}
.doc-description {
  margin-top: 8px;
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.doc-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

/* === Prose === */
.doc-body h2 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 40px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
  color: var(--text);
}
.doc-body h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--text);
}
.doc-body h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text-secondary);
}
.doc-body p { margin-bottom: 16px; max-width: var(--content-max); }
.doc-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-muted);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}
.doc-body a:hover { text-decoration-color: var(--accent); }
.doc-body strong { font-weight: 600; }
.doc-body ul, .doc-body ol {
  margin-bottom: 16px;
  padding-left: 24px;
  max-width: var(--content-max);
}
.doc-body li { margin-bottom: 6px; }
.doc-body li::marker { color: var(--text-muted); }

/* Code */
.doc-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--text);
}
.doc-body pre {
  background: var(--bg-code-block);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,0.06);
}
.doc-body pre code {
  background: none;
  padding: 0;
  color: var(--text-code);
  font-size: 13.5px;
  line-height: 1.6;
}

/* Tables */
.doc-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 14px;
}
.doc-body thead th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 10px 16px;
  border-bottom: 2px solid var(--border);
}
.doc-body td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
.doc-body tr:last-child td { border-bottom: none; }

/* Blockquotes / Callouts */
.doc-body blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  padding: 16px 20px;
  margin: 0 0 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  max-width: var(--content-max);
}
.doc-body blockquote p { margin-bottom: 0; color: var(--text-secondary); }

/* Images */
.doc-body img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 8px 0 20px;
}

/* === Callout shortcode === */
.callout {
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  border-left: 3px solid;
  max-width: var(--content-max);
}
.callout-title {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.callout-info { background: #eff6ff; border-color: #3b82f6; }
.callout-info .callout-title { color: #1d4ed8; }
.callout-warning { background: #fffbeb; border-color: #f59e0b; }
.callout-warning .callout-title { color: #b45309; }
.callout-danger { background: #fef2f2; border-color: #ef4444; }
.callout-danger .callout-title { color: #b91c1c; }
.callout-success { background: #f0fdf4; border-color: #22c55e; }
.callout-success .callout-title { color: #15803d; }

/* === Home Page === */
.home { max-width: 820px; }
.home-hero { margin-bottom: 40px; }
.home-hero h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.home-tagline {
  font-size: 18px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 8px;
}
.home-description {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.6;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.home-card {
  display: block;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}
.home-card:hover {
  border-color: var(--accent-muted);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  transform: translateY(-1px);
}
.home-card-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius);
  color: var(--accent);
  margin-bottom: 14px;
}
.home-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.home-card p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* === Section List === */
.section-list {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}
.section-item {
  display: block;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}
.section-item:hover {
  border-color: var(--accent-muted);
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.section-item h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.section-item p { font-size: 13.5px; color: var(--text-secondary); margin: 0; }

/* === Doc Nav (Prev/Next) === */
.doc-footer { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border-light); }
.doc-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.doc-nav-link {
  display: block;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all 0.2s;
}
.doc-nav-link:hover { border-color: var(--accent-muted); }
.doc-nav-link.next { text-align: right; grid-column: 2; }
.doc-nav-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.doc-nav-title { font-size: 14px; font-weight: 500; color: var(--accent); }

/* === Responsive === */
@media (max-width: 1100px) {
  .toc { display: none; }
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
}
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: 280px;
    background: var(--bg-sidebar);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0,0,0,0.08);
    padding: 24px;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-toggle { display: block; }
  .header-nav { display: none; }
  .content { padding: 24px 20px; }
  .home-grid { grid-template-columns: 1fr; }
  .doc-header h1 { font-size: 26px; }
  .home-hero h1 { font-size: 28px; }
  .doc-nav { grid-template-columns: 1fr; }
  .doc-nav-link.next { grid-column: 1; text-align: left; }
}
