#135 ui dark mobile: high Spatial & Canvas

Interactive Node / Flow Graph Inspector

Blueprint node-graph editor with draggable workflow nodes, live SVG bezier edges, animated run pulses, and a property inspector.

Inspired by React Flow ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Combines direct-manipulation node positioning and animated signal flow along cubic bezier edges with a live property inspector that collapses into a bottom drawer on mobile.

BEST FOR

AI agent and LLM pipeline buildersETL data orchestration and webhook flowsAudio/shader node graph editorsState machine and CI/CD visualizers

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Inter
Body
Inter
Mono
JetBrains Mono
Scale
13.5px node titles, 11px mono latency/status pills, 12px inspector form labels.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Fluid dot-grid node stage on the left paired with a 300px right-hand node property inspector on desktop; slide-up or collapsible inspector panel on mobile.

INTERACTION

Drag any node to recompute SVG bezier connectors in real time; click a node to edit its label, status, or latency budget; click Run Pipeline to animate execution pulses across edges.

MOBILE

Provides Fit View and zoom controls plus a toggleable node inspector sheet so users can inspect and edit nodes cleanly at 390px without losing the graph.

AI AGENT GUARDRAILS

DO

  • Recompute SVG bezier paths smoothly on every pointermove frame using node port anchors.
  • Indicate node execution state with both color and text/icon status badges.
  • Dock the node inspector as a collapsible panel or bottom sheet on mobile screens.

DON'T

  • Never leave edges disconnected or stale when a node is dragged.
  • Avoid hardcoding fixed pixel canvas dimensions that clip nodes on 390px screens.
STANDALONE SOURCE · demos/node-flow-graph-inspector.html (27.6 KB)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>CircuitFlow — Node Graph Inspector</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
  <style>
    :root {
      --bg: #080d1a;
      --grid-dot: rgba(148, 163, 184, 0.22);
      --panel: #0f172a;
      --card: #141e33;
      --card-hover: #1a2742;
      --border: #24324d;
      --border-active: #38bdf8;
      --ink: #f1f5f9;
      --ink-muted: #94a3b8;
      --ink-faint: #64748b;

      --c-trigger: #f59e0b;
      --c-transform: #38bdf8;
      --c-model: #a78bfa;
      --c-router: #10b981;
      --c-sink: #fb7185;

      --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }

    html, body {
      height: 100%;
      background: var(--bg);
      color: var(--ink);
      font-family: var(--font-sans);
      -webkit-font-smoothing: antialiased;
      overflow: hidden;
    }

    .app {
      display: flex;
      flex-direction: column;
      height: 100dvh;
      width: 100vw;
      overflow: hidden;
    }

    /* Top Header */
    .topbar {
      height: 56px;
      padding: 0 16px;
      background: var(--panel);
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-shrink: 0;
      z-index: 20;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }

    .brand-icon {
      width: 30px;
      height: 30px;
      border-radius: 8px;
      background: rgba(56, 189, 248, 0.14);
      border: 1px solid rgba(56, 189, 248, 0.35);
      color: #38bdf8;
      display: grid;
      place-items: center;
      flex-shrink: 0;
    }

    .brand-text h1 {
      font-size: 14px;
      font-weight: 600;
      letter-spacing: -0.01em;
      white-space: nowrap;
    }

    .brand-text span {
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--ink-muted);
    }

    .top-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .btn {
      appearance: none;
      border: 1px solid var(--border);
      background: var(--card);
      color: var(--ink);
      font-family: var(--font-sans);
      font-size: 12.5px;
      font-weight: 500;
      padding: 0 12px;
      min-height: 38px;
      border-radius: 8px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: background 0.15s, border-color 0.15s, transform 0.1s;
      white-space: nowrap;
    }

    .btn:hover {
      background: var(--card-hover);
      border-color: #3b517a;
    }

    .btn-run {
      background: linear-gradient(135deg, #0284c7, #2563eb);
      border-color: rgba(56, 189, 248, 0.5);
      color: #fff;
      font-weight: 600;
    }
    .btn-run:hover {
      background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    }
    .btn-run:disabled {
      opacity: 0.65;
      cursor: wait;
    }

    /* Main Split */
    .main {
      flex: 1;
      display: grid;
      grid-template-columns: 1fr 330px;
      min-height: 0;
      position: relative;
      overflow: hidden;
    }

    /* Blueprint Canvas */
    .canvas-wrap {
      position: relative;
      overflow: hidden;
      background-color: var(--bg);
      background-image: radial-gradient(var(--grid-dot) 1.25px, transparent 1.25px);
      background-size: 24px 24px;
      touch-action: none;
      user-select: none;
    }

    .viewport {
      position: absolute;
      inset: 0;
      transform-origin: 0 0;
    }

    .edges-layer {
      position: absolute;
      inset: 0;
      width: 1600px;
      height: 1000px;
      overflow: visible;
      pointer-events: none;
    }

    .edge-path {
      fill: none;
      stroke: #334155;
      stroke-width: 2.25;
      transition: stroke 0.25s;
    }

    .edge-path.active {
      stroke: #38bdf8;
      stroke-width: 2.75;
    }

    .edge-path.pulse-running {
      stroke: #38bdf8;
      stroke-dasharray: 8 6;
      animation: dashFlow 0.7s linear infinite;
    }

    @keyframes dashFlow {
      to { stroke-dashoffset: -28; }
    }

    .pulse-dot {
      fill: #38bdf8;
      filter: drop-shadow(0 0 6px #38bdf8);
    }

    /* Node Cards */
    .node {
      position: absolute;
      width: 214px;
      background: var(--card);
      border: 1.5px solid var(--border);
      border-radius: 11px;
      padding: 11px 13px;
      cursor: grab;
      box-shadow: 0 8px 24px rgba(2, 6, 23, 0.45);
      transition: border-color 0.15s, box-shadow 0.15s, opacity 0.2s;
      touch-action: none;
    }

    .node:active { cursor: grabbing; }

    .node.selected {
      border-color: var(--border-active);
      box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18), 0 12px 28px rgba(2, 6, 23, 0.6);
    }

    .node.disabled {
      opacity: 0.48;
      border-style: dashed;
    }

    .node.running {
      border-color: #38bdf8;
      box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.28);
    }

    .node.done {
      border-color: #10b981;
    }

    .node-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 6px;
      margin-bottom: 6px;
    }

    .node-kind {
      font-family: var(--font-mono);
      font-size: 10px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      padding: 2px 6px;
      border-radius: 4px;
    }

    .node-status {
      font-family: var(--font-mono);
      font-size: 10.5px;
      color: var(--ink-muted);
    }

    .node.done .node-status { color: #34d399; }
    .node.running .node-status { color: #38bdf8; }

    .node-title {
      font-size: 13.5px;
      font-weight: 600;
      color: var(--ink);
      margin-bottom: 4px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .node-sub {
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--ink-muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .port {
      position: absolute;
      top: 50%;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #0f172a;
      border: 2px solid #64748b;
      transform: translateY(-50%);
    }
    .port-in { left: -6px; }
    .port-out { right: -6px; }
    .node.selected .port { border-color: #38bdf8; }

    /* Floating Canvas Controls */
    .canvas-controls {
      position: absolute;
      left: 14px;
      bottom: 14px;
      display: flex;
      align-items: center;
      gap: 4px;
      background: rgba(15, 23, 42, 0.92);
      border: 1px solid var(--border);
      padding: 4px;
      border-radius: 10px;
      backdrop-filter: blur(8px);
      z-index: 10;
    }

    .zoom-btn {
      appearance: none;
      border: none;
      background: transparent;
      color: var(--ink-muted);
      font-family: var(--font-mono);
      font-size: 12px;
      min-width: 36px;
      min-height: 36px;
      padding: 0 8px;
      border-radius: 6px;
      cursor: pointer;
    }
    .zoom-btn:hover {
      background: var(--card-hover);
      color: var(--ink);
    }

    .run-banner {
      position: absolute;
      left: 14px;
      top: 14px;
      background: rgba(15, 23, 42, 0.9);
      border: 1px solid var(--border);
      padding: 7px 12px;
      border-radius: 8px;
      font-family: var(--font-mono);
      font-size: 11.5px;
      color: var(--ink-muted);
      pointer-events: none;
      z-index: 10;
    }

    /* Inspector Sidebar / Mobile Drawer */
    .inspector {
      background: var(--panel);
      border-left: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      min-height: 0;
      overflow-y: auto;
      z-index: 15;
    }

    .inspector-head {
      padding: 14px 16px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .inspector-head h2 {
      font-size: 13px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--ink-muted);
    }

    .close-drawer {
      display: none;
      appearance: none;
      border: 1px solid var(--border);
      background: var(--card);
      color: var(--ink);
      min-width: 44px;
      min-height: 44px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 16px;
    }

    .inspector-body {
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .field {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .field label {
      font-size: 12px;
      font-weight: 500;
      color: var(--ink-muted);
    }

    .field input[type="text"],
    .field input[type="number"],
    .field select,
    .field textarea {
      width: 100%;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 7px;
      color: var(--ink);
      font-family: var(--font-mono);
      font-size: 12.5px;
      padding: 9px 10px;
      outline: none;
      transition: border-color 0.15s;
    }

    .field input:focus,
    .field select:focus,
    .field textarea:focus {
      border-color: var(--border-active);
    }

    .field-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    .toggle-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 12px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
    }

    .toggle-row span {
      font-size: 13px;
      font-weight: 500;
    }

    .toggle-row input[type="checkbox"] {
      width: 18px;
      height: 18px;
      accent-color: #38bdf8;
      cursor: pointer;
    }

    .metrics-box {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 12px;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    .metric-item span {
      display: block;
      font-size: 11px;
      color: var(--ink-faint);
      margin-bottom: 2px;
    }

    .metric-item strong {
      font-family: var(--font-mono);
      font-size: 13px;
      color: var(--ink);
    }

    .inspector-toggle-mobile {
      display: none;
    }

    @media (max-width: 860px) {
      .main {
        grid-template-columns: 1fr;
      }

      .hide-mobile { display: none; }

      .btn { min-height: 44px; padding: 0 11px; }
      .zoom-btn { min-width: 44px; min-height: 44px; }

      .inspector-toggle-mobile {
        display: inline-flex;
      }

      .inspector {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 68dvh;
        border-left: none;
        border-top: 1px solid var(--border-active);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.55);
        transform: translateY(105%);
        transition: transform 0.25s ease;
      }

      .inspector.open {
        transform: translateY(0);
      }

      .close-drawer {
        display: inline-grid;
        place-items: center;
      }
    }
  </style>
</head>
<body>
  <div class="app">
    <header class="topbar">
      <div class="brand">
        <div class="brand-icon" aria-hidden="true">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"><rect x="3" y="4" width="6" height="6" rx="1"/><rect x="15" y="14" width="6" height="6" rx="1"/><path d="M9 7h4a2 2 0 0 1 2 2v5"/></svg>
        </div>
        <div class="brand-text">
          <h1>Ingestion &amp; Triage Pipeline</h1>
          <span class="hide-mobile">6 nodes · 5 edges · drag nodes to reposition</span>
        </div>
      </div>

      <div class="top-actions">
        <button id="btnInspectMobile" class="btn inspector-toggle-mobile" type="button">Inspector</button>
        <button id="btnFit" class="btn hide-mobile" type="button">Fit View</button>
        <button id="btnRun" class="btn btn-run" type="button">
          <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="6 4 20 12 6 20 6 4"/></svg>
          <span>Run Pipeline</span>
        </button>
      </div>
    </header>

    <div class="main">
      <div id="canvasWrap" class="canvas-wrap" aria-label="Interactive flow graph canvas">
        <div id="runBanner" class="run-banner">Idle · Select any node to inspect or drag</div>
        <div id="viewport" class="viewport">
          <svg id="edgesLayer" class="edges-layer"></svg>
          <div id="nodesLayer"></div>
        </div>

        <div class="canvas-controls">
          <button id="zoomOut" class="zoom-btn" type="button" aria-label="Zoom out">−</button>
          <span id="zoomPct" style="font-family:var(--font-mono);font-size:11.5px;color:var(--ink-muted);padding:0 6px;">100%</span>
          <button id="zoomIn" class="zoom-btn" type="button" aria-label="Zoom in">+</button>
          <button id="zoomReset" class="zoom-btn" type="button">Fit</button>
        </div>
      </div>

      <aside id="inspector" class="inspector" aria-label="Node property inspector">
        <div class="inspector-head">
          <h2>Node Inspector</h2>
          <button id="closeDrawer" class="close-drawer" type="button" aria-label="Close inspector">✕</button>
        </div>
        <div id="inspectorBody" class="inspector-body"></div>
      </aside>
    </div>
  </div>

  <script>
    const KIND_COLORS = {
      trigger: { color: '#f59e0b', bg: 'rgba(245, 158, 11, 0.14)' },
      transform: { color: '#38bdf8', bg: 'rgba(56, 189, 248, 0.14)' },
      model: { color: '#a78bfa', bg: 'rgba(167, 139, 250, 0.14)' },
      router: { color: '#10b981', bg: 'rgba(16, 185, 129, 0.14)' },
      sink: { color: '#fb7185', bg: 'rgba(251, 113, 133, 0.14)' }
    };

    const nodes = [
      { id: 'n1', kind: 'trigger', title: 'Webhook Ingest', config: 'POST /v2/events/support', timeout: 800, retries: 2, enabled: true, x: 40, y: 170, latency: 18, notes: 'Verifies HMAC-SHA256 signature before enqueueing.' },
      { id: 'n2', kind: 'transform', title: 'PII Redactor', config: 'regex + presidio-fast', timeout: 1200, retries: 1, enabled: true, x: 300, y: 170, latency: 42, notes: 'Strips credit cards, SSNs, and bearer tokens.' },
      { id: 'n3', kind: 'model', title: 'Embedding Classifier', config: 'text-embed-v3 · 768d', timeout: 3500, retries: 2, enabled: true, x: 560, y: 80, latency: 164, notes: 'Computes intent vector and urgency score.' },
      { id: 'n4', kind: 'router', title: 'Confidence Router', config: 'score >= 0.86', timeout: 400, retries: 0, enabled: true, x: 560, y: 270, latency: 9, notes: 'Routes high-confidence tickets to auto-index.' },
      { id: 'n5', kind: 'sink', title: 'Vector Index', config: 'qdrant://prod-us-east', timeout: 1500, retries: 3, enabled: true, x: 830, y: 120, latency: 31, notes: 'Upserts payload with tenant namespace.' },
      { id: 'n6', kind: 'sink', title: 'Human Review Queue', config: 'linear://triage-inbox', timeout: 2000, retries: 2, enabled: true, x: 830, y: 290, latency: 54, notes: 'Escalates low-confidence items to on-call.' }
    ];

    const edges = [
      { id: 'e1', from: 'n1', to: 'n2' },
      { id: 'e2', from: 'n2', to: 'n3' },
      { id: 'e3', from: 'n3', to: 'n4' },
      { id: 'e4', from: 'n4', to: 'n5' },
      { id: 'e5', from: 'n4', to: 'n6' }
    ];

    let selectedId = 'n3';
    let scale = 1;
    let panX = 0;
    let panY = 0;
    let isRunning = false;

    const canvasWrap = document.getElementById('canvasWrap');
    const viewport = document.getElementById('viewport');
    const edgesLayer = document.getElementById('edgesLayer');
    const nodesLayer = document.getElementById('nodesLayer');
    const inspector = document.getElementById('inspector');
    const inspectorBody = document.getElementById('inspectorBody');
    const runBanner = document.getElementById('runBanner');
    const zoomPct = document.getElementById('zoomPct');

    function getNode(id) {
      return nodes.find(n => n.id === id);
    }

    function applyTransform() {
      viewport.style.transform = `translate(${panX}px, ${panY}px) scale(${scale})`;
      zoomPct.textContent = `${Math.round(scale * 100)}%`;
    }

    function fitView() {
      const rect = canvasWrap.getBoundingClientRect();
      const minX = Math.min(...nodes.map(n => n.x)) - 28;
      const minY = Math.min(...nodes.map(n => n.y)) - 36;
      const maxX = Math.max(...nodes.map(n => n.x + 214)) + 28;
      const maxY = Math.max(...nodes.map(n => n.y + 92)) + 60;
      const w = maxX - minX;
      const h = maxY - minY;
      scale = Math.min(1.05, Math.max(0.32, Math.min(rect.width / w, rect.height / h)));
      panX = (rect.width - w * scale) / 2 - minX * scale;
      panY = (rect.height - h * scale) / 2 - minY * scale;
      applyTransform();
    }

    function bezierPath(a, b) {
      const x1 = a.x + 214;
      const y1 = a.y + 44;
      const x2 = b.x;
      const y2 = b.y + 44;
      const dx = Math.max(60, Math.abs(x2 - x1) * 0.5);
      return `M ${x1} ${y1} C ${x1 + dx} ${y1}, ${x2 - dx} ${y2}, ${x2} ${y2}`;
    }

    function renderEdges() {
      const svgNS = 'http://www.w3.org/2000/svg';
      edgesLayer.innerHTML = '';
      edges.forEach(edge => {
        const a = getNode(edge.from);
        const b = getNode(edge.to);
        const path = document.createElementNS(svgNS, 'path');
        path.setAttribute('id', `path-${edge.id}`);
        path.setAttribute('d', bezierPath(a, b));
        const isSel = edge.from === selectedId || edge.to === selectedId;
        path.setAttribute('class', `edge-path ${isSel ? 'active' : ''}`);
        edgesLayer.appendChild(path);
      });
    }

    function renderNodes() {
      nodesLayer.innerHTML = '';
      nodes.forEach(n => {
        const k = KIND_COLORS[n.kind];
        const el = document.createElement('div');
        el.className = `node ${n.id === selectedId ? 'selected' : ''} ${n.enabled ? '' : 'disabled'}`;
        el.dataset.id = n.id;
        el.style.left = `${n.x}px`;
        el.style.top = `${n.y}px`;
        el.innerHTML = `
          ${n.kind !== 'trigger' ? '<div class="port port-in"></div>' : ''}
          ${n.kind !== 'sink' ? '<div class="port port-out"></div>' : ''}
          <div class="node-head">
            <span class="node-kind" style="color:${k.color};background:${k.bg}">${n.kind}</span>
            <span class="node-status" id="status-${n.id}">${n.enabled ? `${n.latency}ms` : 'paused'}</span>
          </div>
          <div class="node-title">${n.title}</div>
          <div class="node-sub">${n.config}</div>
        `;
        attachDrag(el, n);
        nodesLayer.appendChild(el);
      });
    }

    function attachDrag(el, node) {
      let dragging = false;
      let startX = 0, startY = 0, origX = 0, origY = 0;

      el.addEventListener('pointerdown', (e) => {
        e.stopPropagation();
        selectNode(node.id, false);
        dragging = true;
        startX = e.clientX;
        startY = e.clientY;
        origX = node.x;
        origY = node.y;
        el.setPointerCapture(e.pointerId);
      });

      el.addEventListener('pointermove', (e) => {
        if (!dragging) return;
        const dx = (e.clientX - startX) / scale;
        const dy = (e.clientY - startY) / scale;
        node.x = Math.round(origX + dx);
        node.y = Math.round(origY + dy);
        el.style.left = `${node.x}px`;
        el.style.top = `${node.y}px`;
        renderEdges();
      });

      el.addEventListener('pointerup', (e) => {
        if (!dragging) return;
        dragging = false;
        el.releasePointerCapture(e.pointerId);
        const moved = Math.hypot(e.clientX - startX, e.clientY - startY);
        if (moved < 5 && window.innerWidth <= 860) {
          inspector.classList.add('open');
        }
      });
    }

    function selectNode(id, openDrawer = true) {
      selectedId = id;
      document.querySelectorAll('.node').forEach(el => {
        el.classList.toggle('selected', el.dataset.id === id);
      });
      renderEdges();
      renderInspector();
      if (openDrawer && window.innerWidth <= 860) {
        inspector.classList.add('open');
      }
    }

    function renderInspector() {
      const n = getNode(selectedId);
      if (!n) return;
      const k = KIND_COLORS[n.kind];
      inspectorBody.innerHTML = `
        <div style="display:flex;align-items:center;justify-content:space-between;">
          <span class="node-kind" style="color:${k.color};background:${k.bg};font-size:11px;">${n.kind} · ${n.id}</span>
          <span style="font-family:var(--font-mono);font-size:11px;color:var(--ink-faint);">x:${n.x} y:${n.y}</span>
        </div>

        <div class="field">
          <label for="inpTitle">Node Name</label>
          <input id="inpTitle" type="text" value="${n.title.replace(/"/g, '&quot;')}">
        </div>

        <div class="field">
          <label for="inpConfig">Endpoint / Model / Expression</label>
          <input id="inpConfig" type="text" value="${n.config.replace(/"/g, '&quot;')}">
        </div>

        <div class="field-row">
          <div class="field">
            <label for="inpTimeout">Timeout (ms)</label>
            <input id="inpTimeout" type="number" min="100" step="100" value="${n.timeout}">
          </div>
          <div class="field">
            <label for="inpRetries">Max Retries</label>
            <input id="inpRetries" type="number" min="0" max="5" value="${n.retries}">
          </div>
        </div>

        <label class="toggle-row">
          <span>Node Enabled</span>
          <input id="inpEnabled" type="checkbox" ${n.enabled ? 'checked' : ''}>
        </label>

        <div class="field">
          <label for="inpNotes">Operator Notes</label>
          <textarea id="inpNotes" rows="3">${n.notes}</textarea>
        </div>

        <div class="metrics-box">
          <div class="metric-item"><span>P95 Latency</span><strong>${n.latency} ms</strong></div>
          <div class="metric-item"><span>Success Rate</span><strong>99.94%</strong></div>
        </div>
      `;

      const syncNodeCard = () => {
        const card = nodesLayer.querySelector(`.node[data-id="${n.id}"]`);
        if (!card) return;
        card.querySelector('.node-title').textContent = n.title || 'Untitled Node';
        card.querySelector('.node-sub').textContent = n.config;
        card.classList.toggle('disabled', !n.enabled);
        const st = document.getElementById(`status-${n.id}`);
        if (st) st.textContent = n.enabled ? `${n.latency}ms` : 'paused';
      };

      document.getElementById('inpTitle').addEventListener('input', (e) => { n.title = e.target.value; syncNodeCard(); });
      document.getElementById('inpConfig').addEventListener('input', (e) => { n.config = e.target.value; syncNodeCard(); });
      document.getElementById('inpTimeout').addEventListener('input', (e) => { n.timeout = Number(e.target.value) || 0; });
      document.getElementById('inpRetries').addEventListener('input', (e) => { n.retries = Number(e.target.value) || 0; });
      document.getElementById('inpEnabled').addEventListener('change', (e) => { n.enabled = e.target.checked; syncNodeCard(); });
      document.getElementById('inpNotes').addEventListener('input', (e) => { n.notes = e.target.value; });
    }

    // Canvas panning
    let panning = false, pStartX = 0, pStartY = 0, origPanX = 0, origPanY = 0;
    canvasWrap.addEventListener('pointerdown', (e) => {
      if (e.target.closest('.node') || e.target.closest('.canvas-controls')) return;
      panning = true;
      pStartX = e.clientX;
      pStartY = e.clientY;
      origPanX = panX;
      origPanY = panY;
      canvasWrap.setPointerCapture(e.pointerId);
    });
    canvasWrap.addEventListener('pointermove', (e) => {
      if (!panning) return;
      panX = origPanX + (e.clientX - pStartX);
      panY = origPanY + (e.clientY - pStartY);
      applyTransform();
    });
    canvasWrap.addEventListener('pointerup', () => { panning = false; });

    // Animated Run Pipeline
    async function animateEdge(edgeId, duration = 420) {
      const path = document.getElementById(`path-${edgeId}`);
      if (!path) return;
      path.classList.add('pulse-running');
      const len = path.getTotalLength();
      const dot = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
      dot.setAttribute('r', '5');
      dot.setAttribute('class', 'pulse-dot');
      edgesLayer.appendChild(dot);

      const start = performance.now();
      await new Promise(resolve => {
        function step(now) {
          const t = Math.min(1, (now - start) / duration);
          const pt = path.getPointAtLength(len * t);
          dot.setAttribute('cx', pt.x);
          dot.setAttribute('cy', pt.y);
          if (t < 1) requestAnimationFrame(step);
          else resolve();
        }
        requestAnimationFrame(step);
      });

      dot.remove();
      path.classList.remove('pulse-running');
    }

    async function runPipeline() {
      if (isRunning) return;
      isRunning = true;
      const btnRun = document.getElementById('btnRun');
      btnRun.disabled = true;
      runBanner.textContent = 'Running pipeline trace…';

      document.querySelectorAll('.node').forEach(el => el.classList.remove('running', 'done'));

      const stages = [
        { nodeIds: ['n1'], outEdges: ['e1'] },
        { nodeIds: ['n2'], outEdges: ['e2'] },
        { nodeIds: ['n3'], outEdges: ['e3'] },
        { nodeIds: ['n4'], outEdges: ['e4', 'e5'] },
        { nodeIds: ['n5', 'n6'], outEdges: [] }
      ];

      let totalMs = 0;
      for (const stage of stages) {
        stage.nodeIds.forEach(id => {
          const card = nodesLayer.querySelector(`.node[data-id="${id}"]`);
          const st = document.getElementById(`status-${id}`);
          const n = getNode(id);
          if (card && n.enabled) {
            card.classList.add('running');
            st.textContent = 'running…';
          }
        });
        await new Promise(r => setTimeout(r, 260));
        stage.nodeIds.forEach(id => {
          const card = nodesLayer.querySelector(`.node[data-id="${id}"]`);
          const st = document.getElementById(`status-${id}`);
          const n = getNode(id);
          if (card && n.enabled) {
            card.classList.remove('running');
            card.classList.add('done');
            const jitter = Math.max(5, n.latency + Math.round((Math.random() - 0.5) * 10));
            totalMs += jitter;
            st.textContent = `200 · ${jitter}ms`;
          }
        });
        if (stage.outEdges.length) {
          await Promise.all(stage.outEdges.map(eid => animateEdge(eid, 380)));
        }
      }

      runBanner.textContent = `Trace succeeded · ${totalMs}ms total · 6/6 nodes healthy`;
      btnRun.disabled = false;
      isRunning = false;
    }

    document.getElementById('btnRun').addEventListener('click', runPipeline);
    document.getElementById('btnFit').addEventListener('click', fitView);
    document.getElementById('zoomReset').addEventListener('click', fitView);
    document.getElementById('zoomIn').addEventListener('click', () => { scale = Math.min(1.6, scale + 0.15); applyTransform(); });
    document.getElementById('zoomOut').addEventListener('click', () => { scale = Math.max(0.3, scale - 0.15); applyTransform(); });
    document.getElementById('btnInspectMobile').addEventListener('click', () => inspector.classList.toggle('open'));
    document.getElementById('closeDrawer').addEventListener('click', () => inspector.classList.remove('open'));

    window.addEventListener('resize', fitView);

    renderNodes();
    renderEdges();
    renderInspector();
    requestAnimationFrame(fitView);
  </script>
</body>
</html>