@import '../tokens/foundation.css';
@import '../tokens/semantic.css';
@import '../tokens/components.css';

/* ──── Design Tokens ──── */
:root {
  /* Canvas */
  --canvas-bg: var(--background);

  /* Node type accents */
  --incast-accent: var(--success);
  --incast-accent-dim: color-mix(in srgb, var(--success) 18%, transparent);
  --incast-accent-glow: color-mix(in srgb, var(--success) 6%, transparent);
  --op-accent: var(--primary);
  --op-accent-dim: color-mix(in srgb, var(--primary) 22%, transparent);
  --op-pill-bg: var(--primary);
  --tensor-accent: var(--accent);
  --tensor-accent-dim: color-mix(in srgb, var(--accent) 18%, transparent);
  --outcast-accent: var(--danger);
  --outcast-accent-dim: color-mix(in srgb, var(--danger) 18%, transparent);
  --outcast-accent-glow: color-mix(in srgb, var(--danger) 6%, transparent);

  /* Node base */
  --node-bg: var(--surface-2);
  --node-bg-hover: var(--surface-3);
  --node-bg-selected: var(--surface-3);
  --node-border: var(--border-subtle);
  --node-border-hover: var(--border-default);
  --node-radius: var(--radius-lg);
  --node-shadow: none;
  --node-shadow-hover: none;

  /* Node text */
  --text-primary: var(--foreground);
  --text-secondary: var(--foreground-secondary);
  --text-label: var(--foreground-muted);
  --text-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Tag chips */
  --tag-bg: var(--comp-tag-bg);
  --tag-border: var(--comp-tag-border);

  /* Toolbar */
  --toolbar-bg: var(--comp-toolbar-bg);
  --toolbar-border: var(--comp-toolbar-border);
  --toolbar-height: var(--comp-toolbar-height);

  /* Edges */
  --edge-default: var(--border-default);
  --edge-width: 1.5px;

  /* Group card */
  --group-count-color: var(--accent);
  --group-tab-border: var(--border-default);

  /* Alias tokens (consumed by pypto and other modules) */
  --severity-critical: var(--danger);
  --severity-warning: var(--warning);
  --severity-info: var(--primary);
  --accent-blue: var(--primary);
  --accent-yellow: var(--warning);
  --accent-green: var(--success);

  /* Pass-IR elevated node surface (intentionally lighter than canvas) */
  --node-bg-elevated: #3b3b3b;
  --node-bg-elevated-hover: #3c3c3c;
  --node-bg-elevated-selected: #3e3e3e;
}

/* ──── Reset & Base ──── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-primary);
  background: var(--canvas-bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* ──── Toolbar ──── */
.toolbar {
  height: var(--toolbar-height);
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  z-index: 100;
}

.toolbar-l, .toolbar-r {
  display: flex;
  align-items: center;
  gap: 6px;
}

.home-link {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--tag-border);
  background: var(--tag-bg);
  color: var(--text-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.home-link:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.toolbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 4px;
  padding-right: 12px;
  border-right: 1px solid var(--toolbar-border);
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--toolbar-border);
  margin: 0 2px;
}

.graph-title {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--text-mono);
}

.graph-stats {
  display: flex;
  gap: 8px;
}

.lock-exit {
  padding: 5px 12px;
  color: #111111;
  border-color: rgba(255, 255, 255, 0.88);
  background: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.lock-exit:hover {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(255, 255, 255, 0.94);
}

.lock-exit-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-chip {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--text-secondary);
}

/* ──── Buttons ──── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.18); }
.btn:active { background: rgba(255,255,255,0.14); }

.btn-icon {
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 400;
  min-width: 28px;
  justify-content: center;
}

.btn-primary {
  background: var(--op-accent);
  border-color: transparent;
  font-weight: 500;
}
.btn-primary:hover { background: #4a8af8; }

input[type="file"] { display: none; }


/* ──── Viewport & Canvas ──── */
.viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  background-color: var(--canvas-bg);
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: grab;
}
.viewport.panning { cursor: grabbing; }

.graph-root {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.edges-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
}

/* ──── Empty State ──── */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}
.empty-state.hidden { display: none; }

.empty-card {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 48px 36px;
  border-radius: 20px;
  background: rgba(28, 28, 30, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 0.5px rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  text-align: center;
  min-width: 340px;
}

.empty-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
}

.empty-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
  margin-bottom: 4px;
}

.empty-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.btn-md-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 24px;
  border-radius: 24px;
  background: var(--op-accent);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 12px rgba(53,119,246,0.4);
  white-space: nowrap;
}
.btn-md-primary:hover { background: #4a8af8; box-shadow: 0 4px 16px rgba(53,119,246,0.5); }
.btn-md-primary:active { background: #2b5fd4; }

.btn-md-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.12s;
}
.btn-md-text:hover { color: var(--text-primary); }

.recent-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.recent-row.hidden { display: none; }

.recent-label {
  font-size: 11px;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--text-mono);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-chip:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.18); color: var(--text-primary); }
.recent-chip svg { flex-shrink: 0; opacity: 0.6; }

.empty-hint {
  font-size: 11px;
  color: var(--text-label);
  margin-top: 4px;
}

.sample-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ──── Node Cards ──── */
.node-card {
  position: absolute;
  width: 150px;
  border-radius: var(--node-radius);
  background: var(--node-bg);
  box-shadow: var(--node-shadow);
  cursor: pointer;
  transition: box-shadow 0.15s, background 0.15s, transform 0.1s;
  user-select: none;
  overflow: hidden;
}

.node-card:not(.node-card-group) {
  padding-top: 4px;
  padding-bottom: 4px;
}
.node-card:hover {
  background: var(--node-bg-hover);
  box-shadow: var(--node-shadow-hover);
  z-index: 10;
}
.node-card.selected {
  background: var(--node-bg-selected);
  z-index: 20;
}

/* Pass IR page only: use a distinct card language from source-logic view */
.pass-ir-page .node-card {
  border: 1px solid var(--border-default);
  background: var(--node-bg-elevated);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-xl);
}

.pass-ir-page .node-card:hover {
  border-color: var(--border-strong);
  background: var(--node-bg-elevated-hover);
  box-shadow: var(--shadow-lg);
}

.pass-ir-page .node-card.selected {
  background: var(--node-bg-elevated-selected);
}

.huge-graph-mode .node-card {
  transition: none !important;
  box-shadow: none !important;
  will-change: auto;
}

.huge-graph-mode .node-card:hover,
.huge-graph-mode .node-card.selected {
  box-shadow: none !important;
}

.huge-graph-mode .op-pill,
.huge-graph-mode .tensor-rect,
.huge-graph-mode .group-stack-item {
  box-shadow: none !important;
}

.huge-graph-mode .node-wave {
  display: none !important;
}

.pass-ir-page .op-pill {
  border-radius: 40px;
  box-shadow:
    inset 0 0 8px rgba(255,255,255,0.25),
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 6px 20px color-mix(in srgb, var(--node-accent, #3577F6) 30%, transparent),
    0 2px 8px rgba(0,0,0,0.45);
}

.pass-ir-page .tensor-rect {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  height: auto;
  padding: 13px 16px;
  box-shadow:
    inset 0 0 8px rgba(255,255,255,0.25),
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 6px 20px color-mix(in srgb, var(--node-accent, #F97316) 50%, transparent),
    0 2px 8px rgba(0,0,0,0.45);
}

.pass-ir-page .op-pill-name {
  font-size: 14px;
  font-weight: 700;
}

.pass-ir-page .tensor-rect-name {
  font-size: 14px;
  font-weight: 700;
}

/* compact mode: strip colored glow, keep inset highlight */
.pass-ir-page[data-compact] .op-pill,
.pass-ir-page [data-compact] .op-pill,
.pass-ir-page[data-compact] .tensor-rect,
.pass-ir-page [data-compact] .tensor-rect {
  box-shadow:
    inset 0 0 8px rgba(255,255,255,0.25),
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 2px 6px rgba(0,0,0,0.35);
}

/* huge-graph mode: remove all shadows for perf */
.huge-graph-mode .pass-ir-page .op-pill,
.huge-graph-mode .pass-ir-page .tensor-rect {
  box-shadow: none !important;
}

/* Group card – keeps base node width, increases height via layout */
.node-card-group {
  position: absolute;
  overflow: hidden;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

.node-card-group:hover {
  filter: brightness(1.02);
}

.node-card-group.selected {
  filter: brightness(1.05);
}

.node-card-group .group-shell {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.node-card-group .group-shell-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.node-card-group .group-shell-fill {
  fill: var(--node-bg-elevated);
}

.node-card-group .group-content {
  position: relative;
  z-index: 1;
  height: 100%;
  padding-top: 12px;
}

.node-card-group .group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 10px 4px;
}

.node-card-group .group-title {
  min-width: 0;
  margin: 0;
}

.node-card-group .group-count {
  font-size: 16px;
  font-weight: 700;
  color: var(--group-count-color);
  font-family: var(--text-mono);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.node-card-group .group-rows {
  padding-top: 4px;
  padding-bottom: 4px;
}

.node-card-group .group-stack {
  margin: 2px 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.node-card-group .group-stack-item {
  height: 10px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--group-item-color, #3577F6) 86%, #fff 14%) 0%,
    color-mix(in srgb, var(--group-item-color, #3577F6) 82%, #000 18%) 100%
  );
  border: 1px solid color-mix(in srgb, var(--group-item-color, #3577F6) 60%, rgba(255,255,255,0.22) 40%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset;
}

.node-card-group .group-stack-item.is-member-clickable {
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}

.node-card-group .group-stack-item.is-member-clickable:hover {
  filter: brightness(1.12);
  transform: translateY(-0.5px);
}

.node-card-group .group-stack-item.is-op {
  border-radius: 999px;
}

.node-card-group .group-stack-item.is-tensor {
  border-radius: 3px;
}

.node-card-group .group-stack-item.is-ellipsis {
  border-radius: 4px;
  background: rgba(61, 83, 147, 0.62);
  border: 1px solid rgba(125, 150, 221, 0.32);
  color: rgba(255,255,255,0.76);
  font-size: 10px;
  font-family: var(--text-mono);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.12em;
}

/* Node header */
.node-head {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.node-card-op .node-head,
.node-card-tensor .node-head {
  border-bottom: none;
  padding-bottom: 2px;
}

.node-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--tag-border);
  background: var(--tag-bg);
  color: var(--text-secondary);
}

.node-tag-type {
  border-color: transparent;
}

.node-tag-incast  { background: var(--incast-accent-dim);  color: var(--incast-accent);  border-color: rgba(135,200,15,0.25); }
.node-tag-outcast { background: var(--outcast-accent-dim); color: var(--outcast-accent); border-color: rgba(245,158,11,0.25); }
.node-tag-op      { background: var(--op-accent-dim);      color: var(--op-accent);      border-color: rgba(53,119,246,0.3); }
.node-tag-tensor  { background: var(--tensor-accent-dim);  color: var(--tensor-accent);  border-color: rgba(168,85,247,0.25); }
.node-tag-id      { background: rgba(255,255,255,0.04);    color: var(--text-label);      border-color: rgba(255,255,255,0.08); }

.node-sublabel {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--text-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Op pill – blue action bar */
.op-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 8px;
  padding: 9px 10px; /* 增加2px上下padding，总共增加4px高度 */
  border-radius: 40px;
  background: linear-gradient(180deg, var(--node-accent, #3577F6) 0%, color-mix(in srgb, var(--node-accent, #2459CC) 75%, #000) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.1) inset, 0 2px 5px rgba(0,0,0,0.18);
  min-height: 44px; /* 确保最小高度，文字垂直居中 */
  justify-content: center; /* 水平居中 */
}
.op-pill-icon {
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.op-pill-name {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  font-family: 'PingFang SC', -apple-system, sans-serif;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.op-pill-latency {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  font-family: var(--text-mono);
  flex-shrink: 0;
}

/* Tensor rect – rounded rectangle (same visual style as op-pill) */
.tensor-rect {
  margin: 6px 8px;
  padding: 0 12px;
  height: 78px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--node-accent, #A855F7) 0%, color-mix(in srgb, var(--node-accent, #7C3AED) 75%, #000) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 3px 8px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tensor-rect-name {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  font-family: 'PingFang SC', -apple-system, sans-serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}
.tensor-rect-shape {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  font-family: var(--text-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Incast/Outcast – cast card header */
.cast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}
.cast-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  font-family: 'PingFang SC', -apple-system, sans-serif;
  letter-spacing: -0.01em;
}
.cast-rows {
  padding: 0 14px 8px;
}

/* Wave SVG pinned to bottom */
.node-wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30px;
  pointer-events: none;
  display: block;
}

/* Selected outlines */
.node-card-incast.selected  { box-shadow: var(--node-shadow-hover), 0 0 0 1.5px var(--node-accent, var(--incast-accent)); }
.node-card-outcast.selected { box-shadow: var(--node-shadow-hover), 0 0 0 1.5px var(--node-accent, var(--outcast-accent)); }
.node-card-op.selected      { box-shadow: var(--node-shadow-hover), 0 0 0 1.5px var(--node-accent, var(--op-accent)); }
.node-card-tensor.selected  { box-shadow: var(--node-shadow-hover), 0 0 0 1.5px var(--node-accent, var(--tensor-accent)); }
.node-card-group.selected   { box-shadow: var(--node-shadow-hover), 0 0 0 1.5px var(--node-accent, var(--op-accent)); }

/* Data rows */
.node-rows {
  padding: 5px 10px 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.node-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 16px;
}
.row-key {
  font-size: 12px;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 52px;
  flex-shrink: 0;
}
.row-val {
  font-size: 12px;
  color: var(--text-primary);
  font-family: var(--text-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.row-val-dim { color: var(--text-secondary); }

/* Op io row */
.op-io-row {
  display: flex;
  align-items: center;
  padding: 5px 10px 7px;
  gap: 4px;
  font-size: 10.5px;
  font-family: var(--text-mono);
}
.io-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--text-secondary);
  font-size: 12px;
}
.io-arrow {
  color: var(--text-label);
  font-size: 10px;
}

/* ──── Detail Panel ──── */
.detail-panel {
  position: fixed;
  right: 0;
  top: var(--toolbar-height);
  bottom: 0;
  width: 260px;
  background: rgba(22, 22, 22, 0.96);
  border-left: 1px solid var(--toolbar-border);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 50;
}
.detail-panel.open {
  transform: translateX(0);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--toolbar-border);
  flex-shrink: 0;
}
.detail-type-badge {
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.detail-name {
  flex: 1;
  font-size: 11px;
  font-family: var(--text-mono);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-close {
  padding: 3px 6px;
  color: var(--text-secondary);
  border-color: transparent;
  background: transparent;
}
.detail-close:hover { color: var(--text-primary); background: var(--tag-bg); }

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.detail-body::-webkit-scrollbar { width: 4px; }
.detail-body::-webkit-scrollbar-track { background: transparent; }
.detail-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-section-title {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-label);
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.detail-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.detail-row-key {
  font-size: 10.5px;
  color: var(--text-secondary);
  min-width: 70px;
  flex-shrink: 0;
}
.detail-row-val {
  font-size: 11px;
  font-family: var(--text-mono);
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
}
.detail-connections {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.detail-conn-chip {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--text-mono);
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.12s;
}
.detail-conn-chip:hover { border-color: rgba(255,255,255,0.25); color: var(--text-primary); }

/* ──── Minimap ──── */
.minimap {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 360px;
  border-radius: 8px;
  background: rgba(18,18,18,0.88);
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
  backdrop-filter: blur(8px);
  display: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.minimap.visible { display: block; }

.mm-toggle-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
}

.minimap.is-collapsed {
  width: 44px;
  height: 44px;
  padding: 0;
}

.minimap.is-collapsed #minimapCanvas,
.minimap.is-collapsed .minimap-viewport,
.minimap.is-collapsed .minimap-controls {
  display: none;
}

.minimap.is-collapsed .mm-toggle-btn {
  top: 12px;
  right: 12px;
}

#minimapCanvas { display: block; width: 360px; height: 210px; }

.minimap-viewport {
  position: absolute;
  border: 1.5px solid #555;
  border-radius: 2px;
  pointer-events: none;
}

.minimap-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.2);
}

.mm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.mm-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.mm-btn:active { background: rgba(255,255,255,0.14); }

.mm-sep {
  width: 1px;
  height: 14px;
  background: rgba(255,255,255,0.1);
  margin: 0 4px;
  flex-shrink: 0;
}

.mm-fit { margin-left: auto; }

.zoom-label {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
  font-family: var(--text-mono);
}

/* ──── Edge styles (SVG) ──── */
.edge { fill: none; }
.edge-default,
.edge-incast,
.edge-op,
.edge-outcast   { stroke: rgba(255,255,255,0.12); stroke-width: 1.5px; }

.huge-graph-mode .edge {
  stroke-width: 1px;
}

.edge-highlight {
  stroke-opacity: 1 !important;
  stroke-width: 2.5px !important;
}

/* ──── Dual-canvas layout ──── */
.vt-canvas-area {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
}
.vt-canvas-area .vt-viewport {
  flex: 1;
  min-width: 0;
}
.vt-tb-panel {
  border-left: 1px solid var(--toolbar-border);
  display: none;
}
.vt-tb-panel.visible {
  display: flex;
  flex-direction: column;
}
.vt-panel-label {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-label);
  font-family: var(--text-mono);
  z-index: 10;
  pointer-events: none;
  background: rgba(14,14,18,0.82);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ──── Graph Picker Dropdown ──── */
.graph-picker {
  position: relative;
}

.graph-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: rgba(22, 22, 22, 0.97);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 0.5px rgba(255,255,255,0.05);
  backdrop-filter: blur(16px);
  padding: 4px;
  z-index: 200;
}
.graph-menu.open { display: block; }

.graph-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--text-mono);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  white-space: nowrap;
}
.graph-menu-item:hover { background: rgba(255,255,255,0.08); }
.graph-menu-item:active { background: rgba(255,255,255,0.13); }
.graph-menu-item svg { flex-shrink: 0; opacity: 0.55; }

.graph-menu-sep {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 3px 4px;
}

/* ──── Drag highlight ──── */
.viewport.drag-over .empty-state {
  background: rgba(53,119,246,0.04);
}

/* ──── Color panel (floating canvas overlay) ──── */
.color-panel {
  position: absolute;
  top: 60px;
  right: 12px;
  width: 292px;
  border-radius: 16px;
  background: rgba(18, 18, 18, 0.90);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.04);
  display: none;
  z-index: 10;
  overflow: hidden;
}
.color-panel.visible { display: block; }

.cp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
}

.cp-header-main {
  padding-top: 12px;
}

.cp-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  user-select: none;
}

.cp-section {
  padding: 0 10px 10px;
}

.cp-section-label {
  padding: 0 4px 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-label);
  user-select: none;
}

.cp-buttons {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 6px;
}
.cp-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cp-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.cp-btn.active {
  background: rgba(53,119,246,0.14);
  border-color: rgba(53,119,246,0.30);
  color: var(--text-primary);
}
.cp-btn:disabled,
.cp-btn.disabled {
  opacity: 0.30;
  cursor: not-allowed;
  pointer-events: none;
}
.cp-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.cp-btn:hover .cp-btn-icon {
  background: rgba(255,255,255,0.09);
  color: var(--text-primary);
}
.cp-btn.active .cp-btn-icon {
  background: rgba(53,119,246,0.22);
  color: #6ea8fe;
}
.cp-btn-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.cp-btn-label {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: inherit;
}
.cp-btn-sub {
  font-size: 12px;
  color: var(--text-label);
  line-height: 1.35;
}
.cp-btn.active .cp-btn-sub {
  color: rgba(110,168,254,0.70);
}

.panel-toggle-btn {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 5px;
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.panel-toggle-btn:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.24);
  color: var(--text-primary);
}

.panel-toggle-icon {
  font-size: 13px;
  font-family: var(--text-mono);
  transform: translateY(-0.5px);
}

.panel-toggle-expand {
  display: none;
}

.color-panel.is-collapsed {
  width: 44px;
  min-width: 44px;
  padding: 8px 6px;
}

.color-panel.is-collapsed .cp-header {
  justify-content: center;
  padding: 0;
}

.color-panel.is-collapsed .cp-title,
.color-panel.is-collapsed .cp-section,
.color-panel.is-collapsed .cp-buttons,
.color-panel.is-collapsed .cp-divider,
.color-panel.is-collapsed .legend {
  display: none;
}

.color-panel.is-collapsed .panel-toggle-collapse,
.minimap.is-collapsed .panel-toggle-collapse {
  display: none;
}

.color-panel.is-collapsed .panel-toggle-expand,
.minimap.is-collapsed .panel-toggle-expand {
  display: inline;
}

.cp-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 0;
}

/* ──── Legend (inside color panel) ──── */
.legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 12px 10px;
  max-height: 200px;
  overflow-y: auto;
}
.legend::-webkit-scrollbar { width: 3px; }
.legend::-webkit-scrollbar-track { background: transparent; }
.legend::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 2px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 0;
}
.legend-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.legend-item-count {
  opacity: 0.38;
  font-size: 10px;
  flex-shrink: 0;
}
.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-gradient {
  width: 100%;
  max-width: 100px;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #5ba4f5, #4ecb71, #f5a623, #e8453c);
  flex-shrink: 0;
}

/* ──── Hover color-hint badge ──── */
.node-card[data-color-hint]:not([data-color-hint=""])::after {
  content: attr(data-color-hint);
  position: absolute;
  top: 7px;
  right: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.72);
  color: rgba(255,255,255,0.82);
  font-size: 10px;
  font-family: var(--text-mono);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  border: 1px solid rgba(255,255,255,0.1);
}
.node-card[data-color-hint]:not([data-color-hint=""]):hover::after {
  opacity: 1;
}

/* ── Pass Nav Bar ─────────────────────────────────────────────── */

.nav-bar {
  position: fixed;
  top: calc(var(--toolbar-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  height: 40px;
  padding: 0;
  background: transparent;
  display: flex;
  align-items: center;
  pointer-events: none;
  user-select: none;
  z-index: 50;
}
.nav-bar.hidden { display: none; }

.nav-shell {
  pointer-events: auto;
  width: 100%;
  height: 40px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background: #050505;
  display: flex;
  align-items: center;
  overflow: visible;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  flex-shrink: 0;
  height: 100%;
}
.nav-left { border-right: 1px solid rgba(255, 255, 255, 0.1); }
.nav-right { border-left: 1px solid rgba(255, 255, 255, 0.1); }

/* Pill button */
.nav-pill-wrap { position: relative; }

.nav-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  background: #000;
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.nav-pill:hover {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.nav-pill svg {
  opacity: 0.8;
  flex-shrink: 0;
}

.nav-pill-snap {
  border-color: rgba(255, 255, 255, 0.18);
}

.nav-pill-wrap.snap-main .nav-pill-snap {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.nav-pill-wrap.snap-root .nav-pill-snap {
  border-color: rgba(216, 185, 0, 0.66);
  box-shadow:
    0 0 0 1px rgba(216, 185, 0, 0.28),
    0 4px 10px rgba(216, 185, 0, 0.2);
}

.nav-pill-wrap.snap-leaf .nav-pill-snap {
  border-color: rgba(67, 213, 207, 0.72);
  box-shadow:
    0 0 0 1px rgba(67, 213, 207, 0.32),
    0 4px 10px rgba(67, 213, 207, 0.2);
}

.nav-source-tag {
  display: none;
  max-width: 190px;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-family: var(--text-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-source-tag.visible {
  display: inline-flex;
}

/* Dropdown menu */
.nav-pill-menu {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 200;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 5px;
  min-width: 170px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}
.nav-pill-wrap.open .nav-pill-menu { display: block; }

.nav-pill-item {
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.nav-pill-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}
.nav-pill-item.active {
  color: #6b92ff;
  background: rgba(107, 146, 255, 0.16);
}

/* Timeline */
.nav-timeline-wrap {
  flex: none;
  width: auto;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  display: flex;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.nav-timeline-wrap::-webkit-scrollbar { height: 3px; }
.nav-timeline-wrap::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 2px; }

.nav-timeline {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  white-space: nowrap;
}

.nav-stage-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-stage-chip {
  height: 20px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: #f7f7f7;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-family: 'PingFang SC', -apple-system, sans-serif;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.nav-stage-chip:hover {
  transform: translateY(-1px);
  filter: brightness(1.07);
}

.nav-stage-chip.stage-tensor {
  min-width: 60px;
  background: #4E76E8;
  border-color: rgba(114, 155, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(114, 155, 255, 0.35), 0 4px 10px rgba(114, 155, 255, 0.26);
}

.nav-stage-chip.stage-tile {
  min-width: 42px;
  background: #5CB41C;
  border-color: rgba(106, 219, 2, 0.62);
  box-shadow: 0 0 0 1px rgba(106, 219, 2, 0.32), 0 4px 10px rgba(106, 219, 2, 0.22);
}

.nav-stage-chip.stage-split {
  min-width: 50px;
  background: #5CB41C;
  border-color: rgba(106, 219, 2, 0.62);
  box-shadow: 0 0 0 1px rgba(106, 219, 2, 0.32), 0 4px 10px rgba(106, 219, 2, 0.22);
}

.nav-stage-chip.stage-block {
  min-width: 53px;
  background: #B89500;
  border-color: rgba(216, 185, 0, 0.68);
  box-shadow: 0 0 0 1px rgba(216, 185, 0, 0.34), 0 4px 10px rgba(216, 185, 0, 0.24);
}

.nav-stage-chip.stage-execute {
  min-width: 60px;
  background: #2BADA8;
  border-color: rgba(67, 213, 207, 0.68);
  box-shadow: 0 0 0 1px rgba(67, 213, 207, 0.3), 0 4px 10px rgba(67, 213, 207, 0.24);
}

.nav-stage-chip.stage-unknown {
  background: #606060;
  border-color: rgba(160, 160, 160, 0.6);
}

.nav-dot-tooltip {
  position: fixed;
  display: none;
  transform: translate(-50%, calc(-100% - 6px));
  padding: 2px 6px;
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  color: rgba(255,255,255,0.9);
  font-size: 10px;
  font-family: var(--text-mono);
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}

.nav-stage-dots {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

/* Pass dot */
.nav-pass-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dot-color, #7f7f7f);
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  opacity: 0.88;
}
.nav-pass-dot:hover {
  opacity: 1;
  transform: scale(1.34);
}
.nav-pass-dot.active {
  opacity: 1;
  transform: scale(1.66);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.22),
    0 0 8px var(--dot-color, #fff);
}

@media (max-width: 1100px) {
  .nav-source-tag {
    display: none;
  }
}

@media (max-width: 820px) {
  .nav-bar {
    height: 40px;
  }

  .nav-shell {
    height: 40px;
  }

  .nav-left, .nav-right {
    gap: 5px;
    padding: 0 7px;
  }

  .nav-pill {
    height: 26px;
    padding: 0 10px;
    font-size: 13px;
  }

  .nav-stage-chip {
    height: 18px;
    padding: 0 10px;
    font-size: 9px;
  }

  .nav-timeline {
    gap: 7px;
    padding: 0 8px;
  }

  .nav-stage-dots {
    gap: 8px;
  }
}

/* ──── Control Flow Panel ──── */
.cf-panel {
  position: fixed;
  top: var(--toolbar-height);
  left: 0;
  width: 460px;
  height: calc(100vh - var(--toolbar-height));
  background: rgba(16, 16, 16, 0.97);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  flex-direction: column;
  z-index: 60;
  backdrop-filter: blur(8px);
  display: none;
}

@keyframes cf-slide-in {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

.cf-panel.cf-visible {
  display: flex;
  animation: cf-slide-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.cf-panel-title {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cf-toggle-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.cf-toggle-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.06);
}


.cf-panel-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cf-columns {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  height: 100%;
  position: relative;
  overflow-y: auto;
  padding: 12px 0;
}

.cf-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex-shrink: 0;
  padding: 0 8px;
}

.cf-col-source {
  width: 190px;
}

.cf-col-compiled {
  width: 190px;
}

.cf-col-label {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.28);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 6px;
  margin-bottom: 6px;
}

.cf-mapping-svg {
  position: absolute;
  top: 36px;
  left: 0;
  width: 100%;
  height: calc(100% - 36px);
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}

.cf-node {
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(30, 30, 30, 0.8);
  padding: 6px 8px;
  transition: border-color 0.15s, background 0.15s;
}

.cf-node-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cf-node-label {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--text-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cf-node-annotation {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  font-family: var(--text-mono);
  line-height: 1.4;
}

.cf-node-entry {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(40, 40, 40, 0.9);
}

.cf-node-entry > .cf-node-main > .cf-node-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cf-node-loop,
.cf-node-loop_unroll {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(28, 28, 36, 0.85);
}

.cf-node-loop > .cf-node-main > .cf-node-label,
.cf-node-loop_unroll > .cf-node-main > .cf-node-label {
  color: rgba(180, 160, 255, 0.8);
}

.cf-node-unroll {
  background: rgba(26, 26, 26, 0.7);
  border-color: rgba(255, 255, 255, 0.06);
}

.cf-node-path {
  background: rgba(24, 24, 30, 0.8);
  border-color: rgba(255, 255, 255, 0.07);
}

.cf-node-path > .cf-node-main > .cf-node-label {
  color: rgba(120, 160, 255, 0.8);
}

.cf-clickable {
  cursor: pointer;
}

.cf-node-path.cf-clickable:hover,
.cf-node-unroll.cf-clickable:hover {
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.08);
}

.cf-node-path.cf-active,
.cf-node-unroll.cf-active,
.cf-node-loop.cf-active {
  border-color: rgba(124, 58, 237, 0.7);
  background: rgba(124, 58, 237, 0.12);
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.25);
}

.cf-node-path.cf-active > .cf-node-main > .cf-node-label,
.cf-node-unroll.cf-active > .cf-node-main > .cf-node-label {
  color: #a78bfa;
}

.cf-children {
  margin-top: 6px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cf-reopen-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.cf-reopen-btn:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.2);
}

/* ── Locked Flow Panel ──────────────────────────────────────────── */
.flow-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 280px;
  background: rgba(16, 16, 16, 0.97);
  border-top: 1px solid var(--toolbar-border);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  z-index: 45;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.flow-panel.open {
  transform: translateY(0);
}
.flow-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--toolbar-border);
}
.flow-lock-icon {
  opacity: 0.4;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.flow-title {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.4;
  flex-shrink: 0;
}
.flow-stats {
  flex: 1;
  font-size: 11px;
  font-family: var(--text-mono);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flow-unlock {
  color: var(--text-secondary);
  border-color: transparent;
  background: transparent;
  flex-shrink: 0;
}
.flow-unlock:hover { color: var(--text-primary); background: var(--tag-bg); }

.flow-viewport {
  flex: 1;
  overflow: auto;
  position: relative;
}
.flow-graph-root {
  position: relative;
  display: block;
}

/* Detail panel — Lock button */
.detail-lock {
  padding: 3px 6px;
  color: var(--text-secondary);
  border-color: transparent;
  background: transparent;
  flex-shrink: 0;
  transition: color 0.15s, opacity 0.15s, background 0.15s;
}
.detail-lock:hover { color: var(--text-primary); background: var(--tag-bg); }
.detail-lock.locked { color: #7c3aed; }
.detail-lock:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  background: transparent;
}
