/* ===================================================================
   TinyNOS / Fabric Air — design system
   NVIDIA-AIR-grade dark control-panel UI. Token-driven, no build step.
   =================================================================== */
:root {
  /* elevation-layered dark surface stack */
  --bg: #0b0f14;
  --surface: #11161d;
  --surface-2: #161c25;
  --elevated: #1b2230;
  --border: #242c38;
  --border-soft: #1c232e;

  --fg: #e8eef5;
  --muted: #8a97a8;
  --muted-2: #5d6877;

  /* NVIDIA-green accent (AIR homage) */
  --accent: #76b900;
  --accent-bright: #8fd400;
  --accent-dim: #5c9200;
  --accent-soft: rgba(118, 185, 0, .14);
  --accent-ink: #0a1500;

  --ok: #3fb950;   --ok-soft: rgba(63, 185, 80, .16);
  --warn: #d29922; --warn-soft: rgba(210, 153, 34, .16);
  --fail: #da3633; --fail-soft: rgba(218, 54, 51, .15);
  --info: #3b9eff; --info-soft: rgba(59, 158, 255, .16);

  /* role palette (parity with app.js ROLE_COLOR) */
  --r-spine: #f778ba; --r-leaf: #58a6ff; --r-borderleaf: #a371f7;
  --r-rr: #ffa657; --r-host: #3fb950; --r-edge: #db61a2; --r-obs: #8b949e;

  /* type */
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* radius / shadow / motion */
  --r-1: 6px; --r-2: 9px; --r-3: 14px;
  --sh-1: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.22);
  --sh-2: 0 8px 30px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.4);
  --glow: 0 0 0 1px var(--accent), 0 0 14px rgba(118,185,0,.35);
  --t-fast: .12s ease;
  --t: .2s ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 13px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
body { display: flex; flex-direction: column; overflow: hidden; }
::selection { background: var(--accent-soft); }

/* thin modern scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: #313b49; }

/* ------------------------------------------------------------------ topbar */
#topbar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-bottom: 1px solid var(--border); box-shadow: var(--sh-1); z-index: 30; }
.brand { display: flex; align-items: center; gap: 11px; }
.logo { font-size: 24px; line-height: 1; color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(118,185,0,.5)); }
.title { font-size: 16px; font-weight: 800; letter-spacing: .4px; }
.subtitle { font-size: 10.5px; color: var(--muted); letter-spacing: .3px; }
.lab-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* status chips */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: 999px; font-size: 11px; font-weight: 700; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.pill-idle::before { background: var(--muted-2); }
.pill-up { background: var(--ok-soft); color: var(--ok); border-color: rgba(63,185,80,.35); }
.pill-up::before { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.pill-down { background: var(--fail-soft); color: var(--fail); border-color: rgba(218,54,51,.35); }
.pill-down::before { background: var(--fail); }
.pill-up#obs-status { background: var(--info-soft); color: var(--info); border-color: rgba(59,158,255,.35); }
.pill-up#obs-status::before { background: var(--info); box-shadow: 0 0 6px var(--info); }

/* observability quick-links — open Grafana / Prometheus / Alertmanager in a new tab */
.obs-links { display: inline-flex; align-items: center; gap: 4px; }
.obs-link { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-decoration: none; border: 1px solid rgba(59,158,255,.35);
  background: var(--info-soft); color: var(--info); white-space: nowrap; transition: background .12s ease; }
.obs-link:hover { background: rgba(59,158,255,.22); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2);
  color: var(--fg); border: 1px solid var(--border); padding: 6px 13px; border-radius: var(--r-1);
  cursor: pointer; font: 600 12px/1 var(--ui); transition: border-color var(--t-fast),
  background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast); }
.btn:hover { border-color: var(--accent); background: var(--elevated); }
.btn:active { transform: translateY(1px); }
.btn-go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn-go:hover { background: var(--accent-bright); border-color: var(--accent-bright); box-shadow: 0 0 14px rgba(118,185,0,.35); }
.btn-stop { background: transparent; border-color: rgba(218,54,51,.5); color: #ff7b72; }
.btn-stop:hover { background: var(--fail-soft); border-color: var(--fail); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 13px; height: 13px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: var(--fg); animation: spin .7s linear infinite; }

select, input { background: var(--surface); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--r-1); padding: 5px 9px; font: 500 12px/1.2 var(--ui); transition: border-color var(--t-fast); }
select:hover, input:hover { border-color: #313b49; }
select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* icon-only ghost button (rail collapse toggles) */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border-radius: var(--r-1); border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 1; transition: all var(--t-fast); }
.icon-btn:hover { background: var(--elevated); color: var(--fg); border-color: var(--border); }

/* ------------------------------------------------------------------ layout */
/* 5-column grid: panel | 6px drag-handle | panel | 6px drag-handle | panel */
#layout { flex: 1; display: grid;
  grid-template-columns: var(--col-left,340px) 6px 1fr 6px var(--col-right,460px);
  gap: 1px; background: var(--border); min-height: 0; position: relative; transition: grid-template-columns var(--t); }
.panel { background: var(--bg); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 44px; }
.panel-head h2 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted); font-weight: 700; }
.head-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
#scn-filter { width: 130px; }

/* resize handles between panels */
.resize-handle { background: var(--bg); cursor: col-resize; position: relative;
  z-index: 2; transition: background var(--t-fast); user-select: none; }
.resize-handle::after { content: ""; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%); width: 3px; height: 36px; border-radius: 2px;
  background: var(--border); opacity: 0.7; transition: all var(--t-fast); }
.resize-handle:hover { background: var(--surface); }
.resize-handle:hover::after, .resize-handle.active::after {
  background: var(--accent); opacity: 1; box-shadow: 0 0 6px rgba(118,185,0,.4); height: 50px; }
.resize-handle.active { background: var(--surface); cursor: col-resize; }

/* collapsed side rails (≥1024): collapse both the panel and its adjacent handle */
#layout.collapse-left  { grid-template-columns: 0 0 1fr 6px var(--col-right,460px); }
#layout.collapse-right { grid-template-columns: var(--col-left,340px) 6px 1fr 0 0; }
#layout.collapse-left.collapse-right { grid-template-columns: 0 0 1fr 0 0; }
#scenarios, #right { overflow: hidden; transition: opacity var(--t); }
#layout.collapse-left #scenarios, #layout.collapse-right #right { opacity: 0; pointer-events: none; }
#layout.collapse-left #rh-left, #layout.collapse-right #rh-right { opacity: 0; pointer-events: none; }

/* floating un-collapse tabs shown when a rail is hidden */
.rail-restore { position: absolute; top: 10px; z-index: 20; display: none; }
.rail-restore.left { left: 0; }
.rail-restore.right { right: 0; }
#layout.collapse-left .rail-restore.left { display: block; }
#layout.collapse-right .rail-restore.right { display: block; }
.rail-restore .btn { border-radius: 0 var(--r-1) var(--r-1) 0; box-shadow: var(--sh-1); }
.rail-restore.right .btn { border-radius: var(--r-1) 0 0 var(--r-1); }

/* scrim for drawer mode */
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  z-index: 40; opacity: 0; pointer-events: none; transition: opacity var(--t); }
#scrim.show { opacity: 1; pointer-events: auto; }

/* ------------------------------------------------ scenario menu (left rail) */
#scenario-list { overflow-y: auto; padding: 8px; }
.scn { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-2);
  padding: 9px 11px; margin-bottom: 7px; cursor: pointer; position: relative;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast); }
.scn::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: var(--r-2) 0 0 var(--r-2); background: transparent; transition: background var(--t-fast); }
.scn:hover { border-color: #313b49; transform: translateY(-1px); box-shadow: var(--sh-1); }
.scn.sel { border-color: var(--accent); background: linear-gradient(90deg, var(--accent-soft), var(--surface) 60%); }
.scn.sel::before { background: var(--accent); }
.scn-top { display: flex; align-items: center; gap: 7px; }
.scn-num { color: var(--accent); font-weight: 800; font-family: var(--mono); font-size: 12px; }
.scn-title { font-weight: 700; flex: 1; font-size: 12.5px; }
.scn-sum { color: var(--muted); font-size: 11px; margin-top: 3px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* verdict badges */
.badge { font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent; }
.badge.pass { background: var(--ok-soft); color: var(--ok); border-color: rgba(63,185,80,.3); }
.badge.fail { background: var(--fail-soft); color: #ff7b72; border-color: rgba(218,54,51,.3); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(210,153,34,.3); }
.badge.env  { background: var(--info-soft); color: var(--info); border-color: rgba(59,158,255,.3); }
.badge.unknown { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge.note { background: rgba(163,113,247,.18); color: var(--r-borderleaf); border-color: rgba(163,113,247,.3); }
.badge.scaffold { background: rgba(57,197,187,.14); color: #39c5bb; border: 1px dashed rgba(57,197,187,.55); }

/* ------------------------------------------------------- center (topology) */
/* topo-area fills center; dock lives below it */
.topo-area { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.topo-area .view { position: absolute; inset: 0; display: none; }
.topo-area .view.active { display: block; }
#topo { width: 100%; height: 100%; position: relative; }
.tab { flex: 1; display: none; min-height: 0; }
.tab.active { display: block; }

/* horizontal dock resize handle */
/* horizontal resize handle — always visible as topology/dock separator */
.resize-handle-h {
  height: 6px; flex-shrink: 0; cursor: ns-resize;
  background: var(--border); position: relative; display: block;
}
.resize-handle-h::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%,-50%); width: 36px; height: 3px;
  background: var(--border); border-radius: 2px; transition: background var(--t-fast);
}
.resize-handle-h:hover, .resize-handle-h:active { background: var(--surface-2); }
.resize-handle-h:hover::after, .resize-handle-h:active::after { background: var(--accent); }

/* multi-console dock — header always visible, panes expand on first open */
#console-dock {
  flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg); border-top: 1px solid var(--border);
}

.dock-header {
  display: flex; align-items: center; gap: 6px; padding: 3px 8px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; min-height: 32px;
}
.dock-tabs {
  display: flex; gap: 3px; flex: 1; overflow-x: auto; scrollbar-width: none;
}
.dock-tabs::-webkit-scrollbar { display: none; }
.dock-tab {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px 2px 9px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-1);
  white-space: nowrap; font-size: 11px; color: var(--muted); flex-shrink: 0;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.dock-tab.active { background: var(--elevated); border-color: var(--accent); color: var(--fg); }
.dock-tab:not(.active):hover { background: var(--elevated); color: var(--fg); }
.dock-tab-lbl { cursor: pointer; }
.dock-tab-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 0; line-height: 1; display: flex; align-items: center;
  margin-left: 2px; transition: color var(--t-fast);
}
.dock-tab-close:hover { color: var(--fail); }
.dock-controls { flex-shrink: 0; }
/* panes collapse to 0 when no consoles, expand when open (height via inline style) */
.dock-panes {
  flex-shrink: 0; height: 0; overflow: hidden;
  position: relative; background: #0b0f14;
  transition: height var(--t);
}
.dock-pane {
  position: absolute; inset: 0; padding: 4px;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast);
}
.dock-pane.active { opacity: 1; pointer-events: auto; }
.iface-lbl {
  position: absolute; transform: translate(-50%,-50%);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px; color: #c9d4e0; white-space: nowrap; pointer-events: none;
  background: rgba(11,15,20,0.94); padding: 2px 5px; border-radius: 4px;
  border: 1px solid var(--accent); line-height: 1.4; z-index: 20;
  box-shadow: 0 0 6px rgba(118,185,0,0.25);
  opacity: 0; transition: opacity var(--t-fast);
}
.iface-lbl--active { opacity: 1; }
#overlay { overflow: auto; padding: 18px; text-align: center; background:
  radial-gradient(1200px 600px at 50% -10%, rgba(118,185,0,.04), transparent), var(--bg); }
#overlay .mermaid { display: inline-block; }
.hint { color: var(--muted); padding: 34px; text-align: center; font-size: 12px; }

/* segmented control (center view + right tabs) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-1);
  overflow: hidden; background: var(--surface); }
.seg-btn { background: transparent; color: var(--muted); border: none; padding: 5px 11px;
  cursor: pointer; font: 600 11.5px/1 var(--ui); transition: all var(--t-fast); white-space: nowrap; }
.seg-btn:hover { color: var(--fg); background: var(--elevated); }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* topology legend — floating glass chip row */
#legend { position: absolute; bottom: 10px; left: 10px; display: flex; flex-wrap: wrap; gap: 10px;
  background: rgba(11,15,20,.78); backdrop-filter: blur(8px); padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--r-2); font-size: 11px; box-shadow: var(--sh-1); }
#legend span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); text-transform: capitalize; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* weathermap util colour-scale legend — floating glass chip, bottom-right */
#util-legend { position: absolute; bottom: 10px; right: 10px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 9px; background: rgba(11,15,20,.78); backdrop-filter: blur(8px);
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r-2);
  font-size: 11px; box-shadow: var(--sh-1); z-index: 6; }
#util-legend:empty { display: none; }
.ll-title { color: var(--fg); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; font-size: 10px; }
.ll-stop { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.ll-dot { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.ll-src { font-size: 9.5px; padding: 1px 6px; border-radius: 8px; text-transform: uppercase; letter-spacing: .4px; }
.ll-src-on { color: var(--accent); border: 1px solid var(--accent-dim); background: var(--accent-soft); }
.ll-src-off { color: #8b949e; border: 1px solid #30363d; background: rgba(139,148,158,.1); }

/* click-edge load detail card (CloudVision / NetQ style) */
.link-load-card {
  position: absolute; transform: translate(-50%,-115%);
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10.5px;
  color: #c9d4e0; white-space: nowrap; pointer-events: none; z-index: 21;
  background: rgba(11,15,20,0.97); border: 1px solid var(--accent); border-radius: 6px;
  padding: 6px 9px; line-height: 1.5; box-shadow: 0 0 10px rgba(118,185,0,0.3);
}
.link-load-card .ll-head { display: flex; align-items: center; gap: 6px; font-weight: 700;
  color: var(--fg); margin-bottom: 4px; border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.link-load-card .ll-util { margin-left: auto; color: var(--accent-bright); padding-left: 12px; }
.link-load-card .ll-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.link-load-card .ll-row { display: grid; grid-template-columns: 90px 80px 70px; gap: 8px; }
.link-load-card .ll-dir { color: var(--muted); }
.link-load-card .ll-err { color: #f85149; }
.link-load-card .ll-muted { color: var(--muted); }

/* topology spinner overlay */
#topo-loading { position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(11,15,20,.5); z-index: 5; }
#topo-loading.show { display: flex; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------- right rail tabs */
#output { overflow-y: auto; padding: 9px 11px; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.55 var(--mono); }
#output .l-start { color: var(--accent-bright); }
#output .l-done { color: var(--ok); font-weight: 700; }
#output .l-err, #output .l-fail { color: #ff7b72; }
#output .l-pass { color: var(--ok); }
#output .l-warn { color: var(--warn); }
#output .l-skip { color: var(--info); }
#console { padding: 6px; background: #000; }

/* node state panel */
#nodestate { overflow-y: auto; padding: 11px; }
.ns-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px;
  color: var(--accent); margin-bottom: 10px; }
.ns-role { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.ns-refresh { margin-left: auto; padding: 3px 9px; }
.ns-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-2);
  padding: 10px 12px; margin-bottom: 9px; box-shadow: var(--sh-1); }
.ns-card-h { display: flex; align-items: center; gap: 8px; font-weight: 700; text-transform: uppercase;
  font-size: 10.5px; letter-spacing: 1px; color: var(--muted); margin-bottom: 7px; }
.ns-meta { color: var(--muted); font-size: 11px; margin-bottom: 7px; font-family: var(--mono); }
.ns-na { color: var(--muted); font-style: italic; font-size: 11px; }
.ns-peers { width: 100%; border-collapse: collapse; font-size: 11px; font-family: var(--mono); }
.ns-peers th { text-align: left; color: var(--muted); font-weight: 600; padding: 3px 6px;
  border-bottom: 1px solid var(--border); }
.ns-peers td { padding: 3px 6px; border-bottom: 1px solid var(--border-soft); }
.ns-peers tr.ns-up td:nth-child(4) { color: var(--ok); font-weight: 700; }
.ns-peers tr.ns-down td:nth-child(4) { color: #ff7b72; font-weight: 700; }
.ns-stats { display: flex; gap: 20px; }
.ns-stats > div { display: flex; flex-direction: column; }
.ns-num { font-size: 22px; font-weight: 800; color: var(--fg); }
.ns-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* run-all batch table */
#runall { overflow-y: auto; padding: 11px; }
.runall-bar { margin-bottom: 9px; }
#runall-summary { font-size: 12px; color: var(--muted); }
#runall-table { width: 100%; border-collapse: collapse; font-size: 12px; }
#runall-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 7px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); }
#runall-table td { padding: 5px 7px; border-bottom: 1px solid var(--border-soft); }
#runall-table tr:hover td { background: var(--surface); }
.ra-state { font-weight: 700; font-family: var(--mono); font-size: 11px; }
.ra-active { color: var(--accent-bright); } .ra-done { color: var(--ok); }
.ra-fail { color: #ff7b72; } .ra-skip { color: var(--muted); } .ra-queued { color: var(--muted-2); }

/* settle checkbox + converge pill */
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); cursor: pointer; }
.chk input { accent-color: var(--accent); }
#converge-pill.hidden { display: none; }

/* footer action bar → floating glass toolbar */
#actionbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2)); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,.3); z-index: 20; }
#actionbar.hidden { display: none; }
#sel-name { font-weight: 800; color: var(--accent); }
.spacer { flex: 1; }

/* ------------------------------------------------------------ toasts */
#toasts { position: fixed; top: 64px; right: 16px; z-index: 60; display: flex; flex-direction: column;
  gap: 8px; max-width: 360px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px;
  background: var(--elevated); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-2);
  box-shadow: var(--sh-2); font-size: 12px; color: var(--fg);
  animation: toast-in .22s cubic-bezier(.2,.8,.2,1); }
.toast.out { animation: toast-out .2s ease forwards; }
.toast .t-ico { font-weight: 800; line-height: 1.3; }
.toast.ok { border-left-color: var(--ok); } .toast.ok .t-ico { color: var(--ok); }
.toast.fail { border-left-color: var(--fail); } .toast.fail .t-ico { color: #ff7b72; }
.toast.warn { border-left-color: var(--warn); } .toast.warn .t-ico { color: var(--warn); }
.toast.info { border-left-color: var(--info); } .toast.info .t-ico { color: var(--info); }
.toast .t-body { min-width: 0; } .toast .t-body b { display: block; margin-bottom: 1px; }
.toast .t-sub { color: var(--muted); font-size: 11px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ------------------------------------------------------------ skeletons */
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--r-1); }
.sk-scn { height: 52px; margin-bottom: 7px; border-radius: var(--r-2); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ------------------------------------------------------------ CLI guide tab */
#guide { overflow-y: auto; padding: 0; }
.guide-body { padding: 15px 17px; }
.guide-body h3 { margin: 0 0 9px; font-size: 15px; color: var(--accent); font-weight: 800; }
.g-lead { color: var(--muted); font-size: 12px; margin: 0 0 15px; line-height: 1.55; }
.g-lead em { color: var(--fg); font-style: normal; }
.g-step { display: flex; gap: 11px; margin-bottom: 13px; }
.g-n { flex: none; width: 23px; height: 23px; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.g-step > div { min-width: 0; } .g-step b { color: var(--fg); }
.guide-body code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font: 11px/1.4 var(--mono); color: var(--accent-bright); }
.g-code { background: #000; border: 1px solid var(--border); border-radius: var(--r-2); padding: 9px 11px;
  margin: 7px 0; font: 11px/1.55 var(--mono); color: var(--fg); white-space: pre; overflow-x: auto; }
.g-code .g-cmt, .g-cmt { color: var(--muted); }
.g-note { display: block; color: var(--warn); font-size: 11px; margin: 5px 0; }
.kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 7px;
  font-weight: 700; color: var(--accent); }
.g-warn { background: var(--fail-soft); border: 1px solid rgba(218,54,51,.4); border-radius: var(--r-2);
  padding: 10px 12px; font-size: 11px; margin: 15px 0; line-height: 1.5; }
.g-warn b { color: #ff7b72; }
.g-tip { background: var(--ok-soft); border: 1px solid rgba(63,185,80,.3); border-radius: var(--r-2);
  padding: 10px 12px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.g-tip b { color: var(--ok); }

/* ------------------------------------------------- verdict filter chips */
#scn-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px 2px;
  border-bottom: 1px solid var(--border-soft); }
.chip { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
.chip:hover { background: var(--elevated); color: var(--fg); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(118,185,0,.35); }
.chip[data-verdict="pass"].active { background: var(--ok-soft); color: var(--ok); border-color: rgba(63,185,80,.35); }
.chip[data-verdict="fail"].active { background: var(--fail-soft); color: var(--fail); border-color: rgba(218,54,51,.35); }
.chip[data-verdict="warn"].active { background: var(--warn-soft); color: var(--warn); border-color: rgba(210,153,34,.35); }
.chip[data-verdict="scaffold"].active { background: var(--info-soft); color: var(--info); border-color: rgba(59,158,255,.35); }

/* ------------------------------------------------- output controls bar */
#out-controls { display: flex; gap: 4px; padding: 0 0 6px 0;
  border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; }

/* ============================================================ responsive */
/* narrow rails between 1024 and 1400 — keep CSS vars so drag sizing is preserved */
@media (max-width: 1400px) {
  #layout { grid-template-columns: var(--col-left,300px) 6px 1fr 6px var(--col-right,400px); }
  #layout.collapse-left  { grid-template-columns: 0 0 1fr 6px var(--col-right,400px); }
  #layout.collapse-right { grid-template-columns: var(--col-left,300px) 6px 1fr 0 0; }
  #layout.collapse-left.collapse-right { grid-template-columns: 0 0 1fr 0 0; }
}
/* drawers below 1024: side rails float over the canvas; handles hidden */
@media (max-width: 1024px) {
  #layout { grid-template-columns: 1fr; }
  .resize-handle { display: none; }
  #scenarios, #right { position: fixed; top: 0; bottom: 0; width: min(360px, 86vw); z-index: 50;
    background: var(--surface); box-shadow: var(--sh-2); opacity: 1 !important; pointer-events: auto !important;
    transition: transform var(--t); }
  #scenarios { left: 0; transform: translateX(-101%); border-right: 1px solid var(--border); }
  #right { right: 0; transform: translateX(101%); border-left: 1px solid var(--border); }
  #scenarios.open, #right.open { transform: translateX(0); }
  .rail-restore { display: block !important; top: 8px; }
  .rail-restore.left .btn { border-radius: 0 var(--r-1) var(--r-1) 0; }
  .rail-restore.right .btn { border-radius: var(--r-1) 0 0 var(--r-1); }
  /* in drawer mode collapse-* classes are irrelevant; transform drives it */
  #layout.collapse-left, #layout.collapse-right, #layout.collapse-left.collapse-right { grid-template-columns: 1fr; }
}

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

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---- floating per-node terminal windows (multi-console) ---- */
#float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 4000; }
.term-win {
  position: absolute; width: 560px; height: 340px; min-width: 300px; min-height: 170px;
  background: #0b0f14; border: 1px solid var(--accent, #76b900); border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,.65); pointer-events: auto;
  resize: both; overflow: hidden; display: flex; flex-direction: column;
}
.tw-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--surface-2, #161b22); border-bottom: 1px solid var(--border, #283040);
  cursor: move; user-select: none; flex: 0 0 auto;
}
.tw-dot { width: 8px; height: 8px; border-radius: 50%; background: #76b900; flex: 0 0 auto; }
.tw-title { flex: 1; font-size: 13px; font-weight: 600; color: var(--fg, #e6ebf5);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-btn { background: none; border: 0; color: var(--muted, #8b97ad); font-size: 18px;
  line-height: 1; cursor: pointer; padding: 0 4px; }
.tw-close:hover { color: var(--fail, #d5524a); }
.tw-body { flex: 1 1 auto; padding: 4px 6px; overflow: hidden; min-height: 0; }
.tw-body .xterm { height: 100%; }

/* ---- scenario Details view: verify result + applied CLI commands ---- */
#detail { overflow: auto; padding: 14px 16px; }
.detail-sec { margin-bottom: 18px; }
.detail-sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); margin: 0 0 8px; font-weight: 700; }
.detail-verdict { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-note { font-size: 11px; color: var(--muted); }
.detail-lines { list-style: none; margin: 10px 0 0; padding: 0;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6; }
.detail-lines li { display: flex; gap: 8px; align-items: baseline;
  padding: 2px 6px; border-radius: 5px; }
.detail-lines li:nth-child(odd) { background: rgba(255,255,255,.02); }
.dl-tag { flex: 0 0 auto; font-weight: 700; font-size: 9.5px; padding: 1px 5px;
  border-radius: 4px; min-width: 38px; text-align: center; }
.dl-pass .dl-tag { background: var(--ok-soft); color: var(--ok); }
.dl-fail .dl-tag { background: var(--fail-soft); color: #ff7b72; }
.dl-warn .dl-tag { background: var(--warn-soft); color: var(--warn); }
.dl-skip .dl-tag { background: var(--surface-2); color: var(--muted); }
.dl-fail { color: #ff7b72; }
.dl-warn { color: var(--warn); }
.cli-node { margin-bottom: 12px; border: 1px solid var(--border);
  border-radius: var(--r-1); overflow: hidden; }
.cli-node-name { background: var(--surface-2); color: var(--accent);
  font-family: var(--mono); font-weight: 700; font-size: 11.5px;
  padding: 6px 10px; border-bottom: 1px solid var(--border); }
.cli-body { margin: 0; padding: 10px 12px; font-family: var(--mono);
  font-size: 11.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  color: var(--text, #d7dde5); background: var(--bg, #0b0f14); max-height: none; }

/* ---- assistant (netclaw chat) ---- */
#chat.tab.active { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px; display: flex;
  flex-direction: column; gap: 8px; }
.chat-msg { max-width: 85%; padding: 8px 11px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.chat-msg.bot { align-self: flex-start; background: var(--elevated); color: var(--fg);
  border: 1px solid var(--border); }
.chat-msg.err { align-self: flex-start; background: var(--fail-soft); color: var(--fail);
  border: 1px solid var(--fail); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--fg); font-family: var(--ui); font-size: 13px; }
.chat-form input:focus { outline: none; box-shadow: var(--glow); }
