:root {
  --bg: #101614;
  --surface: #161f1c;
  --border: #26312e;
  --text: #e6ecea;
  --muted: #9aa8a3;
  --accent: #74c7a4;
  --accent-soft: #1a2723;
  --code-bg: #141d1a;
  --scroll: #2f3d39;
  --scroll-hover: #435450;

  --tok-keyword: #e5a0c4;
  --tok-type: #8ecae6;
  --tok-string: #8fd6ac;
  --tok-comment: #7c8b86;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --page: 78rem;
  --header: 3.5rem;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

html {
  scroll-padding-top: calc(var(--header) + 1rem);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  letter-spacing: -0.015em;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
}

.skip-link:focus {
  left: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  min-height: var(--header);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 600;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 22px;
  height: 22px;
}

.brand-text {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
}

.brand-suffix {
  color: var(--muted);
  font-weight: 400;
}

.site-nav {
  display: flex;
  gap: 1rem;
  margin-right: auto;
}

.nav-link {
  color: var(--muted);
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 12rem;
  justify-content: flex-end;
}

/* Cataract's island() wraps every island's markup in an unstyled
   `[data-cataract-island]` div, which is the actual flex child here —
   `.search` is one level further in, so sizing has to target the wrapper,
   not `.search` itself (which has no direct effect on the row layout). */
.header-tools > [data-cataract-island="search"] {
  flex: 1 1 auto;
  max-width: 18rem;
}

.search {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.4rem 0.65rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.search-results {
  position: absolute;
  z-index: 60;
  top: calc(100% + 0.35rem);
  left: auto;
  right: 0;
  width: min(26rem, calc(100vw - 2.5rem));
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 20rem;
  overflow-y: auto;
}

/* Below 30rem the header wraps to two rows and .header-tools has the row
   to itself — let the search box fill it instead of floating narrow and
   right-aligned with dead space beside it, and size the results dropdown
   to match exactly instead of guessing from the viewport width. */
@media (max-width: 30rem) {
  .header-tools > [data-cataract-island="search"] {
    max-width: none;
  }

  .search-results {
    left: 0;
    right: 0;
    width: auto;
  }
}

.search-results[hidden] {
  display: none;
}

.search-hit {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 5px;
  color: var(--text);
}

.search-hit:hover {
  background: var(--surface);
  text-decoration: none;
}

.search-hit-title {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
}

.search-hit-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.search-status {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.page-main,
.docs-shell {
  flex: 1 0 auto;
  width: 100%;
}

.page-main {
  max-width: var(--page);
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}

.page-narrow {
  max-width: 44rem;
}

.hero {
  max-width: 40rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.75rem);
}

.hero-lede {
  margin: 1rem 0 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.95rem;
}

.button:hover {
  text-decoration: none;
  opacity: 0.9;
}

.text-link {
  font-size: 0.95rem;
  font-weight: 600;
}

.features {
  display: grid;
  gap: 2rem;
  margin-top: 4rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}

.feature h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.feature p {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.sections {
  margin-top: 4rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}

.sections h2 {
  margin: 0 0 1.5rem;
  font-size: 1.05rem;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1.5rem 2rem;
}

.section-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.98rem;
}

.section-card h3 a {
  color: var(--text);
}

.section-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.section-links a {
  color: var(--muted);
  font-size: 0.92rem;
}

.docs-shell {
  display: grid;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.docs-main {
  min-width: 0;
  padding: 2.5rem 0 4rem;
}

.sidebar {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
}

.sidebar-title {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.tree,
.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree ul {
  margin: 0.15rem 0 0.35rem 0.55rem;
  padding-left: 0.7rem;
  border-left: 1px solid var(--border);
}

.tree-link {
  display: block;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.tree-link:hover {
  color: var(--text);
  text-decoration: none;
}

.tree-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.section-title {
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  list-style: none;
}

.section-title::-webkit-details-marker {
  display: none;
}

.section-title::before {
  content: "›";
  display: inline-block;
  width: 0.9rem;
  color: var(--muted);
}

details[open] > .section-title::before {
  transform: rotate(90deg);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--muted);
}

.breadcrumbs li + li::before {
  content: "/";
  margin-right: 0.3rem;
  color: var(--border);
}

.doc-header h1,
.page-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.25rem);
}

.doc-lede,
.page-lede {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.doc-meta {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.dot {
  padding: 0 0.35rem;
}

.toc {
  margin: 2rem 0 0;
  padding-left: 0.9rem;
  border-left: 1px solid var(--border);
}

.toc-title {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}

.toc a {
  color: var(--muted);
  font-size: 0.9rem;
}

.toc-level-3 {
  padding-left: 0.9rem;
}

.prose {
  margin-top: 2.5rem;
  max-width: 44rem;
}

.prose > * + * {
  margin-top: 1.1rem;
}

.prose h2 {
  margin-top: 2.5rem;
  font-size: 1.35rem;
}

.prose h3 {
  margin-top: 1.9rem;
  font-size: 1.08rem;
}

.prose p {
  margin-bottom: 0;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: 0.3rem;
}

.prose li > ul,
.prose li > ol {
  margin-top: 0.3rem;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.prose blockquote p {
  margin: 0;
}

.prose code {
  padding: 0.1em 0.3em;
  background: var(--surface);
  border-radius: 4px;
}

.prose pre {
  margin: 1.5rem 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  line-height: 1.55;
}

.prose pre code {
  padding: 0;
  background: none;
}

.prose hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.table-scroll {
  overflow-x: auto;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.prose th,
.prose td {
  padding: 0.55rem 0.75rem 0.55rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.prose thead th {
  color: var(--muted);
  font-weight: 600;
}

.align-left {
  text-align: left;
}

.align-center {
  text-align: center;
}

.align-right {
  text-align: right;
}

.doc-pager {
  display: grid;
  gap: 0.5rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

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

.notice {
  padding: 0 0 2rem;
}

.notice h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.8rem, 4vw, 2.25rem);
}

.notice-actions {
  margin-top: 1.5rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

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

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 2.5rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.footer-inner p {
  margin: 0;
}

.footer-nav {
  display: flex;
  gap: 1.25rem;
}

.tok-kw {
  color: var(--tok-keyword);
}

.tok-ty,
.tok-fn {
  color: var(--tok-type);
}

.tok-st,
.tok-nu,
.tok-at {
  color: var(--tok-string);
}

.tok-cm {
  color: var(--tok-comment);
}

@media (min-width: 48rem) {
  .features {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.5rem;
  }

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

  .doc-pager .pager-link.next:only-child {
    grid-column: 2;
  }
}

@media (min-width: 64rem) {
  .docs-shell {
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 3rem;
  }

  .sidebar {
    order: -1;
    position: sticky;
    top: var(--header);
    max-height: calc(100vh - var(--header));
    overflow-y: auto;
    padding: 2.5rem 0.5rem 2rem 0;
    border-top: 0;
  }

  .docs-main {
    padding: 2.5rem 0 5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
