:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --border: #2a2a2a;
  --text: #f2f2f2;
  --muted: #a8a8a8;
  --accent: #1e88e5;
  --accent-dim: #1565c0;
  --sidebar-w: 280px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

a { color: #7eb8ff; }
a:hover { color: #b3d4ff; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - 3.5rem);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 1.25rem 0 2rem;
}

.sidebar-brand {
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-brand a {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}

.sidebar-brand .sub {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}

.nav-toc { list-style: none; margin: 0; padding: 0; }

.nav-toc li a {
  display: block;
  padding: 0.45rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}

.nav-toc li a:hover { color: var(--text); background: rgba(255,255,255,.04); }

.nav-toc li a.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: rgba(30, 136, 229, 0.12);
  font-weight: 600;
}

.main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.menu-btn {
  background: #333;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.content {
  flex: 1;
  max-width: 52rem;
  padding: 2rem 2.5rem 1rem;
}

.content h1 {
  margin: 0 0 1.25rem;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.content h2, .content h3 {
  margin: 1.75rem 0 0.65rem;
  font-size: 1.15rem;
}

.content p, .content li { color: #ddd; }

.content pre {
  background: #111;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: #1c1c1c;
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.content pre code { background: none; padding: 0; }

.content ol, .content ul { padding-left: 1.35rem; }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding: 1.25rem 0 2.5rem;
  border-top: 1px solid var(--border);
}

.pager a {
  flex: 1;
  max-width: 48%;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.pager a:hover {
  border-color: var(--accent);
  background: #1a1a1a;
}

.pager a.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.pager .label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}

.pager .title { font-weight: 600; font-size: 0.95rem; }

.pager .next { text-align: right; margin-left: auto; }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 40;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .overlay.open { display: block; }
  .content { padding: 1.25rem 1.1rem 1rem; }
}
