/* ─────────────────────────────────────────
   BOND OS Live Monitor — Full-screen
   ───────────────────────────────────────── */

:root, [data-theme="dark"] {
  --bg:            #09090a;
  --surface:       #111112;
  --surface-2:     #161618;
  --surface-3:     #1c1c1e;
  --border:        #242426;
  --border-subtle: #1c1c1e;
  --divider:       #191919;

  --text:          #e4e3e0;
  --text-muted:    #646360;
  --text-faint:    #38373500;

  --c-teal:    #00d4c8;
  --c-purple:  #a78bfa;
  --c-blue:    #60a5fa;
  --c-orange:  #fb923c;
  --c-green:   #34d399;
  --c-yellow:  #fbbf24;
  --c-red:     #f87171;

  --c-teal-dim:   rgba(0,212,200,0.12);
  --c-purple-dim: rgba(167,139,250,0.12);
  --c-blue-dim:   rgba(96,165,250,0.12);
  --c-orange-dim: rgba(251,146,60,0.12);
  --c-green-dim:  rgba(52,211,153,0.12);
  --c-yellow-dim: rgba(251,191,36,0.12);
  --c-red-dim:    rgba(248,113,113,0.12);

  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-body:    'Satoshi', 'Helvetica Neue', sans-serif;
  --font-mono:    'SF Mono','Fira Code','Cascadia Code',monospace;

  --ease: 200ms cubic-bezier(0.16,1,0.3,1);
  --r: 6px;
}

[data-theme="light"] {
  --bg:            #f4f3f0;
  --surface:       #fafaf8;
  --surface-2:     #ffffff;
  --surface-3:     #f0efec;
  --border:        #dddbd6;
  --border-subtle: #e6e5e1;
  --divider:       #e8e7e3;
  --text:          #17171a;
  --text-muted:    #757370;
  --text-faint:    #b8b7b2;
  --c-teal:    #007a73;
  --c-purple:  #6d28d9;
  --c-blue:    #1d4ed8;
  --c-orange:  #c2540a;
  --c-green:   #14704a;
  --c-yellow:  #a16207;
  --c-red:     #b91c1c;
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { height:100%; -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; }
body {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button { cursor:pointer; background:none; border:none; font:inherit; color:inherit; }
input  { font:inherit; color:inherit; }
::-webkit-scrollbar { width:3px; height:3px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }

/* ── CONNECTION OVERLAY ── */
.conn-overlay {
  position: fixed; inset:0;
  background: var(--bg);
  display: flex; align-items:center; justify-content:center;
  z-index: 100;
}
.conn-box {
  display: flex; flex-direction: column; align-items:center;
  gap: 16px;
  width: 380px;
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.conn-logo {
  width: 44px; height: 44px;
  color: var(--c-teal);
}
.conn-title {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 800;
  letter-spacing: -0.02em;
}
.conn-sub {
  font-size: 12px; color: var(--text-muted);
  text-align:center;
}
.conn-input-row {
  display:flex; gap:8px; width:100%;
}
.conn-input {
  flex:1;
  padding: 8px 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12px;
  outline:none;
  transition: border-color var(--ease);
}
.conn-input:focus { border-color: var(--c-teal); }
.conn-btn {
  padding: 8px 18px;
  background: var(--c-teal);
  color: #000;
  border-radius: var(--r);
  font-size: 12px; font-weight: 600;
  transition: opacity var(--ease);
  white-space: nowrap;
}
.conn-btn:hover { opacity:0.85; }
.conn-status {
  font-size: 11px;
  min-height: 16px;
  color: var(--text-muted);
}
.conn-status.error { color: var(--c-red); }
.conn-status.ok    { color: var(--c-green); }

/* ── HEADER ── */
.header {
  display:flex; align-items:center; justify-content:space-between;
  padding: 0 20px;
  height: 48px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink:0;
}
.header-left { display:flex; align-items:center; gap:12px; }
.logo { width:26px; height:26px; color:var(--c-teal); }
.logo-text {
  font-family: var(--font-display);
  font-size: 16px; font-weight:800;
  letter-spacing: -0.02em;
}
.logo-os { color:var(--text-muted); font-weight:500; }
.live-badge {
  display:flex; align-items:center; gap:5px;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.25);
  font-size: 10px; font-weight:700;
  letter-spacing:0.1em;
  color: var(--c-red);
}
.live-dot {
  width:5px; height:5px; border-radius:50%;
  background: var(--c-red);
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.header-center { display:flex; align-items:center; gap:12px; }
.system-status {
  display:flex; align-items:center; gap:6px;
  padding: 3px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.sys-dot {
  width:6px; height:6px; border-radius:50%;
  background: var(--c-green);
  box-shadow: 0 0 6px var(--c-green);
  animation: blink 2s ease-in-out infinite;
}
.sys-dot.processing {
  background: var(--c-yellow);
  box-shadow: 0 0 6px var(--c-yellow);
  animation: blink 0.7s ease-in-out infinite;
}
.trace-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  padding: 3px 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.header-right { display:flex; align-items:center; gap:10px; }
.ws-indicator { display:flex; align-items:center; gap:5px; font-size:11px; color:var(--text-muted); }
.ws-dot {
  width:5px; height:5px; border-radius:50%;
}
.ws-dot.connected    { background:var(--c-green); box-shadow:0 0 5px var(--c-green); }
.ws-dot.disconnected { background:var(--c-red); }
.ws-dot.connecting   { background:var(--c-yellow); animation:blink 0.8s infinite; }
.version-tag { font-family:var(--font-mono); font-size:10px; color:var(--text-muted); opacity:0.6; }
.icon-btn {
  display:flex; align-items:center; justify-content:center;
  width:28px; height:28px;
  border-radius: var(--r);
  color: var(--text-muted);
  transition: color var(--ease), background var(--ease);
}
.icon-btn:hover { color:var(--text); background:var(--surface-3); }

/* ── MAIN LAYOUT ── */
.main {
  display:grid;
  grid-template-columns: 1fr 340px 240px;
  flex:1;
  overflow:hidden;
}

/* ── COLUMN BASE ── */
.col {
  display:flex; flex-direction:column;
  border-right: 1px solid var(--border);
  overflow:hidden;
}
.col:last-child { border-right:none; }

.col-header {
  display:flex; align-items:center; justify-content:space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink:0;
  height:36px;
}
.col-label {
  font-size: 10px; font-weight:700;
  text-transform:uppercase; letter-spacing:0.08em;
  color: var(--text-muted);
}
.col-meta {
  font-family:var(--font-mono);
  font-size:10px; color:var(--text-muted);
}
.col-actions { display:flex; align-items:center; gap:10px; }
.event-count { font-size:10px; color:var(--text-muted); font-family:var(--font-mono); }
.text-btn { font-size:10px; color:var(--text-muted); padding:2px 6px; border-radius:3px; transition:color var(--ease),background var(--ease); }
.text-btn:hover { color:var(--text); background:var(--surface-3); }

/* ── FLOW AREA ── */
.col-flow { background:var(--bg); }
.flow-area {
  flex:1; overflow-y:auto;
  padding: 32px 0;
  display:flex; flex-direction:column;
  align-items:center;
  gap:0;
  scrollbar-width:thin; scrollbar-color:var(--border) transparent;
}
.flow-idle {
  display:flex; flex-direction:column; align-items:center;
  gap:12px; margin-top:60px;
  color:var(--text-muted);
  text-align:center;
}
.idle-icon { opacity:0.2; }
.flow-idle p { font-size:14px; font-weight:500; }
.flow-idle span { font-size:11px; color:var(--text-muted); opacity:0.6; max-width:240px; line-height:1.5; }

/* Flow nodes */
.flow-node {
  display:flex; flex-direction:column; align-items:center;
  animation: node-appear 280ms cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes node-appear {
  from { opacity:0; transform:scale(0.93) translateY(-8px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}

.node-card {
  width: 260px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display:flex; flex-direction:column; gap:5px;
  position:relative; overflow:hidden;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
.node-card::before {
  content:'';
  position:absolute; left:0; top:0; bottom:0; width:3px;
  background: var(--nc, var(--border));
  transition: background var(--ease);
}
.node-card.is-active {
  border-color: var(--nc, var(--c-teal));
  background: var(--surface-2);
  box-shadow: 0 0 28px color-mix(in srgb, var(--nc, var(--c-teal)) 12%, transparent);
}
.node-card.is-done { opacity:0.55; }
.node-card.is-done::before { background:var(--c-green); }
.node-card.is-error::before { background:var(--c-red); }

/* Layer accent vars */
.nc-bond   { --nc: var(--c-teal); }
.nc-master { --nc: var(--c-purple); }
.nc-sub    { --nc: var(--c-blue); }
.nc-memory { --nc: var(--c-orange); }
.nc-ops    { --nc: var(--c-green); }
.nc-tool   { --nc: var(--c-yellow); }

.node-row1 { display:flex; align-items:center; justify-content:space-between; }
.node-name {
  font-family: var(--font-display);
  font-size:13px; font-weight:700;
}
.node-badge {
  font-size:9px; font-weight:700;
  padding:2px 6px; border-radius:3px;
  text-transform:uppercase; letter-spacing:0.06em;
}
.badge-bond   { background:var(--c-teal-dim);   color:var(--c-teal); }
.badge-master { background:var(--c-purple-dim);  color:var(--c-purple); }
.badge-sub    { background:var(--c-blue-dim);    color:var(--c-blue); }
.badge-memory { background:var(--c-orange-dim);  color:var(--c-orange); }
.badge-ops    { background:var(--c-green-dim);   color:var(--c-green); }
.badge-tool   { background:var(--c-yellow-dim);  color:var(--c-yellow); }

.node-action {
  font-size:11px; color:var(--text-muted); line-height:1.4;
}
.node-action.lit { color: var(--nc, var(--c-teal)); }

.node-footer { display:flex; align-items:center; gap:6px; }
.ndot {
  width:5px; height:5px; border-radius:50%;
  flex-shrink:0;
}
.ndot.pending  { background:var(--text-muted); opacity:0.4; }
.ndot.active   { background:var(--c-yellow); box-shadow:0 0 5px var(--c-yellow); animation:blink 0.7s infinite; }
.ndot.done     { background:var(--c-green); }
.ndot.error    { background:var(--c-red); }
.nstatus { font-family:var(--font-mono); font-size:10px; color:var(--text-muted); }

/* Node duration badge */
.node-dur {
  margin-left:auto;
  font-family:var(--font-mono); font-size:9px;
  color:var(--text-muted); opacity:0.6;
}

/* Connector */
.flow-conn {
  width:1px; height:24px;
  background: var(--border);
  position:relative; flex-shrink:0;
  transition: background var(--ease);
}
.flow-conn::after {
  content:'';
  position:absolute; bottom:0; left:50%; transform:translateX(-50%);
  border-left:3px solid transparent; border-right:3px solid transparent;
  border-top:4px solid var(--border);
  transition: border-top-color var(--ease);
}
.flow-conn.live { background:var(--c-teal); opacity:0.6; }
.flow-conn.live::after { border-top-color:var(--c-teal); }

/* ── AGENT BAR ── */
.agent-bar {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  background: var(--surface);
  flex-shrink:0;
}
.agent-bar-inner { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:8px; }
.ab-left { display:flex; flex-direction:column; gap:2px; }
.ab-name { font-family:var(--font-display); font-size:14px; font-weight:700; color:var(--c-teal); }
.ab-action { font-size:11px; color:var(--text-muted); }
.ab-score { font-family:var(--font-mono); font-size:11px; color:var(--c-green); }
.ab-progress-track { height:2px; background:var(--surface-3); border-radius:1px; overflow:hidden; }
.ab-progress-bar { height:100%; background:var(--c-teal); border-radius:1px; width:0%; transition:width 400ms ease; }

/* ── TRACE COLUMN ── */
.col-trace { background:var(--surface); }
.trace-area {
  flex:1; overflow-y:auto;
  padding: 8px 10px;
  display:flex; flex-direction:column;
  gap:4px;
  scrollbar-width:thin; scrollbar-color:var(--border) transparent;
}
.trace-empty { font-size:11px; color:var(--text-muted); text-align:center; margin-top:40px; opacity:0.5; }

.trace-entry {
  padding: 7px 10px;
  border-radius: var(--r);
  border-left: 2px solid var(--border);
  background: var(--surface-2);
  display:flex; flex-direction:column; gap:3px;
  animation: trace-slide 180ms ease both;
  transition: border-color var(--ease);
  flex-shrink:0;
}
@keyframes trace-slide { from{opacity:0;transform:translateX(6px)} to{opacity:1;transform:translateX(0)} }
.trace-entry:hover { border-left-color:var(--c-teal); }

.te-top { display:flex; align-items:center; justify-content:space-between; gap:6px; }
.te-agent { font-size:11px; font-weight:600; }
.te-time  { font-family:var(--font-mono); font-size:9px; color:var(--text-muted); flex-shrink:0; }
.te-msg   { font-size:11px; color:var(--text-muted); line-height:1.4; }
.te-tags  { display:flex; flex-wrap:wrap; gap:4px; }
.te-tag {
  font-family:var(--font-mono); font-size:9px;
  padding:1px 5px; border-radius:3px;
  background:var(--surface-3); color:var(--text-muted);
}
.te-tag.ok    { background:var(--c-green-dim); color:var(--c-green); }
.te-tag.warn  { background:var(--c-yellow-dim); color:var(--c-yellow); }
.te-tag.err   { background:var(--c-red-dim); color:var(--c-red); }
.te-tag.tool  { background:var(--c-blue-dim); color:var(--c-blue); }
.te-tag.info  { background:var(--c-teal-dim); color:var(--c-teal); }

/* ── METRICS COLUMN ── */
.col-metrics { background:var(--surface); overflow-y:auto; }
.metrics-stack {
  display:grid; grid-template-columns:1fr 1fr;
  border-bottom:1px solid var(--border);
}
.metric-block {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:14px 8px;
  border-right:1px solid var(--border);
  border-bottom:1px solid var(--border);
  gap:2px;
  text-align:center;
}
.metric-block:nth-child(2n) { border-right:none; }
.metric-val {
  font-family:var(--font-display);
  font-size:22px; font-weight:800;
  letter-spacing:-0.02em;
}
.score-val { color:var(--c-green); }
.metric-label { font-size:9px; text-transform:uppercase; letter-spacing:0.08em; color:var(--text-muted); }
.metric-sub { font-size:9px; color:var(--text-muted); opacity:0.5; font-family:var(--font-mono); }

/* Layer section */
.layer-section, .tools-section, .conn-info-block {
  padding:12px 14px;
  border-bottom:1px solid var(--border);
}
.layer-title {
  font-size:9px; text-transform:uppercase; letter-spacing:0.1em;
  color:var(--text-muted); font-weight:700; margin-bottom:8px;
}
.layer-list { display:flex; flex-direction:column; gap:5px; }
.layer-row {
  display:flex; align-items:center; gap:7px;
  padding:4px 0;
}
.layer-row.active-layer { background:var(--surface-3); border-radius:4px; padding:4px 6px; }
.layer-dot { width:6px; height:6px; border-radius:50%; flex-shrink:0; }
.layer-name { font-size:11px; flex:1; }
.layer-count { font-family:var(--font-mono); font-size:10px; color:var(--text-muted); }

.tools-list { display:flex; flex-direction:column; gap:4px; max-height:120px; overflow-y:auto; }
.tools-empty { font-size:10px; color:var(--text-muted); opacity:0.5; }
.tool-call-entry {
  display:flex; align-items:center; justify-content:space-between;
  padding:3px 0;
  border-bottom:1px solid var(--border-subtle);
  animation: trace-slide 180ms ease both;
}
.tc-name { font-size:10px; font-weight:600; }
.tc-meta { font-family:var(--font-mono); font-size:9px; color:var(--text-muted); }

.conn-info-block { border-bottom:none; }
.conn-detail { font-family:var(--font-mono); font-size:10px; color:var(--text-muted); margin-bottom:6px; word-break:break-all; }
.conn-monitors { display:flex; align-items:center; gap:6px; font-size:10px; color:var(--text-muted); }
