:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d1f24; --muted: #62666f; --line: #e2e0d8;
  --accent: #2f6f5e; --accent-ink: #ffffff; --warn: #a4541b; --bad: #a3322b; --good: #2f6f5e;
  --code-bg: #efede6; --pulse: #2f6f5e;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1113; --panel: #171a1d; --ink: #e7e5df; --muted: #9a9ea6; --line: #2a2e33;
    --accent: #6cc3a6; --accent-ink: #0f1113; --warn: #e0a15a; --bad: #ef7d74; --good: #6cc3a6;
    --code-bg: #1f2327; --pulse: #6cc3a6;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); }
a { color: var(--accent); }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
pre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 8px 0 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
header.top { border-bottom: 1px solid var(--line); background: var(--panel); }
header.top .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { font-weight: 650; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pulse); box-shadow: 0 0 0 0 var(--pulse); animation: beat 2.4s infinite; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pulse) 60%, transparent); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
nav a { color: var(--muted); text-decoration: none; margin-left: 14px; font-size: 14px; }
nav a:hover { color: var(--ink); }
nav { margin-left: auto; }
.hero { padding: 40px 0 16px; }
.hero h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; font-weight: 650; }
.hero p { color: var(--muted); max-width: 720px; margin: 0; }
section { margin: 28px 0; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 6px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.two { display: grid; gap: 14px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } }
.feed { max-height: 480px; overflow-y: auto; }
.pulse { border-top: 1px solid var(--line); padding: 8px 0; font-size: 13px; min-width: 0; }
.pulse:first-child { border-top: 0; }
.pulse .meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.pulse .payload { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
.fresh { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--pulse) 18%, transparent); } to { background: transparent; } }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: 12px; color: var(--muted); margin: 2px 4px 0 0; }
.badge { display: inline-block; border-radius: 4px; padding: 0 6px; font-size: 12px; font-weight: 600; }
.badge.good { color: var(--good); border: 1px solid var(--good); }
.badge.warn { color: var(--warn); border: 1px solid var(--warn); }
.badge.bad { color: var(--bad); border: 1px solid var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
.table-wrap { overflow-x: auto; }
input, select, textarea, button { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
button { cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:hover { border-color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.hidden { display: none !important; }
.rev { border-left: 2px solid var(--line); padding: 4px 0 10px 12px; margin-left: 4px; position: relative; }
.rev::before { content: ""; position: absolute; left: -5px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.rej td { color: var(--bad); }
footer { color: var(--muted); font-size: 13px; padding: 30px 0 40px; border-top: 1px solid var(--line); margin-top: 40px; }
.m0 { margin: 0; }
.grow { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
td.mono, .mono { overflow-wrap: anywhere; }
.rev pre { max-height: 240px; overflow: auto; }
@media (max-width: 640px) {
  header.top .wrap { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; gap: 6px; }
  nav { margin-left: 0; width: 100%; }
  nav a { margin: 0 14px 0 0; }
  .hero h1 { font-size: 25px; }
}

/* ---- docs ---- */
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; padding-top: 28px; }
.toc { position: sticky; top: 16px; align-self: start; font-size: 14px; }
.toc summary { font-weight: 650; cursor: pointer; margin-bottom: 8px; }
.toc ol { list-style: none; padding: 0; margin: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { display: block; padding: 4px 10px; color: var(--muted); text-decoration: none; border-left: 2px solid var(--line); }
.toc a::before { content: counter(toc) ". "; }
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); border-left-color: var(--accent); }
.doc { min-width: 0; max-width: 820px; }
.doc h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; }
.doc .lead { color: var(--muted); font-size: 16px; margin: 0 0 8px; }
.doc section { margin: 0; padding: 30px 0 6px; border-top: 1px solid var(--line); scroll-margin-top: 12px; }
.doc section:first-of-type { border-top: 0; }
.doc h2 { font-size: 21px; margin: 0 0 12px; }
.doc h3 { font-size: 15px; margin: 22px 0 8px; }
.doc p, .doc li { max-width: 72ch; }
.doc table { margin: 10px 0 14px; }
.doc td code, .doc p code, .doc li code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; overflow-wrap: anywhere; }
.doc pre { position: relative; }
.doc pre code { background: none; padding: 0; white-space: pre; }
.doc pre .copy { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 2px 8px; opacity: .75; }
.doc pre .copy:hover { opacity: 1; }
.tabset { margin: 12px 0; }
.tabbar { display: flex; gap: 2px; }
.tabbar button { border-radius: 6px 6px 0 0; border-bottom: 0; background: none; color: var(--muted); font-size: 13px; }
.tabbar button.on { background: var(--code-bg); color: var(--ink); border-color: var(--code-bg); }
.tabset pre { margin-top: 0; border-top-left-radius: 0; }
.callout { border-left: 3px solid var(--accent); background: var(--panel); padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 14px 0; }
.note { color: var(--muted); font-size: 14px; }
.terms { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 14px 0; }
.terms dt { font-weight: 650; }
.terms dd { margin: 0; color: var(--muted); }
.steps li { margin: 4px 0; }
table.ref td:nth-child(1), table.ref td:nth-child(3) { white-space: nowrap; color: var(--muted); }
table.ref td:nth-child(2) { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
table.ref tr.grp td { font-weight: 650; color: var(--ink); padding-top: 14px; font-family: var(--sans); }
.diagram { margin: 16px 0; }
.diagram svg { width: 100%; height: auto; max-width: 720px; display: block; }
.dg-box rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.dg-beacon rect { fill: color-mix(in srgb, var(--accent) 12%, var(--panel)); stroke: var(--accent); stroke-width: 1.5; }
.dg-line line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.dg-text text { fill: var(--ink); font: 600 14px var(--sans); text-anchor: middle; }
.dg-text text.dg-sub { fill: var(--muted); font-weight: 400; font-size: 12px; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:hover { border-color: var(--muted); }
@media (max-width: 900px) {
  .docs { grid-template-columns: 1fr; gap: 8px; padding-top: 16px; }
  .toc { position: static; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
  .toc summary { margin: 0; }
  .terms { grid-template-columns: 1fr; }
  .terms dd { margin-bottom: 6px; }
}
.doc table.ops td:first-child code { white-space: nowrap; overflow-wrap: normal; }
.doc pre { padding-top: 32px; }
.diagram { overflow-x: auto; }
.diagram svg { min-width: 560px; }
