:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --surface-strong: #e2e8f0;
  --text: #172033;
  --muted: #667085;
  --faint: #94a3b8;
  --line: #d8dee9;
  --line-strong: #c5ccd8;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #0f9f6e;
  --green-soft: #dff7ea;
  --orange: #e66a1f;
  --orange-soft: #fff1e8;
  --red: #dc2626;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --topbar: 64px;
  --sidebar: 288px;
  --toc: 240px;
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

body.home-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.09), transparent 36%),
    linear-gradient(315deg, rgba(16, 185, 129, 0.1), transparent 34%),
    var(--bg);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.home-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
}

.home-hero {
  width: min(100%, 760px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(28px, 6vw, 56px);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.home-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 30px;
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
  text-decoration: none;
}

.home-brand img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.home-hero h1 {
  margin: 10px 0 18px;
  color: #101828;
  font-size: clamp(42px, 8vw, 76px);
  line-height: 0.95;
  letter-spacing: 0;
}

.home-hero h1 code,
.home-note code {
  border-radius: 8px;
  padding: 0.08em 0.15em;
  background: #eef2ff;
  color: #1d4ed8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.home-copy {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.primary-link {
  background: var(--blue);
  color: #ffffff;
}

.secondary-link {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.primary-link:hover,
.primary-link:focus-visible,
.secondary-link:hover,
.secondary-link:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.home-note {
  margin-top: 32px;
  border-left: 4px solid var(--blue);
  padding: 2px 0 2px 16px;
}

.home-note h2 {
  margin: 0 0 8px;
  color: #111827;
  font-size: 15px;
  line-height: 1.3;
}

.home-note p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto auto minmax(220px, 620px) auto;
  align-items: center;
  gap: 16px;
  min-height: var(--topbar);
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button svg,
.search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-toggle {
  display: none;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(100%, 620px);
  color: var(--muted);
}

.search svg {
  position: absolute;
  left: 14px;
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px 0 42px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

.search input:focus {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.top-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.top-links a {
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.top-links a:hover,
.top-links a:focus-visible {
  background: var(--surface-soft);
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc);
  min-height: calc(100vh - var(--topbar));
}

.sidebar,
.toc-panel {
  position: sticky;
  top: var(--topbar);
  align-self: start;
  height: calc(100vh - var(--topbar));
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.toc-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.sidebar-head,
.toc-head {
  padding: 22px 22px 10px;
}

.eyebrow {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pack-count {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.pack-nav {
  padding: 0 12px 28px;
}

.pack-group {
  margin-top: 16px;
}

.pack-group-title {
  margin: 0 10px 7px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pack-link {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.pack-link:hover,
.pack-link:focus-visible {
  background: var(--surface-soft);
  outline: none;
}

.pack-link.is-active {
  border-color: #b7cdfb;
  background: var(--blue-soft);
}

.pack-title {
  font-size: 14px;
  font-weight: 750;
}

.pack-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.reader {
  min-width: 0;
  padding: 38px clamp(24px, 5vw, 76px) 72px;
}

.doc {
  max-width: 860px;
  margin: 0 auto;
}

.doc-header {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.doc-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 4px 9px;
  background: var(--green-soft);
  color: #087553;
  font-size: 12px;
  font-weight: 800;
}

.path-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 4px 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.doc h1 {
  margin: 0 0 14px;
  color: #101828;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

.doc-summary {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.doc-body {
  color: #243047;
  font-size: 16px;
  line-height: 1.72;
}

.doc-body h1 {
  display: none;
}

.doc-body h2 {
  margin: 42px 0 14px;
  padding-top: 6px;
  color: #111827;
  font-size: 25px;
  line-height: 1.2;
  letter-spacing: 0;
}

.doc-body h3 {
  margin: 30px 0 10px;
  color: #1f2937;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0;
}

.doc-body h4 {
  margin: 24px 0 8px;
  color: #334155;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0;
}

.doc-body p {
  margin: 0 0 15px;
}

.doc-body ul,
.doc-body ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.doc-body li {
  margin: 7px 0;
  padding-left: 2px;
}

.doc-body code {
  border-radius: 6px;
  padding: 2px 5px;
  background: #eef2f7;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.code-block {
  position: relative;
  margin: 18px 0 24px;
  overflow: hidden;
  border: 1px solid #c8d1df;
  border-radius: 8px;
  background: #0f172a;
  box-shadow: var(--shadow);
}

.code-block pre {
  margin: 0;
  overflow: auto;
  padding: 20px;
  color: #e5edf8;
  font-size: 14px;
  line-height: 1.55;
}

.code-block code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.copy-code {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.84);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.copy-code:hover,
.copy-code:focus-visible {
  background: rgba(37, 99, 235, 0.95);
  outline: none;
}

.toc {
  padding: 0 14px 28px;
}

.toc a {
  display: block;
  border-left: 2px solid transparent;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
}

.toc a:hover,
.toc a:focus-visible {
  color: var(--text);
  background: var(--surface-soft);
  outline: none;
}

.toc a.is-h3 {
  padding-left: 22px;
}

.toc a.is-active {
  border-left-color: var(--blue);
  color: var(--blue);
  font-weight: 750;
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--topbar) - 80px);
  color: var(--muted);
  text-align: center;
}

.loading-state p,
.empty-state p,
.error-state p {
  margin: 12px 0 0;
}

.loading-mark {
  width: 38px;
  height: 38px;
  border: 3px solid var(--surface-strong);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.error-state strong {
  display: block;
  color: var(--red);
  font-size: 18px;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(15, 23, 42, 0.34);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
  }

  .toc-panel {
    display: none;
  }
}

@media (max-width: 860px) {
  :root {
    --topbar: 58px;
  }

  .topbar {
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 10px;
    padding: 8px 14px;
  }

  .nav-toggle {
    display: inline-grid;
  }

  .top-links {
    display: none;
  }

  .brand span {
    display: none;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    width: min(86vw, 320px);
    height: 100vh;
    transform: translateX(-104%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

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

  body.nav-open .scrim {
    display: block;
  }

  .reader {
    padding: 26px 18px 56px;
  }

  .doc h1 {
    font-size: 36px;
    line-height: 1.04;
  }

  .doc-summary {
    font-size: 16px;
  }

  .doc-body h2 {
    font-size: 22px;
  }
}
