/* ─── Theme Tokens ───────────────────────────────────── */
:root,
html[data-theme="light"] {
  --bg-body:        #f5f7fb;
  --bg-sidebar:     #0f172a;
  --sidebar-fg:     #f8fafc;
  --sidebar-muted:  #cbd5e1;
  --sidebar-nav:    #e2e8f0;
  --sidebar-border: rgba(148, 163, 184, 0.16);
  --bg-section:     #ffffff;
  --section-border: rgba(148, 163, 184, 0.24);
  --section-shadow: 0 18px 54px rgba(15, 23, 42, 0.08);
  --text-primary:   #1f2937;
  --code-bg:        rgba(175, 184, 193, 0.2);
  --bg-pre:         #111827;
  --pre-fg:         #e5e7eb;
  --accent:         #2563eb;
  --nav-active-bg:  rgba(59, 130, 246, 0.18);
  --toggle-bg:      rgba(255, 255, 255, 0.08);
  --toggle-hover:   rgba(255, 255, 255, 0.15);
}

html[data-theme="dark"] {
  --bg-body:        #0d1117;
  --bg-sidebar:     #010409;
  --sidebar-fg:     #e6edf3;
  --sidebar-muted:  #8b949e;
  --sidebar-nav:    #c9d1d9;
  --sidebar-border: rgba(48, 54, 61, 0.8);
  --bg-section:     #161b22;
  --section-border: rgba(48, 54, 61, 0.8);
  --section-shadow: 0 18px 54px rgba(0, 0, 0, 0.4);
  --text-primary:   #e6edf3;
  --code-bg:        rgba(110, 118, 129, 0.4);
  --bg-pre:         #0d1117;
  --pre-fg:         #e6edf3;
  --accent:         #388bfd;
  --nav-active-bg:  rgba(56, 139, 253, 0.15);
  --toggle-bg:      rgba(255, 255, 255, 0.06);
  --toggle-hover:   rgba(255, 255, 255, 0.1);
}

html[data-theme="night"] {
  --bg-body:        #1c2128;
  --bg-sidebar:     #14191f;
  --sidebar-fg:     #adbac7;
  --sidebar-muted:  #768390;
  --sidebar-nav:    #909dab;
  --sidebar-border: rgba(55, 62, 71, 0.8);
  --bg-section:     #22272e;
  --section-border: rgba(55, 62, 71, 0.8);
  --section-shadow: 0 18px 54px rgba(0, 0, 0, 0.3);
  --text-primary:   #adbac7;
  --code-bg:        rgba(99, 110, 123, 0.4);
  --bg-pre:         #1c2128;
  --pre-fg:         #adbac7;
  --accent:         #6cb6ff;
  --nav-active-bg:  rgba(108, 182, 255, 0.12);
  --toggle-bg:      rgba(255, 255, 255, 0.05);
  --toggle-hover:   rgba(255, 255, 255, 0.09);
}

html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"],
html[data-theme="night"]  { color-scheme: dark; }

/* ─── Base ───────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  transition: background 0.2s ease, color 0.2s ease;
}

/* ─── Layout ─────────────────────────────────────────── */
.site-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  color: var(--sidebar-fg);
  padding: 32px 24px;
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  align-self: start;
  display: flex;
  flex-direction: column;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  transition: background 0.2s ease;
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--sidebar-fg);
}

.brand p {
  margin: 6px 0 0;
  color: var(--sidebar-muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.nav-list {
  display: grid;
  gap: 4px;
  flex: 1;
}

.nav-list a {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--sidebar-nav);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-list a:hover,
.nav-list a.active {
  background: var(--nav-active-bg);
  color: var(--sidebar-fg);
}

/* ─── Theme Switcher ─────────────────────────────────── */
.theme-switcher {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--sidebar-border);
}

.theme-switcher-label {
  margin: 0 0 10px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-muted);
}

.theme-options {
  display: flex;
  gap: 4px;
  background: var(--toggle-bg);
  border-radius: 10px;
  padding: 3px;
}

.theme-btn {
  flex: 1;
  padding: 7px 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--sidebar-nav);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme-btn:hover {
  background: var(--toggle-hover);
  color: var(--sidebar-fg);
}

.theme-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}

/* ─── Content ────────────────────────────────────────── */
.content {
  padding: 32px;
  max-width: 940px;
  margin: 0 auto;
}

.section {
  background: var(--bg-section);
  border: 1px solid var(--section-border);
  border-radius: 16px;
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: var(--section-shadow);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.section h2 {
  margin-top: 0;
}

.section p,
.section ul {
  line-height: 1.8;
}

:not(pre) > code {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 0.15em 0.45em;
  font-size: 0.88em;
}

pre {
  background: var(--bg-pre);
  color: var(--pre-fg);
  padding: 18px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 18px 0 0;
  transition: background 0.2s ease, color 0.2s ease;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 980px) {
  .site-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }
}

@media (max-width: 640px) {
  .sidebar { padding: 20px; }
  .content { padding: 20px; }
}
