:root {
  --bg: #0a0a0a;
  --bg-raised: #111113;
  --bg-code: #0d0d0e;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8e6e3;
  --text-muted: #9a9a9a;
  --text-dim: #6b6b6b;
  --accent: #f5a524;
  --accent-strong: #ffb84d;
  --accent-dim: rgba(245, 165, 36, 0.12);
  --accent-border: rgba(245, 165, 36, 0.35);
  --radius: 10px;
  --sidebar-w: 264px;
  --toc-w: 220px;
  --topbar-h: 64px;
  --content-max: 760px;
  --green: #4ade80;
  --red: #f87171;
  --blue: #60a5fa;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

code, pre, kbd {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

img, svg {
  max-width: 100%;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 800;
  font-size: 19px;
  color: var(--text);
  flex-shrink: 0;
}

.topbar .version-pill {
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  margin-left: 2px;
}

.topbar .menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.topbar .search-trigger {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
}

.topbar .search-trigger:hover {
  border-color: var(--border-strong);
}

.topbar .search-trigger kbd {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

.topbar .right-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.topbar .gh-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar .gh-link:hover {
  color: var(--text);
}

.topbar .gh-stars {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 28px 16px 40px;
  border-right: 1px solid var(--border);
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
}

.sidebar .group-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 18px 10px 8px;
}
.sidebar .group-label:first-child {
  padding-top: 0;
}

.sidebar nav a {
  display: block;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text-muted);
  margin: 1px 0;
}

.sidebar nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar nav a.active {
  color: var(--accent-strong);
  background: var(--accent-dim);
  font-weight: 600;
}

main {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 100px;
  max-width: var(--content-max);
}

.toc {
  width: var(--toc-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 40px 20px 40px 0;
  font-size: 13px;
}

.toc .toc-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 12px;
}

.toc a {
  display: block;
  padding: 5px 0 5px 14px;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
}

.toc a:hover {
  color: var(--text);
}

.toc a.active {
  color: var(--accent-strong);
  border-left-color: var(--accent);
}

/* ---------- Content typography ---------- */

.eyebrow {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 6px;
}

main h1 {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
}

main h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 44px 0 14px;
  padding-top: 8px;
  scroll-margin-top: 84px;
}

main h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 30px 0 10px;
  scroll-margin-top: 84px;
}

main p {
  color: #d6d4d0;
  margin: 14px 0;
}

main ul, main ol {
  color: #d6d4d0;
  padding-left: 22px;
}
main li {
  margin: 6px 0;
}

main strong {
  color: var(--text);
  font-weight: 650;
}

main a.inline-link {
  color: var(--accent-strong);
  border-bottom: 1px solid var(--accent-border);
}
main a.inline-link:hover {
  border-bottom-color: var(--accent-strong);
}

code:not(pre code) {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 13px;
  color: #ffd48a;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 16px 0 22px;
  font-size: 13px;
  line-height: 1.6;
}
pre code {
  color: #d6d4d0;
  background: none;
  border: none;
  padding: 0;
}

.tok-kw { color: #ff7ab6; }
.tok-str { color: #ffd48a; }
.tok-com { color: #6b6b6b; font-style: italic; }
.tok-fn { color: #7dd3fc; }
.tok-num { color: #c4b5fd; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 26px;
  font-size: 13.5px;
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
td code {
  white-space: nowrap;
}

/* ---------- Callouts ---------- */

.callout {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 20px 0;
  font-size: 14px;
  color: #d6d4d0;
}
.callout .icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}
.callout.info { border-left: 3px solid var(--blue); }
.callout.warn { border-left: 3px solid var(--accent); }
.callout.danger { border-left: 3px solid var(--red); }
.callout.tip { border-left: 3px solid var(--green); }
.callout p { margin: 0; }
.callout p + p { margin-top: 8px; }

/* ---------- Cards (homepage) ---------- */

.hero {
  padding: 72px 24px 24px;
  text-align: center;
  max-width: 760px;
  margin: 0 auto;
}
.hero h1 {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 14px 0 10px;
}
.hero p {
  color: var(--text-muted);
  font-size: 17px;
  max-width: 560px;
  margin: 0 auto;
}
.hero .badges {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}
.badge {
  font-size: 12.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
}
.badge.accent {
  color: var(--accent-strong);
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 40px auto 0;
  max-width: 980px;
  padding: 0 24px 80px;
}

.card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 22px;
  background: var(--bg-raised);
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover {
  border-color: var(--accent-border);
  transform: translateY(-1px);
}
.card .card-icon {
  font-size: 20px;
  color: var(--accent);
  margin-bottom: 12px;
}
.card .card-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  color: var(--text);
}
.card .card-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

.section-label {
  max-width: 980px;
  margin: 8px auto 0;
  padding: 0 24px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.intro {
  max-width: 680px;
  margin: 14px auto 40px;
  padding: 0 24px;
  color: #d6d4d0;
  font-size: 15.5px;
  line-height: 1.75;
}
.intro p {
  margin: 14px 0;
}
.intro code {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 13.5px;
  color: #ffd48a;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ---------- Prev/next footer nav ---------- */

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.page-nav a {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
}
.page-nav a:hover {
  border-color: var(--accent-border);
}
.page-nav .dir {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.page-nav .next {
  text-align: right;
}
.page-nav .title {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Search modal ---------- */

.search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.search-backdrop.open {
  display: flex;
}
.search-modal {
  width: 100%;
  max-width: 560px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.search-modal input {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  padding: 16px 18px;
  outline: none;
}
.search-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}
.search-results a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.search-results a .sr-page {
  font-size: 11px;
  color: var(--text-dim);
}
.search-results a:hover,
.search-results a.selected {
  background: var(--accent-dim);
  color: var(--accent-strong);
}
.search-empty {
  padding: 24px 18px;
  color: var(--text-dim);
  font-size: 13.5px;
  text-align: center;
}

/* ---------- Mobile ---------- */

@media (max-width: 1100px) {
  .toc { display: none; }
  main { max-width: none; }
}

@media (max-width: 820px) {
  .topbar .menu-toggle { display: flex; }
  .topbar .search-trigger { max-width: none; }
  .sidebar {
    position: fixed;
    left: -100%;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    width: 82vw;
    max-width: 320px;
    background: var(--bg);
    z-index: 40;
    transition: left 0.2s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
  }
  .sidebar.open { left: 0; }
  .card-grid { grid-template-columns: 1fr; }
  main { padding: 32px 20px 80px; }
  .hero h1 { font-size: 34px; }
  .hero { padding: 48px 20px 12px; }
}
