:root {
  color-scheme: dark;
  /* backgrounds */
  --bg: #0A0E14; --bg-vignette: #07090E; --panel: #11161F; --panel-raised: #151C28;
  --hairline: #1E2633;
  /* text */
  --text: #E8EDF4; --text-dim: #9FB0C3; --text-mute: #6B7A8D;
  /* graph */
  --edge-idle: #1E3A5F; --node-unverified: #3B5070;
  /* accents (interaction) */
  --accent-blue: #4C8DFF; --accent-cyan: #5CC8FF;
  /* state (verification semantics, reserved) */
  --success: #34D399; --success-glow: #6EE7A8; --gold: #FACC15; --fail: #FF4D6D;
  /* lane identity (never a node body fill). alpha/beta/gamma are cool + desaturated; delta is a
     deliberately warm amber, the visual cue that the fourth store is unlike the vector RAGs. */
  --lane-alpha: #8B7CFF; --lane-beta: #3FA9F5; --lane-gamma: #36C5C0; --lane-delta: #E0A458;

  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Space Grotesk", var(--sans);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #0d1420 0%, var(--bg) 55%, var(--bg-vignette) 100%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; }
code, .mono { font-family: var(--mono); }
.muted { color: var(--text-dim); }
button { font-family: var(--sans); cursor: pointer; }

/* register toggle: show/hide by [data-register] on <body> */
body[data-register="expert"] [data-x="plain"] { display: none !important; }
body[data-register="plain"] [data-x="expert"] { display: none !important; }

/* ---------- header rail ---------- */
.rail {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 26px; background: rgba(10,14,20,0.82); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.brand h1 { margin: 0; font-size: 24px; letter-spacing: 0.04em; }
.brand .dek { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }
.rail-right { display: flex; align-items: center; gap: 16px; }
.verdict {
  font-family: var(--mono); font-size: 12.5px; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--hairline); color: var(--text-dim); white-space: nowrap;
}
.verdict.idle { color: var(--text-dim); }
.verdict.pass { color: var(--success-glow); border-color: rgba(52,211,153,0.5); background: rgba(52,211,153,0.08); }
.verdict.fail { color: var(--fail); border-color: rgba(255,77,109,0.5); background: rgba(255,77,109,0.08); }
.register { display: inline-flex; border: 1px solid var(--hairline); border-radius: 8px; overflow: hidden; }
.register button {
  background: transparent; color: var(--text-dim); border: 0; padding: 6px 12px; font-size: 12.5px;
}
.register button.on { background: var(--accent-blue); color: #06101f; font-weight: 600; }

/* ---------- main stage ---------- */
.stage {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px;
  padding: 18px 26px; align-items: start;
}
@media (max-width: 940px) { .stage { grid-template-columns: 1fr; } }

.explorer { background: var(--panel); border: 1px solid var(--hairline); border-radius: 14px; padding: 14px; }
.lanes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.lane-head {
  border: 1px solid var(--hairline); border-top: 2px solid var(--lane); border-radius: 8px;
  padding: 9px 11px; background: linear-gradient(180deg, color-mix(in srgb, var(--lane) 9%, transparent), transparent);
}
.lane-head .lh-name { font-family: var(--mono); font-size: 13px; color: var(--text); font-weight: 500; }
.lane-head .lh-meta { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-family: var(--mono); font-size: 10.5px; padding: 2px 6px; border-radius: 5px;
  background: var(--panel-raised); border: 1px solid var(--hairline); color: var(--text-dim);
}
.chip.anchor-fp { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 30%, var(--hairline)); }

.dag-wrap { width: 100%; }
#dag { width: 100%; height: auto; display: block; }

.controls { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.controls .primary {
  background: var(--accent-blue); color: #06101f; font-weight: 600; border: 0;
  padding: 9px 18px; border-radius: 8px; font-size: 14px;
}
.controls .primary:disabled { opacity: 0.45; cursor: progress; }
.controls button:not(.primary) {
  background: var(--panel-raised); color: var(--text-dim); border: 1px solid var(--hairline);
  padding: 9px 14px; border-radius: 8px;
}
.controls-hint { color: var(--text-mute); font-size: 12px; }

/* ---------- SVG graph ---------- */
.lane-wash { opacity: 0.5; }
.edge { fill: none; stroke: var(--edge-idle); stroke-width: 1.6; transition: stroke 0.25s; }
.edge.pass { stroke: var(--success); }
.edge.fail { stroke: var(--fail); }
.edge-label { fill: var(--text-mute); font-family: var(--mono); font-size: 9px; }

.waist-band { fill: rgba(76,141,255,0.06); stroke: rgba(92,200,255,0.4); stroke-width: 1; }
.waist-band.flare { fill: rgba(255,77,109,0.10); stroke: var(--fail); }
.waist-chip { fill: var(--panel-raised); stroke: var(--hairline); }
.waist-chip-text { fill: var(--accent-cyan); font-family: var(--mono); font-size: 11px; }
.gate { fill: var(--text); font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; }

.node { cursor: pointer; }
.node .body { fill: var(--node-unverified); stroke: var(--lane, var(--hairline)); stroke-width: 1.4; transition: fill 0.2s, stroke 0.2s; }
.node.live .body { fill: var(--accent-cyan); }
.node.pass .body { fill: var(--success); stroke: var(--success-glow); }
.node.fail .body { fill: var(--fail); stroke: #ff7d97; }
.node.tainted .body { fill: color-mix(in srgb, var(--fail) 55%, var(--panel)); stroke: var(--fail); stroke-dasharray: 4 3; }
.node.selected .body { stroke: var(--gold); stroke-width: 2.4; }
.node .kind { fill: rgba(255,255,255,0.6); font-family: var(--mono); font-size: 8px; letter-spacing: 0.06em; }
.node .nm { fill: var(--text); font-family: var(--mono); font-size: 10.5px; }
.node.pass .nm, .node.fail .nm, .node.live .nm { fill: #06101f; }
.node .pip { fill: rgba(255,255,255,0.18); }
.node .pip.on { fill: #06101f; }

.anchor polygon { fill: color-mix(in srgb, var(--gold) 18%, var(--panel-raised)); stroke: var(--gold); stroke-width: 1.2; }
.anchor text { fill: var(--gold); font-family: var(--mono); font-size: 9px; }
.anchor .lock { fill: var(--gold); }

/* ---------- inspector ---------- */
.inspector {
  position: sticky; top: 82px; background: var(--panel-raised);
  border: 1px solid var(--hairline); border-radius: 14px; padding: 16px; min-height: 360px;
}
.inspector h2 { margin: 0 0 8px; font-size: 16px; }
.legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.legend li { font-size: 12.5px; color: var(--text-dim); display: grid; grid-template-columns: 14px 1fr; gap: 8px; align-items: start; }
.legend b { color: var(--text); }
.key { width: 11px; height: 11px; border-radius: 3px; margin-top: 3px; }
.k-integrity { background: var(--accent-cyan); } .k-auth { background: var(--accent-blue); } .k-authz { background: var(--gold); }

.rec-name { font-family: var(--mono); font-size: 13px; color: var(--text); word-break: break-all; }
.rec-kindrow { display: flex; gap: 8px; align-items: center; margin: 2px 0 12px; }
.rec-kind { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--text-dim); border: 1px solid var(--hairline); border-radius: 4px; padding: 1px 6px; }
.rec-field { margin: 10px 0; }
.rec-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); margin-bottom: 3px; }
.rec-val { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); word-break: break-all; }
.rec-val .ok { color: var(--success-glow); } .rec-val .bad { color: var(--fail); }
.hexdiff .same { color: var(--text-mute); } .hexdiff .diff { color: var(--fail); background: rgba(255,77,109,0.14); }

.layers { display: grid; gap: 8px; margin: 14px 0; }
.layer-row { display: grid; grid-template-columns: 18px 1fr auto; gap: 9px; align-items: center;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 8px; padding: 9px 11px; }
.layer-row .ic { width: 12px; height: 12px; border-radius: 50%; background: var(--node-unverified); }
.layer-row.pass .ic { background: var(--success); } .layer-row.fail .ic { background: var(--fail); }
.layer-row .lr-name { font-size: 13px; } .layer-row .lr-sub { font-size: 11.5px; color: var(--text-dim); }
.layer-row .tok { font-family: var(--mono); font-size: 11px; color: var(--text-mute); }
.layer-row.pass .tok { color: var(--success-glow); } .layer-row.fail .tok { color: var(--fail); }

.tamper { margin-top: 14px; border-top: 1px solid var(--hairline); padding-top: 12px; }
.tamper h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); margin: 0 0 8px; }
.tamper textarea { width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--hairline);
  border-radius: 7px; padding: 8px; font-family: var(--mono); font-size: 12px; resize: vertical; min-height: 48px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.preset-row button { background: var(--panel); border: 1px solid var(--hairline); color: var(--text-dim);
  border-radius: 7px; padding: 6px 9px; font-size: 11.5px; }
.preset-row button:hover { border-color: var(--fail); color: var(--text); }

/* ---------- log ---------- */
.log-strip { margin: 0 26px 16px; background: var(--panel); border: 1px solid var(--hairline); border-radius: 12px; }
.log-head { padding: 9px 14px; border-bottom: 1px solid var(--hairline); color: var(--text-dim); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.log-head .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.log { margin: 0; padding: 10px 14px; list-style: none; font-family: var(--mono); font-size: 12px;
  max-height: 168px; overflow-y: auto; color: var(--text-dim); }
.log li { padding: 1px 0; white-space: pre-wrap; }
.log li .t { color: var(--text-mute); } .log li .ok { color: var(--success-glow); } .log li .bad { color: var(--fail); } .log li .hi { color: var(--accent-cyan); }

/* ---------- explainer ---------- */
.explainer { margin: 0 26px 40px; border-top: 1px solid var(--hairline); padding-top: 22px; }
.explainer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 820px) { .explainer-grid { grid-template-columns: 1fr; } }
.explainer h3 { font-size: 15px; margin: 0 0 8px; }
.explainer p { color: var(--text-dim); font-size: 13.5px; }
.thesis { color: var(--text); font-style: italic; border-left: 2px solid var(--accent-cyan); padding-left: 14px; }
.provenance-note code { color: var(--accent-cyan); }

/* ---------- footer ---------- */
.site-footer { text-align: center; padding: 28px 26px 44px; border-top: 1px solid var(--hairline); }
.site-footer a { color: var(--accent-blue); font-weight: 700; text-decoration: underline; }
.site-footer a:hover { color: var(--accent-cyan); }

/* ---------- client telemetry (loop-amortized wasm profiling) ---------- */
.telemetry {
  margin-top: 12px; border: 1px solid var(--hairline); border-radius: 10px; padding: 11px 13px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--success) 7%, var(--panel)), var(--panel));
}
.tele-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--text); font-weight: 600; }
.tele-head .tele-sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-mute); font-weight: 400; }
.tele-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 9px; }
@media (max-width: 620px) { .tele-rows { grid-template-columns: 1fr; } }
.tele-row {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px;
  background: var(--panel-raised); border: 1px solid var(--hairline); border-radius: 7px;
}
.tele-label { font-size: 11px; color: var(--text-dim); }
.tele-val { font-family: var(--mono); font-size: 14px; color: var(--success-glow); }

/* ---------- per-store performance + unit-economics panel ---------- */
.perf { margin: 0 26px 40px; background: var(--panel); border: 1px solid var(--hairline); border-radius: 14px; padding: 16px 18px; }
.perf-head h3 { font-size: 15px; margin: 0 0 6px; }
.perf-head p { font-size: 13px; margin: 0; color: var(--text-dim); }
.perf-head code { color: var(--accent-cyan); }
.perf-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
@media (max-width: 720px) { .perf-cards { grid-template-columns: 1fr; } }
.perf-card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-cyan) 7%, var(--panel-raised)), var(--panel-raised));
  border: 1px solid var(--hairline); border-radius: 10px; padding: 11px 13px;
}
.perf-card-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); }
.perf-card-val { font-family: var(--mono); font-size: 18px; color: var(--accent-cyan); margin: 3px 0; }
.perf-card-sub { font-size: 11.5px; color: var(--text-dim); }
.perf-ctrl { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.perf-ctrl-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); }
.perf-seg { display: inline-flex; border: 1px solid var(--hairline); border-radius: 8px; overflow: hidden; }
.perf-seg button { background: transparent; color: var(--text-dim); border: 0; padding: 5px 11px; font-size: 12px; font-family: var(--mono); }
.perf-seg button.on { background: var(--accent-blue); color: #06101f; font-weight: 600; }
.perf-table-wrap { overflow-x: auto; }
.perf-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.perf-table th {
  text-align: right; font-weight: 500; color: var(--text-mute); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 7px 10px; border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
.perf-table th:first-child, .perf-table th:nth-child(2) { text-align: left; }
.perf-table td { padding: 7px 10px; border-bottom: 1px solid var(--hairline); }
.perf-num { font-family: var(--mono); text-align: right; color: var(--text-dim); white-space: nowrap; }
.perf-strong { color: var(--text); }
.perf-store { font-family: var(--mono); color: var(--text); }
.perf-dim { font-family: var(--mono); color: var(--text-mute); font-size: 11.5px; }
.perf-slowest td { background: rgba(250,204,21,0.07); }
.perf-slowest .perf-store { color: var(--gold); }
.perf-cap { font-size: 11px; margin-top: 7px; }
.perf-note { font-size: 11.5px; margin-top: 12px; border-top: 1px solid var(--hairline); padding-top: 10px; }
