:root {
  color-scheme: light dark;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-soft: #eef3f6;
  --text: #102635;
  --muted: #556a78;
  --line: #d6e0e6;
  --navy: #071a2a;
  --navy-soft: #12314a;
  --teal: #137f70;
  --teal-soft: #d9f2ec;
  --blue: #286da8;
  --code: #edf2f5;
  --max: 1480px;
  --content: 820px;
  --radius: 10px;
  --shadow: 0 12px 32px rgb(7 26 42 / 8%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08151f;
    --surface: #0d202d;
    --surface-soft: #112a3a;
    --text: #e8f1f5;
    --muted: #a5b8c3;
    --line: #284152;
    --navy: #06121b;
    --navy-soft: #17394f;
    --teal: #65d8c2;
    --teal-soft: #173f3b;
    --blue: #89c2f3;
    --code: #132b3a;
    --shadow: 0 12px 36px rgb(0 0 0 / 24%);
  }
}

* {
  box-sizing: border-box;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--blue);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.08em;
}

a:hover {
  color: var(--teal);
}

:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  transform: translateY(-180%);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

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

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  background: rgb(7 26 42 / 96%);
  color: #f4fbff;
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(calc(100% - 2rem), var(--max));
  min-height: 4.25rem;
  margin: 0 auto;
  gap: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: #f4fbff;
  font-size: 1.05rem;
  font-weight: 760;
  letter-spacing: -0.015em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 1.9rem;
  height: 1.9rem;
  place-items: center;
  border: 1px solid rgb(84 214 187 / 55%);
  border-radius: 7px;
  color: #54d6bb;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-action {
  min-height: 2.35rem;
  padding: 0.48rem 0.72rem;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 7px;
  background: transparent;
  color: #f4fbff;
  font: inherit;
  font-size: 0.88rem;
  text-decoration: none;
  cursor: pointer;
}

.header-action:hover {
  border-color: #54d6bb;
  color: #ffffff;
}

.search-shortcut {
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 4px;
  color: #b9cbd5;
  font-size: 0.72rem;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(0, var(--content)) minmax(160px, 230px);
  align-items: start;
  justify-content: center;
  width: min(calc(100% - 2rem), var(--max));
  margin: 0 auto;
  gap: clamp(1.5rem, 3vw, 3.5rem);
}

.side-nav,
.page-toc {
  position: sticky;
  top: 5.6rem;
  max-height: calc(100vh - 6.6rem);
  padding: 2.35rem 0 2rem;
  overflow: auto;
  scrollbar-width: thin;
}

.nav-group + .nav-group {
  margin-top: 1.45rem;
}

.nav-label,
.toc-label {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.nav-list,
.toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a,
.toc-list a {
  display: block;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  text-decoration: none;
}

.nav-list a {
  padding: 0.38rem 0.55rem;
}

.toc-list a {
  padding: 0.28rem 0.5rem;
}

.nav-list a:hover,
.toc-list a:hover,
.nav-list a[aria-current="page"] {
  border-left-color: var(--teal);
  color: var(--text);
}

.nav-list a[aria-current="page"] {
  background: var(--teal-soft);
  font-weight: 700;
}

.article {
  min-width: 0;
  padding: clamp(2.6rem, 5vw, 4.6rem) 0 5rem;
}

.article-header {
  margin-bottom: 2.4rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.article-description {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  margin-top: 1rem;
  gap: 0.45rem 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.article-content > :first-child {
  margin-top: 0;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
  color: var(--text);
  font-weight: 760;
  line-height: 1.22;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.article-content h1 {
  margin: 0 0 1.15rem;
  font-size: clamp(2.1rem, 5vw, 3.7rem);
}

.article-content h2 {
  margin-top: 3.2rem;
  padding-top: 0.2rem;
  font-size: clamp(1.55rem, 3vw, 2rem);
}

.article-content h3 {
  margin-top: 2.2rem;
  font-size: 1.28rem;
}

.article-content h4 {
  margin-top: 1.8rem;
  font-size: 1.05rem;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content blockquote {
  max-width: 75ch;
}

.article-content strong {
  color: var(--text);
}

.article-content blockquote {
  margin: 1.6rem 0;
  padding: 0.85rem 1.2rem;
  border-left: 4px solid var(--teal);
  background: var(--surface-soft);
  color: var(--text);
}

.article-content blockquote > :first-child,
.article-content details > :first-child {
  margin-top: 0;
}

.article-content blockquote > :last-child,
.article-content details > :last-child {
  margin-bottom: 0;
}

.article-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.8rem 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.article-content a > img {
  display: inline-block;
  width: auto;
  margin: 0.2rem 0.35rem 0.2rem 0;
  border-radius: 0;
  box-shadow: none;
  vertical-align: middle;
}

.table-wrap {
  margin: 1.6rem 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.article-content table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
}

.article-content th,
.article-content td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.article-content th {
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.article-content tr:last-child td {
  border-bottom: 0;
}

.article-content code {
  padding: 0.12em 0.34em;
  border-radius: 4px;
  background: var(--code);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.article-content pre {
  max-width: 100%;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--navy);
  color: #e8f4fa;
  line-height: 1.5;
  tab-size: 2;
}

.article-content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.article-content pre.mermaid {
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

.article-content details {
  margin: 1.4rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.article-content summary {
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.source-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  gap: 1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(calc(100% - 2rem), var(--max));
  min-height: 5rem;
  margin: 0 auto;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.search-dialog {
  width: min(calc(100% - 2rem), 680px);
  max-height: min(80vh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 72px rgb(0 0 0 / 28%);
}

.search-dialog::backdrop {
  background: rgb(2 12 20 / 62%);
  backdrop-filter: blur(3px);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 0.85rem;
  border-bottom: 1px solid var(--line);
  gap: 0.55rem;
}

.search-input {
  min-width: 0;
  padding: 0.72rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.search-close {
  padding: 0.5rem 0.75rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.search-results {
  max-height: 60vh;
  margin: 0;
  padding: 0.55rem;
  overflow-y: auto;
  list-style: none;
}

.search-result a {
  display: block;
  padding: 0.8rem 0.85rem;
  border-radius: 7px;
  text-decoration: none;
}

.search-result a:hover {
  background: var(--surface-soft);
}

.search-result-title {
  display: block;
  color: var(--text);
  font-weight: 720;
}

.search-result-description {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.search-empty {
  padding: 1.5rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .page-shell {
    grid-template-columns: minmax(175px, 215px) minmax(0, var(--content));
  }

  .page-toc {
    display: none;
  }
}

@media (max-width: 780px) {
  .header-inner {
    width: min(calc(100% - 1.25rem), var(--max));
  }

  .header-action-source,
  .search-shortcut {
    display: none;
  }

  .page-shell {
    display: block;
    width: min(calc(100% - 1.5rem), var(--content));
  }

  .side-nav {
    position: static;
    max-height: none;
    padding: 1rem 0 0;
  }

  .side-nav details {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }

  .side-nav summary {
    padding: 0.7rem 0.85rem;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
  }

  .side-nav-inner {
    padding: 0 0.6rem 0.8rem;
  }

  .nav-group + .nav-group {
    margin-top: 1rem;
  }

  .article {
    padding-top: 2.2rem;
  }

  .article-content h1 {
    font-size: clamp(2rem, 10vw, 2.75rem);
  }

  .source-note,
  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-inner {
    justify-content: center;
    padding: 1rem 0;
  }
}

@media (min-width: 781px) {
  .side-nav > details > summary {
    display: none;
  }
}

@media print {
  .site-header,
  .side-nav,
  .page-toc,
  .search-dialog,
  .site-footer {
    display: none;
  }

  .page-shell {
    display: block;
    width: 100%;
  }

  .article {
    max-width: none;
    padding: 0;
  }
}
