:root {
  --bg: #fbfaf8;
  --bg-soft: #f3f1ed;
  --bg-code: #f5f3ef;
  --border: #e4e0d8;
  --text: #1d1b18;
  --text-soft: #5e5a52;
  --text-faint: #8b867c;
  --accent: #c2410c;
  --accent-soft: #fdeee4;
  --note: #2563eb;
  --tip: #15803d;
  --warn: #b45309;
  --tok-keyword: #a626a4;
  --tok-string: #2f7d32;
  --tok-number: #b35c00;
  --tok-comment: #8b867c;
  --tok-title: #1f5fbf;
  --tok-attr: #9a5b00;
  --tok-tag: #c2410c;
  --shadow: 0 10px 30px rgb(29 27 24 / 0.12);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311;
    --bg-soft: #1c1a17;
    --bg-code: #1e1c19;
    --border: #2f2c27;
    --text: #ece8e1;
    --text-soft: #b3ada3;
    --text-faint: #7f796f;
    --accent: #fb8a4c;
    --accent-soft: #2e1d13;
    --note: #7aa7ff;
    --tip: #5fcf8a;
    --warn: #f0b45a;
    --tok-keyword: #d79ef0;
    --tok-string: #9ad08a;
    --tok-number: #f0b45a;
    --tok-comment: #7f796f;
    --tok-title: #7fb0ff;
    --tok-attr: #e8c07a;
    --tok-tag: #fb8a4c;
    --shadow: 0 10px 30px rgb(0 0 0 / 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141311;
  --bg-soft: #1c1a17;
  --bg-code: #1e1c19;
  --border: #2f2c27;
  --text: #ece8e1;
  --text-soft: #b3ada3;
  --text-faint: #7f796f;
  --accent: #fb8a4c;
  --accent-soft: #2e1d13;
  --note: #7aa7ff;
  --tip: #5fcf8a;
  --warn: #f0b45a;
  --tok-keyword: #d79ef0;
  --tok-string: #9ad08a;
  --tok-number: #f0b45a;
  --tok-comment: #7f796f;
  --tok-title: #7fb0ff;
  --tok-attr: #e8c07a;
  --tok-tag: #fb8a4c;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: conic-gradient(from 210deg, #f97316, #facc15, #22d3ee, #6366f1, #f97316);
  box-shadow: inset 0 0 0 5px var(--bg);
  outline: 1.5px solid var(--text);
}
.search { position: relative; margin-left: auto; width: min(340px, 100%); }
.search input {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.search input:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.search kbd {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 0 6px;
  font: 12px/18px var(--mono);
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.results {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow: auto;
}
.results a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.results a:hover, .results [aria-selected="true"] a { background: var(--accent-soft); text-decoration: none; }
.results strong { font-weight: 600; font-size: 14px; }
.results span { font-size: 12px; color: var(--text-faint); }
.results .empty { padding: 10px; color: var(--text-faint); font-size: 14px; }
.menu-button, .theme-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 18px;
  color: var(--text-soft);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.menu-button:hover, .theme-button:hover { color: var(--text); background: var(--bg-soft); }
.menu-button { display: none; }
.github {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px;
  font-size: 13.5px; color: var(--text-soft);
  border: 1px solid var(--border); border-radius: 8px;
}
.github:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.github > svg { width: 18px; height: 18px; }
.github .stars { display: flex; align-items: center; gap: 4px; padding-left: 8px; border-left: 1px solid var(--border); }
.github .stars[hidden] { display: none; }
.github .stars svg { width: 13px; height: 13px; color: #eab308; }
.github b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Three columns: navigation, the page, its contents */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  max-width: 1440px;
  margin: 0 auto;
}
.sidebar, .toc {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 28px 20px 40px;
}
.sidebar { border-right: 1px solid var(--border); }
.nav-section + .nav-section { margin-top: 22px; }
.nav-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sidebar ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: block;
  padding: 5px 10px;
  margin: 1px 0;
  font-size: 14.5px;
  color: var(--text-soft);
  border-radius: 6px;
}
.sidebar a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.sidebar a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.toc a { display: block; padding: 3px 0 3px 12px; font-size: 13.5px; color: var(--text-faint); border-left: 2px solid var(--border); }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
.toc .l3 a { padding-left: 24px; }

main { min-width: 0; padding: 40px 56px 80px; }
article { max-width: 760px; }

/* Prose */
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: 0.02em; }
h1 { margin: 0 0 20px; font-size: 40px; line-height: 1.15; letter-spacing: -0.025em; font-weight: 750; }
h2 { margin: 52px 0 14px; padding-top: 4px; font-size: 26px; line-height: 1.25; letter-spacing: -0.015em; }
h3 { margin: 34px 0 10px; font-size: 19px; line-height: 1.35; }
h4 { margin: 26px 0 8px; font-size: 16px; }
h2, h3, h4 { position: relative; }
.anchor { position: absolute; left: -22px; padding-right: 6px; color: var(--text-faint); opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: 1; text-decoration: none; }
p, ul, ol { margin: 0 0 16px; }
h1 + p { font-size: 18px; color: var(--text-soft); }
li { margin: 4px 0; }
li > ul, li > ol { margin: 4px 0 0; }
strong { font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
blockquote { margin: 0 0 16px; padding: 2px 18px; color: var(--text-soft); border-left: 3px solid var(--border); }

code {
  font: 0.86em/1.5 var(--mono);
  padding: 0.12em 0.38em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow-wrap: anywhere;
}
a code { color: inherit; }
pre {
  position: relative;
  margin: 0 0 20px;
  padding: 16px 18px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}
pre code { padding: 0; background: none; border: 0; font-size: 13.5px; line-height: 1.6; overflow-wrap: normal; }
.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  font: 12px/20px var(--sans);
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
pre:hover .copy, .copy:focus { opacity: 1; }
.copy:hover { color: var(--text); }

.table-wrap { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { font-weight: 600; background: var(--bg-soft); }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

.callout { margin: 0 0 20px; padding: 14px 18px; border: 1px solid var(--border); border-left: 3px solid var(--note); border-radius: 8px; background: var(--bg-soft); }
.callout p:last-child { margin-bottom: 0; }
.callout-title { margin: 0 0 4px; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--note); }
.callout.tip { border-left-color: var(--tip); }
.callout.tip .callout-title { color: var(--tip); }
.callout.warning { border-left-color: var(--warn); }
.callout.warning .callout-title { color: var(--warn); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 760px; margin-top: 64px; }
.pager a { display: flex; flex-direction: column; padding: 14px 18px; color: var(--text); font-weight: 600; border: 1px solid var(--border); border-radius: 10px; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager span { font-size: 12.5px; font-weight: 500; color: var(--text-faint); }
.pager-next { text-align: right; }

/* highlight.js tokens, in the page's palette */
.hljs-keyword, .hljs-built_in, .hljs-literal, .hljs-selector-tag, .hljs-meta .hljs-keyword { color: var(--tok-keyword); }
.hljs-string, .hljs-regexp, .hljs-meta .hljs-string { color: var(--tok-string); }
.hljs-number, .hljs-symbol, .hljs-variable.constant_ { color: var(--tok-number); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--tok-comment); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-selector-class, .hljs-selector-id { color: var(--tok-title); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-params, .hljs-selector-attr, .hljs-selector-pseudo { color: var(--tok-attr); }
.hljs-tag, .hljs-name, .hljs-type, .hljs-title.class_ { color: var(--tok-tag); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .menu-button { display: grid; }
  .search { flex: 1; min-width: 0; width: auto; }
  .search kbd { display: none; }
  .github .stars { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 60px 0 0 0;
    z-index: 15;
    width: auto;
    height: auto;
    background: var(--bg);
    border-right: 0;
    display: none;
  }
  .nav-open .sidebar { display: block; }
  main { padding: 28px 16px 64px; }
  h1 { font-size: 32px; }
  h2 { font-size: 23px; }
  .anchor { display: none; }
  .pager { grid-template-columns: 1fr; }
}
