:root {
  --bg: #0d1117; --bg2: #161b22; --card: #161b22; --line: #21262d;
  --fg: #e6edf3; --muted: #8b949e;
  --bid: #3fb950; --ask: #f85149; --gold: #d4a547; --link: #58a6ff;
  --bidDim: rgba(63,185,80,.14); --askDim: rgba(248,81,73,.13);
  --maxw: 1040px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff; --bg2: #f6f8fa; --card: #ffffff; --line: #d0d7de;
    --fg: #1f2328; --muted: #59636e; --link: #0969da;
    --bidDim: rgba(31,136,61,.10); --askDim: rgba(207,34,46,.09);
    --bid: #1a7f37; --ask: #cf222e;
  }
}
:root[data-theme="dark"] { --bg:#0d1117; --bg2:#161b22; --card:#161b22; --line:#21262d; --fg:#e6edf3; --muted:#8b949e; }
:root[data-theme="light"] { --bg:#fff; --bg2:#f6f8fa; --card:#fff; --line:#d0d7de; --fg:#1f2328; --muted:#59636e; --link:#0969da; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; background: var(--line); padding: 1px 6px; border-radius: 5px; }
b, strong { color: var(--fg); font-weight: 650; }

/* nav */
.nav {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px max(20px, calc((100% - var(--maxw)) / 2));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--fg); }
.nav-links { display: flex; gap: 18px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--fg); text-decoration: none; }
.nav-gh { color: var(--gold) !important; font-weight: 600; }
@media (max-width: 760px) { .nav-links a:not(.nav-gh) { display: none; } }

/* layout */
main, .hero { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.sec { padding: 54px 0; border-top: 1px solid var(--line); }
.sec h2 { font-size: 30px; letter-spacing: -.02em; margin: 0 0 12px; }
.sec-lede { color: var(--muted); font-size: 17px; max-width: 70ch; margin: 0 0 18px; }
.sec-lede strong, .sec-lede em { color: var(--fg); }

/* hero */
.hero { padding-top: 60px; padding-bottom: 40px; text-align: center; }
.eyebrow { font-size: 12px; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.hero h1 { font-size: 46px; line-height: 1.1; letter-spacing: -.03em; margin: 14px 0 18px; }
.lede { color: var(--muted); font-size: 18px; max-width: 62ch; margin: 0 auto 26px; }
.lede strong { color: var(--fg); }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn { display: inline-block; font-size: 15px; font-weight: 600; padding: 11px 20px; border-radius: 9px;
  border: 1px solid var(--line); color: var(--fg); background: var(--card); cursor: pointer; transition: filter .15s, transform .05s; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #241a04; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { display: block; text-align: center; margin-top: 14px; }
@media (max-width: 640px) { .hero h1 { font-size: 32px; } }

.stat-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 34px; }
.stat-row div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 20px; min-width: 130px; }
.stat-row b { display: block; font-size: 22px; color: var(--gold); }
.stat-row span { font-size: 12.5px; color: var(--muted); }

/* two-column */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }
.explain { margin: 0 0 16px; padding-left: 20px; }
.explain li { margin: 0 0 12px; color: var(--fg); }
.explain .g { color: var(--bid); font-weight: 600; } .explain .r { color: var(--ask); font-weight: 600; }
.hint { color: var(--muted); font-size: 14px; }

/* order book panel */
.ob-panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.ob-head, .ob-mid { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.ob-head { padding: 0 6px 8px; border-bottom: 1px solid var(--line); }
.ob-mid { padding: 9px 6px; margin: 3px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.ob-side { display: flex; flex-direction: column; }
.ob-row { position: relative; display: flex; justify-content: space-between; padding: 4px 6px; font-variant-numeric: tabular-nums; font-size: 14px; border-radius: 5px; overflow: hidden; }
.ob-row .p { z-index: 1; font-weight: 600; } .ob-row .s { z-index: 1; color: var(--muted); }
.ob-row .bar { position: absolute; top: 0; right: 0; height: 100%; width: 0; transition: width .4s cubic-bezier(.22,.61,.36,1); }
.ob-side.a .p { color: var(--ask); } .ob-side.a .bar { background: var(--askDim); }
.ob-side.b .p { color: var(--bid); } .ob-side.b .bar { background: var(--bidDim); }
.ob-row.best .p { text-shadow: 0 0 8px currentColor; }
.ob-row.hit { animation: hit .5s ease; }
@keyframes hit { from { background: var(--gold); } to { background: transparent; } }
.tape { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; min-height: 26px; font-size: 13px; font-variant-numeric: tabular-nums; }
.tape .t { display: flex; justify-content: space-between; padding: 1px 4px; animation: fadein .4s ease; }
.tape .t.buy { color: var(--bid); } .tape .t.sell { color: var(--ask); }
@keyframes fadein { from { opacity: 0; } }

.steps { display: flex; gap: 10px; margin-bottom: 14px; }
.step-text { font-size: 15px; min-height: 48px; }
.mini { color: var(--muted); font-size: 14px; padding-left: 18px; }
.mini li { margin: 6px 0; }

/* features */
.feat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.feat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.feat h3 { margin: 0 0 10px; font-size: 16px; color: var(--gold); }
.feat ul { margin: 0; padding-left: 18px; }
.feat li { margin: 6px 0; font-size: 14.5px; }

/* production */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.prod { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.prod h3 { margin: 0 0 8px; font-size: 16px; }
.prod p { margin: 0; color: var(--muted); font-size: 14.5px; }
.prod b { color: var(--gold); }

/* code */
.code { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; overflow-x: auto; margin: 0 0 18px; }
.code code { background: none; padding: 0; font-size: 13px; line-height: 1.6; color: var(--fg); white-space: pre; }
.doclist { padding-left: 18px; } .doclist li { margin: 7px 0; }
.start-col { align-items: start; }

/* footer + loading */
.foot { max-width: var(--maxw); margin: 0 auto; padding: 30px 20px 50px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; border-top: 1px solid var(--line); }
.loading { position: fixed; top: 12px; right: 16px; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.loading.done { display: none; }

/* ---------- docs page (deliberately plain & text-first) ---------- */
.docs-top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 28px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.docs-toplinks { display: flex; gap: 20px; font-size: 14px; }
.docs-toplinks a { color: var(--muted); } .docs-toplinks a:hover { color: var(--fg); text-decoration: none; }

.docs { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 40px; max-width: 1020px; margin: 0 auto; padding: 0 28px; }
@media (max-width: 800px) { .docs { grid-template-columns: 1fr; } .docs-nav { display: none; } }

.docs-nav { position: sticky; top: 64px; align-self: start; height: calc(100vh - 80px); overflow-y: auto; padding: 28px 0; }
.docs-nav nav { display: flex; flex-direction: column; gap: 2px; }
.docs-nav-title { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.docs-nav a { color: var(--muted); font-size: 14px; padding: 5px 12px; border-left: 2px solid transparent; }
.docs-nav a:hover { color: var(--fg); text-decoration: none; }
.docs-nav a.on { color: var(--fg); border-left-color: var(--gold); }

.docs-main { max-width: 720px; padding: 30px 0 90px; }
.docs-main h1 { font-size: 30px; letter-spacing: -.02em; margin: 0 0 16px; }
.docs-main h2 { font-size: 22px; letter-spacing: -.01em; margin: 46px 0 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.docs-main h3 { font-size: 16px; margin: 26px 0 8px; }
.docs-main p { margin: 0 0 14px; }
.docs-main ul { margin: 0 0 14px; padding-left: 22px; } .docs-main li { margin: 6px 0; }
.docs-main a { color: var(--link); }
.docs-main section { scroll-margin-top: 76px; }

.tbl { width: 100%; border-collapse: collapse; margin: 4px 0 18px; font-size: 14.5px; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12.5px; letter-spacing: .03em; }
.tbl td:first-child { white-space: nowrap; font-weight: 600; }
.tbl td:nth-child(2), .tbl td:nth-child(3) { font-variant-numeric: tabular-nums; }
.diagram { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 16px; overflow-x: auto; margin: 0 0 16px; }
.diagram code { background: none; padding: 0; font-size: 12.5px; line-height: 1.7; color: var(--muted); white-space: pre; }
