/* xeer.run — one stylesheet, no imports, no web fonts.
   Light and dark both come from `prefers-color-scheme`; `[data-theme]` on <html> overrides it when a
   reader has chosen explicitly, so the toggle wins in both directions. */

:root {
  --ink: #17161c;
  --ink-soft: #5c5a68;
  --ink-faint: #86838f;
  --page: #fbfaf8;
  --panel: #ffffff;
  --line: #e3e0da;
  --line-soft: #eeebe5;
  --accent: #b4380f;
  --accent-soft: #fdf1ec;
  --code-page: #f6f4f0;
  --shadow: 0 1px 2px rgba(23, 22, 28, .05), 0 8px 24px -16px rgba(23, 22, 28, .18);

  --tok-keyword: #9b2d76;
  --tok-string: #1f6b40;
  --tok-number: #8a4a05;
  --tok-comment: #83808c;
  --tok-name: #1b4f96;
  --tok-type: #7a4bb8;

  --measure: 46rem;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

:root[data-theme="dark"], :root:not([data-theme="light"]) {
  /* Overridden back below for light; kept together so the dark palette reads as one block. */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eceaf2;
    --ink-soft: #a7a4b2;
    --ink-faint: #837f8e;
    --page: #121116;
    --panel: #1a1920;
    --line: #2e2c36;
    --line-soft: #24232b;
    --accent: #ff8a5c;
    --accent-soft: #2a1a13;
    --code-page: #1c1b22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .7);

    --tok-keyword: #f19cd4;
    --tok-string: #86d9a5;
    --tok-number: #f0b678;
    --tok-comment: #857f92;
    --tok-name: #85bdf7;
    --tok-type: #c6a6f5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eceaf2;
  --ink-soft: #a7a4b2;
  --ink-faint: #837f8e;
  --page: #121116;
  --panel: #1a1920;
  --line: #2e2c36;
  --line-soft: #24232b;
  --accent: #ff8a5c;
  --accent-soft: #2a1a13;
  --code-page: #1c1b22;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .7);

  --tok-keyword: #f19cd4;
  --tok-string: #86d9a5;
  --tok-number: #f0b678;
  --tok-comment: #857f92;
  --tok-name: #85bdf7;
  --tok-type: #c6a6f5;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  /* An anchored heading should not land underneath the sticky masthead. */
  scroll-padding-top: 5rem;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }

.skip {
  position: absolute; left: -9999px;
  padding: .6rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: .4rem;
}
.skip:focus { left: 1rem; top: 1rem; z-index: 20; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: .2rem; }

/* ---------- masthead ---------- */

.masthead {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  color: var(--ink); text-decoration: none;
  font-weight: 640; font-size: 1.05rem; letter-spacing: -.01em;
}
.brand .logo { width: 1.15rem; height: 1.15rem; color: var(--accent); }

.masthead-links { margin-left: auto; display: flex; align-items: center; gap: clamp(.6rem, 2vw, 1.4rem); }
.masthead-links a {
  color: var(--ink-soft); text-decoration: none; font-size: .92rem;
}
.masthead-links a:hover { color: var(--ink); }

.theme, .menu {
  border: 1px solid var(--line); border-radius: .4rem; background: var(--panel);
  color: var(--ink-soft); font: inherit; font-size: .85rem; padding: .25rem .5rem; cursor: pointer;
}
.theme { line-height: 1; padding: .3rem .45rem; }
.theme:hover, .menu:hover { color: var(--ink); }
.menu { display: none; }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 13rem;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  max-width: 84rem;
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 4vw, 2.5rem) 4rem;
}
.shell-home { display: block; max-width: 74rem; padding-top: 0; }

main { min-width: 0; }

/* ---------- sidebar and toc ---------- */

.sidebar, .toc {
  position: sticky; top: 4.5rem; align-self: start;
  max-height: calc(100vh - 6rem); overflow-y: auto;
  font-size: .92rem;
}
.sidebar ul, .toc ul { list-style: none; margin: 0 0 1.4rem; padding: 0; }
.sidebar li, .toc li { margin: 0; }
.nav-title {
  margin: 0 0 .45rem; font-size: .72rem; font-weight: 680; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint);
}
.sidebar a, .toc a {
  display: block; padding: .26rem .6rem; margin-left: -.6rem;
  color: var(--ink-soft); text-decoration: none; border-radius: .35rem;
}
.sidebar a:hover, .toc a:hover { color: var(--ink); background: var(--line-soft); }
.sidebar a[aria-current="page"] {
  color: var(--accent); background: var(--accent-soft); font-weight: 560;
}
.toc { border-left: 1px solid var(--line); padding-left: 1rem; }
.toc .depth-3 a { padding-left: 1.2rem; font-size: .88rem; }
/* A heading that is a code span becomes a navigation label here, not a code chip. */
.sidebar code, .toc code {
  padding: 0; border: 0; background: none; font-size: .95em; white-space: normal;
}

/* ---------- prose ---------- */

main h1 {
  margin: 0 0 .6rem; font-size: clamp(2rem, 4.4vw, 2.7rem); line-height: 1.1;
  letter-spacing: -.025em; font-weight: 660;
}
main h2 {
  margin: 3rem 0 .8rem; font-size: 1.45rem; line-height: 1.25; letter-spacing: -.015em; font-weight: 640;
  padding-top: .6rem; border-top: 1px solid var(--line-soft);
}
main h3 { margin: 2.1rem 0 .6rem; font-size: 1.12rem; font-weight: 640; letter-spacing: -.01em; }
main h4 { margin: 1.6rem 0 .5rem; font-size: 1rem; font-weight: 640; }

main h2 .anchor, main h3 .anchor {
  float: left; margin-left: -1.1rem; width: 1.1rem;
  color: var(--ink-faint); text-decoration: none; opacity: 0; font-weight: 400;
}
main h2:hover .anchor, main h3:hover .anchor, .anchor:focus { opacity: 1; }

main p, main ul, main ol, main blockquote, main .table-scroll, main figure.code, main dl {
  max-width: var(--measure);
}
main p, main ul, main ol { margin: 0 0 1.1rem; }
main li { margin: 0 0 .35rem; }
main ul, main ol { padding-left: 1.4rem; }
main li > ul, main li > ol { margin-top: .35rem; }

main strong { font-weight: 640; }

blockquote {
  margin: 1.4rem 0; padding: .1rem 0 .1rem 1.1rem;
  border-left: 3px solid var(--accent); color: var(--ink-soft);
}
blockquote p:last-child { margin-bottom: 0; }

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

/* ---------- code ---------- */

code {
  font-family: var(--mono); font-size: .875em;
}
:not(pre) > code {
  padding: .12em .34em; border-radius: .3rem;
  background: var(--code-page); border: 1px solid var(--line-soft);
  white-space: nowrap;
}

figure.code {
  position: relative; margin: 1.4rem 0;
  background: var(--code-page); border: 1px solid var(--line); border-radius: .6rem;
  box-shadow: var(--shadow);
}
figure.code figcaption {
  padding: .4rem .85rem; border-bottom: 1px solid var(--line);
  font-size: .72rem; font-weight: 620; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint);
}
figure.code pre {
  margin: 0; padding: .9rem 1rem; overflow-x: auto;
  font-family: var(--mono); font-size: .855rem; line-height: 1.62; tab-size: 2;
}
figure.code pre code { font-size: inherit; background: none; border: 0; padding: 0; white-space: pre; }

.copy {
  position: absolute; top: .4rem; right: .5rem;
  padding: .2rem .5rem; border: 1px solid var(--line); border-radius: .35rem;
  background: var(--panel); color: var(--ink-soft);
  font: inherit; font-size: .72rem; cursor: pointer; opacity: 0; transition: opacity .12s;
}
figure.code:hover .copy, .copy:focus-visible { opacity: 1; }
.copy:hover { color: var(--ink); }
.copy[data-copied] { color: var(--tok-string); border-color: currentColor; opacity: 1; }

.hljs-keyword, .hljs-literal, .hljs-built_in, .hljs-selector-tag { color: var(--tok-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attr, .hljs-attribute { color: var(--tok-string); }
.hljs-number, .hljs-symbol, .hljs-meta { color: var(--tok-number); }
.hljs-comment, .hljs-quote { color: var(--tok-comment); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-section, .hljs-name, .hljs-variable { color: var(--tok-name); }
.hljs-type, .hljs-class .hljs-title, .hljs-title.class_, .hljs-params { color: var(--tok-type); }
.hljs-deletion { color: var(--accent); }
.hljs-property, .hljs-punctuation { color: inherit; }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; margin: 1.4rem 0; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; vertical-align: top; padding: .5rem .8rem; border-bottom: 1px solid var(--line-soft); }
th { font-weight: 640; color: var(--ink); border-bottom: 1px solid var(--line); white-space: nowrap; }
td code { white-space: nowrap; }

/* ---------- landing page ---------- */

.hero { padding: clamp(3rem, 9vw, 6rem) 0 2rem; }
.hero .eyebrow {
  margin: 0 0 1rem; font-size: .75rem; font-weight: 640; letter-spacing: .11em; text-transform: uppercase;
  color: var(--accent);
}
.hero h1 {
  margin: 0 0 1.1rem; max-width: 30ch;
  font-size: clamp(2.4rem, 6.4vw, 4.1rem); line-height: 1.03; letter-spacing: -.035em; font-weight: 680;
}
.hero .lede { max-width: 40rem; font-size: clamp(1.05rem, 2.2vw, 1.28rem); color: var(--ink-soft); }
.hero .lede strong { color: var(--ink); font-weight: 600; }

.cta { display: flex; flex-wrap: wrap; gap: .7rem; margin: 2rem 0 0; }
.cta a {
  display: inline-block; padding: .62rem 1.15rem; border-radius: .45rem;
  text-decoration: none; font-weight: 560; font-size: .96rem; border: 1px solid transparent;
}
.cta a.primary { background: var(--ink); color: var(--page); }
.cta a.primary:hover { background: var(--accent); }
.cta a.secondary { border-color: var(--line); color: var(--ink); background: var(--panel); }
.cta a.secondary:hover { border-color: var(--ink-faint); }

.home main > h2 {
  max-width: none; margin-top: 4rem; border-top: 0; padding-top: 0;
  font-size: clamp(1.5rem, 3vw, 1.9rem); letter-spacing: -.02em;
}
.home main > p, .home main > ul, .home main > ol { max-width: var(--measure); }

.grid {
  display: grid; gap: 1rem; margin: 1.5rem 0 0;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.grid .card {
  padding: 1.1rem 1.2rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: .6rem; box-shadow: var(--shadow);
}
.grid .card h3 { margin: 0 0 .4rem; font-size: 1rem; }
.grid .card p { margin: 0; font-size: .93rem; color: var(--ink-soft); }
.grid .card p + p { margin-top: .5rem; }
.grid .card a { font-weight: 560; }

.split { display: grid; gap: clamp(1.5rem, 4vw, 3rem); grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); align-items: start; }
.split > div { min-width: 0; }
.split h3 { margin-top: 0; }
.split figure.code { max-width: none; }

.note {
  margin: 2rem 0; padding: 1rem 1.2rem; max-width: var(--measure);
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: .5rem; font-size: .95rem;
}
.note p { margin: 0; }
.note p + p { margin-top: .6rem; }
.note strong { color: var(--ink); }

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--line);
  padding: 2rem clamp(1rem, 4vw, 2.5rem) 3rem;
  color: var(--ink-faint); font-size: .9rem;
}
.footer p { max-width: 84rem; margin: 0 auto .3rem; }
.footer a { color: var(--ink-soft); }

/* ---------- narrow ---------- */

@media (max-width: 60rem) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-top: 1.5rem; }
  .toc { display: none; }
  .menu { display: inline-block; order: 3; }
  .masthead-links { order: 4; }
  .masthead-links a { display: none; }
  .masthead-links a:last-of-type { display: inline; }
  .sidebar {
    position: static; max-height: none; overflow: visible;
    padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem;
  }
  .sidebar[hidden] { display: none; }
  .sidebar ul { margin-bottom: 1rem; }
}
