/* ── Theme tokens ──────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-app:          #1a1a2e;
  --bg-toolbar:      #242424;
  --bg-canvas:       #0d1117;
  --bg-surface:      #1e293b;
  --bg-deep:         #0f172a;
  --bg-panel:        #16213e;
  --bg-backdrop:     rgba(0, 0, 0, 0.6);
  --bg-overlay-dim:  rgba(2, 6, 23, 0.58);

  /* Borders */
  --border-default:  #334155;
  --border-strong:   #0f3460;
  --border-toolbar:  #000000;
  --border-subtle:   rgba(51, 65, 85, 0.35);
  --border-table:    rgba(51, 65, 85, 0.75);
  --border-title:    rgba(0, 0, 0, 0.3);

  /* Text */
  --text-primary:    #e0e0e0;
  --text-bright:     #e2e8f0;
  --text-heading:    #ffffff;
  --text-secondary:  #94a3b8;
  --text-muted:      #64748b;
  --text-faint:      #475569;
  --text-disabled:   #607d8b;
  --text-table:      #cbd5e1;
  --text-value:      #e0f2fe;
  --text-value-unit: rgba(224, 242, 254, 0.82);

  /* Accent */
  --accent:          #3a7abf;
  --accent-bg:       #0f3460;
  --accent-hover:    #1a4a8a;
  --accent-pressed:  #0a2040;
  --accent-light:    #90caf9;
  --accent-lighter:  #7dd3fc;
  --accent-lightest: #bae6fd;
  --accent-deep:     #172554;
  --accent-deep-text:#dbeafe;

  /* Danger */
  --danger:          #e94560;
  --danger-hover:    #ff6b81;
  --danger-locked:   #e91e63;
  --error-text:      #ef9a9a;
  --error-bg:        rgba(183, 28, 28, 0.2);

  /* Warning */
  --warning:         #fbbf24;
  --warning-bg:      rgba(251, 191, 36, 0.1);
  --warning-border:  rgba(251, 191, 36, 0.2);

  /* Selection */
  --selection:       #90caf9;
  --selection-glow:  rgba(144, 202, 249, 0.4);
  --selection-edge:  rgba(144, 202, 249, 0.6);

  /* Marker / cursor */
  --marker:          #ffd700;
  --marker-active:   #ffeb3b;
  --marker-border:   #ffffff;
  --marker-shadow:   rgba(0, 0, 0, 0.6);
  --marker-shadow-light: rgba(0, 0, 0, 0.45);

  /* Plot */
  --plot-line:       #ff9800;

  /* Linked state */
  --linked-border:   rgba(244, 114, 182, 0.45);
  --linked-bg:       rgba(30, 41, 59, 0.55);
  --linked-text:     #f9a8d4;

  /* Value display */
  --value-label:     #7dd3fc;
  --value-border:    rgba(125, 211, 252, 0.45);
  --value-grad-top:  rgba(14, 116, 144, 0.2);
  --value-grad-bot:  rgba(8, 47, 73, 0.45);
  --value-grad-a:    rgba(125, 211, 252, 0.08);
  --value-grad-b:    rgba(56, 189, 248, 0.02);
  --value-shadow-in: rgba(255, 255, 255, 0.05);
  --value-shadow:    rgba(2, 132, 199, 0.14);

  /* Node title meta */
  --meta-bg:         rgba(15, 23, 42, 0.28);
  --meta-text:       rgba(255, 255, 255, 0.88);

  /* Mask paint cursor */
  --mask-cursor-border: rgba(255, 255, 255, 0.95);
  --mask-cursor-bg:     rgba(255, 255, 255, 0.08);
  --mask-cursor-ring:   rgba(239, 68, 68, 0.85);
  --mask-cursor-shadow: rgba(15, 23, 42, 0.35);

  /* Shadows */
  --shadow-heavy:    rgba(0, 0, 0, 0.5);

  /* Gallery */
  --gallery-name-border: rgba(51, 65, 85, 0.9);
  --gallery-name-bg:     rgba(15, 23, 42, 0.8);

  /* Benchmark */
  --benchmark-border: rgba(148, 163, 184, 0.28);
  --benchmark-bg:     rgba(15, 23, 42, 0.92);

  /* Markup toolbar */
  --markup-btn-border: rgba(148, 163, 184, 0.35);
  --markup-btn-bg:     rgba(15, 23, 42, 0.88);

  /* Table */
  --table-stripe:    rgba(30, 41, 59, 0.38);

  /* Crop */
  --crop-inset:      rgba(255, 255, 255, 0.22);

  /* Shape default */
  --shape-default:   #ffd54f;

  /* Dynamic-lookup fallbacks */
  --fallback-type:   #999;
  --fallback-cat:    #333;
}

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

html, body, #root {
  width: 100%;
  height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

.app-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Toolbar ───────────────────────────────────────────────────────── */
#toolbar {
  height: 44px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-toolbar);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 100;
  user-select: none;
  flex-shrink: 0;
}

#app-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-heading);
  margin-right: 8px;
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  padding: 5px 12px;
  border: 1px solid var(--accent-bg);
  border-radius: 5px;
  background: var(--accent-bg);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent);
}
.btn:active {
  background: var(--accent-pressed);
}
.btn-primary {
  background: var(--danger);
  border-color: var(--danger);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

/* ── Status bar ────────────────────────────────────────────────────── */
.status-bar {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  max-width: 60%;
  flex-shrink: 1;
}
.status-bar.info  { color: var(--accent-light); }
.status-bar.error { color: var(--error-text); background: var(--error-bg); }

/* ── React Flow container ──────────────────────────────────────────── */
.flow-container {
  flex: 1;
  position: relative;
}

/* ── React Flow dark overrides ─────────────────────────────────────── */
.react-flow {
  background: var(--bg-canvas) !important;
}

/* ── Custom node ───────────────────────────────────────────────────── */
.custom-node {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-primary);
  width: 200px;
  min-width: 160px;
  resize: horizontal;
  overflow: hidden;
}

/* Let React Flow node wrapper fit to the custom-node's size */
.react-flow__node-custom {
  width: auto !important;
  height: auto !important;
}

/* Title bar is the drag handle for moving the node */
.drag-handle {
  cursor: grab;
}
.drag-handle:active {
  cursor: grabbing;
}

/* Selected node — target via React Flow's wrapper class */
.react-flow__node.selected .custom-node {
  border-color: var(--selection);
  box-shadow: 0 0 0 1px var(--selection), 0 0 12px var(--selection-glow);
}

/* Selected edge */
.react-flow__edge.selected .react-flow__edge-path {
  stroke: var(--selection) !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 4px var(--selection-edge));
}

.node-title {
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-heading);
  border-radius: 5px 5px 0 0;
  border-bottom: 1px solid var(--border-title);
}

.node-title-main {
  min-width: 0;
}

.node-title-meta {
  max-width: 48%;
  min-width: 0;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--meta-bg);
  color: var(--meta-text);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-body {
  padding: 4px 0;
  display: flex;
  flex-direction: column;
}

.top-widget-section {
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2px;
}

.node-warning {
  padding: 3px 10px;
  font-size: 10px;
  color: var(--warning);
  background: var(--warning-bg);
  border-top: 1px solid var(--warning-border);
  border-bottom: 1px solid var(--warning-border);
}

.node-value-display {
  padding: 8px 10px 4px;
}

.node-value-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--value-label);
  margin-bottom: 5px;
}

.node-value-box {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--value-border);
  background:
    linear-gradient(180deg, var(--value-grad-top), var(--value-grad-bot)),
    linear-gradient(135deg, var(--value-grad-a), var(--value-grad-b));
  box-shadow:
    inset 0 1px 0 var(--value-shadow-in),
    0 8px 20px var(--value-shadow);
  color: var(--text-value);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-align: center;
  font-variant-numeric: tabular-nums lining-nums;
  overflow-wrap: anywhere;
}

.node-value-box-number {
  display: inline-block;
}

.node-value-box-unit {
  display: inline-block;
  margin-left: 0.35em;
  font-size: 0.58em;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-value-unit);
  vertical-align: baseline;
}

/* ── I/O rows ──────────────────────────────────────────────────────── */
.io-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 12px;
  min-height: 22px;
  position: relative;
}

.io-left, .io-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.io-left {
  flex: 1;
  min-width: 0;
}

.io-label {
  font-size: 10px;
  color: var(--text-secondary);
}

/* ── Handles ───────────────────────────────────────────────────────── */
.typed-handle {
  width: 10px !important;
  height: 10px !important;
  border: 2px solid var(--bg-surface) !important;
  border-radius: 50% !important;
  position: absolute;
  overflow: visible !important;
  cursor: crosshair;
}

.typed-handle::before {
  content: '';
  position: absolute;
  top: -7px;
  bottom: -7px;
  pointer-events: auto;
}

.typed-handle.react-flow__handle-left::before {
  left: -4px;
  right: -16px;
}

.typed-handle.react-flow__handle-right::before {
  left: -16px;
  right: -4px;
}

/* ── Widget rows ───────────────────────────────────────────────────── */
.widget-row {
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.widget-row-socket {
  padding-left: 20px;
}

.widget-row label {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 40px;
  flex-shrink: 0;
}

.io-inline-widget {
  flex: 1;
  min-width: 0;
  margin-left: 8px;
  display: flex;
  align-items: center;
}

.io-inline-widget .widget-row,
.io-inline-widget label {
  display: none;
}

.io-inline-widget input[type="text"],
.io-inline-widget input[type="number"],
.io-inline-widget input[type="color"],
.io-inline-widget select {
  background: var(--bg-deep);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 11px;
  flex: 1;
  min-width: 0;
}

.widget-row input[type="text"],
.widget-row input[type="number"],
.widget-row input[type="color"],
.widget-row select {
  background: var(--bg-deep);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 11px;
  flex: 1;
  min-width: 0;
}

.widget-row input[type="color"] {
  padding: 2px;
  height: 24px;
}

.widget-row input[type="checkbox"] {
  accent-color: var(--accent);
}

.widget-button {
  flex: 1;
  min-width: 0;
  background: var(--accent-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}

.widget-button:hover {
  background: var(--accent-hover);
  border-color: var(--accent);
}

.widget-linked-state {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px dashed var(--linked-border);
  border-radius: 4px;
  background: var(--linked-bg);
  color: var(--linked-text);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.colormap-editor {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.colormap-preview {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--border-default);
  background-color: var(--bg-deep);
}

.colormap-stop-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.colormap-stop-row {
  display: grid;
  grid-template-columns: 34px 34px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.colormap-stop-label,
.colormap-stop-boundary {
  font-size: 10px;
  color: var(--text-secondary);
}

.colormap-stop-color {
  width: 34px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  background: var(--bg-deep);
}

.colormap-stop-position {
  width: 100%;
}

.colormap-stop-action {
  background: var(--accent-deep);
  color: var(--accent-deep-text);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 10px;
  cursor: pointer;
}

.colormap-stop-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.colormap-add-stop {
  margin-top: 2px;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.slider-input {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent-lighter);
}

.slider-value {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 10px;
  color: var(--text-table);
  min-width: 52px;
  text-align: right;
}

.widget-row input:focus,
.widget-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.file-picker-row {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.file-picker-row input {
  flex: 1;
  min-width: 0;
}

/* ── Draggable number ──────────────────────────────────────────────── */
.drag-number {
  flex: 1;
  min-width: 0;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  padding: 2px 6px;
  cursor: ew-resize;
  user-select: none;
  text-align: center;
  font-size: 11px;
  color: var(--text-primary);
  touch-action: none;
}
.drag-number:hover {
  border-color: var(--accent);
}
.drag-number-val {
  pointer-events: none;
}
.drag-number-edit {
  flex: 1;
  min-width: 0;
  background: var(--bg-deep);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 11px;
  color: var(--text-primary);
  text-align: center;
  outline: none;
}

.browse-btn {
  background: var(--accent-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.browse-btn:hover {
  background: var(--accent-hover);
}

/* ── Collapsible section ───────────────────────────────────────────── */
.collapsible {
  border-top: 1px solid var(--border-default);
  margin-top: 4px;
}
.collapsible-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  padding: 3px 10px;
  cursor: pointer;
  text-align: left;
}
.collapsible-toggle:hover {
  color: var(--text-secondary);
}
.collapsible-arrow {
  font-size: 9px;
}

/* ── Node preview ──────────────────────────────────────────────────── */
.node-preview {
  overflow: hidden;
}

.node-preview img {
  width: 100%;
  max-width: 100%;
  display: block;
}

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

.layer-gallery-toolbar {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
}

.layer-gallery-btn {
  height: 26px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-deep);
  color: var(--text-bright);
  font-size: 14px;
  cursor: pointer;
}

.layer-gallery-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.layer-gallery-name {
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--gallery-name-border);
  border-radius: 6px;
  background: var(--gallery-name-bg);
  color: var(--text-table);
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-gallery-count {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Cross-section overlay ────────────────────────────────────────── */
.cs-overlay {
  position: relative;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}
.cs-image {
  width: 100%;
  display: block;
}
.cs-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cs-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--marker);
  border: 1px solid var(--marker-border);
  transform: translate(-50%, -50%);
  cursor: grab;
  box-shadow: 0 0 4px var(--marker-shadow);
  z-index: 1;
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--bg-deep);
}
.cs-marker:active:not(.cs-marker-locked) {
  cursor: grabbing;
  background: var(--marker-active);
  transform: translate(-50%, -50%) scale(1.2);
}
.cs-marker-locked {
  background: var(--danger-locked);
  border-color: var(--danger-locked);
  cursor: default;
  opacity: 0.9;
}

.lineplot-overlay {
  width: 100%;
  aspect-ratio: 32 / 22;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.lineplot-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.lineplot-marker {
  fill: var(--marker);
  stroke: var(--marker-border);
  stroke-width: 2px;
  cursor: grab;
  filter: drop-shadow(0 0 4px var(--marker-shadow-light));
}

.lineplot-marker:active {
  cursor: grabbing;
}

.lineplot-marker-locked {
  fill: var(--danger-locked);
  stroke: var(--danger-locked);
  cursor: default;
}

.crop-overlay {
  position: relative;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}

.crop-image {
  width: 100%;
  display: block;
}

.crop-dim {
  position: absolute;
  background: var(--bg-overlay-dim);
  pointer-events: none;
}

.crop-rect {
  position: absolute;
  border: 2px solid var(--accent-lighter);
  box-shadow: inset 0 0 0 1px var(--crop-inset);
  background: transparent;
  pointer-events: none;
}

.crop-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-lighter);
  border: 2px solid var(--marker-border);
  transform: translate(-50%, -50%);
  cursor: grab;
  box-shadow: 0 0 4px var(--marker-shadow);
  z-index: 1;
}

.crop-marker:active:not(.crop-marker-locked) {
  cursor: grabbing;
  background: var(--accent-lightest);
  transform: translate(-50%, -50%) scale(1.15);
}

.crop-marker-locked {
  background: var(--danger-locked);
  border-color: var(--danger-locked);
  cursor: default;
  opacity: 0.9;
}

.mask-paint-overlay {
  position: relative;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  cursor: crosshair;
}

.mask-paint-overlay-drawing {
  cursor: crosshair;
}

.mask-paint-image {
  width: 100%;
  display: block;
}

.mask-paint-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mask-paint-cursor {
  position: absolute;
  border: 1.5px solid var(--mask-cursor-border);
  border-radius: 50%;
  background: var(--mask-cursor-bg);
  box-shadow:
    0 0 0 1px var(--mask-cursor-ring),
    0 0 10px var(--mask-cursor-shadow);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}

.markup-overlay {
  position: relative;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  cursor: crosshair;
}

.markup-overlay-drawing {
  cursor: crosshair;
}

.markup-image {
  width: 100%;
  display: block;
}

.markup-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.markup-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.markup-tool-btn {
  border: 1px solid var(--markup-btn-border);
  background: var(--markup-btn-bg);
  color: var(--text-bright);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}

.markup-tool-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ── 3D surface view ──────────────────────────────────────────────── */
.surface-view-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  cursor: grab;
  overflow: hidden;
}
.surface-view-container:active {
  cursor: grabbing;
}
.surface-view-container canvas {
  display: block;
}

/* ── Node table ────────────────────────────────────────────────────── */
.node-table-wrap {
  padding: 4px 10px 8px;
}

.node-table-scroll {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-deep);
}

.node-table-grid {
  width: 100%;
  border-collapse: collapse;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 10px;
  color: var(--text-table);
  table-layout: auto;
  font-variant-numeric: tabular-nums lining-nums;
}

.node-table-grid th,
.node-table-grid td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-table);
  white-space: nowrap;
  text-align: left;
  vertical-align: top;
}

.node-table-grid thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.node-table-grid tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.node-table-grid tbody tr:last-child td {
  border-bottom: none;
}

.node-table-col-quantity {
  width: 46%;
}

.node-table-col-value {
  width: 32%;
  text-align: right !important;
}

.node-table-col-unit {
  width: 22%;
  text-align: left;
}

.node-table-num {
  text-align: right !important;
}

.node-benchmark {
  align-self: flex-end;
  margin: 8px 10px 4px;
  padding: 3px 7px;
  border: 1px solid var(--benchmark-border);
  border-radius: 999px;
  background: var(--benchmark-bg);
  color: var(--text-secondary);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 10px;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
}

/* ── Node resize handles ───────────────────────────────────────────── */
.node-resize-line {
  border-color: var(--selection) !important;
}
.node-resize-handle {
  background: var(--selection) !important;
  width: 8px !important;
  height: 8px !important;
}

/* ── Context menu ──────────────────────────────────────────────────── */
.context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  min-width: 180px;
  box-shadow: 0 4px 16px var(--shadow-heavy);
  padding: 4px 0;
}

.ctx-title {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-strong);
}

.ctx-search-row {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-strong);
}
.ctx-search {
  width: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}
.ctx-search:focus {
  border-color: var(--accent);
}
.ctx-search::placeholder {
  color: var(--text-faint);
}

.ctx-list {
  max-height: 50vh;
  overflow-y: auto;
}

/* ── Category leaf items ── */
.ctx-cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
}
.ctx-cat-item:hover,
.ctx-cat-active {
  background: var(--accent-bg);
}
.ctx-cat-label {
  text-transform: capitalize;
}
.ctx-cat-arrow {
  font-size: 8px;
  color: var(--text-muted);
  margin-left: 12px;
  flex-shrink: 0;
}
.ctx-cat-active .ctx-cat-arrow {
  color: var(--text-primary);
}

/* ── Submenu panel (separate fixed-position sibling) ── */
.ctx-submenu {
  position: fixed;
  max-height: 50vh;
  overflow-y: auto;
}

.context-item {
  padding: 5px 20px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
  white-space: nowrap;
}
.context-item:hover {
  background: var(--accent-bg);
}

/* ── File browser dialog ──────────────────────────────────────────── */
.fb-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-backdrop);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fb-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  width: 520px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px var(--shadow-heavy);
}
.fb-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-strong);
}
.fb-path {
  font-size: 12px;
  color: var(--accent-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 10px;
}
.fb-close {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}
.fb-close:hover { color: var(--danger); }
.fb-select-btn {
  background: var(--accent-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.fb-select-btn:hover { background: var(--accent-hover); }
.fb-list {
  overflow-y: auto;
  padding: 6px 0;
  flex: 1;
}
.fb-entry {
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fb-entry:hover { background: var(--accent-bg); }
.fb-dir  { color: var(--accent-light); }
.fb-file { color: var(--text-primary); }
.fb-file-disabled {
  cursor: default;
  opacity: 0.5;
}
.fb-file-disabled:hover {
  background: transparent;
}
.fb-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-disabled);
}

/* ── Scrollbar styling ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-app); }
::-webkit-scrollbar-thumb { background: var(--accent-bg); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── React Flow MiniMap ────────────────────────────────────────────── */
.react-flow__minimap {
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 4px !important;
}
