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

:root {
  --bg: #0e1117;
  --bg-card: #161b22;
  --bg-card-hover: #1c2230;
  --bg-code: #1a1f2b;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #1f4270;
  --accent-glow: rgba(88, 166, 255, 0.15);
  --green: #3fb950;
  --orange: #d29922;
  --purple: #bc8cff;
  --red: #f85149;
  --sidebar-width: 280px;
  --header-height: 60px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-height);
  background: rgba(14, 17, 23, 0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); z-index: 100;
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
}
.header-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.header-logo:hover { text-decoration: none; }
.header-logo svg { width: 28px; height: 28px; }
.header-logo span { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }

.header-search { flex: 1; max-width: 480px; margin: 0 auto; position: relative; }
.header-search input {
  width: 100%; padding: 8px 14px 8px 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s;
}
.header-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.header-search input::placeholder { color: var(--text-muted); }
.header-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; max-height: 360px; overflow-y: auto; display: none; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.search-results.visible { display: block; }
.search-result-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: var(--accent-dim); }
.search-result-item .result-title { font-weight: 600; font-size: 14px; }
.search-result-item .result-section { font-size: 12px; color: var(--text-muted); }
.search-result-item .result-preview { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.search-kbd { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.search-kbd kbd {
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border); font-family: inherit; font-size: 11px;
}
.header-site-link {
  font-size: 14px; color: var(--text-muted); text-decoration: none; white-space: nowrap;
}
.header-site-link:hover { color: var(--text); text-decoration: none; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: var(--header-height); left: 0;
  width: var(--sidebar-width); height: calc(100vh - var(--header-height));
  background: var(--bg); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 0; z-index: 50;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.nav-section { padding: 0 16px; margin-bottom: 8px; }
.nav-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted); padding: 8px 0 4px;
}
.nav-link {
  display: block; padding: 6px 16px; font-size: 14px;
  color: var(--text-muted); text-decoration: none; border-radius: 6px;
  transition: all 0.15s; margin: 1px 8px;
}
.nav-link:hover { color: var(--text); background: var(--bg-card); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-glow); font-weight: 500; }

.sidebar-toggle {
  display: none; background: none; border: none; color: var(--text);
  cursor: pointer; padding: 8px;
}

/* ── Main ── */
.main {
  margin-left: var(--sidebar-width); padding: 100px 48px 80px;
  max-width: 1080px;
  margin-right: auto;
  margin-left: calc(var(--sidebar-width) + max(48px, (100vw - var(--sidebar-width) - 1080px) / 2));
}

/* ── Sections ── */
.section { margin-bottom: 64px; scroll-margin-top: 80px; }
.section h2 {
  font-size: 28px; font-weight: 700; margin-bottom: 16px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.section h3 { font-size: 20px; font-weight: 600; margin: 32px 0 12px; color: var(--accent); }
.section h4 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; color: var(--purple); }
.section p { margin-bottom: 12px; color: var(--text-muted); }
.section ul, .section ol { margin: 8px 0 16px 24px; color: var(--text-muted); }
.section li { margin-bottom: 4px; }

/* ── Hero ── */
.hero {
  text-align: center; padding: 60px 0 48px; margin-bottom: 48px;
  border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: 48px; font-weight: 800; letter-spacing: -1.5px; margin-bottom: 12px; }
.hero h1 .accent { color: var(--accent); }
.hero .subtitle { font-size: 20px; color: var(--text-muted); margin-bottom: 32px; }
.hero-features { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; font-size: 14px; color: var(--text-muted);
}
.hero-badge svg { width: 16px; height: 16px; }

/* ── Cards ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 16px 0; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; transition: all 0.2s; text-decoration: none; color: inherit; display: block;
}
.card:hover { border-color: var(--accent); background: var(--bg-card-hover); transform: translateY(-2px); text-decoration: none; }
.card h4 { margin: 0 0 8px; color: var(--text); font-size: 16px; }
.card p { margin: 0; font-size: 14px; color: var(--text-muted); }

/* ── Code ── */
pre {
  background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; overflow-x: auto; margin: 12px 0 20px; font-size: 13px; line-height: 1.7;
}
code { font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace; }
:not(pre) > code {
  background: var(--bg-code); padding: 2px 6px; border-radius: 4px;
  font-size: 0.9em; border: 1px solid var(--border);
}
.code-comment { color: #6a737d; }
.code-keyword { color: var(--red); }
.code-string { color: var(--green); }
.code-number { color: var(--orange); }
.code-param { color: var(--purple); }

/* ── Command blocks ── */
.cmd-block {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  margin: 20px 0; overflow: hidden;
}
.cmd-header {
  padding: 14px 20px; background: rgba(88, 166, 255, 0.08);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.cmd-name { font-weight: 700; font-size: 18px; font-family: 'Cascadia Code', monospace; }
.cmd-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.cmd-tag.data { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.cmd-tag.style { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.cmd-tag.selection { background: rgba(188, 140, 255, 0.15); color: var(--purple); }
.cmd-tag.scripting { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.cmd-body { padding: 20px; }
.cmd-body p { margin-bottom: 10px; }

/* ── Tables ── */
.param-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.param-table th {
  text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border);
  color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.param-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.param-table td:first-child { font-family: monospace; color: var(--accent); font-weight: 500; white-space: nowrap; }
.param-table tr:last-child td { border-bottom: none; }

/* ── Shortcuts ── */
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; margin: 12px 0; }
.shortcut-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--bg-card); border-radius: 8px;
  border: 1px solid var(--border); font-size: 14px;
}
.shortcut-item kbd {
  background: var(--bg); padding: 4px 8px; border-radius: 4px;
  border: 1px solid var(--border); font-family: monospace; font-size: 12px;
  min-width: 32px; text-align: center;
}

/* ── Misc ── */
.op { color: var(--accent); font-weight: 600; }

.page-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--border);
}
.page-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
  background: var(--bg-card); border: 1px solid var(--border); transition: all 0.15s;
}
.page-nav a:hover { border-color: var(--accent); background: var(--bg-card-hover); text-decoration: none; }
.page-nav .spacer { flex: 1; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); z-index: 150; }
  .sidebar-toggle { display: block; }
  .main { margin-left: 0; margin-right: 0; padding: 90px 20px 60px; max-width: 100%; }
  .hero h1 { font-size: 32px; }
  .card-grid { grid-template-columns: 1fr; }
}
