/*! 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(--accent); outline-offset: 2px; border-radius: 6px; }

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

  --bg-0: #07080d;
  --bg-1: #0b0d15;
  --bg-2: #0f1220;

  --hair:   rgba(255,255,255,.08);
  --hair-2: rgba(255,255,255,.14);
  --hair-3: rgba(255,255,255,.22);

  --text:   #ecf0fb;
  --text-2: #9aa3c0;
  --text-3: #5b6585;

  --accent:      #7c9cff;
  --accent-2:    #a6b8ff;
  --accent-glow: rgba(124,156,255,.35);
  --accent-dim:  rgba(124,156,255,.14);

  --danger:  #ff7a85;
  --success: #5ee1a1;
  --warn:    #fbbf24;

  --role-input:      #ff9f45;
  --role-retrieve:   #22d3ee;
  --role-plan:       #a78bfa;
  --role-tool:       #f472b6;
  --role-synthesize: #34d399;
  --role-validate:   #fbbf24;
  --role-output:     #60a5fa;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --ease:     cubic-bezier(.4,0,.2,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --t-fast: 120ms;
  --t-med:  200ms;

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

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Menlo', monospace;
}

/* ── Base ──────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
body {
  background:
    radial-gradient(1200px 800px at 10% -10%, rgba(124,156,255,.10), transparent 60%),
    radial-gradient(900px 700px at 110% 10%, rgba(236,72,153,.06), transparent 55%),
    radial-gradient(1000px 800px at 50% 120%, rgba(52,211,153,.05), transparent 60%),
    var(--bg-0);
  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: 12px;
  padding: 0 16px; height: 52px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(20,24,38,.78), rgba(16,18,30,.68));
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--hair);
  position: relative; z-index: 10;
}
#header::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--hair-2) 20%, var(--hair-2) 80%, transparent);
  pointer-events: none;
}
#header .logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700;
  font-size: 15px; letter-spacing: -.02em;
}
#header .logo svg { flex-shrink: 0; filter: drop-shadow(0 0 12px var(--accent-glow)); }
#header .tagline { font-size: 11px; color: var(--text-3); margin-left: 6px; letter-spacing: .01em; }
#header .spacer { flex: 1; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hair-2);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  color: var(--text); font-size: 12px; font-weight: 500;
  cursor: pointer; user-select: none; white-space: nowrap;
  box-shadow: var(--sh-1);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:hover { background: linear-gradient(180deg, rgba(255,255,255,.09), rgba(255,255,255,.04)); border-color: var(--hair-3); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { flex-shrink: 0; }

.btn.primary {
  background: linear-gradient(180deg, #8fa8ff, #5f7ef5);
  color: #0b0d15; font-weight: 600;
  border-color: rgba(255,255,255,.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 16px -6px var(--accent-glow), 0 2px 4px rgba(0,0,0,.3);
}
.btn.primary:hover {
  background: linear-gradient(180deg, #a4b8ff, #7491ff);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 8px 20px -6px var(--accent-glow), 0 2px 6px rgba(0,0,0,.35);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(255,122,133,.3);
  background: linear-gradient(180deg, rgba(255,122,133,.08), rgba(255,122,133,.03));
}
.btn.danger:hover { background: linear-gradient(180deg, rgba(255,122,133,.16), rgba(255,122,133,.08)); border-color: rgba(255,122,133,.5); }

/* ── Sidebar ───────────────────────────────────────── */
#sidebar {
  width: 272px; flex-shrink: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, rgba(18,22,34,.65), rgba(14,16,26,.55));
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-right: 1px solid var(--hair);
}
#sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--hair);
}
#sidebar-header h2 {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
}
#runs-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }

.run-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; 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);
  contain: layout;
}
.run-item:hover { background: rgba(255,255,255,.04); border-color: var(--hair); }
.run-item.active {
  background: linear-gradient(180deg, rgba(124,156,255,.18), rgba(124,156,255,.08));
  border-color: rgba(124,156,255,.35);
  box-shadow: 0 0 0 1px rgba(124,156,255,.15), 0 6px 16px -8px var(--accent-glow);
}
.run-item.active::before {
  content: ''; position: absolute; left: -8px; top: 50%;
  width: 3px; height: 18px;
  background: var(--accent); border-radius: 2px;
  transform: translateY(-50%);
  box-shadow: 0 0 10px var(--accent-glow);
}
.run-item.active .run-name { color: var(--accent-2); }
.run-meta { flex: 1; min-width: 0; }
.run-name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -.005em;
}
.run-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.run-badge {
  font-size: 10px; padding: 3px 7px; border-radius: 10px;
  background: rgba(255,122,133,.12); color: var(--danger);
  font-weight: 600; flex-shrink: 0;
  border: 1px solid rgba(255,122,133,.2);
}
.no-runs-msg { padding: 32px 14px; text-align: center; color: var(--text-3); font-size: 12px; line-height: 1.6; }

/* ── 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: 10px 14px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(18,22,34,.6), rgba(14,16,26,.5));
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--hair);
  position: relative; z-index: 5;
}
#toolbar .section-label {
  font-size: 10.5px; color: var(--text-3);
  margin-right: 4px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
}

.tab-bar {
  display: flex; gap: 2px; padding: 2px;
  background: rgba(0,0,0,.25);
  border-radius: var(--r-sm);
  border: 1px solid var(--hair);
}
.tab {
  padding: 5px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-2); user-select: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active {
  background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.04));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 3px rgba(0,0,0,.2);
}

.cf-selector { display: flex; align-items: center; gap: 6px; }
.cf-selector label { font-size: 11px; color: var(--text-3); }
.cf-selector select {
  background: rgba(0,0,0,.25);
  border: 1px solid var(--hair-2);
  color: var(--text);
  padding: 4px 8px; border-radius: 6px;
  font-size: 12px; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}
.cf-selector select:hover { border-color: var(--hair-3); }
.cf-selector select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

#cf-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; padding: 4px 9px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(124,156,255,.22), rgba(124,156,255,.12));
  color: var(--accent-2); font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid rgba(124,156,255,.35);
  box-shadow: 0 0 12px -2px var(--accent-glow);
}

/* ── Legend ────────────────────────────────────────── */
#legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  padding: 8px 14px; flex-shrink: 0;
  background: rgba(11,13,21,.4);
  border-bottom: 1px solid var(--hair);
}
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--text-2);
  font-weight: 500; letter-spacing: .02em;
}
.legend-dot { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }

/* ── Graph ─────────────────────────────────────────── */
#graph-scroll {
  flex: 1; overflow: auto; position: relative;
  background:
    radial-gradient(circle at 20% 30%, rgba(124,156,255,.03), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(244,114,182,.03), transparent 50%);
}
#graph-scroll::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 90%);
}
#graph-canvas { position: relative; min-width: 100%; }

/* ── Nodes (no backdrop-filter — perf at N≫100) ────── */
.node-wrapper { position: absolute; contain: layout style; }
.node {
  width: 220px;
  border-radius: var(--r-md);
  border: 1px solid var(--hair-2);
  background: linear-gradient(180deg, rgba(38,44,64,.98), rgba(24,28,44,.98));
  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(--hair-3), transparent);
  pointer-events: none;
}
.node:hover { border-color: var(--hair-3); box-shadow: var(--sh-3); transform: translateY(-1px); }
.node.selected { border-color: var(--accent) !important; box-shadow: var(--sh-accent); }
.node.cf-override {
  border-style: dashed !important;
  background: linear-gradient(180deg, rgba(124,156,255,.18), rgba(40,46,70,.98));
}

.node-header {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px 8px; user-select: none;
}
.role-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 10px currentColor; }
.role-label { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.node-name {
  padding: 0 14px 6px;
  font-size: 13px; font-weight: 600; line-height: 1.3;
  letter-spacing: -.01em; color: var(--text);
}
.node-content {
  padding: 0 14px 10px;
  font-size: 11.5px; color: var(--text-2); line-height: 1.55;
  max-height: 58px; overflow: hidden;
  mask-image: linear-gradient(180deg, black 60%, transparent);
  -webkit-mask-image: linear-gradient(180deg, black 60%, transparent);
}
.node-footer {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-top: 1px solid var(--hair);
  background: rgba(0,0,0,.2);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-label { font-size: 10px; color: var(--text-3); letter-spacing: .02em; }
.node-duration {
  font-size: 10px; color: var(--text-3); margin-left: auto;
  font-family: var(--mono); 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(154,163,192,.3); stroke-width: 1.5; transition: stroke var(--t-med) var(--ease); }
.edge.cf {
  stroke: var(--accent); stroke-dasharray: 5 3; opacity: .7;
  filter: drop-shadow(0 0 4px var(--accent-glow));
}

/* ── Detail panel ──────────────────────────────────── */
#detail {
  width: 340px; flex-shrink: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, rgba(18,22,34,.7), rgba(14,16,26,.6));
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-left: 1px solid var(--hair);
}
#detail-inner { flex: 1; overflow-y: auto; padding: 18px; }
#detail.empty { display: flex; align-items: center; justify-content: center; }
.detail-empty-state { text-align: center; color: var(--text-3); }
.detail-empty-state svg { margin-bottom: 14px; opacity: .4; }
.detail-empty-state p { font-size: 12px; letter-spacing: .01em; }

.detail-section { margin-bottom: 22px; }
.detail-section h3 {
  font-size: 10px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid var(--hair);
}
.detail-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.detail-row .label { color: var(--text-3); min-width: 80px; flex-shrink: 0; font-weight: 500; }
.detail-row .value { color: var(--text); word-break: break-word; }
.detail-content-box {
  background: rgba(0,0,0,.3);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 12px; line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
  max-height: 220px; overflow-y: auto;
  font-family: var(--mono);
}

.cf-note {
  display: flex; align-items: flex-start; gap: 10px;
  background: linear-gradient(180deg, rgba(124,156,255,.14), rgba(124,156,255,.06));
  border: 1px solid rgba(124,156,255,.3);
  border-radius: var(--r-sm);
  padding: 11px 12px;
  font-size: 11.5px; color: var(--accent-2); line-height: 1.55;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px -6px var(--accent-glow);
}
.cf-note svg { flex-shrink: 0; margin-top: 1px; }

/* ── Metrics bar ───────────────────────────────────── */
#metrics-bar {
  display: flex; gap: 20px; align-items: center;
  padding: 10px 18px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(18,22,34,.65), rgba(12,14,22,.75));
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-top: 1px solid var(--hair);
  position: relative; z-index: 2;
}
#metrics-bar::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--hair-2), transparent);
}
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric-label {
  font-size: 9.5px; color: var(--text-3);
  letter-spacing: .1em; font-weight: 600; text-transform: uppercase;
}
.metric-value {
  font-size: 16px; font-weight: 600;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.metric-delta { font-size: 10px; font-weight: 600; font-family: var(--mono); }
.metric-delta.pos { color: var(--success); }
.metric-delta.neg { color: var(--danger); }
.metric-sep { width: 1px; height: 32px; background: linear-gradient(180deg, transparent, var(--hair-2), transparent); }

/* ── Answer panel ──────────────────────────────────── */
#answer-panel {
  padding: 14px 18px;
  border-top: 1px solid var(--hair);
  background: rgba(0,0,0,.2);
}
#answer-panel h3 {
  font-size: 10px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 10px;
}
.answer-box {
  background: rgba(0,0,0,.35);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 14px;
  font-size: 13px; line-height: 1.65;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
  max-height: 200px; overflow-y: auto;
  letter-spacing: -.005em;
}
.answer-box.cf {
  border-color: rgba(124,156,255,.35);
  background: linear-gradient(180deg, rgba(124,156,255,.08), rgba(124,156,255,.03));
  box-shadow: inset 0 1px 0 rgba(124,156,255,.1);
}

/* ── Empty state ───────────────────────────────────── */
#empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 18px; color: var(--text-3);
  text-align: center; padding: 48px;
}
#empty-state svg { opacity: .35; }
#empty-state h2 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 600;
  color: var(--text-2); letter-spacing: -.02em;
}
#empty-state p { font-size: 13px; max-width: 360px; line-height: 1.65; color: var(--text-3); }

/* ── Counterfactual cards ──────────────────────────── */
#cf-list { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-width: 720px; margin: 0 auto; }
.cf-card {
  background: linear-gradient(180deg, rgba(32,36,54,.85), rgba(22,26,40,.9));
  border: 1px solid var(--hair-2);
  border-radius: var(--r-md);
  padding: 14px 16px;
  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), box-shadow var(--t-fast) var(--ease);
}
.cf-card:hover { border-color: var(--hair-3); transform: translateY(-1px); box-shadow: var(--sh-3); }
.cf-card.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(124,156,255,.14), rgba(124,156,255,.06));
  box-shadow: 0 0 0 1px var(--accent-dim), 0 12px 32px -8px var(--accent-glow);
}
.cf-card-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.cf-card-desc { font-size: 11.5px; color: var(--text-2); 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: 3px 8px; border-radius: 10px;
  background: rgba(255,255,255,.06); color: var(--text-2);
  border: 1px solid var(--hair); font-weight: 500;
}

/* ── Scrollbars ────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.08);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent; }

/* ── Modal ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4,6,12,.6);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 180ms var(--ease-out);
}
.modal {
  background: linear-gradient(180deg, rgba(30,34,52,.95), rgba(22,26,40,.95));
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-lg);
  padding: 26px;
  width: 500px; max-width: 92vw;
  box-shadow: var(--sh-3), 0 0 0 1px var(--hair);
  animation: scaleIn 220ms var(--ease-out);
}
.modal h2 {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 600;
  margin-bottom: 18px; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 8px;
}
.modal label {
  display: block;
  font-size: 10.5px; color: var(--text-3);
  font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  margin: 14px 0 6px;
}
.modal input, .modal textarea, .modal select {
  width: 100%;
  background: rgba(0,0,0,.3);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 13px; color: var(--text);
  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(--mono); font-size: 12px; }
.modal input:focus, .modal textarea:focus, .modal select:focus {
  outline: none; border-color: var(--accent);
  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(--danger); margin-top: 8px; }

/* ── Status colors ─────────────────────────────────── */
.s-pending { background: var(--text-3); }
.s-running { background: var(--warn); box-shadow: 0 0 10px var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.s-success { background: var(--success); box-shadow: 0 0 8px rgba(94,225,161,.5); }
.s-failed  { background: var(--danger);  box-shadow: 0 0 8px rgba(255,122,133,.5); }
.s-skipped { background: var(--text-3); opacity: .4; }

/* ── Animations ────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .5; }
}

/* ── Reduced motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Backdrop-filter fallback ──────────────────────── */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #header, #sidebar, #toolbar, #detail, #metrics-bar, .modal-backdrop, .modal { background: var(--bg-2); }
}

/* Header logo image — sized to match previous SVG glyph dimensions */
.logo-img {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  margin-right: 6px;
  border-radius: 4px;
}

/* ── Import toast ──────────────────────────────────── */
.import-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(30,34,52,.97), rgba(22,26,40,.97));
  border: 1px solid var(--hair-2);
  border-radius: var(--r-sm);
  padding: 10px 18px;
  font-size: 12px; color: var(--text-2);
  box-shadow: var(--sh-3);
  z-index: 200;
  animation: fadeIn 180ms var(--ease-out);
  pointer-events: none;
}

/* ── Search box ────────────────────────────────────── */
.search-box { position: relative; }
.search-box input[type="search"] {
  background: rgba(0,0,0,.25);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 4px 10px 4px 28px;
  font-size: 12px; width: 180px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              width var(--t-med) var(--ease);
}
.search-box input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  width: 240px;
  outline: none;
}
.search-box input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.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='%235b6585' 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;
}

.edge-dimmed { opacity: 0.08 !important; }

/* ── CF diff summary ───────────────────────────────── */
.cf-diff-summary {
  margin: 12px 0 8px;
  background: rgba(0,0,0,.2);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}
.cf-diff-title {
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 10px;
}
.cf-diff-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px; font-size: 11.5px;
}
.cf-diff-row:last-child { margin-bottom: 0; }
.cf-diff-name { color: var(--text); font-weight: 500; flex-shrink: 0; }
.cf-diff-arrow { color: var(--text-3); font-size: 10px; }
.cf-diff-badge {
  font-size: 9.5px; padding: 2px 7px; border-radius: 8px;
  font-weight: 600; border: 1px solid transparent;
}
.cf-diff-badge.s-success { background: rgba(94,225,161,.12); color: var(--success); border-color: rgba(94,225,161,.2); }
.cf-diff-badge.s-failed  { background: rgba(255,122,133,.12); color: var(--danger);  border-color: rgba(255,122,133,.2); }
.cf-diff-badge.s-skipped { background: rgba(91,101,133,.12);  color: var(--text-3);  border-color: rgba(91,101,133,.2); }
.cf-diff-badge.s-running { background: rgba(251,191,36,.12);  color: var(--warn);    border-color: rgba(251,191,36,.2); }
.cf-diff-badge.s-pending { background: rgba(91,101,133,.1);   color: var(--text-3);  border-color: rgba(91,101,133,.15); }
.cf-diff-badge.cf-diff-added   { background: rgba(94,225,161,.12); color: var(--success); border-color: rgba(94,225,161,.2); }
.cf-diff-badge.cf-diff-removed { background: rgba(255,122,133,.12); color: var(--danger); border-color: rgba(255,122,133,.2); }
.cf-diff-content {
  width: 100%; margin-top: 3px;
  font-size: 11px; color: var(--text-3);
  font-family: var(--mono); line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}


.logic-engine-btn {
  margin-left: 8px;
  background: rgba(139, 92, 246, 0.12);
  color: #b794f6;
  border: 1px solid rgba(139, 92, 246, 0.3);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.logic-engine-btn:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.5);
  color: #d6bcfa;
}
.logic-engine-btn:active {
  background: rgba(139, 92, 246, 0.25);
}
.logic-engine-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
