:root {
  --bg: #1b1b1f;
  --bg-soft: #202127;
  --bg-surface: #252529;
  --bg-hover: #2e2e33;
  --bg-alt: #161618;
  --text: #dddde3;
  --text-muted: #7c7c84;
  --text-light: #a8a8b3;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --accent-hover: #16a34a;
  --border: #2e2e32;
  --divider: #2e2e32;
  --sidebar-width: 272px;
  --topnav-height: 64px;
  --content-max: 784px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* Archived banner */
.archived-banner {
  background: #78350f;
  color: #fef3c7;
  padding: 10px 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid #92400e;
}
.archived-banner a { color: #fde68a; text-decoration: underline; }
.archived-banner a:hover { color: #fff; }

/* Top nav */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topnav-height);
  padding: 0 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--divider);
}
.topnav .logo {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.topnav .logo:hover { color: var(--accent); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}
.nav-links > a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s;
}
.nav-links > a:hover { color: var(--text); }
.nav-links > a.active { color: var(--accent); }

/* Version dropdown */
.version-dropdown {
  position: relative;
}
.version-dropdown button {
  background: transparent;
  border: 1px solid var(--divider);
  color: var(--text-light);
  padding: 2px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
  line-height: 24px;
}
.version-dropdown button:hover { color: var(--text); border-color: var(--text-muted); }
.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: 12px;
  min-width: 180px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  z-index: 200;
  padding: 4px;
  overflow: hidden;
}
.version-dropdown:hover .dropdown-content,
.version-dropdown:focus-within .dropdown-content { display: block; }
.dropdown-content a {
  display: block;
  padding: 8px 14px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  transition: background 0.1s, color 0.1s;
}
.dropdown-content a:hover { background: var(--bg-hover); color: var(--text); }

/* Layout */
.layout {
  display: flex;
  min-height: calc(100vh - var(--topnav-height));
}
.layout-home { justify-content: center; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 32px 24px 32px 32px;
  border-right: 1px solid var(--divider);
  position: sticky;
  top: var(--topnav-height);
  height: calc(100vh - var(--topnav-height));
  overflow-y: auto;
  background: var(--bg);
}
.sidebar-section { margin-bottom: 28px; }
.sidebar-section h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  padding: 0 8px;
}
.sidebar ul { list-style: none; }
.sidebar li a {
  display: block;
  padding: 4px 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.sidebar li a:hover { color: var(--text); }
.sidebar li a.active { color: var(--accent); }

/* Main content */
main {
  flex: 1;
  max-width: var(--content-max);
  padding: 32px 32px 64px;
  min-width: 0;
}

/* Hero */
.hero {
  text-align: center;
  padding: 76px 24px 60px;
  max-width: 640px;
  margin: 0 auto;
}
.hero h1 {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #4ade80 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.hero .hero-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}
.hero .hero-tagline {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.6;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.btn {
  display: inline-block;
  padding: 10px 24px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-alt); color: var(--text-light); border: 1px solid var(--divider); }
.btn-secondary:hover { border-color: var(--text-muted); }

/* Article content */
.content h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  line-height: 1.2;
}
.content h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
}
.content h3 { font-size: 18px; font-weight: 600; margin-top: 32px; margin-bottom: 8px; }
.content h4 { font-size: 16px; font-weight: 600; margin-top: 24px; margin-bottom: 8px; }
.content p { margin-bottom: 16px; color: var(--text-light); }
.content ul, .content ol { margin-bottom: 16px; padding-left: 20px; color: var(--text-light); }
.content li { margin-bottom: 4px; }
.content li::marker { color: var(--text-muted); }
.content a { color: var(--accent); text-decoration: none; font-weight: 500; }
.content a:hover { text-decoration: underline; }
.content code {
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  color: var(--text);
}
.content pre {
  background: var(--bg-alt);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 20px 24px;
  overflow-x: auto;
  margin-bottom: 16px;
  font-variant-ligatures: none;
  -webkit-font-variant-ligatures: none;
}
.content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-light);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}
.content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
}
.content th, .content td {
  padding: 10px 16px;
  border: 1px solid var(--divider);
  text-align: left;
}
.content th { background: var(--bg-soft); font-weight: 600; color: var(--text); }
.content td { color: var(--text-light); }
.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin-bottom: 16px;
  color: var(--text-muted);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
}
.content blockquote p { margin-bottom: 0; }
.content strong { font-weight: 600; color: var(--text); }
.content hr { border: none; border-top: 1px solid var(--divider); margin: 32px 0; }
.content hr + h2 { border-top: none; margin-top: 0; padding-top: 0; }
.content img { max-width: 100%; border-radius: 8px; }

/* Offset anchors for sticky nav */
.content h1[id], .content h2[id], .content h3[id], .content h4[id] {
  scroll-margin-top: calc(var(--topnav-height) + 16px);
}

/* Header anchor links — the anchor wraps the text, so style it to look like a heading */
.content .header-anchor { color: inherit; text-decoration: none; font-weight: inherit; }
.content .header-anchor:hover { color: var(--accent); }

/* Mermaid diagrams */
.mermaid {
  background: var(--bg-alt) !important;
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
  overflow-x: auto;
}

/* Code highlighting */
.hljs { background: transparent !important; color: var(--text-light); }
.hljs-keyword, .hljs-selector-tag { color: #c792ea; }
.hljs-string, .hljs-addition { color: #c3e88d; }
.hljs-number { color: #f78c6c; }
.hljs-comment, .hljs-quote { color: #676e95; font-style: italic; }
.hljs-built_in, .hljs-builtin-name { color: #82aaff; }
.hljs-attr, .hljs-attribute { color: #ffcb6b; }
.hljs-title, .hljs-section { color: #82aaff; font-weight: 600; }
.hljs-name, .hljs-tag { color: #f07178; }
.hljs-variable { color: #eeffff; }
.hljs-deletion { color: #ff5370; }
.hljs-type, .hljs-class .hljs-title { color: #ffcb6b; }
.hljs-meta { color: #89ddff; }
.hljs-literal { color: #f78c6c; }
.hljs-regexp { color: #89ddff; }

/* Table of contents (right sidebar) */
.toc {
  width: 220px;
  flex-shrink: 0;
  padding: 32px 16px 32px 0;
  position: sticky;
  top: var(--topnav-height);
  height: calc(100vh - var(--topnav-height));
  overflow-y: auto;
}
.toc-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
  margin-bottom: 8px;
  padding-left: 12px;
}
.toc ul { list-style: none; border-left: 1px solid var(--divider); }
.toc li a {
  display: block;
  padding: 3px 0 3px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.toc li a:hover { color: var(--text); }
.toc li a.active { color: var(--accent); border-left: 2px solid var(--accent); margin-left: -1px; }
.toc li.toc-level-3 a { padding-left: 24px; }

/* Previous / Next navigation */
.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
}
.prev-next a {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.prev-next a:hover { border-color: var(--accent); }
.prev-next .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.prev-next .title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.prev-next .prev { align-items: flex-start; }
.prev-next .next { align-items: flex-end; margin-left: auto; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--divider);
  padding: 24px 32px;
  text-align: center;
}
.site-footer p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Mobile responsive */
@media (max-width: 1200px) {
  .toc { display: none; }
}

@media (max-width: 960px) {
  .sidebar { display: none; }
  main { padding: 24px 24px 48px; max-width: 100%; }
  .topnav { padding: 0 16px; }
  .nav-links { gap: 16px; }
  .nav-links > a { font-size: 13px; }
  .hero h1 { font-size: 36px; }
  .hero .hero-text { font-size: 18px; }
}

@media (max-width: 640px) {
  .nav-links > a:not(:last-child) { display: none; }
  .hero { padding: 40px 16px; }
  .hero h1 { font-size: 28px; }
}

/* Task list checkboxes */
.checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  line-height: 1;
  vertical-align: -2px;
  margin-right: 4px;
  color: transparent;
}
.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
}
li:has(> .checkbox) { list-style: none; margin-left: -1.25em; }
