/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  /* Zinc scale – neutral near-black */
  --bg:        #09090b;   /* zinc-950 */
  --surface:   #111116;   /* zinc-900+ */
  --panel:     #18181b;   /* zinc-900 */
  --card:      #27272a;   /* zinc-800 */
  --border:    #3f3f46;   /* zinc-700 */
  --border-s:  rgba(255,255,255,0.06);  /* subtle */

  /* Typography */
  --text:  #fafafa;   /* zinc-50  */
  --muted: #a1a1aa;   /* zinc-400 */
  --dim:   #71717a;   /* zinc-500 */

  /* Accent – single indigo */
  --accent:     #6366f1;
  --accent-lt:  #818cf8;
  --accent-dim: rgba(99,102,241,0.12);

  /* Semantic — muted, professional */
  --green:     #166534;
  --green-lt:  #6db392;
  --green-dim: rgba(109,179,146,0.10);

  --amber:     #92400e;
  --amber-lt:  #c49a52;
  --amber-dim: rgba(196,154,82,0.10);

  --red:     #991b1b;
  --red-lt:  #c47878;
  --red-dim: rgba(196,120,120,0.10);

  --cyan:    #155e75;
  --cyan-lt: #5aafc4;
  --cyan-dim: rgba(90,175,196,0.10);

  /* Geometry */
  --radius:    9px;
  --radius-sm: 6px;
  --shadow:    0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);

  /* Type */
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
}

/* ── Reset ──────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased; }

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--card); border-radius: 3px; }

/* ── Typography ─────────────────────────────────── */
h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
h3 { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--dim);
}

/* ── Header ─────────────────────────────────────── */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 28px; height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-s);
  position: sticky; top: 0; z-index: 100;
}

.hd-left { display: flex; align-items: center; gap: 14px; }

.hd-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; letter-spacing: 0.02em;
}

.hd-label { display: flex; flex-direction: column; gap: 1px; }
.hd-label .label { color: #52525b; }
.hd-label h1 { font-size: 14px; }

.mode-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 99px;
  border: 1px solid var(--border-s);
  font-size: 12px; font-weight: 500; color: var(--muted);
}
.mode-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); transition: background .3s; }
.mode-pill.live .dot { background: var(--green-lt); }
.mode-pill.archive .dot { background: var(--cyan-lt); }

/* ── Section wrapper ────────────────────────────── */
.sec { padding: 24px 28px; }
.sec + .sec { padding-top: 0; }

.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sec-head .cnt { font-size: 11px; font-weight: 600; color: var(--dim); }

/* ── Filter chips ───────────────────────────────── */
.filters { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.fchip {
  padding: 4px 13px; border-radius: 99px; border: 1px solid var(--border-s);
  background: transparent; color: var(--dim);
  font-size: 12px; font-weight: 500; cursor: pointer; transition: all .12s;
  font-family: var(--sans); white-space: nowrap;
}
.fchip:hover { border-color: var(--border); color: var(--muted); }
.fchip.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-lt); }
.fchip.on.tp { background: var(--green-dim); border-color: var(--green); color: var(--green-lt); }
.fchip.on.fp { background: var(--amber-dim); border-color: var(--amber); color: var(--amber-lt); }
.fchip.on.fn { background: var(--red-dim); border-color: var(--red); color: var(--red-lt); }

/* ── Transaction cards ──────────────────────────── */
.tx-scroll { overflow-x: auto; padding-bottom: 4px; }
.tx-row { display: flex; gap: 10px; min-width: max-content; padding: 2px 2px 10px; }

.tx-card {
  width: 196px; flex-shrink: 0;
  background: var(--panel); border: 1px solid var(--border-s);
  border-radius: var(--radius); padding: 13px 14px;
  cursor: pointer; text-align: left;
  transition: border-color .12s, background .12s;
  font-family: var(--sans);
}
.tx-card:hover { border-color: var(--border); background: var(--card); }
.tx-card.on {
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(99,102,241,.15);
}

.tx-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }

.cbadge {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.tp { background: var(--green-dim); color: var(--green-lt); }
.fp { background: var(--amber-dim); color: var(--amber-lt); }
.tn { background: rgba(255,255,255,0.04); color: var(--dim); }
.fn { background: var(--red-dim); color: var(--red-lt); }
.bl { background: var(--accent-dim); color: var(--accent-lt); }

.tx-proof { font-size: 10px; font-weight: 600; color: var(--cyan-lt); letter-spacing: 0.04em; }

.tx-score { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.score-hi { color: var(--red-lt); }
.score-md { color: var(--amber-lt); }
.score-lo { color: var(--dim); }

.tx-meta { font-size: 11px; color: var(--dim); line-height: 1.4; }
.tx-meta b { color: var(--muted); font-weight: 500; }

.tx-bar { height: 2px; background: var(--border-s); border-radius: 1px; margin-top: 10px; overflow: hidden; position: relative; }
.tx-fill { height: 100%; border-radius: 1px; transition: width .4s; }
/* threshold tick at 55% */
.tx-bar::after { content:''; position:absolute; top:-2px; bottom:-2px; left:55%; width:1px; background: rgba(255,255,255,0.25); }

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); font-family: var(--sans); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .12s; white-space: nowrap; line-height: 1;
}
.btn:hover { border-color: var(--border); color: var(--text); background: var(--card); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4f46e5; border-color: #4f46e5; }
.btn.ghost { background: transparent; border-color: var(--border-s); }
.btn.ghost:hover { border-color: var(--border); color: var(--text); }
.btn.teal { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.btn.teal:hover { background: #0e7490; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Pipeline ───────────────────────────────────── */
#pipeline { padding: 0 28px 24px; }

.pipe-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pipe-head h2 { font-size: 14px; }
.pipe-acts { display: flex; gap: 7px; }

/* ── Stage accordion ────────────────────────────── */
.stage {
  border: 1px solid var(--border-s);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color .15s;
}
.stage.open { border-color: var(--border); }

.stage-hd {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 16px; cursor: pointer; user-select: none;
}
.stage-hd:hover .stage-title { color: var(--text); }

.s-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--border); display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--dim);
  transition: all .15s;
}
.stage.open .s-num { border-color: var(--accent); color: var(--accent-lt); }
.stage.done .s-num { border-color: var(--green); color: var(--green-lt); background: var(--green-dim); font-size: 13px; }

.s-info { flex: 1; min-width: 0; }
.stage-title { font-size: 13px; font-weight: 600; color: var(--muted); transition: color .15s; }
.stage.open .stage-title, .stage.done .stage-title { color: var(--text); }
.stage-sub { font-size: 11px; color: var(--dim); margin-top: 1px; }

.s-chip {
  font-size: 11px; font-weight: 500; padding: 3px 9px;
  border-radius: 99px; border: 1px solid var(--border-s);
  color: var(--dim); display: none; flex-shrink: 0;
}
.stage.done .s-chip { display: block; }
.stage.done.ok .s-chip { color: var(--green-lt); border-color: rgba(109,179,146,.2); background: var(--green-dim); }
.stage.done.warn .s-chip { color: var(--amber-lt); border-color: rgba(196,154,82,.2); background: var(--amber-dim); }

.chevron { color: var(--dim); font-size: 10px; transition: transform .2s; flex-shrink: 0; }
.stage.open .chevron { transform: rotate(90deg); }

.stage-body { max-height: 0; overflow: hidden; transition: max-height .35s cubic-bezier(.4,0,.2,1); }
.stage.open .stage-body { max-height: 2400px; }

.stage-inner {
  padding: 0 16px 18px;
  border-top: 1px solid var(--border-s);
}

/* ── Graph ──────────────────────────────────────── */
.graph-wrap {
  position: relative; height: 460px; margin-top: 14px;
  border-radius: var(--radius-sm); overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.018) 0, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.018) 0, transparent 1px, transparent 40px),
    var(--surface);
  border: 1px solid var(--border-s);
}
#graph-svg { width: 100%; height: 100%; }

.graph-badge {
  position: absolute; top: 12px; right: 12px;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  border: 1px solid;
  backdrop-filter: blur(4px);
}
.graph-badge .bdot { width: 7px; height: 7px; border-radius: 50%; animation: pulse 2s ease-in-out infinite; }

.badge-tp { background: rgba(140,60,60,.22); border-color: rgba(196,120,120,.3); color: #c47878; }
.badge-fn { background: rgba(150,100,50,.20); border-color: rgba(196,154,82,.28); color: #c49a70; }
.badge-fp { background: rgba(140,110,40,.18); border-color: rgba(196,154,82,.25); color: #c4a850; }
.badge-tn { background: rgba(70,75,160,.20); border-color: rgba(100,105,200,.28); color: #8b90c9; }

.badge-tp .bdot { background: #c47878; }
.badge-fn .bdot { background: #c49a70; }
.badge-fp .bdot { background: #c4a850; }
.badge-tn .bdot { background: #8b90c9; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.graph-legend {
  position: absolute; bottom: 10px; left: 12px;
  display: flex; gap: 12px;
}
.leg-item { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--dim); font-weight: 500; }
.leg-dot { width: 8px; height: 8px; border-radius: 50%; }

.g-tooltip {
  position: absolute; pointer-events: none; display: none;
  background: rgba(9,9,11,.96); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px;
  font-size: 11px; max-width: 220px; box-shadow: var(--shadow); z-index: 10;
}
.g-tooltip b { color: var(--text); display: block; margin-bottom: 4px; }
.g-tooltip .trow { color: var(--muted); line-height: 1.6; }
.g-tooltip .tsel { color: #fca5a5; font-weight: 600; margin-top: 3px; }

/* SVG graph elements */
.g-edge { stroke-width: 1.5; fill: none; }
.g-edge.sel { stroke-width: 3; }
.g-edge.sel.anim { stroke-dasharray: 7 4; animation: dash .5s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -22; } }

.g-node-circle { stroke-width: 2; }
.g-node-glow { opacity: .3; }
.g-label { font-family: var(--mono); fill: rgba(255,255,255,0.85); font-size: 9px; font-weight: 600; pointer-events: none; text-anchor: middle; }
.g-amount-label { font-family: var(--mono); font-size: 9px; font-weight: 600; pointer-events: none; text-anchor: middle; fill: rgba(255,255,255,.75); }

/* ── Feature panel ──────────────────────────────── */
.feat-section { margin-top: 16px; }
.feat-table { width: 100%; border-collapse: collapse; }
.feat-table th {
  text-align: left; font-size: 10px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--dim); padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--border-s);
}
.feat-table td {
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--border-s);
  vertical-align: middle;
}
.feat-table tr:last-child td { border-bottom: none; }
.feat-name { font-size: 12px; color: var(--muted); }
.feat-val { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.feat-bar-wrap { width: 100px; height: 4px; background: var(--card); border-radius: 2px; overflow: hidden; }
.feat-bar-fill { height: 100%; border-radius: 2px; }
.feat-note {
  margin-top: 12px; padding: 9px 12px;
  background: rgba(8,145,178,.07); border-left: 2px solid var(--cyan);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 11px; color: var(--muted); line-height: 1.55;
}

/* ── Key stage ──────────────────────────────────── */
.key-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.key-field {
  background: var(--panel); border: 1px solid var(--border-s);
  border-radius: var(--radius-sm); padding: 12px;
}
.kf-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); margin-bottom: 5px; }
.kf-val { font-family: var(--mono); font-size: 12px; color: var(--cyan-lt); word-break: break-all; }
.kf-sub { font-size: 11px; color: var(--dim); margin-top: 4px; }

.circ-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 10px; }
.circ-stat { background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius-sm); padding: 10px 12px; }
.circ-val { font-size: 19px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.circ-lbl { font-size: 10px; color: var(--dim); margin-top: 2px; }

/* ── Encrypt stage ──────────────────────────────── */
.enc-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; margin-top: 14px; }
.enc-side { background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius-sm); padding: 12px; }
.enc-side-lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); margin-bottom: 9px; }
.enc-arrow { display: flex; flex-direction: column; align-items: center; gap: 5px; padding-top: 32px; color: var(--cyan-lt); }
.enc-arrow .icon { font-size: 18px; }
.enc-arrow span { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); }

.fg-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-top: 1px solid var(--border-s); font-size: 12px; }
.fg-row:first-child { border-top: none; }
.fg-cnt { font-family: var(--mono); font-size: 11px; color: var(--accent-lt); }
.fg-total { font-size: 11px; color: var(--dim); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-s); }

.hex-block {
  font-family: var(--mono); font-size: 11px; color: var(--cyan-lt);
  line-height: 1.85; word-break: break-all; letter-spacing: 0.03em;
}
.hex-block.dim { color: var(--dim); }
.hex-size { font-size: 10px; color: var(--dim); margin-top: 6px; }

/* ── FHE Execute stage ──────────────────────────── */
.fhe-row { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; }
.fhe-out {
  flex: 1; background: var(--panel); border: 1px solid var(--border-s);
  border-radius: var(--radius-sm); padding: 13px;
  transition: border-color .2s;
}
.fhe-out.running { border-color: var(--amber); }
.fhe-out.done { border-color: var(--cyan); background: rgba(8,145,178,.04); }
.fhe-out.err { border-color: var(--red); }

.fhe-out-lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); margin-bottom: 8px; }
.fhe-body { font-size: 12px; color: var(--muted); line-height: 1.6; }
.fhe-body b { color: var(--text); }

.fhe-progress { margin: 4px 0 10px; }
.fhe-prog-row { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.fhe-prog-bar { flex: 1; height: 3px; background: var(--card); border-radius: 2px; overflow: hidden; }
.fhe-prog-fill { height: 100%; width: 0%; background: var(--accent-lt); border-radius: 2px; transition: width 0.12s linear; }
.fhe-prog-pct { font-family: var(--mono); font-size: 11px; color: var(--muted); width: 32px; text-align: right; flex-shrink: 0; }
.fhe-prog-timer { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--accent-lt); width: 40px; text-align: right; flex-shrink: 0; }
.fhe-prog-stage { font-size: 11px; color: var(--dim); min-height: 15px; transition: opacity .3s; }

.spin { display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--card); border-top-color: var(--amber-lt); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.enc-output {
  margin-top: 10px; padding: 10px;
  background: var(--surface); border: 1px solid var(--border-s);
  border-radius: var(--radius-sm);
}
.enc-output .label { margin-bottom: 7px; }
.lock-msg { font-size: 12px; color: var(--dim); margin-top: 8px; font-style: italic; }

/* ── Decrypt stage ──────────────────────────────── */
.dec-grid { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; margin-top: 14px; }
.dec-input-wrap { background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius-sm); padding: 13px; }
.dec-lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); margin-bottom: 7px; }
#key-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 11px;
  color: var(--cyan-lt); font-family: var(--mono); font-size: 12px;
  transition: border-color .15s; outline: none;
}
#key-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,.15); }
#key-input.bad { border-color: var(--red-lt); color: var(--red-lt); }
.dec-hint { font-size: 11px; color: var(--dim); margin-top: 5px; line-height: 1.5; }
.dec-btns { display: flex; flex-direction: column; gap: 7px; }
.dec-result {
  margin-top: 12px; background: var(--panel); border: 1px solid var(--border-s);
  border-radius: var(--radius-sm); padding: 13px;
  font-size: 12px; color: var(--muted); min-height: 54px; transition: all .2s;
}
.dec-result.ok { border-color: rgba(34,197,94,.25); background: var(--green-dim); color: var(--text); }
.dec-result.fail { border-color: rgba(239,68,68,.25); background: var(--red-dim); color: var(--text); }
.dec-pred { font-size: 19px; font-weight: 700; margin-top: 5px; }

/* ── Compare stage ──────────────────────────────── */
.cmp-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 12px; }
.cmp-table th {
  text-align: left; padding: 7px 10px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--dim); border-bottom: 1px solid var(--border-s);
}
.cmp-table td { padding: 10px 10px; border-bottom: 1px solid var(--border-s); color: var(--muted); }
.cmp-table td b { color: var(--text); }
.cmp-table tr:last-child td { border-bottom: none; }
.match-y { color: var(--green-lt); font-weight: 700; }
.match-n { color: var(--red-lt); font-weight: 700; }

/* ── Performance section ────────────────────────── */
#performance { padding: 0 28px 36px; }

.sep { height: 1px; background: var(--border-s); margin: 0 0 24px; }

.perf-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.perf-hl h2 { font-size: 20px; margin-bottom: 5px; }
.perf-hl p { font-size: 12px; color: var(--muted); max-width: 440px; }

.imb-card {
  background: var(--panel); border: 1px solid var(--border-s);
  border-radius: var(--radius); padding: 14px 20px;
  display: flex; gap: 24px; align-items: center; flex-shrink: 0;
}
.imb-stat .v { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.imb-stat .l { font-size: 11px; color: var(--dim); margin-top: 1px; }

/* Slider */
.slider-card { background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; max-width: 560px; margin-left: auto; margin-right: auto; }
.slider-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.thr-val { font-size: 30px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.04em; color: var(--text); }
.thr-note { font-size: 11px; font-weight: 600; color: var(--accent-lt); }
.slider-wrap { position: relative; padding: 10px 0 20px; }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; background: var(--card); border-radius: 2px; cursor: pointer; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,.2); cursor: grab;
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: none; cursor: grab;
}
.thr-mark {
  position: absolute; bottom: 0; transform: translateX(-50%);
  font-size: 10px; font-weight: 600; color: var(--accent-lt); letter-spacing: 0.04em;
  pointer-events: none;
}
.thr-mark::before { content: '▲'; display: block; text-align: center; font-size: 7px; }
.slider-ends { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); }

/* Threshold plot */
.plot-card { background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; max-width: 560px; margin-left: auto; margin-right: auto; }
.plot-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.plot-legend { display: flex; gap: 14px; }
.pleg { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.pleg-line { width: 16px; height: 2px; border-radius: 1px; }
#threshold-plot { width: 100%; overflow: visible; }

/* Perf grid */
.perf-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; margin-bottom: 14px; }

/* Confusion matrix */
.conf-card { background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius); padding: 18px; }
.matrix { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 5px; margin-top: 12px; }
.mhdr { display: grid; place-items: center; font-size: 10px; font-weight: 600; color: var(--dim); text-align: center; padding: 4px; }
.mlbl { display: grid; place-items: center; font-size: 10px; color: var(--dim); text-align: center; padding: 4px; }
.mcell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60px; border-radius: var(--radius-sm); border: 1px solid var(--border-s);
  background: var(--surface);
}
.mcell .cv { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.mcell .cl { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; margin-top: 3px; }
.mtp { border-color: rgba(109,179,146,.2); background: var(--green-dim); color: var(--green-lt); }
.mfp { border-color: rgba(196,154,82,.2); background: var(--amber-dim); color: var(--amber-lt); }
.mtn { color: var(--dim); }
.mfn { border-color: rgba(196,120,120,.2); background: var(--red-dim); color: var(--red-lt); }

/* Metrics */
.met-card { background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius); padding: 18px; }
.met-item { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border-s); }
.met-item:first-child { border-top: none; padding-top: 4px; }
.met-num { font-size: 24px; font-weight: 700; color: #d4a93d; font-family: var(--mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.met-name { font-size: 11px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.met-formula { font-family: var(--mono); font-size: 10px; color: var(--dim); }
.met-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Prediction table */
.pred-card { background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius); padding: 18px; }
.pred-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.pred-ctrl { display: flex; gap: 7px; align-items: center; }
select {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--muted); font-family: var(--sans); font-size: 12px; padding: 5px 9px; cursor: pointer; outline: none;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 7px 10px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim);
  border-bottom: 1px solid var(--border-s);
}
td { padding: 7px 10px; font-size: 12px; border-bottom: 1px solid var(--border-s); color: var(--muted); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.015); }

.pred-load-more { display: flex; justify-content: center; padding-top: 14px; }

/* ── Feature group cards (stage 0) ─────────────── */
.fg-card {
  background: var(--panel); border: 1px solid var(--border-s);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.fg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.fg-more { font-size: 10px; color: var(--dim); margin-top: 6px; }
.fg-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 7px; border-bottom: 1px solid var(--border-s);
}
.fg-card-name { font-size: 12px; font-weight: 600; color: var(--text); }
.fg-card-count {
  font-size: 10px; font-weight: 600; padding: 2px 7px;
  border-radius: 99px; background: var(--accent-dim); color: var(--accent-lt);
}
.fg-feat-row { display: flex; justify-content: space-between; font-size: 11px; }
.fg-feat-name { color: var(--muted); }
.fg-feat-val { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Model info row (FHE Execute stage) ─────────── */
.model-info-row {
  display: flex; align-items: center; gap: 0;
  background: var(--panel); border: 1px solid var(--border-s);
  border-radius: var(--radius-sm); padding: 10px 16px;
  margin-bottom: 14px; margin-top: 14px;
  flex-wrap: wrap; gap: 0;
}
.mi-stat { display: flex; align-items: baseline; gap: 5px; padding: 4px 0; }
.mi-val { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.mi-lbl { font-size: 11px; color: var(--dim); }
.mi-sep { width: 1px; height: 20px; background: var(--border-s); margin: 0 16px; }

/* ── Decrypt fixed layout ────────────────────────── */
.dec-fixed { margin-top: 14px; }
.dec-key-row { display: flex; align-items: center; gap: 14px; }
.dec-key-row .dec-input-wrap { flex: 1; background: var(--panel); border: 1px solid var(--border-s); border-radius: var(--radius-sm); padding: 12px 14px; }

/* ── Signal light (decrypt reveal) ─────────────── */
.signal-wrap { display: flex; align-items: center; gap: 14px; padding: 6px 0; }
.signal-dot {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.06);
  transition: box-shadow .3s;
}
.signal-green { background: var(--green-lt); box-shadow: 0 0 12px rgba(109,179,146,.35), 0 0 0 4px rgba(109,179,146,.12); }
.signal-amber { background: var(--amber-lt); box-shadow: 0 0 12px rgba(196,154,82,.35), 0 0 0 4px rgba(196,154,82,.12); }
.signal-label { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.signal-green-text { color: var(--green-lt); }
.signal-amber-text { color: var(--amber-lt); }

/* ── Match banner (plaintext compare) ───────────── */
.match-banner {
  display: flex; align-items: center; gap: 16px;
  margin-top: 12px; padding: 16px 18px;
  border-radius: var(--radius); border: 1px solid;
}
.match-ok { background: var(--green-dim); border-color: rgba(34,197,94,.25); }
.match-fail { background: var(--red-dim); border-color: rgba(239,68,68,.25); }
.match-icon-wrap { flex-shrink: 0; }
.match-check { font-size: 22px; font-weight: 700; }
.match-ok .match-check { color: var(--green-lt); }
.match-fail .match-check { color: var(--red-lt); }
.match-title { font-size: 14px; font-weight: 700; color: var(--text); }
.match-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* ── Misc ───────────────────────────────────────── */
.row-gap { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.row-gap .note { font-size: 11px; color: var(--dim); flex: 1; }

@media (max-width: 860px) {
  .perf-grid, .enc-grid, .key-grid, .circ-grid { grid-template-columns: 1fr; }
  .sec, #pipeline, #performance { padding-left: 14px; padding-right: 14px; }
  .enc-arrow { padding-top: 0; }
}

/* ── Fade-in animation for hex bytes ────────────── */
@keyframes fadein { from { opacity:0; transform:translateY(3px); } to { opacity:1; transform:translateY(0); } }
.hexfade { opacity: 0; animation: fadein .25s ease forwards; }
