:root {
  --sg-bg: #F4F7FB;
  --sg-bg-deep: #0B1220;
  --sg-bg-elevated: #FFFFFF;
  --sg-ink: #0F172A;
  --sg-ink-soft: #334155;
  --sg-muted: #64748B;
  --sg-line: rgba(148, 163, 184, 0.35);
  --sg-accent: #3B82F6;
  --sg-accent-hover: #2563EB;
  --sg-accent-deep: #1D4ED8;
  --sg-navy: #1A2233;
  --sg-success: #16A34A;
  --sg-danger: #DC2626;
  --sg-warn: #D97706;
  --sg-radius: 10px;
  --sg-font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --sg-mono: "IBM Plex Mono", ui-monospace, monospace;
  --sg-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  --sg-header-h: 64px;
  --sg-sidebar-w: 280px;
  --sg-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sg-prose: 720px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--sg-font);
  color: var(--sg-ink);
  background: var(--sg-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--sg-accent-hover);
  text-decoration: none;
}

a:hover {
  color: var(--sg-accent);
}

h1, h2, h3, h4 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  font-weight: 600;
  color: var(--sg-ink);
}

p {
  margin: 0 0 1rem;
  color: var(--sg-ink-soft);
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.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;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  background: var(--sg-accent);
  color: #fff;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
}

.skip-link:focus {
  top: 0.75rem;
  color: #fff;
}

.mono-label {
  font-family: var(--sg-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sg-muted);
  margin: 0 0 0.65rem;
}

.lead {
  font-size: 1.1rem;
  color: var(--sg-ink-soft);
  max-width: 42rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 160ms var(--sg-ease), border-color 160ms var(--sg-ease), color 160ms var(--sg-ease);
}

.btn-primary {
  background: var(--sg-accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--sg-accent-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--sg-line);
  color: var(--sg-ink);
}

.btn-ghost:hover {
  border-color: #94A3B8;
  color: var(--sg-ink);
}

/* Header */
.docs-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--sg-header-h);
  background: rgba(244, 247, 251, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sg-line);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--sg-ink);
  flex-shrink: 0;
}

.brand:hover {
  color: var(--sg-ink);
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-family: var(--sg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sg-accent-deep);
  background: rgba(59, 130, 246, 0.12);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.header-search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-left: auto;
}

.header-search input {
  width: 100%;
  height: 2.4rem;
  border: 1px solid var(--sg-line);
  border-radius: 999px;
  background: var(--sg-bg-elevated);
  padding: 0 1rem;
  font: inherit;
  color: var(--sg-ink);
}

.header-search input:focus {
  outline: none;
  border-color: var(--sg-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

.search-results {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  background: var(--sg-bg-elevated);
  border: 1px solid var(--sg-line);
  border-radius: var(--sg-radius);
  box-shadow: var(--sg-shadow);
  max-height: 22rem;
  overflow: auto;
  z-index: 50;
}

.search-results a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--sg-ink);
  border-bottom: 1px solid var(--sg-line);
}

.search-results a:last-child {
  border-bottom: 0;
}

.search-results a:hover,
.search-results a.is-active {
  background: rgba(59, 130, 246, 0.08);
}

.search-results .result-section {
  display: block;
  font-family: var(--sg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sg-muted);
  margin-bottom: 0.2rem;
}

.search-results .result-title {
  font-weight: 600;
}

.search-results .result-empty {
  padding: 1rem;
  color: var(--sg-muted);
}

.header-links {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.header-links a:not(.btn) {
  color: var(--sg-ink-soft);
  font-weight: 500;
}

.header-links a:not(.btn):hover {
  color: var(--sg-accent-hover);
}

.sidebar-toggle {
  display: none;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--sg-line);
  border-radius: 8px;
  background: var(--sg-bg-elevated);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.nav-toggle-bar {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--sg-ink);
  border-radius: 2px;
}

/* Shell */
.docs-shell {
  display: grid;
  grid-template-columns: var(--sg-sidebar-w) minmax(0, 1fr);
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - var(--sg-header-h));
}

.docs-sidebar {
  position: sticky;
  top: var(--sg-header-h);
  height: calc(100vh - var(--sg-header-h));
  overflow: auto;
  background: var(--sg-navy);
  color: #CBD5E1;
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  padding: 1.25rem 0.85rem 2rem;
}

.sidebar-nav .sidebar-home,
.sidebar-link {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  color: #94A3B8;
  font-size: 0.92rem;
}

.sidebar-home {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #E2E8F0;
}

.sidebar-home:hover,
.sidebar-link:hover {
  color: #F8FAFC;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-home.is-active,
.sidebar-link.is-active {
  color: #fff;
  background: rgba(59, 130, 246, 0.28);
}

.sidebar-group {
  margin-bottom: 1.1rem;
}

.sidebar-label {
  font-family: var(--sg-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748B;
  margin: 0 0 0.35rem 0.75rem;
}

.sidebar-group ul {
  display: grid;
  gap: 0.15rem;
}

.docs-main {
  min-width: 0;
  padding: 2rem 1.75rem 3.5rem;
  background:
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(59, 130, 246, 0.08), transparent 55%),
    var(--sg-bg);
}

.sidebar-backdrop {
  display: none;
}

/* Hub */
.hub-hero {
  max-width: 48rem;
  margin-bottom: 2.5rem;
}

.hub-hero h1 {
  font-size: clamp(1.85rem, 3.5vw, 2.6rem);
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.hub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.hub-curriculum {
  display: grid;
  gap: 1.25rem;
}

.curriculum-section {
  background: var(--sg-bg-elevated);
  border: 1px solid var(--sg-line);
  border-radius: var(--sg-radius);
  padding: 1.25rem 1.35rem;
}

.curriculum-section header {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.curriculum-section header h2 {
  margin: 0 0 0.2rem;
  font-size: 1.15rem;
}

.curriculum-section header p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--sg-muted);
}

.step-num {
  font-family: var(--sg-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sg-accent-deep);
  background: rgba(59, 130, 246, 0.12);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  line-height: 1;
}

.curriculum-list {
  display: grid;
  gap: 0.35rem;
}

.curriculum-list a {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  color: inherit;
  border: 1px solid transparent;
}

.curriculum-list a:hover {
  background: rgba(59, 130, 246, 0.06);
  border-color: rgba(59, 130, 246, 0.2);
}

.curriculum-title {
  font-weight: 600;
  color: var(--sg-ink);
}

.curriculum-summary {
  font-size: 0.92rem;
  color: var(--sg-muted);
}

/* Article */
.doc-article {
  max-width: 1100px;
}

.article-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--sg-line);
}

.article-header h1 {
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  font-weight: 700;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 2rem;
  align-items: start;
}

.article-aside {
  position: sticky;
  top: calc(var(--sg-header-h) + 1rem);
}

.page-toc-label {
  font-family: var(--sg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sg-muted);
  margin: 0 0 0.55rem;
}

.page-toc ul {
  display: grid;
  gap: 0.35rem;
  border-left: 1px solid var(--sg-line);
  padding-left: 0.75rem;
}

.page-toc a {
  display: block;
  color: var(--sg-muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.page-toc a:hover,
.page-toc a.is-active {
  color: var(--sg-accent-hover);
}

.toc-level-3 {
  padding-left: 0.65rem;
}

/* Prose */
.prose {
  max-width: var(--sg-prose);
  font-size: 1.02rem;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h2 {
  margin-top: 2rem;
  padding-top: 0.35rem;
  font-size: 1.35rem;
}

.prose h3 {
  margin-top: 1.5rem;
  font-size: 1.1rem;
}

.prose p,
.prose li {
  color: var(--sg-ink-soft);
}

.prose ul,
.prose ol {
  margin: 0 0 1.1rem;
  padding-left: 1.25rem;
}

.prose ul {
  list-style: disc;
}

.prose ol {
  list-style: decimal;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose li::marker {
  color: var(--sg-accent);
}

.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose code {
  font-family: var(--sg-mono);
  font-size: 0.88em;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.prose pre {
  background: var(--sg-bg-deep);
  color: #E2E8F0;
  border-radius: var(--sg-radius);
  padding: 1rem 1.1rem;
  overflow: auto;
  margin: 0 0 1.25rem;
  box-shadow: var(--sg-shadow);
}

.prose pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 0.86rem;
  line-height: 1.55;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  border: 1px solid var(--sg-line);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: rgba(59, 130, 246, 0.08);
  color: var(--sg-ink);
  font-weight: 600;
}

.prose blockquote {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--sg-accent);
  background: rgba(59, 130, 246, 0.08);
  border-radius: 0 var(--sg-radius) var(--sg-radius) 0;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--sg-line);
  margin: 2rem 0;
}

.prose .callout,
.prose .alert {
  border: 1px solid var(--sg-line);
  border-radius: var(--sg-radius);
  padding: 0.9rem 1rem;
  margin: 0 0 1.25rem;
  background: var(--sg-bg-elevated);
}

.article-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--sg-line);
}

.pager-link {
  display: grid;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--sg-line);
  border-radius: var(--sg-radius);
  background: var(--sg-bg-elevated);
  color: inherit;
}

.pager-link:hover {
  border-color: rgba(59, 130, 246, 0.45);
  color: inherit;
}

.pager-next {
  text-align: right;
  justify-self: end;
  width: 100%;
}

.pager-label {
  font-family: var(--sg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sg-muted);
}

.pager-title {
  font-weight: 600;
  color: var(--sg-ink);
}

.not-found {
  max-width: 32rem;
  padding: 2rem 0;
}

/* Mobile */
@media (max-width: 980px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  .article-aside {
    display: none;
  }
}

@media (max-width: 860px) {
  .sidebar-toggle {
    display: inline-flex;
  }

  .header-links a:not(.btn) {
    display: none;
  }

  .docs-shell {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: fixed;
    left: 0;
    top: var(--sg-header-h);
    width: min(86vw, 300px);
    z-index: 45;
    transform: translateX(-105%);
    transition: transform 220ms var(--sg-ease);
  }

  body.sidebar-open .docs-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: var(--sg-header-h) 0 0 0;
    background: rgba(11, 18, 32, 0.45);
    z-index: 44;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-backdrop[hidden] {
    display: none !important;
  }

  .docs-main {
    padding: 1.35rem 1.1rem 2.5rem;
  }

  .article-pager {
    grid-template-columns: 1fr;
  }

  .pager-next {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
