:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-muted: #f3f4f7;
  --border: #e5e7eb;
  --text: #111827;
  --text-soft: #6b7280;
  --text-faint: #9ca3af;
  --accent: #22c55e;
  --accent-soft: #dcfce7;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --sidebar-width: 300px;
  --content-width: 860px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

img {
  display: block;
  max-width: 100%;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.site-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(246, 247, 251, 0.92);
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.menu-button span,
.menu-button span::before,
.menu-button span::after {
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  display: block;
  content: "";
}

.menu-button span::before {
  transform: translateY(-5px);
}

.menu-button span::after {
  transform: translateY(3px);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #111827, #374151);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-soft);
}

.search {
  margin-left: auto;
  width: min(320px, 100%);
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.search svg {
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  flex: 0 0 auto;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 0;
}

.sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow: auto;
  padding: 24px 16px 48px 24px;
  border-right: 1px solid var(--border);
  background: rgba(246, 247, 251, 0.92);
}

.sidebar-group + .sidebar-group {
  margin-top: 22px;
}

.sidebar-heading {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-links {
  display: grid;
  gap: 4px;
}

.sidebar-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #374151;
  font-size: 14px;
  line-height: 1.45;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 10px 20px rgba(15, 23, 42, 0.04);
  color: var(--text);
}

.content-wrap {
  min-width: 0;
  padding: 28px 32px 56px;
}

.doc-header {
  margin: 0 0 20px;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-soft);
}

.breadcrumb .dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--text-faint);
}

.doc-title {
  margin: 16px 0 10px;
  font-size: clamp(30px, 3vw, 40px);
  line-height: 1.12;
}

.doc-summary {
  margin: 0;
  max-width: 760px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-soft);
}

.content-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, var(--content-width)) 240px;
  justify-content: center;
  gap: 28px;
}

.article-card,
.toc-card,
.overview-card {
  background: var(--surface);
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.article-card {
  padding: 34px 38px;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 22px;
  font-size: 13px;
  color: var(--text-soft);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}

.article-card h2,
.article-card h3,
.article-card h4 {
  scroll-margin-top: 88px;
}

.article-card h2 {
  margin: 34px 0 14px;
  font-size: 28px;
}

.article-card h3 {
  margin: 24px 0 10px;
  font-size: 20px;
}

.article-card h4 {
  margin: 18px 0 8px;
  font-size: 16px;
}

.article-card p,
.article-card li,
.article-card blockquote {
  font-size: 16px;
  line-height: 1.8;
}

.article-card p,
.article-card ul,
.article-card ol,
.article-card pre,
.article-card blockquote {
  margin: 0 0 16px;
}

.article-card ul,
.article-card ol {
  padding-left: 22px;
}

.article-card li + li {
  margin-top: 10px;
}

.article-card a {
  color: #166534;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.article-card strong {
  font-weight: 700;
}

.article-card blockquote {
  margin-left: 0;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
}

.article-card pre {
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #111827;
  color: #f9fafb;
}

.article-card img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.callout {
  margin: 0 0 20px;
  padding: 14px 16px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 14px;
  line-height: 1.7;
}

.danger {
  color: #dc2626;
  font-weight: 700;
}

.toc-card {
  position: sticky;
  top: 92px;
  padding: 18px;
  height: fit-content;
}

.toc-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toc-links {
  display: grid;
  gap: 6px;
}

.toc-links a {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: #4b5563;
}

.toc-links a:hover,
.toc-links a.active {
  background: var(--surface-muted);
  color: var(--text);
}

.doc-nav {
  margin: 18px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.doc-nav a {
  min-height: 92px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.doc-nav-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-nav-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
}

.overview {
  max-width: var(--content-width);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.overview-card {
  padding: 26px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.doc-listing {
  display: grid;
  gap: 18px;
}

.doc-tile {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.doc-cover {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-muted);
}

.doc-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-tile-title {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.3;
}

.doc-tile-text {
  margin: 0 0 14px;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.75;
}

.doc-tile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.quick-link {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.quick-link h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.quick-link p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px 28px;
  color: var(--text-soft);
  font-size: 13px;
}

.overlay {
  position: fixed;
  inset: 64px 0 0;
  background: rgba(17, 24, 39, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

body.nav-open .overlay {
  opacity: 1;
  pointer-events: auto;
}

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

  .toc-card {
    display: none;
  }
}

@media (max-width: 980px) {
  .menu-button {
    display: inline-flex;
  }

  .search {
    display: none;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    height: auto;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 24px 0 48px rgba(15, 23, 42, 0.16);
  }

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

  .content-wrap {
    padding: 20px 16px 40px;
  }

  .article-card {
    padding: 24px 20px;
  }

  .doc-nav,
  .overview-grid,
  .quick-links,
  .doc-tile {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 0 16px;
  }

  .doc-title {
    font-size: 28px;
  }

  .article-card h2 {
    font-size: 24px;
  }

  .doc-tile {
    padding: 14px;
  }

  .footer {
    padding: 0 16px 22px;
  }
}
