:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --ink: #17201f;
  --muted: #63706d;
  --line: #dedbd2;
  --line-strong: #c7c2b7;
  --teal: #007c78;
  --teal-dark: #005f5b;
  --coral: #b55238;
  --amber: #c58a14;
  --code-bg: #101615;
  --code-ink: #e8f2ef;
  --code-line: rgba(255, 255, 255, 0.08);
  --code-head: #17201f;
  --code-muted: #b7c4c0;
  --code-keyword: #ff9f7c;
  --code-string: #7dd3aa;
  --code-template: #f0c674;
  --code-number: #8ab4ff;
  --code-comment: #80908c;
  --code-type: #80cbc4;
  --code-function: #c9a7ff;
  --code-operator: #f6b26b;
  --topbar-bg: rgba(246, 244, 238, 0.92);
  --sidebar-bg: rgba(246, 244, 238, 0.86);
  --note-bg: #fff7e8;
  --note-border: #edd7ad;
  --note-ink: #6e4600;
  --inline-code-bg: rgba(0, 124, 120, 0.1);
  --inline-code-ink: #005f5b;
  --inline-code-border: rgba(0, 124, 120, 0.16);
  --shadow: 0 18px 45px rgba(23, 32, 31, 0.1);
  --radius: 8px;
  --sidebar-width: 280px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1413;
  --surface: #121b1a;
  --surface-soft: #172321;
  --ink: #eff7f4;
  --muted: #a4b2ae;
  --line: #263533;
  --line-strong: #3a4c49;
  --teal: #43c7bd;
  --teal-dark: #8de8df;
  --coral: #ff9a78;
  --amber: #f2be5c;
  --code-bg: #07100f;
  --code-ink: #e7f1ee;
  --code-line: rgba(255, 255, 255, 0.1);
  --code-head: #0b1514;
  --code-muted: #9cafaa;
  --code-keyword: #ff9f7c;
  --code-string: #91e6b7;
  --code-template: #ffd166;
  --code-number: #8ab4ff;
  --code-comment: #788985;
  --code-type: #80cbc4;
  --code-function: #d5b8ff;
  --code-operator: #f6b26b;
  --topbar-bg: rgba(13, 20, 19, 0.9);
  --sidebar-bg: rgba(13, 20, 19, 0.88);
  --note-bg: #261d0f;
  --note-border: #5a4323;
  --note-ink: #f7cc82;
  --inline-code-bg: rgba(67, 199, 189, 0.12);
  --inline-code-ink: #9ff0e8;
  --inline-code-border: rgba(67, 199, 189, 0.22);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1413;
    --surface: #121b1a;
    --surface-soft: #172321;
    --ink: #eff7f4;
    --muted: #a4b2ae;
    --line: #263533;
    --line-strong: #3a4c49;
    --teal: #43c7bd;
    --teal-dark: #8de8df;
    --coral: #ff9a78;
    --amber: #f2be5c;
    --code-bg: #07100f;
    --code-ink: #e7f1ee;
    --code-line: rgba(255, 255, 255, 0.1);
    --code-head: #0b1514;
    --code-muted: #9cafaa;
    --code-keyword: #ff9f7c;
    --code-string: #91e6b7;
    --code-template: #ffd166;
    --code-number: #8ab4ff;
    --code-comment: #788985;
    --code-type: #80cbc4;
    --code-function: #d5b8ff;
    --code-operator: #f6b26b;
    --topbar-bg: rgba(13, 20, 19, 0.9);
    --sidebar-bg: rgba(13, 20, 19, 0.88);
    --note-bg: #261d0f;
    --note-border: #5a4323;
    --note-ink: #f7cc82;
    --inline-code-bg: rgba(67, 199, 189, 0.12);
    --inline-code-ink: #9ff0e8;
    --inline-code-border: rgba(67, 199, 189, 0.22);
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

body.nav-open {
  overflow: hidden;
}

a {
  color: inherit;
}

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

pre {
  margin: 0;
  overflow-x: hidden;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  border: 1px solid var(--code-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  white-space: pre-wrap;
}

pre.code-with-toolbar {
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
}

pre code {
  display: block;
  padding: 1.05rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}

p code,
li code,
strong code,
h3 code,
.inline-code {
  background: var(--inline-code-bg);
  color: var(--inline-code-ink);
  border: 1px solid var(--inline-code-border);
  padding: 0.08rem 0.32rem;
  border-radius: 5px;
}

.tok-keyword {
  color: var(--code-keyword);
  font-weight: 700;
}

.tok-string {
  color: var(--code-string);
}

.tok-template {
  color: var(--code-template);
}

.tok-number {
  color: var(--code-number);
}

.tok-comment {
  color: var(--code-comment);
  font-style: italic;
}

.tok-type {
  color: var(--code-type);
  font-weight: 700;
}

.tok-function {
  color: var(--code-function);
}

.tok-operator {
  color: var(--code-operator);
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 0.75rem;
  margin-top: 0.75rem;
  background: var(--code-head);
  color: var(--code-muted);
  border: 1px solid var(--code-line);
  border-bottom: 0;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.code-toolbar span {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.code-block-wrap {
  min-width: 0;
}

.copy-button {
  min-height: 28px;
  border: 1px solid var(--code-line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--code-ink);
  padding: 0 0.58rem;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.copy-button:hover,
.copy-button.copied {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 0;
  transform: translateY(-140%);
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: white;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 100;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 1.25rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  min-width: 0;
}

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

.brand span {
  display: grid;
  line-height: 1.15;
}

.brand strong {
  font-size: 1.05rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.top-actions,
.top-links {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 0.55rem;
  min-width: 0;
}

.top-links {
  gap: 0.25rem;
}

.top-links a,
.sidebar-nav a,
.button {
  text-decoration: none;
}

.top-links a {
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 650;
  font-size: 0.92rem;
}

.top-links a:hover {
  background: rgba(0, 124, 120, 0.09);
  color: var(--teal-dark);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 0.72rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.theme-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: inset -5px -3px 0 var(--surface);
}

:root[data-theme="light"] .theme-icon {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(197, 138, 20, 0.14);
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 0;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  background: var(--ink);
}

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

.sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  padding: 1rem;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: var(--sidebar-bg);
}

.search {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.search span {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search small {
  color: var(--muted);
  font-size: 0.78rem;
}

.search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 0.8rem;
  font: inherit;
}

.search input:focus {
  outline: 3px solid rgba(0, 124, 120, 0.18);
  border-color: var(--teal);
}

.sidebar-nav {
  display: grid;
  gap: 0.15rem;
}

.sidebar-nav a {
  display: block;
  padding: 0.56rem 0.72rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 650;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--surface);
  color: var(--teal-dark);
  box-shadow: 0 0 0 1px var(--line);
}

.content {
  min-width: 0;
  padding: 1.4rem clamp(1rem, 4vw, 3.5rem) 3rem;
}

.doc-section {
  max-width: 1120px;
  margin: 0 auto 1rem;
  padding: clamp(1.25rem, 3vw, 2.25rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(23, 32, 31, 0.04);
  scroll-margin-top: 92px;
}

.doc-section.hidden {
  display: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: clamp(1.25rem, 4vw, 3rem);
  align-items: center;
  min-height: calc(100vh - 112px);
  background: var(--surface-soft);
}

.hero-copy h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.35rem, 6vw, 5.4rem);
  line-height: 0.98;
  font-weight: 850;
}

.lede {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(1.02rem, 2vw, 1.22rem);
  margin: 1.2rem 0 0;
}

.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.6rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border-radius: 7px;
  font-weight: 800;
  border: 1px solid transparent;
}

.button.primary {
  background: var(--teal);
  color: white;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.hero-panel {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--code-bg);
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0 0.8rem;
  background: var(--code-head);
  color: var(--code-muted);
  border-bottom: 1px solid var(--code-line);
}

.panel-head span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
}

.panel-head span:nth-child(2) {
  background: var(--amber);
}

.panel-head span:nth-child(3) {
  background: var(--teal);
}

.panel-head strong {
  margin-left: auto;
  font-size: 0.8rem;
}

.panel-head .copy-button {
  margin-left: 0.25rem;
}

.hero-panel pre {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.compact-grid,
.reference-grid {
  display: grid;
  gap: 1rem;
}

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

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

.compact-grid > *,
.reference-grid > *,
.steps > *,
.split > *,
.example-list > * {
  min-width: 0;
}

.feature,
.reference-grid article,
.steps article {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

.feature strong,
.reference-grid h3,
.steps h3,
.split h3 {
  display: block;
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.feature p,
.reference-grid p,
.split p,
.note p {
  color: var(--muted);
  margin: 0.45rem 0 0;
}

.section-heading {
  max-width: 820px;
  margin-bottom: 1.25rem;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1.05;
}

.section-heading p:last-child {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 1.04rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.steps article {
  display: grid;
  gap: 0.75rem;
}

.steps article > span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: rgba(0, 124, 120, 0.12);
  color: var(--teal-dark);
  font-weight: 850;
}

.note {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  border-radius: var(--radius);
}

.note strong {
  color: var(--note-ink);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.plain-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.plain-list strong {
  color: var(--ink);
}

.runtime-diagram {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.runtime-diagram div {
  position: relative;
  display: grid;
  align-content: start;
  gap: 0.35rem;
  min-height: 112px;
  padding: 1rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.runtime-diagram div:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -0.58rem;
  width: 0.38rem;
  height: 0.38rem;
  border-top: 2px solid var(--teal);
  border-right: 2px solid var(--teal);
  transform: translateY(-50%) rotate(45deg);
  background: var(--surface);
  z-index: 1;
}

.runtime-diagram strong {
  color: var(--ink);
  line-height: 1.2;
}

.runtime-diagram span {
  color: var(--muted);
  font-size: 0.9rem;
}

.module-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.module-table > div {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.module-table > div:last-child {
  border-bottom: 0;
}

.module-table strong {
  color: var(--teal-dark);
}

.module-table span {
  color: var(--muted);
}

.example-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.example-list a {
  display: grid;
  gap: 0.22rem;
  padding: 0.9rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
}

.example-list a:hover {
  border-color: var(--teal);
  box-shadow: 0 8px 24px rgba(0, 124, 120, 0.08);
}

.example-list span {
  color: var(--muted);
  font-size: 0.92rem;
}

.section-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.pager-link {
  display: grid;
  gap: 0.2rem;
  min-height: 72px;
  padding: 0.9rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
}

.pager-link:hover {
  border-color: var(--teal);
  box-shadow: 0 8px 24px rgba(0, 124, 120, 0.08);
}

.pager-link span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.pager-link strong {
  color: var(--ink);
}

.pager-link.next {
  text-align: right;
}

.pager-link.previous:last-child {
  grid-column: 1 / -1;
}

.pager-link.next:first-child {
  grid-column: 1 / -1;
}

.footer {
  max-width: 1120px;
  margin: 1rem auto 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 0.25rem;
  color: var(--muted);
}

.footer p {
  margin: 0;
  flex: 1;
}

.footer a {
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
}

.empty-state {
  max-width: 1120px;
  margin: 0 auto 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

@media (max-width: 1120px) {
  .compact-grid,
  .reference-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .runtime-diagram {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .runtime-diagram div:nth-child(3)::after {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

@media (max-width: 860px) {
  .top-links {
    display: none;
  }

  .nav-toggle {
    display: block;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 72px 0 auto 0;
    height: calc(100vh - 72px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    z-index: 40;
    background: var(--bg);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .content {
    padding-inline: 0.85rem;
  }

  .hero-copy h1 {
    font-size: clamp(2.1rem, 12vw, 3.7rem);
  }

  .steps,
  .split,
  .runtime-diagram,
  .example-list {
    grid-template-columns: 1fr;
  }

  .runtime-diagram div::after {
    display: none;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 66px;
  }

  .brand small {
    display: none;
  }

  .theme-label {
    display: none;
  }

  .theme-toggle {
    width: 42px;
    justify-content: center;
    padding: 0;
  }

  .sidebar {
    inset: 66px 0 auto 0;
    height: calc(100vh - 66px);
  }

  .doc-section {
    padding: 1rem;
    scroll-margin-top: 82px;
  }

  .compact-grid,
  .reference-grid {
    grid-template-columns: 1fr;
  }

  .module-table > div {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  pre code {
    font-size: 0.82rem;
    padding: 0.85rem;
  }

  .button {
    width: 100%;
  }

  .section-pager {
    grid-template-columns: 1fr;
  }

  .pager-link.next {
    text-align: left;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
