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

:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --sidebar-bg: #f0f0f0;
  --sidebar-w: 280px;
  --accent: #2563eb;
  --border: #ddd;
  --code-bg: #f5f5f5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a2e;
    --fg: #e0e0e0;
    --sidebar-bg: #16213e;
    --accent: #60a5fa;
    --border: #333;
    --code-bg: #0f3460;
  }
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.5em 1em 1em;
  border-bottom: 1px solid var(--border);
}

.site-title {
  display: block;
  font-size: 1.2em;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  margin-bottom: 0.8em;
}

.search-form input {
  width: 100%;
  padding: 0.4em 0.6em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font-size: 0.9em;
}

.sidebar-nav {
  flex: 1;
  padding: 1em 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 1em;
}

.nav-heading {
  display: block;
  padding: 0.3em 1em;
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg);
  opacity: 0.6;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav li a {
  display: block;
  padding: 0.3em 1em 0.3em 1.5em;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9em;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  background: var(--bg);
}

.sidebar-nav li.active a {
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1em;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1em;
  font-size: 0.85em;
}

.sidebar-footer a {
  color: var(--accent);
  text-decoration: none;
}

.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2em 3em;
  max-width: 900px;
}

.content h1 { font-size: 2em; margin: 0.5em 0; border-bottom: 2px solid var(--border); padding-bottom: 0.3em; }
.content h2 { font-size: 1.5em; margin: 1.5em 0 0.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.2em; }
.content h3 { font-size: 1.2em; margin: 1.2em 0 0.4em; }
.content p { margin: 0.8em 0; }
.content ul, .content ol { margin: 0.8em 0; padding-left: 2em; }
.content li { margin: 0.3em 0; }

.content pre {
  background: var(--code-bg);
  padding: 1em;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1em 0;
  font-size: 0.9em;
}

.content code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9em;
}

.content p code, .content li code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.content table {
  border-collapse: collapse;
  margin: 1em 0;
  width: 100%;
}

.content th, .content td {
  border: 1px solid var(--border);
  padding: 0.5em 0.8em;
  text-align: left;
}

.content th {
  background: var(--sidebar-bg);
  font-weight: 600;
}

.content a { color: var(--accent); }

.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 1px solid var(--border);
}

.page-nav a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95em;
}

.page-nav .next { margin-left: auto; }

.search-results { list-style: none; padding: 0; }
.search-results li { margin: 1.5em 0; }
.search-results a { font-size: 1.1em; font-weight: 600; }
.search-results .snippet { margin-top: 0.3em; color: var(--fg); opacity: 0.7; font-size: 0.9em; }

@media (max-width: 768px) {
  .sidebar { position: static; width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .content { margin-left: 0; padding: 1.5em; }
  .layout { flex-direction: column; }
}
