/*! AgentFlow — world-class glass UI
 *  Copyright (c) 2026 Omry Damari "Visigence". All rights reserved.
 *  Proprietary and confidential.
 *
 *  Perf note: real bottleneck is render.js full innerHTML rewrite per setState.
 *  Batch with requestAnimationFrame + diff nodes-only on selection/drag.
 */

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* ── Tokens ────────────────────────────────────────── */
:root {
  color-scheme: dark;

  --bg:#020b0d;
  --bg2:#031114;
  --bg3:#04171b;

  --gold:#00e5ff;
  --gold2:#00cfea;
  --gold3:#00b8d4;

  --rose:#ff5577;
  --violet:#c084fc;

  --ink1:#e8f6f8;
  --ink2:#8bb8c0;
  --ink3:#4a7a82;

  --line:rgba(0,229,255,.06);
  --lineS:rgba(0,229,255,.11);
  --lineH:rgba(0,229,255,.2);

  --text:var(--ink1);
  --text-2:var(--ink2);
  --text-3:var(--ink3);

  --accent:var(--gold);
  --accent-2:var(--gold2);

  --accent-glow:rgba(0,229,255,.28);
  --accent-dim:rgba(0,229,255,.12);

  --danger:var(--rose);
  --success:#4ade80;
  --warn:var(--gold3);

  --hair:var(--line);
  --hair-2:var(--lineS);
  --hair-3:var(--lineH);

  --bg-0:var(--bg);
  --bg-1:var(--bg2);
  --bg-2:var(--bg3);

  --font:var(--ff-b);
  --font-display:var(--ff-d);
  --mono:var(--ff-m);

  --role-input:var(--gold);
  --role-retrieve:#22d3ee;
  --role-plan:var(--violet);
  --role-tool:var(--rose);
  --role-synthesize:#4ade80;
  --role-validate:var(--gold3);
  --role-output:#60a5fa;

  --r-sm:6px;
  --r-md:10px;
  --r-lg:14px;

  --ease:cubic-bezier(.22,1,.36,1);
  --ease-out:cubic-bezier(.16,1,.3,1);
  --t-fast:140ms;
  --t-med:220ms;

  --sh-1:0 1px 0 rgba(0,229,255,.04) inset,0 1px 3px rgba(0,0,0,.6);
  --sh-2:0 1px 0 rgba(0,229,255,.05) inset,0 8px 28px -6px rgba(0,0,0,.8),0 2px 6px rgba(0,0,0,.5);
  --sh-3:0 1px 0 rgba(0,229,255,.06) inset,0 24px 64px -16px rgba(0,0,0,.9),0 8px 24px -8px rgba(0,0,0,.7);
  --sh-gold:0 0 0 1px var(--gold),0 0 0 4px var(--accent-dim),0 12px 32px -8px var(--accent-glow);
}

/* ── Base ──────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink1);
  font-family: var(--ff-b);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body {
  background:
    radial-gradient(900px 700px at 5% -5%,rgba(0,229,255,.06),transparent 55%),
    radial-gradient(700px 600px at 98% 5%,rgba(0,180,220,.04),transparent 50%),
    radial-gradient(800px 600px at 50% 110%,rgba(0,100,140,.05),transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

/* ── Shell ─────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
#main { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* ── Header ────────────────────────────────────────── */
#header {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px; height: 52px; flex-shrink: 0;
  background: linear-gradient(180deg,rgba(3,17,20,.88),rgba(2,11,13,.84));
  backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-bottom: 1px solid var(--line); position: relative; z-index: 10;
}
#header .logo {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--ff-d); font-weight: 700; font-size: 15px;
  letter-spacing: -.01em; color: var(--ink1);
}
#header .logo-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg,rgba(0,229,255,.18),rgba(0,229,255,.05));
  border: 1px solid rgba(0,229,255,.28); display: grid; place-items: center;
  filter: drop-shadow(0 0 10px rgba(0,229,255,.3));
}
#header .tagline {
  font-size: 11px; color: var(--ink3); margin-left: 4px;
  font-family: var(--ff-b); font-weight: 400; letter-spacing: .01em;
}
#header .spacer { flex: 1; }
#header .nav-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 30px; border-radius: var(--r-sm);
  border: 1px solid var(--lineS); background: rgba(0,229,255,.04);
  color: var(--ink2); font-family: var(--ff-b); font-size: 12px; font-weight: 500;
  cursor: pointer; user-select: none; white-space: nowrap;
  box-shadow: var(--sh-1); transition: all var(--t-fast) var(--ease);
}
.btn:hover { background: rgba(0,229,255,.08); border-color: var(--lineH); color: var(--ink1); }
.btn:active { transform: translateY(1px); opacity: .9; }
.btn svg { flex-shrink: 0; }

.btn.primary {
  background: linear-gradient(160deg,var(--gold),var(--gold3));
  color: #000d10; font-weight: 700; border-color: rgba(0,229,255,.25);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 6px 20px -6px rgba(0,229,255,.45), 0 2px 6px rgba(0,0,0,.5);
}
.btn.primary:hover {
  background: linear-gradient(160deg,#33eeff,var(--gold));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 8px 24px -4px rgba(0,229,255,.55);
}

.verify-btn {
  font-family: var(--ff-m); font-size: 10px; font-weight: 700; letter-spacing: .06em;
  color: var(--gold3); border-color: rgba(0,229,255,.18); background: rgba(0,229,255,.05);
}
.verify-btn:hover { background: rgba(0,229,255,.11); border-color: rgba(0,229,255,.32); color: var(--gold); }

/* ── Keyboard hint pills ────────────────────────────────────── */
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--ff-m); font-size: 9.5px; font-weight: 400;
  padding: 1px 5px; border-radius: 4px;
  background: rgba(0,229,255,.05); border: 1px solid var(--line);
  color: var(--ink3); line-height: 1.4; white-space: nowrap;
}

/* ── Sidebar ───────────────────────────────────────── */
#sidebar {
  width: 268px; flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg,rgba(3,17,20,.75),rgba(2,11,13,.65));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--line);
}
#sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
#sidebar-header h2 {
  font-family: var(--ff-d); font-size: 10px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink3);
}
.sidebar-count {
  font-family: var(--ff-m); font-size: 10px; color: var(--ink3);
  background: rgba(0,229,255,.04); border: 1px solid var(--line);
  border-radius: 10px; padding: 1px 7px;
}
#runs-list { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 1px; }

.run-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm); cursor: pointer;
  position: relative; border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.run-item:hover { background: rgba(0,229,255,.04); border-color: var(--line); }
.run-item.active {
  background: linear-gradient(135deg,rgba(0,229,255,.11),rgba(0,229,255,.05));
  border-color: rgba(0,229,255,.26);
  box-shadow: 0 0 0 1px rgba(0,229,255,.08), 0 4px 16px -6px rgba(0,229,255,.18);
}
.run-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; width: 2px; height: 16px;
  background: var(--gold); border-radius: 0 2px 2px 0; transform: translateY(-50%);
  box-shadow: 0 0 8px var(--gold);
}
.run-item.active .run-name { color: var(--gold); }
.run-meta { flex: 1; min-width: 0; }
.run-name {
  font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink1);
}
.run-sub {
  font-size: 10.5px; color: var(--ink3); margin-top: 2px;
  font-family: var(--ff-m); font-variant-numeric: tabular-nums;
}
.run-badge {
  font-size: 9.5px; padding: 2px 6px; border-radius: 8px;
  background: rgba(255,85,119,.12); color: var(--rose); font-weight: 700; flex-shrink: 0;
  border: 1px solid rgba(255,85,119,.2); font-family: var(--ff-m);
}
.no-runs-msg {
  padding: 36px 14px; text-align: center; color: var(--ink3); font-size: 12px; line-height: 1.7;
}
.no-runs-msg strong {
  display: block; color: var(--ink2); font-family: var(--ff-d); font-size: 13px; margin-bottom: 6px;
}

/* ── Canvas area ───────────────────────────────────── */
#canvas-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

#toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; flex-shrink: 0;
  background: linear-gradient(180deg,rgba(3,17,20,.7),rgba(2,11,13,.6));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
#toolbar .section-label {
  font-family: var(--ff-d); font-size: 10px; color: var(--ink3);
  margin-right: 2px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
}
.tab-bar {
  display: flex; gap: 1px; padding: 2px; background: rgba(0,0,0,.3);
  border-radius: var(--r-sm); border: 1px solid var(--line);
}
.tab {
  padding: 4px 12px; border-radius: 5px; font-family: var(--ff-b); font-size: 12px; font-weight: 500;
  cursor: pointer; color: var(--ink3); user-select: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--ink1); }
.tab.active {
  background: linear-gradient(180deg,rgba(0,229,255,.09),rgba(0,229,255,.04)); color: var(--ink1);
  box-shadow: inset 0 1px 0 rgba(0,229,255,.08), 0 1px 3px rgba(0,0,0,.3);
}
.tab.active[data-id="counterfactuals"] { color: var(--gold); }

.cf-selector { display: flex; align-items: center; gap: 6px; }
.cf-selector label { font-family: var(--ff-m); font-size: 10px; color: var(--ink3); }
.cf-selector select {
  background: rgba(0,0,0,.3); border: 1px solid var(--lineS); color: var(--ink1);
  padding: 3px 8px; border-radius: var(--r-sm); font-size: 12px; cursor: pointer;
}

#cf-badge {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--ff-m); font-size: 9.5px;
  padding: 3px 9px; border-radius: 8px;
  background: linear-gradient(135deg,rgba(0,229,255,.18),rgba(0,229,255,.08));
  color: var(--gold); font-weight: 700; letter-spacing: .04em;
  border: 1px solid rgba(0,229,255,.28); box-shadow: 0 0 12px -2px rgba(0,229,255,.22);
}

.logic-engine-btn {
  background: rgba(192,132,252,.1); color: var(--violet); border: 1px solid rgba(192,132,252,.25);
  font-family: var(--ff-b); font-weight: 600; padding: 0 12px; height: 28px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--t-fast) var(--ease); white-space: nowrap;
}
.logic-engine-btn:hover {
  background: rgba(192,132,252,.18); border-color: rgba(192,132,252,.45); color: #d4b4fe;
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
#run-breadcrumb {
  display: flex; align-items: center; gap: 6px; font-family: var(--ff-d); font-size: 11px; color: var(--ink3);
  padding: 0 14px 0 0; border-right: 1px solid var(--line); margin-right: 4px;
  white-space: nowrap; overflow: hidden; max-width: 180px;
}
#run-breadcrumb .run-bc-name { color: var(--ink2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

/* ── Legend ────────────────────────────────────────── */
#legend {
  display: flex; gap: 14px; flex-wrap: wrap; padding: 7px 14px; flex-shrink: 0;
  background: rgba(2,11,13,.5); border-bottom: 1px solid var(--line);
}
.legend-item {
  display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--ink3);
  font-family: var(--ff-b); font-weight: 500; letter-spacing: .03em;
}
.legend-dot { width: 6px; height: 6px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }

/* ── Graph ─────────────────────────────────────────── */
#graph-scroll {
  flex: 1; overflow: auto; position: relative;
  background:
    radial-gradient(circle at 25% 35%,rgba(0,229,255,.025),transparent 45%),
    radial-gradient(circle at 75% 70%,rgba(0,150,200,.02),transparent 45%);
}
#graph-scroll::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(0,229,255,.022) 1px,transparent 1px),
                    linear-gradient(90deg,rgba(0,229,255,.022) 1px,transparent 1px);
  background-size: 28px 28px; pointer-events: none;
  mask-image: radial-gradient(ellipse at center,black 35%,transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse at center,black 35%,transparent 85%);
}
#graph-canvas { position: relative; min-width: 100%; }

/* ── Nodes ─────────────────────────────────────────── */
.node-wrapper { position: absolute; contain: layout style; }
.node {
  width: 220px; border-radius: var(--r-md); border: 1px solid var(--lineS);
  background: linear-gradient(160deg,rgba(4,20,24,.97),rgba(2,12,15,.97));
  cursor: pointer; position: relative; overflow: hidden; box-shadow: var(--sh-2);
  transition: box-shadow var(--t-med) var(--ease-out), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.node::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg,transparent,var(--lineH),transparent); pointer-events: none;
}
.node:hover { border-color: var(--lineH); box-shadow: var(--sh-3); transform: translateY(-1px); }
.node.selected { border-color: var(--gold)!important; box-shadow: var(--sh-gold); }
.node.cf-override {
  border-style: dashed!important;
  background: linear-gradient(160deg,rgba(0,229,255,.1),rgba(2,14,18,.97));
}

.node-header {
  display: flex; align-items: center; gap: 7px; padding: 10px 13px 7px; user-select: none;
}
.role-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.role-label {
  font-family: var(--ff-d); font-size: 9.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
}
.node-name {
  padding: 0 13px 6px; font-family: var(--ff-d); font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--ink1);
}
.node-content {
  padding: 0 13px 10px; font-size: 11.5px; color: var(--ink2); line-height: 1.55;
  max-height: 54px; overflow: hidden;
  mask-image: linear-gradient(180deg,black 55%,transparent);
  -webkit-mask-image: linear-gradient(180deg,black 55%,transparent);
}
.node-footer {
  display: flex; align-items: center; gap: 6px; padding: 6px 13px;
  border-top: 1px solid var(--line); background: rgba(0,0,0,.3);
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.status-label { font-size: 10px; color: var(--ink3); letter-spacing: .03em; font-family: var(--ff-m); }
.node-duration {
  font-size: 10px; color: var(--ink3); margin-left: auto;
  font-family: var(--ff-m); font-variant-numeric: tabular-nums;
}

/* ── Edges ─────────────────────────────────────────── */
svg.edges-layer { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.edge { fill: none; stroke: rgba(139,184,192,.18); stroke-width: 1.5; transition: stroke var(--t-med) var(--ease); }
.edge.cf {
  stroke: var(--gold); stroke-dasharray: 5 3; opacity: .65;
  filter: drop-shadow(0 0 4px rgba(0,229,255,.4));
}
.edge-dimmed { opacity: .07!important; }

/* ── Detail panel ──────────────────────────────────── */
#detail {
  width: 336px; flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg,rgba(3,17,20,.8),rgba(2,11,13,.75));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--line);
}
#detail-inner { flex: 1; overflow-y: auto; padding: 16px; }
#detail.empty { display: flex; align-items: center; justify-content: center; }
.detail-empty-state { text-align: center; color: var(--ink3); padding: 24px 16px; }
.detail-empty-state p { font-size: 12px; }
.detail-empty-state .kbd-tip { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.detail-empty-state .kbd-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--ink3); gap: 8px; }
.detail-empty-state .kbd-row span { text-align: right; }

.detail-section { margin-bottom: 20px; }
.detail-section h3 {
  font-family: var(--ff-d); font-size: 9.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink3); margin-bottom: 9px; padding-bottom: 7px; border-bottom: 1px solid var(--line);
}
.detail-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 7px; font-size: 12px; }
.detail-row .label { color: var(--ink3); min-width: 76px; flex-shrink: 0; font-weight: 500; }
.detail-row .value { color: var(--ink1); word-break: break-word; }
.detail-content-box {
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 13px; font-size: 11.5px; line-height: 1.65; color: var(--ink2);
  white-space: pre-wrap; word-break: break-word; max-height: 210px; overflow-y: auto; font-family: var(--ff-m);
}
.detail-hint { font-size: 11px; color: var(--ink3); line-height: 1.55; margin-bottom: 10px; }

.cf-note {
  display: flex; align-items: flex-start; gap: 10px;
  background: linear-gradient(135deg,rgba(0,229,255,.1),rgba(0,229,255,.04));
  border: 1px solid rgba(0,229,255,.22); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 11.5px; color: var(--gold); line-height: 1.55; margin-bottom: 16px;
  box-shadow: 0 4px 16px -6px rgba(0,229,255,.18);
}

/* ── CF suggestions ─────────────────────────────────────────── */
.cf-suggestion { background: rgba(0,0,0,.25); border: 1px solid var(--lineS); border-radius: var(--r-sm); padding: 11px 13px; margin-bottom: 10px; }
.cf-suggestion-header { display: flex; gap: 7px; margin-bottom: 6px; }
.cf-suggestion-cost, .cf-suggestion-collateral {
  font-size: 9.5px; padding: 2px 7px; border-radius: 7px; font-weight: 700; font-family: var(--ff-m);
}
.cf-suggestion-cost { background: rgba(0,229,255,.1); color: var(--gold); border: 1px solid rgba(0,229,255,.2); }
.cf-suggestion-collateral { background: rgba(255,85,119,.08); color: var(--ink3); border: 1px solid var(--line); }
.cf-suggestion-summary { font-size: 11.5px; color: var(--ink2); line-height: 1.55; margin-bottom: 8px; }
.cf-suggestion-affected { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.cf-suggestion-tag {
  font-size: 10px; padding: 2px 7px; border-radius: 7px;
  background: rgba(0,229,255,.04); color: var(--ink2); border: 1px solid var(--line); font-weight: 500;
}
.cf-suggestion-adopt { width: 100%; justify-content: center; }

/* ── Metrics bar ───────────────────────────────────── */
#metrics-bar {
  display: flex; gap: 18px; align-items: center; padding: 9px 18px; flex-shrink: 0;
  background: linear-gradient(180deg,rgba(3,17,20,.75),rgba(2,11,13,.85));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line); position: relative; z-index: 2;
}
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric-label {
  font-family: var(--ff-d); font-size: 9px; color: var(--ink3);
  letter-spacing: .12em; font-weight: 600; text-transform: uppercase;
}
.metric-value {
  font-size: 15px; font-weight: 600; font-family: var(--ff-m); font-variant-numeric: tabular-nums;
}
.metric-delta { font-size: 10px; font-weight: 700; font-family: var(--ff-m); }
.metric-delta.pos { color: var(--success); }
.metric-delta.neg { color: var(--rose); }
.metric-sep { width: 1px; height: 28px; background: linear-gradient(180deg,transparent,var(--lineS),transparent); }

/* ── Answer panel ──────────────────────────────────── */
#answer-panel {
  padding: 12px 18px; border-top: 1px solid var(--line); background: rgba(0,0,0,.2);
}
#answer-panel h3 {
  font-family: var(--ff-d); font-size: 9.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink3); margin-bottom: 9px;
}
.answer-box {
  background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px; font-size: 13px; line-height: 1.65; color: var(--ink1);
  white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow-y: auto;
}
.answer-box.cf {
  border-color: rgba(0,229,255,.28);
  background: linear-gradient(135deg,rgba(0,229,255,.07),rgba(0,229,255,.02));
}

/* ── Empty state ───────────────────────────────────── */
#empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 0;
  color: var(--ink3); text-align: center; padding: 48px;
}
#empty-state .es-icon {
  width: 64px; height: 64px; border-radius: 16px;
  background: rgba(0,229,255,.05); border: 1px solid rgba(0,229,255,.12);
  display: grid; place-items: center; margin-bottom: 20px;
  box-shadow: 0 0 32px -8px rgba(0,229,255,.18);
}
#empty-state h2 {
  font-family: var(--ff-d); font-size: 21px; font-weight: 700; color: var(--ink1);
  letter-spacing: -.02em; margin-bottom: 8px;
}
#empty-state p { font-size: 12.5px; max-width: 340px; line-height: 1.7; color: var(--ink3); margin-bottom: 22px; }
#empty-state .es-actions { display: flex; gap: 10px; margin-bottom: 32px; }
#empty-state .es-shortcuts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; padding: 16px;
  background: rgba(0,229,255,.02); border: 1px solid var(--line); border-radius: var(--r-md);
  max-width: 320px; width: 100%;
}
#empty-state .sc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--ink3); }

/* ── CF tab ────────────────────────────────────────── */
#cf-list { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-width: 700px; margin: 0 auto; }
.cf-card {
  background: linear-gradient(160deg,rgba(4,20,24,.9),rgba(2,14,18,.95));
  border: 1px solid var(--lineS); border-radius: var(--r-md); padding: 13px 15px;
  cursor: pointer; box-shadow: var(--sh-2);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.cf-card:hover { border-color: var(--lineH); transform: translateY(-1px); box-shadow: var(--sh-3); }
.cf-card.active {
  border-color: var(--gold);
  background: linear-gradient(160deg,rgba(0,229,255,.1),rgba(0,229,255,.04));
  box-shadow: 0 0 0 1px var(--accent-dim), 0 12px 32px -8px var(--accent-glow);
}
.cf-card-title {
  font-family: var(--ff-d); font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px;
}
.cf-card-desc { font-size: 11.5px; color: var(--ink2); margin-top: 6px; line-height: 1.55; }
.cf-overrides { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.cf-override-tag {
  font-size: 10px; padding: 2px 7px; border-radius: 7px;
  background: rgba(0,229,255,.04); color: var(--ink2); border: 1px solid var(--line); font-weight: 500;
}
.cf-diff-summary {
  margin: 11px 0 8px; background: rgba(0,0,0,.2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 13px;
}
.cf-diff-title {
  font-family: var(--ff-d); font-size: 9.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink3); margin-bottom: 9px;
}
.cf-diff-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 7px; font-size: 11.5px;
}
.cf-diff-row:last-child { margin-bottom: 0; }
.cf-diff-name { color: var(--ink1); font-weight: 500; flex-shrink: 0; }
.cf-diff-arrow { color: var(--ink3); font-size: 10px; }
.cf-diff-badge {
  font-size: 9.5px; padding: 2px 7px; border-radius: 7px; font-weight: 700;
  border: 1px solid transparent; font-family: var(--ff-m);
}
.cf-diff-badge.s-success { background: rgba(74,222,128,.1); color: var(--success); border-color: rgba(74,222,128,.2); }
.cf-diff-badge.s-failed { background: rgba(255,85,119,.1); color: var(--rose); border-color: rgba(255,85,119,.2); }
.cf-diff-badge.s-skipped { background: rgba(110,103,96,.1); color: var(--ink3); border-color: rgba(110,103,96,.2); }
.cf-diff-badge.cf-diff-added { background: rgba(74,222,128,.1); color: var(--success); border-color: rgba(74,222,128,.2); }
.cf-diff-badge.cf-diff-removed { background: rgba(255,85,119,.1); color: var(--rose); border-color: rgba(255,85,119,.2); }

/* ── Scrollbars ────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0,229,255,.07); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,229,255,.16); background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: rgba(0,229,255,.08) transparent; }

/* ── Modal ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(1,6,8,.75); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px); display: flex; align-items: center; justify-content: center;
  z-index: 100; animation: fadeIn 180ms var(--ease);
}
.modal {
  background: linear-gradient(180deg,rgba(3,20,24,.97),rgba(2,12,15,.97));
  backdrop-filter: blur(40px) saturate(160%); -webkit-backdrop-filter: blur(40px) saturate(160%);
  border: 1px solid var(--lineS); border-radius: var(--r-lg); padding: 26px;
  width: 500px; max-width: 92vw; box-shadow: var(--sh-3), 0 0 0 1px var(--line);
  animation: scaleIn 220ms var(--ease);
}
.modal h2 {
  font-family: var(--ff-d); font-size: 17px; font-weight: 700; margin-bottom: 18px;
  letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; color: var(--ink1);
}
.modal label {
  display: block; font-family: var(--ff-d); font-size: 10px; color: var(--ink3);
  font-weight: 600; letter-spacing: .1em; text-transform: uppercase; margin: 14px 0 6px;
}
.modal input, .modal textarea, .modal select {
  width: 100%; background: rgba(0,0,0,.35); border: 1px solid var(--lineS);
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; color: var(--ink1);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.modal textarea { min-height: 90px; resize: vertical; font-family: var(--ff-m); font-size: 12px; }
.modal input:focus, .modal textarea:focus, .modal select:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--accent-dim);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.error-msg { font-size: 11.5px; color: var(--rose); margin-top: 8px; }

/* ── Status colours ─────────────────────────────────────────── */
.s-pending { background: var(--ink3); }
.s-running { background: var(--gold); box-shadow: 0 0 10px var(--gold); animation: pulse 1.4s ease-in-out infinite; }
.s-success { background: var(--success); box-shadow: 0 0 7px rgba(74,222,128,.5); }
.s-failed { background: var(--rose); box-shadow: 0 0 7px rgba(255,85,119,.5); }
.s-skipped { background: var(--ink3); opacity: .4; }

/* ── Search ─────────────────────────────────────────────────── */
.search-box { position: relative; }
.search-box input[type=search] {
  background: rgba(0,0,0,.3); border: 1px solid var(--lineS); border-radius: var(--r-sm);
  color: var(--ink1); padding: 4px 10px 4px 27px; font-size: 12px; width: 170px;
  transition: border-color var(--t-fast) var(--ease), width var(--t-med) var(--ease);
}
.search-box input[type=search]:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px var(--accent-dim); width: 230px; outline: none;
}
.search-box::before {
  content: ''; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a7a82' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: contain; pointer-events: none;
}

/* ── Toast ──────────────────────────────────────────────────── */
.import-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg,rgba(3,20,24,.98),rgba(2,12,15,.98));
  border: 1px solid var(--lineS); border-radius: var(--r-sm); padding: 10px 18px;
  font-size: 12px; color: var(--ink2); box-shadow: var(--sh-3); z-index: 200;
  animation: fadeIn 180ms var(--ease); pointer-events: none;
}

/* ── Animations ────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes goldFlare {
  0%,100% { box-shadow: 0 0 0 1px rgba(0,229,255,.15); }
  50%      { box-shadow: 0 0 0 2px rgba(0,229,255,.35), 0 0 16px rgba(0,229,255,.2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #header, #sidebar, #toolbar, #detail, #metrics-bar, .modal-backdrop, .modal { background: var(--bg2); }
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 200px; }
  #detail { width: 280px; }
  #header { padding: 0 10px; height: 48px; }
  #header .tagline { display: none; }
  #metrics-bar { gap: 10px; padding: 8px 12px; overflow-x: auto; }
  .metric-value { font-size: 13px; }
}

@media (max-width: 560px) {
  #main { flex-direction: column; }
  #sidebar {
    width: 100%; height: auto; max-height: 140px; border-right: none;
    border-bottom: 1px solid var(--line); flex-direction: row;
  }
  #runs-list { flex-direction: row; padding: 4px; overflow-x: auto; overflow-y: hidden; gap: 4px; }
  .run-item { flex-shrink: 0; width: 160px; }
  .run-item.active::before {
    left: 0; top: auto; bottom: 0; width: 100%; height: 2px;
    border-radius: 2px 2px 0 0; transform: none;
  }
  #detail { width: 100%; max-height: 240px; border-left: none; border-top: 1px solid var(--line); }
  #canvas-area { min-height: 300px; }
  .modal {
    border-radius: var(--r-md) var(--r-md) 0 0; position: fixed;
    bottom: 0; left: 0; right: 0; max-width: 100%;
  }
  #empty-state .es-shortcuts { grid-template-columns: 1fr; }
  #header .logo-name { display: none; }
}

/* ── Verify overlay ─────────────────────────────────────────── */
#verify-overlay {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: rgba(1,6,8,.85); backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%); animation: fadeIn 200ms var(--ease); padding: 20px;
}
#verify-panel {
  display: flex; flex-direction: column; width: 100%; max-width: 760px; max-height: 90vh;
  background: linear-gradient(180deg,rgba(3,20,24,.99),rgba(2,12,15,.99));
  border: 1px solid var(--lineS); border-radius: var(--r-lg);
  box-shadow: var(--sh-3), 0 0 0 1px rgba(0,229,255,.04);
  overflow: hidden; animation: scaleIn 240ms var(--ease);
}
#verify-panel-hdr {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 20px;
  border-bottom: 1px solid var(--line); flex-shrink: 0;
  background: linear-gradient(135deg,rgba(0,229,255,.04),transparent);
}
.verify-hdr-left { display: flex; align-items: center; gap: 12px; }
#verify-icon {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px;
  background: rgba(0,229,255,.1); border: 1px solid rgba(0,229,255,.25); color: var(--gold); flex-shrink: 0;
}
.verify-panel-title {
  font-family: var(--ff-d); font-size: 15px; font-weight: 800; letter-spacing: -.02em; color: var(--ink1);
}
.verify-panel-sub { font-size: 10.5px; color: var(--ink3); margin-top: 2px; font-family: var(--ff-m); }
.verify-close-btn {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px;
  border: 1px solid var(--line); background: transparent; cursor: pointer; color: var(--ink3);
  font-size: 13px; transition: all .12s; flex-shrink: 0;
}
.verify-close-btn:hover { background: rgba(255,85,119,.1); border-color: rgba(255,85,119,.3); color: var(--rose); }
#verify-progress-wrap {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 8px 20px;
  border-bottom: 1px solid var(--line); background: rgba(0,0,0,.2);
}
#verify-progress {
  flex: 1; height: 3px; background: rgba(0,229,255,.07); border-radius: 2px; overflow: hidden;
}
#verify-progress-fill {
  height: 100%; background: linear-gradient(90deg,var(--gold3),var(--gold)); border-radius: 2px;
  transition: width .35s var(--ease-out);
}
#verify-pct-label { font-family: var(--ff-m); font-size: 10px; color: var(--ink3); white-space: nowrap; flex-shrink: 0; }
#verify-cert-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line);
  flex-shrink: 0; transition: background .3s;
}
.verify-cert-pass { background: linear-gradient(135deg,rgba(74,222,128,.08),rgba(74,222,128,.02)); }
.verify-cert-warn { background: linear-gradient(135deg,rgba(0,229,255,.08),rgba(0,229,255,.02)); }
.verify-cert-fail { background: linear-gradient(135deg,rgba(255,85,119,.08),rgba(255,85,119,.02)); }
.verify-cert-loading { background: rgba(0,229,255,.02); }
.verify-cert-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; border: 1px solid;
}
#verify-cert-title { font-family: var(--ff-d); font-size: 14px; font-weight: 700; color: var(--ink1); letter-spacing: -.01em; }
#verify-cert-sub { font-size: 11.5px; color: var(--ink3); margin-top: 3px; line-height: 1.5; }
#verify-cert-stats { margin-left: auto; display: flex; gap: 14px; flex-shrink: 0; }
.cert-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--ff-m); }
.cert-stat .cs-num { font-size: 18px; font-weight: 700; line-height: 1; }
.cert-stat .cs-lbl { font-size: 9px; letter-spacing: .08em; opacity: .6; text-transform: uppercase; }

#verify-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; padding: 12px 14px; gap: 10px; }
.verify-group { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.verify-group-title {
  display: flex; align-items: center; gap: 8px; padding: 8px 13px;
  background: rgba(0,229,255,.02); border-bottom: 1px solid var(--line);
}
.vg-name {
  font-family: var(--ff-d); font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink2); flex-shrink: 0;
}
.vg-desc { font-size: 10px; color: var(--ink3); font-weight: 400; }
.vg-badge {
  margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 8px; border-radius: 5px; flex-shrink: 0; font-family: var(--ff-m); border: 1px solid transparent;
}
.vg-running { background: rgba(0,229,255,.06); color: var(--ink3); border-color: var(--line); }
.vg-pass { background: rgba(74,222,128,.1); color: var(--success); border-color: rgba(74,222,128,.25); }
.vg-fail { background: rgba(255,85,119,.1); color: var(--rose); border-color: rgba(255,85,119,.25); }
.vg-warn { background: rgba(0,229,255,.08); color: var(--gold3); border-color: rgba(0,229,255,.25); }

.verify-explain {
  padding: 6px 13px 7px; font-size: 10.5px; color: var(--ink3); line-height: 1.55;
  background: rgba(0,229,255,.015); border-bottom: 1px solid var(--line);
}
.vg-rows { display: flex; flex-direction: column; }
.verify-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 13px;
  border-bottom: 1px solid rgba(0,229,255,.04); transition: background .1s;
}
.verify-row:last-child { border-bottom: none; }
.verify-row:hover { background: rgba(0,229,255,.02); }
.verify-row-body { flex: 1; min-width: 0; }
.verify-ms { font-family: var(--ff-m); font-size: 9.5px; color: var(--ink3); flex-shrink: 0; margin-top: 2px; }
.vbadge {
  font-size: 9px; font-weight: 700; letter-spacing: .07em; padding: 2px 7px; border-radius: 5px;
  flex-shrink: 0; margin-top: 1px; font-family: var(--ff-m); min-width: 44px; text-align: center; border: 1px solid transparent;
}
.vbadge.pass { background: rgba(74,222,128,.1); color: var(--success); border-color: rgba(74,222,128,.25); }
.vbadge.fail { background: rgba(255,85,119,.1); color: var(--rose); border-color: rgba(255,85,119,.25); }
.vbadge.warn { background: rgba(0,229,255,.08); color: var(--gold3); border-color: rgba(0,229,255,.25); }
.vbadge.info { background: rgba(0,229,255,.1); color: var(--gold); border-color: rgba(0,229,255,.2); }
.vbadge.skip { background: rgba(74,122,130,.1); color: var(--ink3); border-color: rgba(74,122,130,.15); }
.verify-name { font-size: 12px; font-weight: 500; color: var(--ink1); line-height: 1.35; }
.verify-detail { font-size: 10.5px; color: var(--ink3); margin-top: 3px; font-family: var(--ff-m); line-height: 1.45; }
.verify-detail b { color: var(--ink2); font-weight: 600; }
.header-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin-top: 4px; }
.header-grid .hkey { color: var(--ink3); font-size: 10px; font-family: var(--ff-m); white-space: nowrap; }
.header-grid .hval { font-size: 10px; font-family: var(--ff-m); color: var(--ink2); word-break: break-all; }
.header-grid .hval.present { color: var(--success); }
.header-grid .hval.absent { color: var(--ink3); opacity: .5; font-style: italic; }

#verify-footer-bar {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  border-top: 1px solid var(--line); flex-shrink: 0; background: rgba(0,0,0,.2);
}
#verify-sig { font-family: var(--ff-m); font-size: 10px; color: var(--ink3); letter-spacing: .02em; }
#verify-sig strong { color: var(--gold3); }
#verify-timing-label { font-family: var(--ff-m); font-size: 10px; color: var(--ink3); }
.verify-copy-btn {
  font-family: var(--ff-m); font-size: 10px; color: var(--ink3);
  border: 1px solid var(--line); background: transparent; border-radius: 4px;
  padding: 4px 10px; cursor: pointer; transition: all .12s;
}
.verify-copy-btn:hover { color: var(--gold); border-color: rgba(0,229,255,.3); }
.verify-spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--lineS);
  border-top-color: var(--gold); animation: spin .75s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App footer ─────────────────────────────────────────────── */
#app-footer {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 5px 18px; border-top: 1px solid var(--line);
  background: rgba(2,11,13,.9); font-size: 10px; color: var(--ink3); font-family: var(--ff-m);
}
#app-footer .fs { color: var(--line); margin: 0 2px; }
#app-footer strong { color: var(--gold3); font-weight: 600; }

/* ── Responsive verify ───────────────────────────────────────── */
@media (max-width: 560px) {
  #verify-overlay { padding: 0; align-items: flex-end; }
  #verify-panel { max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
  #verify-cert-stats { display: none; }
  .verify-explain { display: none; }
}

/* ── Logo image ── */
.logo-img { width: 26px; height: 26px; border-radius: 5px; }
