:root {
  --paper: #ffffff;
  --paper-raised: #ffffff;
  --paper-soft: #f5f5f5;
  --ink: #222222;
  --ink-soft: #444444;
  --ink-faint: #666666;
  --line: #e0e0e0;
  --line-strong: #b5b5b5;
  --accent: #245a92;
  --accent-bright: #174675;
  --accent-soft: #edf3f8;
  --amber: #b65f17;
  --code-bg: #17201f;
  --code-ink: #e5ece9;
  --sidebar-width: 248px;
  --topbar-height: 52px;
  --shadow-sm: none;
  --shadow-lg: 0 24px 70px rgb(24 33 31 / 16%);
  --font-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: var(--font-sans);
  --font-display: system-ui, -apple-system, "PingFang SC", sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

html[data-theme="dark"] {
  --paper: #171717;
  --paper-raised: #1d1d1d;
  --paper-soft: #252525;
  --ink: #ededed;
  --ink-soft: #bcbcbc;
  --ink-faint: #a0a0a0;
  --line: #383838;
  --line-strong: #555555;
  --accent: #91b9e6;
  --accent-bright: #bbd6f5;
  --accent-soft: #253345;
  --amber: #eea35e;
  --code-bg: #0b100f;
  --code-ink: #e5ece9;
  --shadow-sm: none;
  --shadow-lg: 0 24px 70px rgb(0 0 0 / 45%);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --paper: #171717;
    --paper-raised: #1d1d1d;
    --paper-soft: #252525;
    --ink: #ededed;
    --ink-soft: #bcbcbc;
    --ink-faint: #a0a0a0;
    --line: #383838;
    --line-strong: #555555;
    --accent: #91b9e6;
    --accent-bright: #bbd6f5;
    --accent-soft: #253345;
    --amber: #eea35e;
    --code-bg: #0b100f;
    --code-ink: #e5ece9;
    --shadow-sm: none;
    --shadow-lg: 0 24px 70px rgb(0 0 0 / 45%);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: auto;
  scroll-padding-top: calc(var(--topbar-height) + 24px);
  background: var(--paper);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
  --pagefind-ui-scale: 0.88;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--ink);
  --pagefind-ui-background: var(--paper-raised);
  --pagefind-ui-border: var(--line);
  --pagefind-ui-tag: var(--accent-soft);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 8px;
  --pagefind-ui-font: var(--font-sans);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}

.sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper-raised) 94%, transparent);
  backdrop-filter: none;
}

.brand-row {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 5px;
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

/* A plain button stands in for the search widget until its bundle is fetched. */
.sidebar-search {
  position: relative;
  display: flex;
  min-height: 42px;
  align-items: center;
  cursor: pointer;
  margin: 5px 16px 14px;
  padding: 0 9px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-faint);
  background: var(--paper-soft);
  gap: 8px;
  text-align: left;
}

.sidebar-search:hover {
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.search-icon {
  font-size: 15px;
  line-height: 1;
}

.search-placeholder {
  flex: 1;
  font-size: 12px;
}

body.search-loading .search-placeholder::after {
  content: " ·";
  animation: search-pulse 900ms steps(3, end) infinite;
}

@keyframes search-pulse {
  to { content: " ···"; }
}

/*
 * The trigger widget stays offscreen and is clicked programmatically; the modal
 * itself must stay outside this container, since clip-path also clips
 * fixed-position descendants.
 */
.pagefind-host {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  pointer-events: none;
}

.sidebar-search kbd {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink-faint);
  background: var(--paper-raised);
  font-family: var(--font-sans);
  font-size: 10px;
  box-shadow: 0 1px 0 var(--line-strong);
}

.primary-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 11px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.nav-group {
  margin: 2px 0 8px;
}

.nav-group summary {
  display: flex;
  cursor: pointer;
  list-style: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.nav-count {
  display: grid;
  min-width: 22px;
  height: 20px;
  place-items: center;
  border-radius: 10px;
  color: var(--ink-faint);
  background: var(--paper-soft);
  font-size: 10px;
  letter-spacing: 0;
}

.nav-home {
  display: flex;
  justify-content: space-between;
  margin: 0 0 12px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
}
.nav-home span { color: var(--ink-faint); }
.nav-home:hover, .nav-home[aria-current] { color: var(--accent); }
.nav-group summary::after { content: "›"; margin-left: 9px; color: var(--ink-faint); font-size: 15px; }
.nav-group[open] > summary::after { transform: rotate(90deg); }
.nav-group summary .nav-count { margin-left: auto; }
.nav-overview { display: flex; justify-content: space-between; margin: 3px 9px 7px; padding-block: 4px; color: var(--accent); font-size: 11px; }
.nav-overview:hover { text-decoration: underline; }
.nav-overview[aria-current] { font-weight: 650; }

.nav-group-links {
  position: relative;
  margin: 2px 0 7px 10px;
  padding-left: 12px;
}

.nav-group-links::before {
  position: absolute;
  inset: 3px auto 3px 0;
  width: 1px;
  background: var(--line);
  content: "";
}

.nav-note {
  position: relative;
  display: block;
  margin: 1px 0;
  padding: 6px 9px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

.nav-note::before {
  position: absolute;
  top: 50%;
  left: -15px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-strong);
  content: "";
  transform: translateY(-50%);
}

.nav-note:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.nav-note.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
}

.nav-note.is-active::before {
  width: 7px;
  height: 7px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sidebar-footer {
  display: flex;
  justify-content: space-between;
  padding: 13px 20px 17px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 11px;
}

.sidebar-footer a:hover {
  color: var(--accent);
}

.sidebar .sidebar-close {
  display: none;
}

.site-shell {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: none;
}

.breadcrumb {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  cursor: pointer;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: var(--ink-soft);
  background: transparent;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.menu-button {
  display: none;
  align-content: center;
  gap: 4px;
}

.menu-button span {
  display: block;
  width: 17px;
  height: 1.5px;
  background: currentColor;
}

.theme-button span {
  position: absolute;
  transition: opacity 160ms ease, transform 160ms ease;
}

.theme-moon,
html[data-theme="dark"] .theme-sun {
  opacity: 0;
  transform: scale(0.7) rotate(-20deg);
}

html[data-theme="dark"] .theme-moon {
  opacity: 1;
  transform: scale(1) rotate(0);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .theme-sun {
    opacity: 0;
    transform: scale(0.7) rotate(-20deg);
  }

  html[data-theme="auto"] .theme-moon {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

.compact-search {
  display: none;
  font-size: 17px;
}

.page-grid {
  display: grid;
  width: min(100%, 1240px);
  margin: 0 auto;
  grid-template-columns: minmax(0, 920px);
  justify-content: center;
}

.page-grid.has-toc {
  width: min(100%, 1320px);
  grid-template-columns: minmax(0, 900px) 220px;
  gap: 46px;
}

.main-content {
  min-width: 0;
  padding: 62px 46px 90px;
}

.toc {
  position: sticky;
  top: calc(var(--topbar-height) + 34px);
  max-height: calc(100vh - var(--topbar-height) - 60px);
  align-self: start;
  overflow-y: auto;
  margin-top: 66px;
  padding-right: 18px;
  color: var(--ink-faint);
  scrollbar-width: thin;
}

.toc > p {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toc nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 13px;
}

.toc nav::before {
  position: absolute;
  inset: 4px auto 4px 0;
  width: 1px;
  background: var(--line);
  content: "";
}

.toc-link {
  position: relative;
  padding: 4px 0;
  font-size: 11px;
  line-height: 1.5;
  transition: color 120ms ease;
}

.toc-link.level-3 {
  padding-left: 11px;
  font-size: 10.5px;
}

.toc-link:hover,
.toc-link.is-active {
  color: var(--accent);
}

.toc-link.is-active::before {
  position: absolute;
  top: 9px;
  left: -16px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--paper);
  content: "";
}

.back-to-top {
  display: inline-block;
  margin: 20px 0 0 13px;
  font-size: 10px;
}

.back-to-top:hover {
  color: var(--accent);
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 25px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.note-meta > * + * {
  position: relative;
}

.note-meta > * + *::before {
  position: absolute;
  top: 50%;
  left: -9px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--line-strong);
  content: "";
}

.note-meta a:hover {
  color: var(--accent);
}

.category-pill {
  padding: 3px 8px;
  border-radius: 12px;
  color: var(--accent);
  background: var(--accent-soft);
}

.note-meta .category-pill::before {
  display: none;
}

.prose {
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.88;
  /* `anywhere` used to split identifiers like "Transformer" mid-word. */
  overflow-wrap: break-word;
}

.prose p {
  text-wrap: pretty;
}

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

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  color: var(--ink);
  text-wrap: balance;
}

.prose h1 {
  max-width: 820px;
  margin: 0 0 22px;
  font-family: var(--font-serif);
  font-size: clamp(1.85rem, 3.4vw, 2.5rem);
  font-weight: 620;
  line-height: 1.24;
  letter-spacing: -0.018em;
}

.prose h2 {
  margin: 52px 0 16px;
  padding-top: 4px;
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  font-weight: 620;
  line-height: 1.38;
  letter-spacing: -0.012em;
}

.prose h3 {
  margin: 32px 0 12px;
  font-size: 1.125rem;
  font-weight: 680;
  line-height: 1.5;
}

.prose h4 {
  margin: 24px 0 8px;
  font-size: 0.98rem;
  font-weight: 680;
}

.prose p,
.prose ul,
.prose ol {
  margin: 15px 0;
}

.prose li + li {
  margin-top: 7px;
}

.prose strong {
  color: var(--ink);
  font-weight: 720;
}

.prose em {
  color: var(--ink);
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 34%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose a:hover {
  color: var(--accent-bright);
  text-decoration-color: currentColor;
}

.prose .external-link::after {
  margin-left: 3px;
  content: "↗";
  font-size: 0.72em;
  text-decoration: none;
}

.prose a.citation {
  padding: 0.12em 0.18em;
  border-radius: 3px;
  font-size: 0.76em;
  line-height: 0;
  vertical-align: super;
  white-space: nowrap;
  text-decoration: none;
}

.prose a.citation:hover,
.prose a.citation:focus-visible {
  background: var(--accent-soft);
}

.prose ol:has([id^="ref-"]) {
  padding-left: 1.7em;
  color: var(--ink-soft);
  font-size: 0.9em;
  line-height: 1.8;
}

.prose [id^="ref-"] {
  scroll-margin-top: 90px;
}

.prose hr {
  width: 72px;
  margin: 60px 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
}

.prose blockquote {
  position: relative;
  margin: 26px 0;
  padding: 18px 22px 18px 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--accent-soft) 46%, transparent);
}

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

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

.prose code:not(pre code) {
  padding: 0.16em 0.38em;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 5px;
  color: color-mix(in srgb, var(--amber) 80%, var(--ink));
  background: var(--paper-soft);
  font-family: var(--font-mono);
  font-size: 0.84em;
}

.prose pre {
  position: relative;
  overflow: auto;
  margin: 25px 0;
  padding: 46px 21px 19px;
  border: 1px solid color-mix(in srgb, #fff 8%, transparent);
  border-radius: 12px;
  color: var(--code-ink);
  background: var(--code-bg);
  box-shadow: var(--shadow-sm);
  line-height: 1.62;
  scrollbar-width: thin;
}

.prose pre::before {
  position: absolute;
  top: 14px;
  left: 18px;
  color: #82908b;
  content: attr(data-language);
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.prose pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 12.5px;
  tab-size: 2;
}

.copy-button {
  position: absolute;
  z-index: 1;
  top: 9px;
  right: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 5px;
  color: #9dacA7;
  background: rgb(255 255 255 / 5%);
  font-size: 9px;
}

.copy-button:hover {
  color: #fff;
  background: rgb(255 255 255 / 10%);
}

.table-scroll {
  overflow-x: auto;
  margin: 26px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm);
}

.prose table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.55;
}

.prose th,
.prose td {
  padding: 11px 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose th:last-child,
.prose td:last-child {
  border-right: 0;
}

.prose tr:last-child td {
  border-bottom: 0;
}

.prose th {
  color: var(--ink);
  background: var(--paper-soft);
  font-size: 11px;
  font-weight: 750;
}

.image-zoom {
  display: block;
  width: 100%;
  cursor: zoom-in;
  padding: 0;
  border: 0;
  margin: 28px 0;
  background: none;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 28px auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.image-zoom img {
  margin: 0 auto;
}

.prose .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 24px 0;
  padding: 10px 2px;
  color: var(--ink);
}

.prose .katex {
  color: var(--ink);
  font-size: 1.03em;
}

.pager {
  display: grid;
  margin-top: 80px;
  padding-top: 25px;
  border-top: 1px solid var(--line);
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.pager-card {
  display: flex;
  min-height: 106px;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease, transform 150ms ease;
}

.pager-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.pager-card.next {
  text-align: right;
}

.pager-card span {
  color: var(--ink-faint);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pager-card strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.image-dialog {
  width: min(94vw, 1500px);
  max-width: none;
  height: min(92vh, 1000px);
  max-height: none;
  padding: 48px 25px 24px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--ink);
  background: var(--paper-raised);
  box-shadow: var(--shadow-lg);
}

.image-dialog::backdrop {
  background: rgb(5 10 9 / 76%);
  backdrop-filter: blur(5px);
}

.image-dialog img {
  display: block;
  width: 100%;
  height: calc(100% - 35px);
  object-fit: contain;
}

.image-dialog p {
  margin: 9px 0 0;
  color: var(--ink-faint);
  font-size: 11px;
  text-align: center;
}

.image-dialog-close {
  position: absolute;
  top: 9px;
  right: 12px;
  width: 31px;
  height: 31px;
  cursor: pointer;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper-soft);
  font-size: 20px;
}

.sidebar-scrim {
  display: none;
}

@media (max-width: 1180px) {
  .page-grid.has-toc {
    width: min(100%, 970px);
    grid-template-columns: minmax(0, 900px);
  }

  .toc {
    display: none;
  }

  .main-content {
    padding-right: 52px;
    padding-left: 52px;
  }
}

@media (max-width: 900px) {
    .sidebar {
    width: min(86vw, 310px);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.menu-open {
    overflow: hidden;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar .sidebar-close {
    display: grid;
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 45;
    inset: 0;
    background: rgb(5 10 9 / 55%);
    backdrop-filter: blur(2px);
  }

  body.menu-open .sidebar-scrim {
    display: block;
  }

  .site-shell {
    margin-left: 0;
  }

  .menu-button {
    display: grid;
  }

  .compact-search {
    display: block;
  }

  .topbar {
    padding: 0 15px;
  }

  .breadcrumb {
    max-width: 55vw;
    margin-right: auto;
    margin-left: 8px;
  }

  .main-content {
    padding: 44px 28px 70px;
  }

  .category-card:last-child {
    grid-column: span 2;
  }
}

@media (max-width: 620px) {
  .main-content {
    padding: 35px 18px 58px;
  }

  .breadcrumb {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .prose {
    font-size: 15px;
    line-height: 1.82;
  }

  .prose h1 {
    margin-bottom: 18px;
    font-size: 1.7rem;
  }

  .prose h2 {
    margin-top: 42px;
    font-size: 1.3rem;
  }

  .prose blockquote {
    margin-right: -4px;
    margin-left: -4px;
    padding: 15px 17px;
  }

  .prose pre {
    margin-right: -8px;
    margin-left: -8px;
    border-radius: 8px;
  }

  .note-meta {
    gap: 7px 13px;
  }

  .note-meta > * + *::before {
    left: -7px;
  }

  .pager {
    display: block;
  }

  .pager-card {
    min-height: 90px;
    margin-top: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ==========================================================================
   Accessibility & navigation affordances
   ========================================================================== */

.skip-link {
  position: fixed;
  z-index: 200;
  top: 8px;
  left: 8px;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  background: var(--paper-raised);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 700;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

/* One visible focus ring for every interactive element on the site. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-note:focus-visible,
.toc-link:focus-visible {
  outline-offset: -2px;
}

.main-content:focus {
  outline: none;
}

/* Section anchors: `#s1`-style aliases sit just above their heading. */
.section-alias {
  display: block;
  height: 0;
  scroll-margin-top: calc(var(--topbar-height) + 24px);
}

.prose :is(h2, h3, h4) {
  position: relative;
  scroll-margin-top: calc(var(--topbar-height) + 24px);
}

.heading-link {
  position: absolute;
  top: 50%;
  right: 100%;
  padding-right: 8px;
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: 0.6em;
  font-weight: 700;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 120ms ease;
}

.prose :is(h2, h3, h4):hover .heading-link,
.heading-link:focus-visible {
  opacity: 1;
}

.heading-link:hover {
  color: var(--accent);
}

@media (max-width: 1180px) {
  /* No gutter to hang the anchor in — put it after the text instead. */
  .heading-link {
    position: static;
    display: inline-block;
    padding-right: 0;
    padding-left: 8px;
    transform: none;
  }
}

/* Inline TOC — the standing-in navigation when the rail TOC is hidden. */
.toc-inline {
  display: none;
  margin: 0 0 30px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-raised);
}

.toc-inline summary {
  display: flex;
  cursor: pointer;
  list-style: none;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.toc-inline summary::-webkit-details-marker {
  display: none;
}

.toc-inline summary::after {
  margin-left: 10px;
  color: var(--ink-faint);
  content: "▾";
  font-size: 11px;
  transition: transform 150ms ease;
}

.toc-inline[open] summary::after {
  transform: rotate(180deg);
}

.toc-inline summary small {
  margin-left: auto;
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.toc-inline nav {
  display: flex;
  flex-direction: column;
  padding: 0 16px 14px;
  gap: 1px;
}

.toc-inline .toc-link {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
}

.toc-inline .toc-link.level-3 {
  padding-left: 14px;
  font-size: 11px;
}

@media (max-width: 1180px) {
  .toc-inline {
    display: block;
  }
}

/* Wide tables scroll in a focusable region so keyboard users can reach them. */
.table-scroll:focus-visible {
  outline-offset: 2px;
}

.prose thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Long formulas scroll rather than overflow the column. */
.prose .katex-display {
  scrollbar-width: thin;
}

/* Reading layout: quiet navigation and a single text column. */
.brand-row { min-height: 66px; }
.brand small { font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.sidebar { background: var(--paper); }
.topbar { background: var(--paper); }
.breadcrumb { font-size: 13px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.sidebar-search { border-radius: 4px; background: var(--paper); }
.nav-note { border-radius: 3px; }
.page-grid { max-width: 860px; }
.page-grid.has-toc { max-width: 1130px; grid-template-columns: minmax(0, 820px) 190px; gap: 24px; }
.main-content { padding: 36px 38px 64px; }
.toc { margin-top: 40px; }
.note-meta { font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; margin-bottom: 20px; }
.category-pill { padding: 0; border-radius: 0; background: none; }
.prose { color: var(--ink); line-height: 1.8; }
.prose h1 { font-size: 28px; font-weight: 650; line-height: 1.4; }
.prose h2 { margin-top: 36px; font-size: 21px; font-weight: 650; }
.prose h3 { font-size: 18px; }
.prose blockquote { padding: 4px 16px; border: 0; border-left: 2px solid var(--line-strong); border-radius: 0; background: none; }
.prose pre, .prose img, .table-scroll { border-radius: 3px; box-shadow: none; }
.prose code:not(pre code) { color: var(--ink); border: 0; border-radius: 2px; }
.prose hr { width: 100%; margin: 32px 0; border-color: var(--line); }
.prose .katex-display { margin: 18px 0; }
.pager { margin-top: 42px; }
.pager-card { min-height: 64px; padding: 8px 0; border: 0; border-radius: 0; background: none; box-shadow: none; gap: 8px; }
.pager-card:hover { transform: none; }
.pager-card:hover strong { color: var(--accent); text-decoration: underline; }
.overview { margin: 16px 0 24px; }
.overview > summary { cursor: pointer; color: var(--ink-soft); font-size: 14px; }
.overview[open] > summary { margin-bottom: 16px; }
.overview .native-diagram { margin-top: 0; }
.prose .note-supplement { border-top: 1px solid var(--line); padding: 12px 0; }
.prose .note-supplement > summary { cursor: pointer; font-size: 15px; line-height: 1.7; }
.prose .note-supplement[open] > summary { margin-bottom: 18px; color: var(--accent); }
.index-header { margin: 0 0 32px; }
.index-header h1 { margin: 0 0 10px; font-size: 28px; font-weight: 650; }
.index-header p { margin: 0; color: var(--ink-soft); }
.index-section { margin-top: 32px; }
.index-section h2 { margin: 0 0 14px; font-size: 18px; font-weight: 650; }
.topic-list, .recent-notes, .note-list { list-style: none; padding: 0; margin: 0; }
.topic-list li, .note-list li { padding: 13px 0; border-bottom: 1px solid var(--line); }
.topic-list a, .recent-notes a, .note-list a { color: var(--accent); text-underline-offset: 3px; }
.topic-list a:hover, .recent-notes a:hover, .note-list a:hover { text-decoration: underline; }
.topic-list span { display: block; margin-top: 4px; color: var(--ink-soft); font-size: 13px; }
.recent-notes li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 7px 0; }
.recent-notes small { flex-shrink: 0; color: var(--ink-faint); font-size: 12px; }
.note-list h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.note-list p { margin: 0; color: var(--ink-soft); font-size: 14px; }

/* Topic discovery and a reading order that follows each existing series. */
.home-header { padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.index-header .index-eyebrow { margin-bottom: 12px; color: var(--ink-faint); font: 10px/1.6 var(--font-mono); letter-spacing: .12em; }
.index-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; margin-top: 18px; color: var(--ink-faint); font-size: 12px; }
.index-meta a, .search-link { color: var(--accent); }
.search-link { padding: 0; border: 0; background: transparent; font-size: inherit; cursor: pointer; }
.search-link:hover, .index-meta a:hover { text-decoration: underline; text-underline-offset: 3px; }
.index-back { display: inline-block; margin-bottom: 18px; color: var(--accent); font-size: 12px; }
.topic-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 32px; }
.topic-list li { display: flex; padding: 0; }
.topic-list .topic-entry { display: flex; flex: 1; min-width: 0; align-items: flex-start; gap: 13px; padding: 19px 0; color: var(--ink); }
.topic-list .topic-entry:hover { text-decoration: none; }
.topic-list .topic-entry:hover strong { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.topic-list .topic-number { flex-shrink: 0; margin-top: 3px; color: var(--ink-faint); font: 10px/1.7 var(--font-mono); }
.topic-list .topic-body { display: block; min-width: 0; margin: 0; }
.topic-list .topic-heading { display: flex; gap: 12px; align-items: baseline; margin: 0; color: var(--ink); }
.topic-heading strong { font-size: 15px; font-weight: 600; }
.topic-heading small { flex-shrink: 0; margin-left: auto; color: var(--ink-faint); font-size: 11px; }
.topic-list .topic-description { margin-top: 7px; color: var(--ink-soft); font-size: 12px; line-height: 1.75; }
.section-heading h2 { margin-bottom: 5px; }
.section-heading > p { margin: 0 0 18px; color: var(--ink-faint); font-size: 12px; }
.reading-routes { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 19px 30px; list-style: none; padding: 0; margin: 0; }
.reading-routes > li { padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.reading-routes h3 { margin: 0 0 7px; font-size: 13px; font-weight: 600; }
.reading-routes ol { display: flex; flex-wrap: wrap; gap: 5px 8px; padding: 0; margin: 0; list-style: none; color: var(--ink-soft); font-size: 12px; line-height: 1.8; }
.reading-routes ol li:not(:last-child)::after { content: "→"; margin-left: 8px; color: var(--ink-faint); }
.reading-routes a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.recent-notes li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.recent-notes a { font-size: 14px; }
.recent-category { display: block; margin-top: 3px; color: var(--ink-faint); font-size: 11px; }
.recent-notes time { flex-shrink: 0; color: var(--ink-faint); font: 11px/1.6 var(--font-mono); }
.note-list li { display: grid; grid-template-columns: 26px minmax(0,1fr); column-gap: 16px; padding: 20px 0; }
.note-number { padding-top: 3px; color: var(--ink-faint); font: 11px/1.6 var(--font-mono); }
.note-list-meta { display: flex; flex-wrap: wrap; gap: 5px 16px; margin-top: 9px; color: var(--ink-faint); font-size: 11px; }
.note-navigation { margin-top: 42px; padding-top: 18px; border-top: 1px solid var(--line); }
.pager-context { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; color: var(--ink-faint); font-size: 12px; }
.pager-context a { color: var(--accent); }
.note-navigation .pager { margin-top: 16px; }
.prose .toc-inline { margin: 0 0 28px; }
.prose .toc-inline .toc-link { text-decoration: none; }
@media (max-width: 1180px) {
  .page-grid.has-toc { max-width: 860px; grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .main-content { padding: 26px 20px 48px; }
  .prose h1, .index-header h1 { font-size: 25px; }
  .prose h2 { font-size: 20px; }
  .prose blockquote, .prose pre { margin-left: 0; margin-right: 0; }
  .recent-notes li { display: block; }
  .recent-notes small { display: block; margin-top: 2px; }
  .topic-list, .reading-routes { grid-template-columns: minmax(0,1fr); }
  .topic-list .topic-entry { padding-block: 16px; }
  .recent-notes time { display: block; margin-top: 4px; }
  .index-meta { column-gap: 16px; }
}

.sidebar-close { display: none; }
.toc-inline { border-radius: 3px; }
@media (max-width: 900px) { .sidebar-close { display: grid; } }

/* Topic groups and reading contracts share the existing quiet reading style. */
.nav-subgroup { margin: 7px 0 12px; }
.nav-subgroup-label { display: block; padding: 5px 10px; color: var(--ink-faint); font-size: 10px; line-height: 1.5; }
.nav-subgroup-label:hover { color: var(--accent); }
.nav-subgroup .nav-note { padding-left: 14px; }
.nav-section { margin: 4px 0 9px; }
.nav-section-label { display: block; padding: 5px 14px 3px; color: var(--ink-soft); font-size: 10px; line-height: 1.5; }
.nav-section-label:hover { color: var(--accent); }
.nav-section .nav-note { padding-left: 22px; }
.sidebar-footer { flex-wrap: wrap; gap: 8px 16px; }
.topic-intro { margin-top: 28px; padding: 20px 0; border-block: 1px solid var(--line); }
.topic-intro h2 { margin: 0 0 10px; font-size: 17px; }
.topic-intro p { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; }
.topic-intro .topic-scope { color: var(--ink-faint); font-size: 13px; }
.topic-jumps { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; font-size: 13px; color: var(--accent); }
.topic-jumps a:hover, .topic-related a:hover, .note-routes a:hover { text-decoration: underline; text-underline-offset: 3px; }
.topic-section { scroll-margin-top: calc(var(--topbar-height) + 20px); }
.topic-group-description { margin: -4px 0 6px; color: var(--ink-soft); font-size: 14px; line-height: 1.7; }
.topic-subsection { margin-top: 24px; scroll-margin-top: calc(var(--topbar-height) + 20px); }
.topic-subsection > h3 { margin: 0 0 4px; color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.note-list h3, .note-list h4 { margin: 0 0 6px; font-size: 17px; font-weight: 600; line-height: 1.55; }
.note-list-meta .content-status { color: var(--amber); }
.reading-routes > li > p { margin: 0 0 12px; color: var(--ink-faint); font-size: 13px; line-height: 1.7; }
.reading-routes > li > .route-gap { margin-top: 10px; font-size: 12px; }
.route-gap { color: var(--ink-soft); border-left: 2px solid var(--amber); padding: 0 0 0 14px; font-size: 14px; }
.topic-related { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px 28px; }
.topic-related a { color: var(--accent); font-size: 14px; font-weight: 600; }
.topic-related p { margin: 7px 0 0; color: var(--ink-faint); font-size: 13px; }
.reading-brief { margin: 18px 0 24px; }
.prose .reading-brief blockquote { margin: 0; padding: 0 0 0 16px; font-size: 14px; line-height: 1.75; color: var(--ink-soft); }
.prose .reading-brief p { margin: 0 0 7px; }
.prose .reading-brief p:last-child { margin-bottom: 0; }
.note-routes { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.note-routes h2 { margin: 0 0 12px; font-size: 15px; }
.note-routes a { display: inline-block; margin: 0 20px 8px 0; color: var(--accent); font-size: 13px; }
.legacy-sections { margin-top: 28px; color: var(--ink-faint); font-size: 12px; }
.legacy-sections summary { cursor: pointer; }
.legacy-sections li { overflow-wrap: anywhere; }
@media (max-width: 620px) {
  .topic-related { grid-template-columns: minmax(0,1fr); }
  .reading-brief { margin-bottom: 20px; }
  .note-list li { column-gap: 10px; }
}

.nav-group > summary { text-transform: none; letter-spacing: 0; }

/* RL's four content types share one reading template. Keep these rules scoped
 * so the remaining topics retain their established layouts. */
.rl-note .rl-header {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line-strong);
}

.rl-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-bottom: 26px;
  font-size: 12px;
  line-height: 1.6;
}

.rl-note .rl-context > a {
  color: var(--ink-faint);
  text-decoration: none;
}

.rl-note .rl-context > a:hover { color: var(--accent); }

.rl-kind {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-faint);
  font-size: 11px;
}

.rl-kind > span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.rl-note .rl-header h1 {
  margin-bottom: 18px;
  font-size: clamp(1.8rem, 2.7vw, 2.2rem);
  line-height: 1.4;
  text-wrap: balance;
}

.rl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.7;
}

.rl-note .rl-meta a {
  margin-left: auto;
  color: var(--ink-faint);
  text-decoration: none;
}

.rl-note .rl-meta a:hover { color: var(--accent); }

.rl-introduction {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.rl-note .rl-introduction h2 {
  margin: 0 0 12px;
  padding: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.07em;
  line-height: 1.6;
}

.rl-note .reading-brief { margin: 0; }

.rl-note .reading-brief > p {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.9;
}

.rl-note .reading-brief blockquote {
  margin: 18px 0 0;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink-faint);
  background: transparent;
  font-size: 13px;
  line-height: 1.8;
}

.rl-note--recipe .reading-brief blockquote strong { color: var(--amber); }

.rl-body > h2 {
  margin: 48px 0 18px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 23px;
  line-height: 1.5;
  text-wrap: pretty;
}

.rl-body > h3 { font-size: 18px; }

.rl-body > blockquote {
  padding: 4px 0 4px 18px;
  border: 0;
  border-left: 2px solid var(--accent);
  border-radius: 0;
  background: transparent;
}

.rl-body .table-scroll { border-radius: 3px; }
.rl-body table { font-size: 13px; line-height: 1.75; }
.rl-body th { font-size: 12px; }

.rl-body .katex-display {
  max-width: 100%;
  padding: 16px 12px;
  border-block: 1px solid var(--line);
  background: var(--paper-soft);
}

.rl-body img { border-radius: 3px; }
.rl-note .toc-inline { margin-bottom: 30px; }

@media (max-width: 620px) {
  .rl-context { align-items: flex-start; gap: 8px 16px; margin-bottom: 20px; }
  .rl-kind { gap: 7px; }
  .rl-note .rl-header { padding-bottom: 22px; margin-bottom: 26px; }
  .rl-note .rl-header h1 { font-size: 25px; }
  .rl-meta { gap: 6px 14px; }
  .rl-note .rl-meta a { margin-left: 0; }
  .rl-introduction { margin-top: 22px; padding-top: 18px; }
  .rl-note .reading-brief > p { font-size: 16px; }
  .rl-body > h2 { margin-top: 38px; padding-top: 20px; font-size: 21px; }
  .rl-body .katex-display { padding: 12px 8px; }
}
