:root {
  color-scheme: dark;
  --bg: #0d0f16;
  --bg-soft: #10131c;
  --panel: #151823;
  --panel-2: #1b2030;
  --panel-3: #111422;
  --ink: #e7e8f2;
  --ink-soft: #c9cddd;
  --muted: #8f93a7;
  --muted-soft: #a8aec0;
  --card: #151823;
  --border: #262b3b;
  --border-strong: #32384a;
  --accent: #f5c46b;
  --accent-strong: #ffd78a;
  --accent-ink: #1c1606;
  --accent-2: #abc6ff;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: var(--mono);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(36, 42, 62, 0.92), transparent 62%),
    radial-gradient(680px 360px at 100% 0%, rgba(245, 196, 107, 0.12), transparent 58%),
    linear-gradient(180deg, #11131b 0%, #0d0f16 24%, #0b0d14 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  color: #d6e2ff;
}

code,
pre {
  font-family: var(--mono);
}

code {
  padding: 0.08em 0.34em;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  background: rgba(17, 20, 34, 0.92);
  color: var(--ink);
}

pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

.container {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.hero {
  padding: 20px 0 16px;
}

.home-page .hero {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(13, 15, 22, 0);
  border-bottom: 1px solid transparent;
  backdrop-filter: none;
  transition: background-color 180ms ease-in-out, border-color 180ms ease-in-out, backdrop-filter 180ms ease-in-out;
}

.home-page.home-scrolled .hero {
  background: rgba(13, 15, 22, 0.92);
  border-bottom-color: var(--border);
  backdrop-filter: blur(12px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  min-height: 58px;
}

.brand {
  font-family: var(--mono);
  font-size: clamp(20px, 2vw, 24px);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.btn:hover {
  border-color: var(--accent-strong);
  background: #1a1e2b;
  color: var(--ink);
  transform: translateY(-1px);
}

.btn.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: none;
}

.btn.primary:hover {
  background: var(--accent-strong);
  color: #1a1405;
}

.headline {
  max-width: 1120px;
  padding: 22px 0 6px;
}

.headline h1 {
  max-width: 18ch;
  margin: 0 0 14px;
  font-size: clamp(30px, 4.6vw, 56px);
  line-height: 1;
  letter-spacing: -0.05em;
}

.headline p {
  max-width: 1100px;
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(16px, 1.8vw, 24px);
}

.headline b {
  color: var(--accent);
}

.section {
  padding: 26px 0 56px;
}

.section h2 {
  margin: 0 0 14px;
  font-size: clamp(28px, 3vw, 42px);
  letter-spacing: -0.04em;
}

.section > .container > p,
.section > p {
  margin: 0 0 24px;
  color: var(--muted-soft);
  font-size: 15px;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.example-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(27, 32, 48, 0.94), rgba(17, 20, 34, 0.98));
  border-radius: 12px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.example-card h3 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.example-card p {
  margin: 10px 0 0;
  color: var(--muted-soft);
  min-height: 3.2em;
}

.viewer-wrap {
  margin-top: 18px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #0b0e17;
}

.example-canvas {
  display: block;
  width: 100%;
  height: 240px;
}

.viewer-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  font-size: 12px;
  color: #bac6e2;
  background: linear-gradient(180deg, rgba(17, 20, 34, 0.74), rgba(17, 20, 34, 0.94));
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.example-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.example-actions button,
.example-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.example-actions button {
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
}

.example-actions button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.example-actions a {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
}

.example-actions a:hover {
  border-color: var(--accent);
  background: #1a1e2b;
  color: var(--ink);
  transform: translateY(-1px);
}

.example-code {
  margin: 14px 0 0;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.footer {
  margin-top: 10px;
  padding: 24px 0 40px;
  border-top: 1px solid var(--border);
  background: rgba(11, 13, 20, 0.82);
  color: var(--muted);
  font-size: 13px;
}

.toc a {
  color: var(--ink-soft);
}

.toc a:hover {
  color: var(--ink);
}

.toc {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.toc h2 {
  margin: 0;
  font-size: clamp(28px, 2.2vw, 38px);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.toc-close {
  display: none;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.toc-group {
  position: relative;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(17, 20, 34, 0.76);
  transition: border-color 150ms ease, background-color 150ms ease;
}

.toc-group:hover {
  border-color: var(--border-strong);
  background: rgba(21, 24, 35, 0.94);
}

.toc-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.toc-group-link {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}

.toc-group-meta {
  display: none;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
}

.toc-group-toggle {
  display: none;
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.toc-group-toggle::before,
.toc-group-toggle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink-soft);
  transform: translate(-50%, -50%);
  transition: transform 140ms ease, opacity 140ms ease;
}

.toc-group-toggle::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.toc-group-toggle:hover {
  border-color: var(--accent);
  background: #1a1e2b;
}

.toc-group ul {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 4px 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toc-group ul::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(180deg, rgba(245, 196, 107, 0.34), rgba(245, 196, 107, 0.02));
}

.toc li {
  position: relative;
  margin: 0;
  padding: 0 0 0 20px;
  color: var(--muted-soft);
  font-size: 13px;
  line-height: 1.3;
}

.toc li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.82em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(245, 196, 107, 0.12);
}

.toc li > a {
  display: block;
  margin-left: -2px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-weight: 500;
  text-decoration: none;
  transition: color 140ms ease, background-color 140ms ease;
}

.toc li > a:hover {
  color: var(--ink);
  background: rgba(245, 196, 107, 0.08);
}

.toc-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-left: 0;
}

.toc-link-row a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 500;
  text-decoration: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.toc-link-row a:hover {
  color: var(--ink);
  background: rgba(245, 196, 107, 0.08);
  border-color: rgba(245, 196, 107, 0.32);
}

.docs-page h2[id],
.docs-page h3[id] {
  position: relative;
  scroll-margin-top: calc(var(--docs-header-offset) + 12px);
}

.docs-page {
  --docs-header-offset: 72px;
}

.docs-page .hero {
  padding-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(13, 15, 22, 0);
  border-bottom: 1px solid transparent;
  backdrop-filter: none;
  transition: background-color 180ms ease-in-out, border-color 180ms ease-in-out, backdrop-filter 180ms ease-in-out;
}

.docs-page.docs-scrolled .hero {
  background: rgba(13, 15, 22, 0.92);
  border-bottom-color: var(--border);
  backdrop-filter: blur(12px);
}

.docs-page .toc-toggle {
  display: none;
  cursor: pointer;
  min-width: 40px;
  padding: 0;
  font-size: 18px;
}

.docs-section {
  padding-top: 22px;
}

.docs-layout {
  display: grid;
  grid-template-columns: minmax(240px, 290px) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.toc-sidebar {
  position: sticky;
  top: calc(var(--docs-header-offset) + 12px);
  align-self: start;
  max-height: calc(100vh - var(--docs-header-offset) - 20px);
  min-height: calc(100vh - var(--docs-header-offset) - 20px);
  overflow: auto;
  padding: 16px;
  background: linear-gradient(180deg, rgba(21, 24, 35, 0.96), rgba(16, 19, 28, 0.98));
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.docs-content {
  min-width: 0;
  padding-left: 4px;
}

.docs-content h2 {
  margin: 40px 0 16px;
  font-size: clamp(30px, 3vw, 48px);
  line-height: 1;
  letter-spacing: -0.05em;
}

.docs-content h2#language-overview {
  margin-top: 0;
}

.docs-content h3 {
  margin: 34px 0 12px;
  font-size: clamp(20px, 2vw, 30px);
  color: var(--accent);
  letter-spacing: -0.03em;
}

.docs-content p,
.docs-content li {
  color: var(--ink-soft);
  font-size: 15px;
}

.docs-content p {
  margin: 0 0 18px;
}

.docs-content ul {
  margin: 10px 0 24px 22px;
  padding: 0;
}

.docs-content li {
  margin-bottom: 8px;
  padding-left: 4px;
}

.docs-content li::marker {
  color: var(--accent);
}

.toc-backdrop {
  display: none;
}

.docs-page .heading-anchor {
  position: absolute;
  left: -0.9em;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 120ms ease-in-out, color 120ms ease-in-out;
}

.docs-page h2[id]:hover .heading-anchor,
.docs-page h3[id]:hover .heading-anchor,
.docs-page .heading-anchor:focus {
  opacity: 1;
}

.docs-page .heading-anchor:hover,
.docs-page .heading-anchor:focus {
  color: var(--accent);
}

@media (max-width: 900px) {
  .docs-page .toc-toggle {
    display: inline-flex;
  }

  .docs-layout {
    display: block;
  }

  .toc-sidebar {
    position: fixed;
    top: var(--docs-header-offset);
    left: 0;
    bottom: 0;
    width: min(86vw, 340px);
    height: calc(100vh - var(--docs-header-offset));
    max-height: calc(100vh - var(--docs-header-offset));
    transform: translateX(-105%);
    transition: transform 140ms ease-in-out;
    z-index: 45;
    background: linear-gradient(180deg, rgba(21, 24, 35, 0.99), rgba(16, 19, 28, 1));
    border-right: 1px solid var(--border);
    border-radius: 0;
    padding: 18px 16px 28px;
    overflow: auto;
    overflow-y: scroll;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.42);
  }

  .docs-page.toc-open .toc-sidebar {
    transform: translateX(0);
  }

  .toc-backdrop {
    display: block;
    position: fixed;
    top: var(--docs-header-offset);
    left: 0;
    right: 0;
    bottom: 0;
    border: 0;
    margin: 0;
    padding: 0;
    background: rgba(4, 6, 10, 0.58);
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease-in-out;
    z-index: 25;
  }

  .docs-page.toc-open .toc-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .toc-header {
    margin: 0 0 14px;
    padding: 0;
  }

  .toc h2 {
    max-width: none;
    font-size: 24px;
    line-height: 1;
  }

  .toc-close,
  .toc-group-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .toc-group {
    padding: 12px;
  }

  .toc-group-head {
    gap: 8px;
  }

  .toc-group-toggle,
  .toc-group-meta {
    display: none;
  }
}

@media (max-width: 740px) {
  .container {
    width: min(1240px, calc(100% - 24px));
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .nav {
    width: 100%;
  }

  .btn {
    flex: 1 1 auto;
  }

  .headline {
    padding-top: 18px;
  }

  .headline h1 {
    max-width: 12ch;
    font-size: clamp(28px, 8vw, 40px);
  }

  .headline p {
    font-size: 15px;
  }

  .section {
    padding: 22px 0 42px;
  }

  .example-card {
    padding: 16px;
  }

  .example-card p {
    min-height: 0;
  }

  .docs-content h2 {
    margin-top: 32px;
    font-size: clamp(26px, 8vw, 38px);
  }

  .docs-content h3 {
    font-size: 20px;
  }
}
