:root {
  --bg: #08080c;
  --panel: #0e0e14;
  --panel-deep: #09090e;
  --input: #0a0a0e;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --btn-edge: rgba(255, 255, 255, 0.28);
  --field-edge: rgba(255, 255, 255, 0.16);
  --text: #f4f4f5;
  --prose: #d4d4d8;
  --muted: oklch(0.67 0.02 215.03);
  --dim: oklch(0.52 0.02 215.03);
  --yes: oklch(0.8 0.145 162.51);
  --no: oklch(0.68 0.17 25);
  --accent: #f4f4f5;
  --warn: oklch(0.78 0.13 77.52);
  --op-redeem: oklch(0.72 0.145 300.02);
  --op-split: oklch(0.78 0.12 215.03);
  --op-merge: oklch(0.72 0.16 352.54);
  --fair: oklch(0.72 0.19 305);
  --tf-d: oklch(0.74 0.145 352.54);
  --tf-w: oklch(0.74 0.145 267.55);
  --tf-m: oklch(0.74 0.145 45.06);
  --tf-q: oklch(0.74 0.145 97.59);
  --tf-y: oklch(0.74 0.145 190);
  --tf-p: oklch(0.74 0.145 310);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 6px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

html {
  min-height: 100%;
  overflow-x: clip;
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--prose);
  font: 15px/1.68 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

/* ---- Header ---- */

header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 12, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

header a { color: var(--text); text-decoration: none; font-family: var(--sans); }

header .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

header .brand:hover { color: #fff; }

header .brand-mark {
  flex-shrink: 0;
  display: block;
  width: 22px;
  height: 22px;
  color: #51daa2;
}

header .brand-word {
  display: block;
  height: 18px;
  width: auto;
  color: #51daa2;
}

header .brand-docs {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  margin-left: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
}

header .site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13.5px;
  font-weight: 500;
}

header .site-nav a:not(.cta) { color: var(--muted); transition: color 0.12s ease; }
header .site-nav a:not(.cta):hover { color: var(--text); }
header .site-nav a.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 4px;
  border: 1px solid var(--btn-edge);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
header .site-nav a.cta:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

/* ---- Layout shell & Sidebar TOC ---- */

.docs-shell {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 0;
  align-items: start;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  min-width: 0;
}

nav.toc {
  padding: 28px 16px 48px 20px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: fixed;
  top: 49px;
  bottom: 0;
  left: max(0px, calc((100% - 1120px) / 2));
  width: 224px;
  overflow: auto;
  z-index: 10;
  background: var(--bg);
}

.toc-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-label {
  padding: 0 8px 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}

.toc-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px 10px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

nav.toc a {
  color: var(--muted);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 450;
  padding: 5px 9px;
  border-radius: 5px;
  transition: color 0.12s ease, background-color 0.12s ease;
}

nav.toc .toc-sub a {
  font-size: 12.5px;
  padding: 4px 8px;
}

nav.toc a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

nav.toc a.active {
  color: var(--text);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
}

/* ---- Main prose ---- */

main {
  grid-column: 2;
  max-width: 780px;
  min-width: 0;
  width: 100%;
  padding: 36px 36px 88px 44px;
  overflow-x: clip;
}

h1, h2, h3, h4 {
  color: var(--text);
  font-family: var(--sans);
  font-weight: 600;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.028em;
  margin: 0 0 12px;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.018em;
  margin: 40px 0 12px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

h3 {
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin: 28px 0 8px;
}

h4 {
  font-size: 13.5px;
  margin: 20px 0 6px;
  color: var(--text);
}

main > h1 { margin-top: 0; }

p {
  margin: 0 0 15px;
  color: var(--prose);
}

ul, ol {
  margin: 0 0 18px;
  padding-left: 1.35em;
}

li {
  color: var(--prose);
  margin-bottom: 8px;
}

li:last-child { margin-bottom: 0; }

strong {
  color: var(--text);
  font-weight: 600;
}

.lead {
  font-size: 16.5px;
  line-height: 1.58;
  color: var(--muted);
  margin: 0 0 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

main a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.28);
  text-underline-offset: 3px;
  transition: color 0.12s ease, text-decoration-color 0.12s ease;
}

main a:hover {
  color: #fff;
  text-decoration-color: #fff;
}

/* ---- Code & pre ---- */

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

code {
  font-size: 0.84em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1.5px 5px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre {
  margin: 14px 0 20px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ---- API Endpoints ---- */

h3.endpoint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  margin: 32px 0 10px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

h3.endpoint .method {
  display: inline-block;
  min-width: 3.8em;
  text-align: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--text);
  border: 1px solid var(--field-edge);
}

h3.endpoint .method.get { color: var(--yes); border-color: color-mix(in srgb, var(--yes) 40%, transparent); background: color-mix(in srgb, var(--yes) 10%, var(--panel)); }
h3.endpoint .method.post { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }
h3.endpoint .method.delete { color: var(--no); border-color: color-mix(in srgb, var(--no) 40%, transparent); background: color-mix(in srgb, var(--no) 10%, var(--panel)); }
h3.endpoint .method.ws { color: var(--op-split); border-color: color-mix(in srgb, var(--op-split) 40%, transparent); background: color-mix(in srgb, var(--op-split) 10%, var(--panel)); }

h3.endpoint code.path {
  font-size: 13px;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
}

.ep-meta { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }

.ep-label {
  margin: 14px 0 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
  font-family: var(--sans);
}

/* ---- Callouts ---- */

.callout {
  margin: 18px 0 22px;
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--op-split);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 14px;
  line-height: 1.6;
  color: var(--prose);
}

.callout.tip { border-left-color: var(--yes); }
.callout.warn { border-left-color: var(--warn); }

.callout-title {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.callout p:last-child { margin-bottom: 0; }

/* ---- Cards ---- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

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

.doc-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 15px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

a.doc-card:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: #13131b;
  text-decoration: none;
}

.doc-card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.doc-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---- Pills ---- */

.pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.pill.yes { color: var(--yes); background: color-mix(in srgb, var(--yes) 14%, transparent); }
.pill.no { color: var(--no); background: color-mix(in srgb, var(--no) 14%, transparent); }
.pill.fair { color: var(--fair); background: color-mix(in srgb, var(--fair) 14%, transparent); }
.pill.d { color: var(--tf-d); background: color-mix(in srgb, var(--tf-d) 14%, transparent); }
.pill.w { color: var(--tf-w); background: color-mix(in srgb, var(--tf-w) 14%, transparent); }
.pill.m { color: var(--tf-m); background: color-mix(in srgb, var(--tf-m) 14%, transparent); }
.pill.q { color: var(--tf-q); background: color-mix(in srgb, var(--tf-q) 14%, transparent); }
.pill.y { color: var(--tf-y); background: color-mix(in srgb, var(--tf-y) 14%, transparent); }
.pill.p { color: var(--tf-p); background: color-mix(in srgb, var(--tf-p) 14%, transparent); }

/* ---- Diagrams & Fee Curve ---- */

.diagram,
.fee-curve {
  margin: 18px 0 24px;
}

.diagram svg,
.fee-curve svg {
  display: block;
  width: 100%;
  height: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
}

.diagram figcaption,
.fee-curve figcaption {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.fee-curve .grid,
.diagram .grid { stroke: var(--line); stroke-width: 1; }
.fee-curve .axis,
.diagram .axis { stroke: rgba(255, 255, 255, 0.24); stroke-width: 1; }
.fee-curve .curve {
  fill: none;
  stroke: var(--text);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.fee-curve .peak { fill: var(--text); }

/* ---- Tables ---- */

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 13.5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

thead {
  background: var(--panel);
}

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

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

th {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

td { color: var(--prose); }
td code { white-space: nowrap; }

/* ---- Pager ---- */

.docs-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 56px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
}

.docs-pager a.pager-link {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 15px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.docs-pager a.pager-prev {
  grid-column: 1;
  align-items: flex-start;
  text-align: left;
}

.docs-pager a.pager-next {
  grid-column: 2;
  align-items: flex-end;
  text-align: right;
}

.docs-pager a.pager-link:hover {
  border-color: rgba(81, 218, 162, 0.45);
  background: #12121a;
  text-decoration: none;
}

.docs-pager .pager-dir {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
  transition: color 0.16s ease;
}

.docs-pager .pager-dir svg {
  flex-shrink: 0;
  transition: transform 0.16s ease, color 0.16s ease;
}

.docs-pager .pager-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  transition: color 0.16s ease;
}

.docs-pager a.pager-link:hover .pager-dir {
  color: var(--muted);
}

.docs-pager a.pager-link:hover .pager-dir svg {
  color: #51daa2;
}

.docs-pager a.pager-prev:hover .pager-dir svg {
  transform: translateX(-3px);
}

.docs-pager a.pager-next:hover .pager-dir svg {
  transform: translateX(3px);
}

.docs-pager a.pager-link:hover .pager-title {
  color: #fff;
}

/* ---- Footer ---- */

.site-footer {
  position: relative;
  z-index: 1;
  background: var(--bg);
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 28px 48px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 32px 36px calc(32px + env(safe-area-inset-bottom, 0px)) 268px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
}

.brand-mini .brand-mark { display: block; width: 16px; height: 16px; color: #51daa2; }
.brand-mini .brand-word { display: block; height: 13px; width: auto; color: #51daa2; }

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 48px;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 112px;
}

.footer-col h3 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.footer-col a { color: var(--muted); text-decoration: none; }
.footer-col a:hover { color: var(--text); }
.muted { color: var(--muted); }

/* ---- Responsive ---- */

@media (max-width: 820px) {
  body { font: 14px/1.6 var(--sans); }
  header { padding: 10px 14px; gap: 10px; }
  header .brand-docs { font-size: 12px; padding-left: 8px; }
  header .site-nav { gap: 14px; font-size: 12.5px; }

  .docs-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  nav.toc {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px 14px;
    gap: 10px;
    position: static;
    top: auto;
    bottom: auto;
    left: auto;
    width: auto;
    max-height: none;
    overflow: visible;
    z-index: auto;
  }

  nav.toc a,
  nav.toc .toc-sub a { font-size: 12px; padding: 4px 7px; }

  .toc-group {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }

  nav.toc .toc-sub {
    flex-direction: row;
    flex-wrap: wrap;
    margin: 0;
    padding-left: 6px;
    border-left: 1px solid var(--line);
    gap: 4px;
  }

  .toc-label {
    flex: 1 0 100%;
    padding-bottom: 2px;
    font-size: 10px;
  }

  main { grid-column: auto; padding: 22px 16px 64px; }
  .site-footer { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 25px; }
  h2 { font-size: 17px; margin: 30px 0 10px; padding-top: 18px; }
  h3 { font-size: 14.5px; margin: 22px 0 6px; }
  .lead { font-size: 14.5px; padding-bottom: 16px; margin-bottom: 20px; }
  .card-grid.two { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  td code { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
  .docs-pager { margin-top: 38px; padding-top: 20px; gap: 10px; }
  .docs-pager a.pager-link { padding: 13px 14px; }
  .docs-pager .pager-title { font-size: 14px; }
  .site-footer { padding: 24px 16px; font-size: 12px; }
}

@media (max-width: 520px) {
  .docs-pager { grid-template-columns: 1fr; }
  .docs-pager a.pager-prev,
  .docs-pager a.pager-next { grid-column: auto; }
}

/* Expandable FAQ accordion (matches landing page) */
.faq-list {
  margin: 14px 0 24px;
  border-top: 1px solid var(--line);
}
.faq-item {
  border-bottom: 1px solid var(--line);
}
.faq-item summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-item summary::after {
  content: "+";
  flex-shrink: 0;
  width: 1ch;
  text-align: center;
  font-family: var(--mono);
  font-weight: 400;
  color: var(--muted);
}
.faq-item[open] summary::after {
  content: "-";
}
.faq-item summary:hover {
  color: #fff;
}
.faq-body {
  padding: 0 0 18px;
}
.faq-body > :first-child {
  margin-top: 0;
}
.faq-body > :last-child {
  margin-bottom: 0;
}
