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

/* ── Theme variables ─────────────────────────────────────────── */

:root, [data-theme="sprout"] {
  --bg:        #191a1b;
  --bg-side:   #131714;
  --bg-code:   #161b17;
  --border:    #243525;
  --accent:    #4be374;
  --accent-dim:#2d6640;
  --fg:        #cfe9d4;
  --fg-dim:    #6f8b78;
  --fg-muted:  #3f5548;
  --amber:     #ffbe3c;
  --side-w:    260px;
  --content-w: 780px;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
}

[data-theme="amber"] {
  --bg:        #191a1b;
  --bg-side:   #16140f;
  --bg-code:   #1c1a10;
  --border:    #443518;
  --accent:    #e3b341;
  --accent-dim:#5c4213;
  --fg:        #cfe9d4;
  --fg-dim:    #9a8450;
  --fg-muted:  #5a4928;
  --amber:     #ffbe3c;
}

[data-theme="mono"] {
  --bg:        #191a1b;
  --bg-side:   #161818;
  --bg-code:   #1b1e1b;
  --border:    #2c322c;
  --accent:    #cfe9d4;
  --accent-dim:#607862;
  --fg:        #cfe9d4;
  --fg-dim:    #78807a;
  --fg-muted:  #444844;
  --amber:     #ffbe3c;
}

[data-theme="ocean"] {
  --bg:        #191a1b;
  --bg-side:   #0f1519;
  --bg-code:   #111a22;
  --border:    #163a50;
  --accent:    #41c3eb;
  --accent-dim:#0f4869;
  --fg:        #cfe9d4;
  --fg-dim:    #4b91af;
  --fg-muted:  #265069;
  --amber:     #ffbe3c;
}

[data-theme="paper"] {
  --bg:        #f8faf8;
  --bg-side:   #eff4f0;
  --bg-code:   #e8eeea;
  --border:    #afc8b9;
  --accent:    #289b55;
  --accent-dim:#5bb27a;
  --fg:        #1c211e;
  --fg-dim:    #58685f;
  --fg-muted:  #9baaa0;
  --amber:     #b97800;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */

nav {
  width: var(--side-w);
  min-width: var(--side-w);
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-muted) transparent;
}

nav::-webkit-scrollbar { width: 4px; }
nav::-webkit-scrollbar-track { background: transparent; }
nav::-webkit-scrollbar-thumb {
  background: var(--fg-muted);
  border-radius: 4px;
}
nav::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

.nav-logo {
  padding: 0 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.nav-logo .name {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-logo .tagline {
  font-size: 0.78rem;
  color: var(--fg-dim);
  margin-top: 2px;
}

.github-corner {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.github-corner:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}

.nav-section {
  padding: 0.5rem 1.5rem 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  font-weight: 600;
}

nav a {
  display: block;
  padding: 0.28rem 1.5rem;
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.12s, background 0.12s;
  border-left: 2px solid transparent;
}

nav a:hover {
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ── Theme switcher ──────────────────────────────────────────── */

.theme-switcher {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.theme-swatches {
  display: flex;
  gap: 8px;
  padding: 0.5rem 1.5rem 0;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.12s, border-color 0.12s;
  outline: none;
}

.swatch:hover { transform: scale(1.2); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch.active { border-color: var(--fg); }

/* ── Main content ────────────────────────────────────────────── */

main {
  flex: 1;
  min-width: 0;
  padding: 3.5rem 3rem 6rem;
  max-width: calc(var(--side-w) + var(--content-w));
}

.content {
  max-width: var(--content-w);
}

/* ── Typography ──────────────────────────────────────────────── */

h1 {
  font-family: var(--font-mono);
  font-size: 2rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
}

h1 .subtitle {
  display: block;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  color: var(--fg-dim);
  letter-spacing: 0;
  margin-top: 0.3rem;
}

h2 {
  font-size: 1.2rem;
  color: var(--fg);
  font-weight: 600;
  margin: 2.75rem 0 0.85rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 1.5rem;
}

h3 {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
  scroll-margin-top: 1.5rem;
}

p { margin-bottom: 0.85rem; color: var(--fg); }
p:last-child { margin-bottom: 0; }

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

/* ── Code ────────────────────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: var(--accent);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 0.85rem 0 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--fg);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ── Tables ──────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin: 0.75rem 0 1.1rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 0.45rem 1rem 0.45rem 0;
  font-weight: 600;
  color: var(--fg-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

td {
  padding: 0.4rem 1rem 0.4rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

td:first-child, th:first-child { min-width: 130px; }

td code { font-size: 0.8em; }

/* ── Callout / note ──────────────────────────────────────────── */

.note {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-left: 3px solid var(--accent-dim);
  border-radius: 0 6px 6px 0;
  padding: 0.7rem 1rem;
  margin: 0.85rem 0 1.1rem;
  font-size: 0.875rem;
  color: var(--fg-dim);
}

.note strong { color: var(--accent); }

.warn {
  background: color-mix(in srgb, var(--amber) 8%, transparent);
  border-left: 3px solid var(--amber);
  border-radius: 0 6px 6px 0;
  padding: 0.7rem 1rem;
  margin: 0.85rem 0 1.1rem;
  font-size: 0.875rem;
  color: var(--fg-dim);
}

.warn strong { color: var(--amber); }

/* ── Key badge ───────────────────────────────────────────────── */

kbd {
  font-family: var(--font-mono);
  font-size: 0.78em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.1em 0.45em;
  color: var(--fg);
  white-space: nowrap;
}

/* ── Section divider ─────────────────────────────────────────── */

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── Hamburger (hidden on desktop) ───────────────────────────── */

#menu-toggle {
  display: none;
}

#sidebar-overlay {
  display: none;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Hamburger button */
  #menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    position: fixed;
    top: 0.9rem;
    left: 1rem;
    z-index: 200;
    width: 36px;
    height: 36px;
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 8px;
  }

  #menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--fg-dim);
    border-radius: 2px;
    transition: transform 0.22s ease, opacity 0.22s ease;
  }

  body.nav-open #menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  body.nav-open #menu-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  body.nav-open #menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Dim overlay */
  #sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 140;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  body.nav-open #sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  body.nav-open { overflow: hidden; }

  /* Sidebar drawer */
  nav {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    min-width: unset;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border);
    padding: 2rem 0;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }

  body.nav-open nav {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }

  /* Main content: leave room for hamburger */
  main {
    padding: 4.5rem 1.25rem 4rem;
  }

  h1 { font-size: 1.5rem; }
}
