:root {
  color-scheme: light;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #ecfdf5;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe3ec;
  --surface: #ffffff;
  --surface-subtle: #f7f9fc;
  --code: #101827;
  --header-height: 72px;
  --sidebar-width: 292px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  line-height: 1.65;
}

a { color: var(--accent-dark); }
a:hover { color: var(--accent); }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 8px 12px;
  background: var(--ink);
  color: white;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 800;
}

.brand strong,
.brand small { display: block; }
.brand strong { font-size: 16px; line-height: 1.25; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.header-actions {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-subtle);
}

.language-link {
  padding: 5px 10px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.language-link[aria-current="page"] {
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.page-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-height));
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  padding: 24px 18px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface-subtle);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-close { display: none; }

#table-of-contents { display: grid; gap: 2px; }

#table-of-contents a {
  display: block;
  padding: 7px 10px;
  border-left: 2px solid transparent;
  color: #475569;
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
}

#table-of-contents a:hover {
  background: #eef2f7;
  color: var(--ink);
}

#table-of-contents a[aria-current="location"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

#table-of-contents .toc-level-3 { padding-left: 24px; font-size: 12px; }

.document-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 24px 10px 4px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
}

.main-content { min-width: 0; }
.mobile-toolbar { display: none; }

.document {
  width: min(100%, 1060px);
  min-height: calc(100vh - 170px);
  margin: 0 auto;
  padding: 58px 64px 72px;
}

.document h1,
.document h2,
.document h3,
.document h4 {
  line-height: 1.25;
  letter-spacing: 0;
}

.document h1 {
  margin: 0 0 14px;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 780;
}

.document h2 {
  margin: 64px 0 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 27px;
}

.document h3 { margin: 38px 0 12px; font-size: 20px; }
.document h4 { margin: 26px 0 8px; font-size: 16px; }

.document p,
.document li { font-size: 16px; }

.document > p:first-of-type {
  color: var(--muted);
  font-size: 14px;
}

.document blockquote {
  margin: 22px 0;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: #334155;
}

.document blockquote p { margin: 0; }
.document ul,
.document ol { padding-left: 26px; }
.document li + li { margin-top: 5px; }

.document img {
  display: block;
  width: 100%;
  height: auto;
  margin: 28px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.document table {
  display: block;
  width: 100%;
  margin: 22px 0;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 14px;
}

.document th,
.document td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.document th { background: var(--surface-subtle); font-weight: 750; }

.document code {
  padding: 0.15em 0.35em;
  border-radius: 4px;
  background: #eef2f7;
  color: #0f4c47;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.document pre {
  margin: 22px 0;
  padding: 18px 20px;
  overflow-x: auto;
  border-radius: 7px;
  background: var(--code);
  color: #dbeafe;
  line-height: 1.55;
}

.document pre code { padding: 0; background: transparent; color: inherit; }

.mermaid {
  margin: 28px 0;
  padding: 22px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-subtle);
  text-align: center;
}

.mermaid svg { max-width: 100%; height: auto; }

.loading-state,
.error-state {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 220px;
  color: var(--muted);
}

.loading-indicator {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: min(100% - 48px, 932px);
  margin: 0 auto;
  padding: 24px 0 36px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  :root { --header-height: 64px; }
  .site-header { padding: 0 18px; }
  .brand small { display: none; }
  .page-shell { display: block; }

  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    width: min(86vw, 320px);
    height: 100vh;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 12px 0 30px rgba(15, 23, 42, 0.18);
  }

  .sidebar.is-open { transform: translateX(0); }
  .nav-close {
    display: inline-grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 24px;
    cursor: pointer;
  }

  .mobile-toolbar {
    display: block;
    padding: 14px 20px 0;
  }

  .nav-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 40;
    inset: 0;
    display: block;
    background: rgba(15, 23, 42, 0.38);
  }

  .sidebar-backdrop[hidden] { display: none; }
  .document { padding: 34px 22px 58px; }
  .document h1 { font-size: 34px; }
  .document h2 { margin-top: 50px; font-size: 24px; }
  .site-footer { display: grid; width: calc(100% - 44px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
