:root {
  --bg: #ffffff;
  --bg-code: #f6f8fa;
  --bg-sidebar: #f8f9fa;
  --bg-nav: #ffffff;
  --text: #1a1a2e;
  --text-muted: #586069;
  --text-code: #24292e;
  --border: #e1e4e8;
  --accent: #3776AB;
  --accent-hover: #2a5f8f;
  --accent-light: #e8f0f8;
  --keyword: #cf222e;
  --string: #0a3069;
  --comment: #6e7781;
  --function: #8250df;
  --builtin: #953800;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 8px;
  --sidebar-width: 280px;
  --nav-height: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --bg-code: #161b22;
    --bg-sidebar: #010409;
    --bg-nav: #161b22;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-code: #e6edf3;
    --border: #30363d;
    --accent: #6BA4D4;
    --accent-hover: #8AB8E0;
    --accent-light: #1a2940;
    --keyword: #ff7b72;
    --string: #a5d6ff;
    --comment: #8b949e;
    --function: #d2a8ff;
    --builtin: #ffa657;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-code: #161b22;
  --bg-sidebar: #010409;
  --bg-nav: #161b22;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-code: #e6edf3;
  --border: #30363d;
  --accent: #6BA4D4;
  --accent-hover: #8AB8E0;
  --accent-light: #1a2940;
  --keyword: #ff7b72;
  --string: #a5d6ff;
  --comment: #8b949e;
  --function: #d2a8ff;
  --builtin: #ffa657;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 24px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}

/* Top navigation bar */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topnav-brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav-brand span {
  color: var(--accent);
}

.topnav-links {
  margin-left: auto;
  display: flex;
  gap: 20px;
  align-items: center;
}

.topnav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s;
}

.topnav-links a:hover {
  color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.version-select {
  background: var(--accent);
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='white'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.version-select option {
  background: var(--bg);
  color: var(--text);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  margin-right: 12px;
}

/* Layout */
.layout {
  display: flex;
  margin-top: var(--nav-height);
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 50;
}

.sidebar nav {
  padding: 0 16px;
}

.sidebar .nav-section {
  margin-bottom: 24px;
}

.sidebar .nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar a {
  display: block;
  padding: 6px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

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

.sidebar a.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* Main content */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  max-width: 860px;
  padding: 48px 56px 96px;
}

/* Banner */
.hero-banner {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 32px;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Hero */
.hero {
  margin-bottom: 48px;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.hero .tagline {
  font-size: 20px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.hero .install-cmd {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 15px;
  color: var(--text-code);
}

.hero .install-cmd .prompt {
  color: var(--text-muted);
  user-select: none;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 32px;
}

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

.feature-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

/* Typography */
h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 48px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

h2:first-of-type {
  margin-top: 0;
}

h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 32px 0 12px;
}

h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 8px;
}

p {
  margin-bottom: 16px;
}

/* Inline code */
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Code blocks */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 0 0 24px;
  line-height: 1.55;
}

pre code {
  background: none;
  padding: 0;
  font-size: 13.5px;
}

/* Pygments syntax highlighting */
.highlight { background: var(--bg-code); border-radius: var(--radius); }
.highlight pre { background: none; border: none; margin: 0; }
.highlight .k, .highlight .kn, .highlight .kd,
.highlight .kc, .highlight .kr, .highlight .ow,
.highlight .kp { color: var(--keyword); }
.highlight .s, .highlight .s1, .highlight .s2,
.highlight .sa, .highlight .sb, .highlight .sc,
.highlight .sd, .highlight .se, .highlight .sh,
.highlight .si, .highlight .sr, .highlight .ss { color: var(--string); }
.highlight .c, .highlight .c1, .highlight .cm,
.highlight .ch, .highlight .cs, .highlight .cp,
.highlight .cpf { color: var(--comment); font-style: italic; }
.highlight .nf, .highlight .fm, .highlight .nd,
.highlight .ni { color: var(--function); }
.highlight .nb, .highlight .bp, .highlight .mi,
.highlight .mf, .highlight .mb, .highlight .mh,
.highlight .mo, .highlight .nc { color: var(--builtin); }
.highlight .o, .highlight .p { color: var(--text-code); }
.highlight .n, .highlight .na, .highlight .nv,
.highlight .no, .highlight .nl { color: var(--text-code); }

.highlight + p {
    margin-top: 16px;
}

/* API reference table */
.api-signature {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 12px 0;
  display: block;
  overflow-x: auto;
}

.param-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 24px;
  font-size: 14px;
}

.param-table th {
  text-align: left;
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.param-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.param-table td:first-child {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  white-space: nowrap;
  color: var(--accent);
}

.param-table td:nth-child(2) {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  color: var(--text-muted);
}

/* Callout boxes */
.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0 24px;
  font-size: 14px;
}

.callout.warning {
  border-left-color: #d1242f;
  background: #fff1e5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .callout.warning {
    background: #2a1500;
  }
}

[data-theme="dark"] .callout.warning {
  background: #2a1500;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
}

/* Lists */
ul, ol {
  margin: 0 0 16px 24px;
}

li {
  margin-bottom: 4px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 14px;
}

th {
  text-align: left;
  font-weight: 600;
  padding: 10px 16px;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Section anchors */
.section-anchor {
  scroll-margin-top: calc(var(--nav-height) + 24px);
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 90;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .overlay {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 80;
  }

  .overlay.open {
    display: block;
  }

  .menu-toggle {
    display: block;
  }

  .main {
    margin-left: 0;
    padding: 32px 20px 64px;
  }
}
