/* QTC ZkTree Desk — the ZK Merkle-tree observatory & proof laboratory.
 * Personality: a deep-space observatory at the edge of the quantum era —
 * near-black indigo, Poseidon teal starlight on everything provable, violet
 * nebula glow on the tree itself. Monospace for hashes, calm Inter for words. */
:root {
  --bg: #050510;
  --panel: #0b0b1c;
  --panel2: #101024;
  --line: #23234a;
  --line-hot: #5b5bd6;
  --txt: #eef0ff;
  --dim: #a7b0d8;
  --faint:#7981a7;
  --teal: #5eead4;
  --violet: #a78bfa;
  --sky: #7dd3fc;
  --grn: #6ee7a8;
  --red: #f87171;
  --amber: #fbbf24;
  --mono: "JetBrains Mono", "SF Mono", Consolas, Menlo, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--txt);
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 500px at 12% -10%, rgba(94, 234, 212, 0.07), transparent 60%),
    radial-gradient(1000px 600px at 105% 110%, rgba(167, 139, 250, 0.08), transparent 60%),
    radial-gradient(700px 400px at 85% 8%, rgba(125, 211, 252, 0.05), transparent 60%),
    var(--bg);
}
main.zkd, header.topbar, main + footer { position: relative; z-index: 1; }
header.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 16, 0.94); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
header.topbar .back { color: var(--dim); text-decoration: none; font-size: 14px; white-space: nowrap; }
header.topbar .back:hover { color: var(--teal); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  font-size: 22px; background: linear-gradient(135deg, #0e2a26, #1d3a52);
  border: 1px solid var(--line-hot); box-shadow: 0 0 18px rgba(94, 234, 212, 0.35);
}
.brand strong { display: block; font-size: 17px; letter-spacing: 0.3px; }
.brand > div span { display: block; font-size: 12px; color: var(--dim); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pill { font-size: 12px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-hot); color: var(--teal); background: rgba(94,234,212,.08); white-space: nowrap; }
.pill.ghost { border-color: var(--line); color: var(--dim); background: transparent; }
.qmb-switch summary { cursor: pointer; list-style: none; font-size: 13px; color: var(--dim); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.qmb-switch summary::-webkit-details-marker { display: none; }
.qmb-switch { position: relative; }
.qmb-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 320px; max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line-hot); border-radius: 12px; padding: 6px; z-index: 50;
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
}
.qmb-menu a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--txt); text-decoration: none; font-size: 13px; }
.qmb-menu a:hover { background: rgba(94,234,212,.08); }
.qmb-menu a.current { background: rgba(94,234,212,.14); border: 1px solid var(--line-hot); }
.qmb-menu .ico { width: 22px; text-align: center; }
.qmb-menu .meta { display: block; font-size: 11px; color: var(--faint); }
.qmb-menu .hub-link { border-top: 1px solid var(--line); margin-top: 4px; }

main.zkd { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-bottom: 18px; }
.panel.sub { background: var(--panel2); padding: 18px; }
.panel h2 { margin: 0 0 10px; font-size: 21px; letter-spacing: .2px; }
.panel h2 .live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); margin-left: 8px; vertical-align: 2px; }
.panel h2 .live-dot.on { background: var(--grn); box-shadow: 0 0 10px var(--grn); }
.panel h2 .live-dot.off { background: var(--red); box-shadow: 0 0 10px var(--red); }
.panel h3 { margin: 18px 0 10px; font-size: 15px; color: var(--teal); }
.hero h1 { font-size: clamp(28px, 4.4vw, 46px); margin: 6px 0 12px; letter-spacing: .3px;
  background: linear-gradient(100deg, #fff, var(--teal) 55%, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { max-width: 820px; color: var(--dim); font-size: 15.5px; line-height: 1.65; }
.lede code, .hint code, p code, li code, td code { font-family: var(--mono); font-size: .85em; background: rgba(94,234,212,.08); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--teal); }
.hero-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 20px; }
.hero-facts > div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: var(--panel2); }
.hero-facts .k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.hero-facts .v { display: block; font-size: 15px; font-weight: 700; color: var(--txt); margin-top: 4px; }

.tabs { display: flex; gap: 8px; margin: 4px 0 18px; flex-wrap: wrap; }
.tabs button { font-size: 14px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--dim); cursor: pointer; font-family: inherit; }
.tabs button:hover { color: var(--txt); border-color: var(--line-hot); }
.tabs button[aria-selected="true"] { color: #04121a; background: linear-gradient(135deg, var(--teal), var(--sky)); border-color: transparent; font-weight: 700; box-shadow: 0 0 22px rgba(94,234,212,.35); }
.hidden { display: none !important; }
.note { color: var(--dim); font-size: 14px; line-height: 1.6; }
.hint { font-size: 12px; color: var(--faint); font-weight: 400; }
.dim { color: var(--faint); }
.tag-note { font-size: 11px; color: var(--faint); font-weight: 500; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; vertical-align: 2px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--dim); margin: 10px 0 4px; }
input.mono, textarea.mono { width: 100%; background: #07071a; border: 1px solid var(--line); border-radius: 10px; color: var(--txt); font-family: var(--mono); font-size: 13px; padding: 10px 12px; margin-top: 4px; }
input.mono:focus, textarea.mono:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(94,234,212,.15); }
input.mono.wide { font-size: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1; min-width: 140px; }
.row.btns { margin-top: 14px; align-items: center; }
.row.wrap { align-items: center; }
.btn { font-size: 13.5px; font-weight: 600; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--txt); cursor: pointer; font-family: inherit; }
.btn:hover { border-color: var(--line-hot); }
.btn.primary { background: linear-gradient(135deg, #0f766e, #155e75); border-color: rgba(94,234,212,.4); color: #eafffb; }
.btn.primary:hover { box-shadow: 0 0 18px rgba(94,234,212,.35); }
.btn.accent { background: linear-gradient(135deg, #6d28d9, #4c1d95); border-color: rgba(167,139,250,.5); color: #f5f0ff; }
.btn.accent:hover { box-shadow: 0 0 18px rgba(167,139,250,.4); }
.btn.danger-ghost { color: var(--red); border-color: rgba(248,113,113,.3); background: transparent; }
.status { font-size: 13px; color: var(--faint); }
.status.ok { color: var(--grn); }
.status.bad { color: var(--red); }
.error { margin-top: 10px; font-size: 13px; color: var(--red); background: rgba(248,113,113,.07); border: 1px solid rgba(248,113,113,.3); border-radius: 10px; padding: 10px 14px; }

.conn-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.conn-row label { margin: 0; min-width: 280px; flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 14px 0; }
.stat-grid.small { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel2); }
.stat.wide { grid-column: 1 / -1; }
.stat .k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.stat .v { display: block; font-size: 19px; font-weight: 700; margin: 4px 0; word-break: break-all; }
.stat .v.small { font-size: 12.5px; font-weight: 500; }
.stat .s { display: block; font-size: 11.5px; color: var(--faint); }

.gauge-wrap { margin: 8px 0 4px; }
.gauge { position: relative; height: 26px; border-radius: 999px; background: #07071a; border: 1px solid var(--line); overflow: visible; }
.gauge-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--teal), var(--violet)); box-shadow: 0 0 16px rgba(94,234,212,.4); transition: width .6s ease; }
.gauge-mark { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--amber); left: 100%; }
.gauge-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: 8px; flex-wrap: wrap; gap: 6px; }
.gauge-labels .mark-label { color: var(--amber); }
.exhaust { margin-top: 12px; font-size: 14px; color: var(--dim); line-height: 1.7; }

.felt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.felt-table th { text-align: left; color: var(--faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.felt-table td { padding: 8px 10px; border-bottom: 1px solid rgba(35,35,74,.5); font-family: var(--mono); vertical-align: top; }
.felt-table td.f { color: var(--teal); word-break: break-all; }
.felt-table td.n { color: var(--faint); }
.felt-table tr.hl td { background: rgba(248,113,113,.06); }
.felt-table tr.hl td.f { color: var(--red); }

.result { margin-top: 14px; background: #07071a; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 12.5px; line-height: 1.7; word-break: break-all; white-space: pre-wrap; }
.result.small { font-size: 11.5px; }
.result .ok-line { color: var(--grn); }
.result .warn-line { color: var(--amber); }

.callouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-top: 16px; }
.callout { border: 1px solid var(--line); border-left: 3px solid var(--violet); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; line-height: 1.6; color: var(--dim); background: rgba(167,139,250,.04); }
.callout strong { color: var(--txt); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.eventlog { max-height: 220px; overflow: auto; background: #07071a; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.8; }
.eventlog .ev-leaf { color: var(--teal); }
.eventlog .ev-grow { color: var(--amber); font-weight: 700; }

#sim-canvas { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; background: radial-gradient(400px 200px at 50% 0%, rgba(167,139,250,.08), transparent 70%), #07071a; cursor: pointer; }

.verdict { margin-top: 12px; border-radius: 12px; padding: 14px 16px; font-size: 14px; font-weight: 600; line-height: 1.6; }
.verdict.pass { background: rgba(110,231,168,.08); border: 1px solid rgba(110,231,168,.4); color: var(--grn); }
.verdict.fail { background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.4); color: var(--red); }
.verdict .detail { display: block; font-weight: 400; font-size: 12.5px; margin-top: 6px; font-family: var(--mono); word-break: break-all; }

.story p { color: var(--dim); line-height: 1.7; font-size: 14.5px; }
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 16px 0; }
.fstep { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--panel2); font-size: 13px; color: var(--dim); line-height: 1.55; }
.fstep .fn { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--violet), var(--sky)); color: #0b0b1c; font-weight: 800; font-size: 13px; margin-right: 8px; }
.fstep strong { display: block; color: var(--txt); margin: 6px 0 4px; font-size: 14px; }
.scenario-table { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.scenario-table > div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 13.5px; border-bottom: 1px solid rgba(35,35,74,.5); }
.scenario-table > div:last-child { border-bottom: none; }
.scenario-table span { color: var(--dim); }
.scenario-table strong { color: var(--teal); font-family: var(--mono); font-size: 12.5px; }

.spec-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 8px 0 4px; }
.spec-table th { text-align: left; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.spec-table td { padding: 8px 10px; border-bottom: 1px solid rgba(35,35,74,.5); vertical-align: top; }
.spec-table td:first-child { color: var(--teal); white-space: nowrap; }

.facts { color: var(--dim); font-size: 14px; line-height: 1.7; padding-left: 20px; }
.facts li { margin-bottom: 8px; }
.facts a { color: var(--sky); }

footer { text-align: center; color: var(--faint); font-size: 13px; line-height: 2; padding: 26px 0 10px; }
footer a { color: var(--teal); text-decoration: none; }
footer code { font-family: var(--mono); font-size: 12px; color: var(--dim); word-break: break-all; }
