:root {
  --accent: #ff2d20;
  --accent-soft: #fff1f0;
  --bg: #ffffff;
  --panel: #fafafa;
  --fg: #1a1a1a;
  --muted: #667085;
  --line: #e7e7ea;
  --code-bg: #f7f8fa;
  --code-fg: #1f2937;
  --code-border: #e4e8ef;
  --code-bar-bg: #eef1f6;
  --code-muted: #6b7280;
  --code-number: #b3bccb;
  --code-hover: rgba(15, 23, 42, .045);
  --inline-bg: #f4f4f5;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  --header: 58px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: "JetBrains Mono", "JetBrains Mono NL", ui-monospace,
    SFMono-Regular, Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --accent: #ff6b5e;
  --accent-soft: rgba(255, 107, 94, .12);
  --bg: #0b0d12;
  --panel: #11141b;
  --fg: #e7e9ee;
  --muted: #9aa3b2;
  --line: #232833;
  --code-bg: #05070c;
  --code-fg: #dbe3f0;
  --code-border: #1b2130;
  --code-bar-bg: rgba(148, 163, 184, .08);
  --code-muted: #8b98ad;
  --code-number: #46536b;
  --code-hover: rgba(148, 163, 184, .07);
  --inline-bg: #1a1f2a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 16px; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── header ─────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 40; height: var(--header);
  display: flex; align-items: center; gap: 18px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; font-weight: 700; }
.brand span { color: var(--accent); }
.brand small { color: var(--muted); font-weight: 500; font-size: 12px; }
.search { margin-left: auto; position: relative; }
.search input {
  width: 260px; padding: 8px 12px 8px 32px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
  font: inherit; font-size: 14px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search::before {
  content: "⌕"; position: absolute; left: 11px; top: 7px; color: var(--muted);
  font-size: 15px;
}
.icon {
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 15px;
}
.icon:hover { border-color: var(--accent); color: var(--accent); }
.menu { display: none; }

/* ── layout ─────────────────────────────────────────────────────────── */
.shell {
  display: grid; grid-template-columns: 272px minmax(0, 1fr) 210px;
  max-width: 1420px; margin: 0 auto; gap: 32px; padding: 0 24px;
}
.sidebar {
  position: sticky; top: var(--header); align-self: start;
  height: calc(100vh - var(--header)); overflow-y: auto;
  padding: 26px 8px 40px 0; font-size: 14px;
}
.sidebar section { margin-bottom: 22px; }
.sidebar h4 {
  margin: 0 0 8px; color: var(--muted); font-size: 11px; letter-spacing: .09em;
  text-transform: uppercase; font-weight: 700;
}
.sidebar a {
  display: block; padding: 6px 10px; border-radius: 6px; color: var(--fg);
  border-left: 2px solid transparent;
}
.sidebar a:hover { background: var(--panel); text-decoration: none; }
.sidebar a.active {
  color: var(--accent); background: var(--accent-soft);
  border-left-color: var(--accent); font-weight: 600;
}
/* The navigation is long and the column is quiet: a default scrollbar is a wide
   grey bar next to it. It is drawn thin, with a transparent track, so only the
   thumb shows. */
.sidebar { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 999px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--muted); }

article { padding: 38px 0 80px; min-width: 0; max-width: 860px; }
article > h1 {
  font-size: 2.4rem; line-height: 1.2; margin: 0 0 26px;
  letter-spacing: -.02em;
}
article h2 {
  font-size: 1.55rem; margin: 46px 0 14px; padding-top: 10px; letter-spacing: -.01em;
}
article h3 { font-size: 1.18rem; margin: 30px 0 10px; }
article p, article li { color: var(--fg); }
article ul, article ol { padding-left: 24px; }
article li { margin: 5px 0; }
article li > ul, article li > ol { margin: 4px 0 4px 6px; }
article hr { border: 0; border-top: 1px solid var(--line); margin: 44px 0; }
article blockquote {
  margin: 22px 0; padding: 12px 18px; color: var(--muted);
  border-left: 3px solid var(--accent); background: var(--panel);
  border-radius: 0 8px 8px 0;
}
article blockquote p { margin: 6px 0; }
article img { max-width: 100%; }

.anchor { opacity: 0; margin-left: 8px; color: var(--muted); font-weight: 400; }
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor { opacity: 1; }

/* ── code and tables ────────────────────────────────────────────────── */
code {
  font-family: var(--mono); font-size: .88em; background: var(--inline-bg);
  padding: .15em .4em; border-radius: 5px; border: 1px solid var(--line);
}
pre {
  background: var(--code-bg); color: var(--code-fg); padding: 18px 20px;
  border-radius: 10px; overflow-x: auto; margin: 20px 0; box-shadow: var(--shadow);
}

/* code blocks: language bar, copy button, line numbers */
.code {
  margin: 22px 0; border-radius: 10px; overflow: hidden;
  background: var(--code-bg); border: 1px solid var(--code-border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.code-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; background: var(--code-bar-bg);
  border-bottom: 1px solid var(--code-border);
  color: var(--code-muted); font: 600 11px/1.6 var(--mono);
  letter-spacing: .09em; text-transform: uppercase;
}
.code-bar .copy {
  background: none; border: 0; color: var(--code-muted); cursor: pointer;
  font: inherit; letter-spacing: .06em; padding: 2px 4px; border-radius: 4px;
}
.code-bar .copy:hover { color: var(--accent); }
.code pre {
  margin: 0; padding: 12px 0; border-radius: 0; box-shadow: none;
  background: transparent; counter-reset: line;
}
.code code {
  display: block; background: none; border: 0; padding: 0;
  color: var(--code-fg); font-size: .87rem; line-height: 1.65;
}
.code .line {
  display: block; padding-right: 18px; min-height: 1.65em;
}
.code .line::before {
  counter-increment: line; content: counter(line);
  display: inline-block; width: 3.1em; margin-right: .9em;
  text-align: right; color: var(--code-number); user-select: none;
}
.code .line:hover { background: var(--code-hover); }

/* token colours: readable on a light page, brighter on the dark one */
.tok-comment { color: #77808f; font-style: italic; }
.tok-cmd { color: #1d4ed8; font-weight: 600; }
.tok-flag { color: #b45309; }
.tok-str { color: #15803d; }
.tok-var { color: #0e7490; }
.tok-num { color: #b91c1c; }
.tok-op { color: #7c3aed; }
.tok-kw { color: #be185d; font-weight: 600; }
.tok-key { color: #1d4ed8; }
[data-theme="dark"] .tok-comment { color: #6b7a90; }
[data-theme="dark"] .tok-cmd { color: #93c5fd; }
[data-theme="dark"] .tok-flag { color: #f0b37e; }
[data-theme="dark"] .tok-str { color: #a5e075; }
[data-theme="dark"] .tok-var { color: #7dd3fc; }
[data-theme="dark"] .tok-num { color: #fca5a5; }
[data-theme="dark"] .tok-op { color: #c4b5fd; }
[data-theme="dark"] .tok-kw { color: #f472b6; }
[data-theme="dark"] .tok-key { color: #93c5fd; }

table { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: .94rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted); font-size: .82rem;
  text-transform: uppercase; letter-spacing: .05em;
}
tbody tr:hover { background: var(--panel); }

/* ── table of contents ──────────────────────────────────────────────── */
.toc {
  position: sticky; top: var(--header); align-self: start;
  max-height: calc(100vh - var(--header)); overflow-y: auto;
  padding: 40px 0 40px; font-size: 13px;
}
.toc h4 {
  margin: 0 0 10px; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .09em;
}
.toc a { display: block; padding: 3px 0; color: var(--muted); }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc a.depth-3 { padding-left: 12px; }

/* ── footer navigation ──────────────────────────────────────────────── */
.pager { display: flex; gap: 16px; margin-top: 56px; }
.pager a, .pager span {
  flex: 1; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 18px; color: var(--fg);
}
.pager a:hover {
  border-color: var(--accent); box-shadow: var(--shadow);
  text-decoration: none;
}
.pager small {
  display: block; color: var(--muted); font-size: 12px;
  margin-bottom: 2px;
}
.pager .next { text-align: right; }
.pager .empty { visibility: hidden; }

.site-foot {
  border-top: 1px solid var(--line); margin-top: 40px; padding: 18px 24px;
  color: var(--muted); font-size: 13px; text-align: center;
}

/* ── small screens ──────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .shell { grid-template-columns: 244px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 0 18px; }
  .menu { display: inline-flex; align-items: center; justify-content: center; }
  .search { display: none; }
  .sidebar {
    position: fixed; top: var(--header); left: 0; z-index: 30; width: 280px;
    background: var(--bg); border-right: 1px solid var(--line);
    padding: 20px 14px; transform: translateX(-105%); transition: transform .18s;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  article { padding-top: 24px; }
  article > h1 { font-size: 1.9rem; }
}
