:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #f6f7f9;
  --text: #1c2024;
  --text-muted: #5b6470;
  --border: #e2e5e9;
  --accent: #5b4ccc;
  --accent-text: #4a3db3;
  --accent-contrast: #ffffff;
  --code-bg: #f3f4f6;
  --pending-bg: #fff3c4;
  --pending-text: #6b4e00;
  --token-comment: #5f6770;
  --token-keyword: #8a3ffc;
  --token-string: #0b7a3e;
  --token-number: #9a4f00;
  --token-function: #1a5fd0;
  --token-property: #0a6f8a;
  --sidebar-width: 16rem;
  --content-width: 48rem;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-subtle: #171a21;
  --text: #e6e8eb;
  --text-muted: #9aa3ad;
  --border: #2a2f38;
  --accent: #9d8cff;
  --accent-text: #b3a6ff;
  --accent-contrast: #0f1115;
  --code-bg: #1b1f27;
  --pending-bg: #4a3a00;
  --pending-text: #ffe28a;
  --token-comment: #8b949e;
  --token-keyword: #c792ea;
  --token-string: #7ee2a8;
  --token-number: #f7b267;
  --token-function: #82aaff;
  --token-property: #7fdbca;
}

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

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
}

a {
  color: var(--accent-text);
}

.skip-link {
  position: absolute;
  left: -999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--bg);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.site-title {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.theme-toggle {
  font: inherit;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

.site-body {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - 3.5rem);
}

.sidebar {
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
}

.sidebar__heading {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar__heading:first-child {
  margin-top: 0;
}

.sidebar__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar__list a {
  display: block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  color: var(--text);
  text-decoration: none;
}

.sidebar__list a:hover {
  background: var(--border);
}

.sidebar__list a[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

.content {
  min-width: 0;
  padding: 2rem 2.5rem 4rem;
}

.prose {
  max-width: var(--content-width);
}

.prose h1 {
  margin: 0 0 1.5rem;
  font-size: 2rem;
  line-height: 1.2;
}

.prose h2 {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.5rem;
}

.prose h3 {
  margin: 2rem 0 0.75rem;
  font-size: 1.2rem;
}

.prose .header-anchor {
  color: inherit;
  text-decoration: none;
}

.prose .header-anchor:hover {
  text-decoration: underline;
}

.prose code {
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Long inline code in prose may wrap anywhere; tables scroll horizontally instead, so keep their code intact. */
.prose code:not(pre code, table code) {
  overflow-wrap: anywhere;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--code-bg);
  line-height: 1.5;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: 0.875rem;
}

.prose table {
  display: block;
  overflow-x: auto;
  margin: 1rem 0;
  border-collapse: collapse;
}

.prose th,
.prose td {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--bg-subtle);
}

.prose blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--bg-subtle);
}

.prose blockquote > :first-child {
  margin-top: 0;
}

.prose blockquote > :last-child {
  margin-bottom: 0;
}

.pending {
  padding: 0.05em 0.4em;
  border-radius: 0.25rem;
  background: var(--pending-bg);
  color: var(--pending-text);
  font-size: 0.85em;
  font-weight: 600;
}

.reference {
  margin-top: 1.5rem;
}

.token.comment,
.token.prolog {
  color: var(--token-comment);
}

.token.keyword,
.token.boolean,
.token.important {
  color: var(--token-keyword);
}

.token.string,
.token.attr-value {
  color: var(--token-string);
}

.token.number {
  color: var(--token-number);
}

.token.function,
.token.class-name {
  color: var(--token-function);
}

.token.property,
.token.variable,
.token.attr-name {
  color: var(--token-property);
}

@media (max-width: 48rem) {
  .site-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 1.5rem 1rem 3rem;
  }
}
