:root {
  --bg: #fafafb;
  --surface: #ffffff;
  --text: #3a3a3a;
  --muted: #6e6e6e;
  --border: #dcdcdc;
  --accent: oklch(0.6487 0.1538 150.3071);
  --accent-text: oklch(0.52 0.14 150);
  --code-bg: #f0f1f3;
  --note: oklch(0.6 0.14 255);
  --tip: oklch(0.6 0.15 150);
  --important: oklch(0.58 0.17 300);
  --warning: oklch(0.7 0.15 75);
  --caution: oklch(0.6 0.2 25);
  --font-sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #1f2023;
    --text: #e2e2e2;
    --muted: #a0a0a0;
    --border: #3a3b3f;
    --accent-text: oklch(0.75 0.15 150);
    --code-bg: #2a2b2f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font-sans);
}
a { color: var(--accent-text); }
a.external::after { content: " \2197"; font-size: 0.8em; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  height: 3.5rem; padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--text); font-weight: 700; text-decoration: none; white-space: nowrap;
}
.links { display: flex; gap: 1rem; margin-left: auto; font-size: 0.9rem; white-space: nowrap; }
.links a { color: var(--muted); text-decoration: none; }
.links a:hover { color: var(--accent-text); }
.nav-toggle {
  display: none; border: 0; background: none; color: var(--text);
  font-size: 1.4rem; cursor: pointer; padding: 0.25rem;
}

.search { position: relative; flex: 0 1 22rem; }
.search input {
  width: 100%; padding: 0.4rem 0.7rem;
  border: 1px solid var(--border); border-radius: 0.5rem;
  background: var(--bg); color: var(--text); font: inherit; font-size: 0.9rem;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.results {
  position: absolute; top: calc(100% + 0.4rem); left: 0; width: min(36rem, 90vw);
  max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.15);
}
.results a { display: block; padding: 0.6rem 0.8rem; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.results a:last-child { border-bottom: 0; }
.results a:hover, .results a.active { background: var(--code-bg); }
.results b { display: block; color: var(--accent-text); }
.results small { color: var(--muted); }
.results p { margin: 0.6rem 0.8rem; color: var(--muted); }
.results mark { background: none; color: inherit; font-weight: 700; }

.layout { display: flex; max-width: 90rem; margin: 0 auto; }
.sidebar {
  position: sticky; top: 3.5rem; align-self: flex-start;
  width: 17rem; flex: none; height: calc(100vh - 3.5rem); overflow-y: auto;
  padding: 1rem 0.5rem 2rem 1.5rem; font-size: 0.9rem;
  border-right: 1px solid var(--border);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar ul ul { padding-left: 0.9rem; }
.sidebar a { display: block; padding: 0.2rem 0.5rem; border-radius: 0.35rem; color: var(--text); text-decoration: none; }
.sidebar a:hover { background: var(--code-bg); }
.sidebar a[aria-current] { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar summary { display: flex; align-items: center; cursor: pointer; list-style: none; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::before {
  content: "\25B8"; flex: none; width: 1rem; margin-left: -1rem;
  color: var(--muted); transition: transform 0.15s;
}
.sidebar details[open] > summary::before { transform: rotate(90deg); }
.sidebar summary a { flex: 1; }
.sidebar > ul > li > a { margin-left: 0; }

.content { flex: 1; min-width: 0; padding: 1.5rem 2.5rem 3rem; }
article { max-width: 52rem; }
article h1, article h2, article h3, article h4 { line-height: 1.3; margin: 1.8em 0 0.6em; }
article h1 { font-size: 2rem; margin-top: 0.5rem; }
article h1, article h2 { padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
article h2 { font-size: 1.45rem; }
article h3 { font-size: 1.15rem; }
article h4 { font-size: 1rem; }
article img { max-width: 100%; height: auto; }
article code {
  font: 0.88em var(--font-mono); background: var(--code-bg);
  padding: 0.1em 0.35em; border-radius: 0.3em;
}
article pre { background: var(--code-bg); padding: 0.8rem 1rem; border-radius: 0.5rem; overflow-x: auto; }
article pre code { padding: 0; background: none; }
article hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
article blockquote { margin: 1rem 0; padding: 0.1rem 1rem; border-left: 4px solid var(--accent); color: var(--muted); }

article table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1rem 0; }
article th, article td { padding: 0.4rem 0.75rem; border: 1px solid var(--border); text-align: left; vertical-align: top; }
article th { background: var(--code-bg); }
.table-no-border th, .table-no-border td { border: 0; padding: 0.15rem 1.5rem 0.15rem 0; }
.table-no-border th { background: none; }

figure { margin: 1rem 0; }
figcaption { margin-top: 0.4rem; color: var(--muted); font-size: 0.9rem; font-style: italic; }
.image-single, .image-row { margin: 1rem 0; }
.image-row { display: flex; gap: 1rem; align-items: flex-start; }
.image-row figure { margin: 0; min-width: 0; }

.alert { margin: 1rem 0; padding: 0.6rem 1rem; border-left: 4px solid var(--c); border-radius: 0.35rem;
  background: color-mix(in oklab, var(--c) 10%, transparent); }
.alert > :last-child { margin-bottom: 0.4rem; }
.alert-title { margin: 0.2rem 0 0.3rem; font-weight: 700; color: var(--c); }
.alert-note { --c: var(--note); }
.alert-tip { --c: var(--tip); }
.alert-important { --c: var(--important); }
.alert-warning { --c: var(--warning); }
.alert-caution { --c: var(--caution); }

.pager { display: flex; gap: 1rem; max-width: 52rem; margin-top: 3rem; }
.pager a {
  flex: 1; padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: 0.5rem;
  text-decoration: none; color: var(--accent-text); font-weight: 600;
}
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--muted); font-weight: 400; }
.pager .next { text-align: right; margin-left: auto; }
footer { max-width: 52rem; margin-top: 2rem; color: var(--muted); font-size: 0.8rem; }

@media (max-width: 64rem) {
  .links { display: none; }
}
@media (max-width: 48rem) {
  .nav-toggle { display: block; }
  .brand span { display: none; }
  .search { flex: 1; }
  .sidebar {
    position: fixed; top: 3.5rem; left: 0; bottom: 0; z-index: 9;
    width: min(20rem, 85vw); height: auto;
    background: var(--surface); transform: translateX(-100%); transition: transform 0.2s;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 24px rgb(0 0 0 / 0.25); }
  .content { padding: 1rem 1rem 2rem; }
  .image-row { flex-wrap: wrap; }
  .pager { flex-direction: column; }
}
