:root {
  --bg: #fbfbf9;
  --sidebar: #f2f2ef;
  --text: #252525;
  --muted: #77756f;
  --faint: #a5a39d;
  --line: #deddd7;
  --accent: #58727c;
  --accent-soft: #e7eeee;
  --code-bg: #efefeb;
  --max-content: 760px;
  --left-width: 250px;
  --right-width: 220px;
  --radius: 8px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
  font-size: 17px;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover { color: #334f59; }

.left-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--left-width);
  padding: 28px 22px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 750;
  font-size: 22px;
  letter-spacing: -0.04em;
  margin-bottom: 28px;
}

.brand a { color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }

.search-wrap {
  position: relative;
  margin-bottom: 30px;
}

.search-wrap label {
  display: block;
  font: 600 11px/1.2 system-ui, sans-serif;
  color: var(--muted);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#site-search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 10px 11px;
  font: 14px system-ui, sans-serif;
  color: var(--text);
  outline: none;
}

#site-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 68px;
  max-height: 330px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 12px 30px rgba(0,0,0,.08);
  display: none;
  z-index: 50;
}

.search-results.open { display: block; }

.search-result {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.search-result:last-child { border-bottom: 0; }

.search-result:hover { background: var(--accent-soft); }

.result-title {
  display: block;
  font: 600 13px system-ui, sans-serif;
  color: var(--text);
}

.result-meta {
  display: block;
  margin-top: 2px;
  font: 11px/1.4 system-ui, sans-serif;
  color: var(--muted);
}

.no-results {
  padding: 12px;
  font: 13px system-ui, sans-serif;
  color: var(--muted);
}

.nav-group { margin-bottom: 25px; }

.nav-heading {
  font: 700 10px/1.2 system-ui, sans-serif;
  color: var(--faint);
  letter-spacing: .14em;
  margin: 0 0 8px 8px;
}

.nav-link {
  display: block;
  padding: 6px 9px;
  border-radius: 5px;
  color: #55534e;
  font: 14px/1.35 system-ui, sans-serif;
  text-decoration: none;
}

.nav-link:hover { background: rgba(255,255,255,.7); color: var(--text); }
.nav-link.active { background: #e5e5e0; color: var(--text); font-weight: 650; }

.sidebar-footer {
  margin-top: auto;
  padding: 22px 8px 0;
  color: var(--faint);
  font: 11px/1.5 system-ui, sans-serif;
}

.page-shell {
  min-height: 100vh;
  margin-left: var(--left-width);
  display: grid;
  grid-template-columns: minmax(0, var(--max-content)) var(--right-width);
  gap: 70px;
  justify-content: center;
  padding: 70px 50px 90px;
}

.content { min-width: 0; }

.page-header {
  padding-bottom: 28px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 13px;
  font: 700 11px/1.2 system-ui, sans-serif;
  letter-spacing: .15em;
  color: var(--accent);
}

h1, h2, h3 {
  font-weight: 650;
  letter-spacing: -.025em;
  line-height: 1.18;
  scroll-margin-top: 30px;
}

h1 {
  font-size: clamp(38px, 5vw, 58px);
  margin: 0 0 18px;
}

h2 {
  font-size: 30px;
  margin: 28px 0 15px;
}

h3 {
  font-size: 22px;
  margin: 38px 0 10px;
}

p { margin: 0 0 10px; }

.lede {
  color: var(--muted);
  font-size: 20px;
  line-height: 1.55;
  max-width: 680px;
}

ul, ol { padding-left: 28px; margin: 18px 0 28px; }
li { margin: 7px 0; }

.callout {
  margin: 28px 0;
  padding: 18px 20px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.callout p:last-child { margin-bottom: 0; }

code {
  font: 0.88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 2px 5px;
}

pre {
  overflow-x: auto;
  background: #252525;
  color: #eee;
  padding: 18px 20px;
  border-radius: var(--radius);
  margin: 22px 0 30px;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.page-footer {
  margin-top: 75px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 12px/1.5 system-ui, sans-serif;
}

.right-sidebar {
  position: sticky;
  top: 70px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.toc {
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.toc-title {
  font: 700 10px/1.2 system-ui, sans-serif;
  letter-spacing: .14em;
  color: var(--faint);
  margin-bottom: 12px;
}

.toc a {
  display: block;
  padding: 5px 0;
  color: var(--muted);
  font: 12px/1.45 system-ui, sans-serif;
  text-decoration: none;
}

.toc a:hover, .toc a.active { color: var(--accent); }

.mobile-menu {
  display: none;
}

@media (max-width: 1050px) {
  :root { --left-width: 220px; --right-width: 180px; }
  .page-shell { gap: 40px; padding-left: 35px; padding-right: 30px; }
}

@media (max-width: 820px) {
  .left-sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 12px 0 30px rgba(0,0,0,.08);
  }

  body.nav-open .left-sidebar { transform: translateX(0); }

  .mobile-menu {
    display: block;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 30;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg);
    color: var(--text);
    font-size: 18px;
  }

  .page-shell {
    margin-left: 0;
    display: block;
    padding: 80px 24px 60px;
  }

  .content { max-width: var(--max-content); margin: 0 auto; }

  .right-sidebar {
    position: static;
    max-height: none;
    margin-top: 45px;
  }

  .toc { border-left: 0; border-top: 1px solid var(--line); padding: 20px 0 0; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171817;
    --sidebar: #121312;
    --text: #e9e9e5;
    --muted: #aaa9a2;
    --faint: #77766f;
    --line: #33342f;
    --accent: #9ebbc5;
    --accent-soft: #243033;
    --code-bg: #292a27;
  }
  .nav-link { color: #aaa9a2; }
  .nav-link.active { background: #292a27; color: var(--text); }
  .nav-link:hover { background: #222320; }
  #site-search { background: #1c1d1b; color: var(--text); }
  .search-results { background: #1c1d1b; }
  .search-result:hover { background: var(--accent-soft); }
  .result-title { color: var(--text); }
}
