/* ── 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:   #ff0000;

  /* 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;
}

/* ── Floating menu ─────────────────────────────────────────────────── */
.floating-menu {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  user-select: none;
}

.floating-menu-toggle {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  border: 1px solid var(--border-toolbar);
  background: var(--bg-toolbar);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.floating-menu-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(85, 126, 255, 0.3);
}

.floating-menu-logo {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.floating-menu-dropdown {
  position: absolute;
  top: 48px;
  left: 0;
  background: var(--bg-toolbar);
  border: 1px solid var(--border-toolbar);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: menu-open 0.15s ease-out;
  transform-origin: top left;
}

@keyframes menu-open {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.floating-menu-dropdown.closing {
  animation: menu-close 0.15s ease-in forwards;
}

@keyframes menu-close {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.9) translateY(-4px);
  }
}

.floating-menu-dropdown .btn {
  width: 100%;
  text-align: left;
  box-sizing: border-box;
}

.floating-menu-divider {
  border: none;
  border-top: 1px solid var(--border-toolbar);
  margin: 3px 0;
}

.floating-menu-update {
  text-decoration: none;
  display: block;
  text-align: left;
}

/* ── 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 toast ─────────────────────────────────────────────────── */
.status-toast {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 11px;
  z-index: 200;
  pointer-events: none;
  background: var(--bg-toolbar);
  border: 1px solid var(--border-toolbar);
  max-width: 60%;
  text-align: center;
  animation: toast-in 0.2s ease-out;
}
.status-toast.closing {
  animation: toast-out 0.3s ease-in forwards;
}
.status-toast.info  { color: var(--accent-light); }
.status-toast.error { color: var(--error-text); background: var(--error-bg); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(8px); }
}

/* ── React Flow container ──────────────────────────────────────────── */
.flow-container {
  flex: 1;
  position: relative;
}
.flow-container.canvas-right-zooming,
.flow-container.canvas-right-zooming .react-flow__pane,
.flow-container.canvas-right-zooming .react-flow__background {
  cursor: ns-resize !important;
}

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

/* ── Custom node ───────────────────────────────────────────────────── */
.custom-node {
  position: relative;
  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;
}

.group-node {
  width: 100%;
  height: 100%;
  min-width: 220px;
  resize: none;
  border-style: dashed;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.82), rgba(15, 23, 42, 0.72));
  box-shadow:
    inset 0 0 0 1px rgba(148, 163, 184, 0.08),
    inset 0 1px 18px rgba(15, 23, 42, 0.28);
}

.group-node-title {
  background: #334155;
}

.group-node-title .node-title-main {
  flex: 1;
}

.group-title-slot {
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.group-title-button {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-heading);
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-title-input {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(40ch, 100%);
  width: auto;
  height: 22px;
  padding: 2px 6px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-heading);
  font: inherit;
}

.group-node-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.group-toggle {
  border: 0;
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-heading);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.group-toggle-collapse {
  min-width: 24px;
  padding: 2px 6px;
}

.group-node-summary {
  padding: 6px 10px;
  color: var(--text-secondary);
  font-size: 10px;
  border-top: 1px solid var(--border-subtle);
}

.group-node .node-body {
  flex: 1;
  min-height: 0;
}

.group-node-expanded .node-body {
  padding: 12px;
}

.group-node-workspace {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 120px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.16), rgba(15, 23, 42, 0.34));
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.12),
    inset 0 12px 28px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

.group-node-workspace-label {
  position: absolute;
  top: 10px;
  left: 12px;
  color: rgba(148, 163, 184, 0.58);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.group-node-expanded .group-node-summary {
  position: absolute;
  right: 10px;
  bottom: 8px;
  border-top: 0;
  padding: 0;
  background: transparent;
}

/* Let React Flow node wrapper fit to the custom-node's size */
.react-flow__node-custom:not(.group-shell) {
  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;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-title-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  flex-shrink: 1;
}

.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-help-btn {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.75);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.node-help-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.5);
}

/* ── Node help panel ─────────────────────────────────────── */

.node-help-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px 0;
  background: #0a0f1a;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}

.node-help-fold-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 9px;
  padding: 0 4px;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
  transition: color 0.12s;
}
.node-help-fold-btn:hover { color: #f1f5f9; }

.node-help-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 5px 5px 0 0;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-bottom: none;
  cursor: pointer;
  font-size: 11px;
  color: #64748b;
  transition: color 0.12s, background 0.12s;
  user-select: none;
  max-width: 160px;
}

.node-help-tab:hover { color: #94a3b8; background: #162032; }

.node-help-tab.active {
  color: #f1f5f9;
  background: #1e293b;
  border-color: #334155;
}

.node-help-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-help-tab-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.6;
  flex-shrink: 0;
  transition: opacity 0.12s;
}
.node-help-tab-close:hover { opacity: 1; }

.node-help-tab-add {
  background: none;
  border: 1px dashed #334155;
  color: #475569;
  font-size: 13px;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s;
}
.node-help-tab-add:hover { color: #f1f5f9; border-color: #64748b; }

.node-help-panel {
  position: fixed;
  top: 12px;
  right: 20px;
  width: 620px;
  max-height: calc(100vh - 32px);
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
}


.node-help-journal {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.node-help-journal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}

.node-help-journal-toggle {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.node-help-journal-toggle:hover { color: #f1f5f9; border-color: #475569; }

.node-help-journal-hint {
  font-size: 10px;
  color: #475569;
}

.node-help-journal-textarea {
  flex: 1;
  background: #0d1624;
  border: none;
  outline: none;
  color: #e2e8f0;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 12px 16px;
  resize: none;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
}

.node-help-journal-preview {
  cursor: text;
}

.node-help-journal-placeholder {
  color: #475569;
  font-style: italic;
}

.node-help-panel-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.65;
}

.node-help-panel-body h1,
.node-help-panel-body h2,
.node-help-panel-body h3 {
  color: #f1f5f9;
  margin: 14px 0 5px;
  font-weight: 600;
}

.node-help-panel-body h1 { font-size: 15px; margin-top: 0; }
.node-help-panel-body h2 { font-size: 13px; }
.node-help-panel-body h3 { font-size: 12px; }

.node-help-panel-body p { margin: 4px 0 8px; }

.node-help-panel-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 11.5px;
  margin: 8px 0 12px;
}

.node-help-panel-body th,
.node-help-panel-body td {
  border: 1px solid #334155;
  padding: 4px 8px;
  text-align: left;
}

.node-help-panel-body th {
  background: #0f172a;
  color: #94a3b8;
  font-weight: 600;
}

.node-help-panel-body code {
  background: #0f172a;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: #7dd3fc;
}

.node-help-panel-body ul,
.node-help-panel-body ol {
  padding-left: 18px;
  margin: 4px 0 8px;
}

.node-help-panel-body li { margin: 2px 0; }

.node-help-panel-body em { color: #94a3b8; }

.node-help-panel-body strong { color: #e2e8f0; }

.node-help-panel-body a { color: #ff9800; }
.node-help-panel-body a:hover { color: #ffb74d; }

/* ── Help panel TOC + content layout ──────────────────────────────── */

.help-content-row {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.help-content-row > .node-help-panel-body {
  flex: 1;
  min-width: 0;
}

.help-toc {
  width: 160px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid #1e293b;
  padding: 8px 0;
  font-size: 11px;
  background: #0f172a;
}

.help-toc-root { padding: 0; }

.help-toc-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 10px;
}

.help-toc-item {
  margin: 0;
}

.help-toc-row {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.help-toc-arrow {
  background: none;
  border: none;
  color: #475569;
  font-size: 7px;
  padding: 0;
  width: 12px;
  flex-shrink: 0;
  cursor: pointer;
  text-align: center;
  line-height: 1;
  transition: color 0.12s;
}
.help-toc-arrow:hover { color: #94a3b8; }

.help-toc-arrow-spacer {
  display: inline-block;
  width: 12px;
  flex-shrink: 0;
}

.help-toc-link {
  color: #94a3b8;
  text-decoration: none;
  padding: 2px 6px 2px 0;
  display: block;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.12s;
}
.help-toc-link:hover { color: #f1f5f9; }

.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);
}

.custom-node.node-error {
  outline: 2px solid #ef4444;
  outline-offset: -1px;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.35);
}

.node-error-message {
  padding: 3px 10px;
  font-size: 10px;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-top: 1px solid rgba(239, 68, 68, 0.3);
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
}

.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 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 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"] {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border-default);
  flex: none;
  cursor: pointer;
  overflow: hidden;
  background: none;
}

.widget-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.widget-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.widget-row input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.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);
}

.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;
}

.angle-overlay {
  --angle-line-color: #ff9800;
  --angle-arc-color: rgb(255, 166, 77);
  --angle-end-handle-color: #ff9800;
  --angle-mid-handle-color: rgb(255, 210, 163);
  --angle-badge-text-color: rgb(255, 210, 163);
  --angle-badge-border-color: rgb(255, 183, 77);
  --angle-stroke-width: 1.35;
  position: relative;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: 6px;
}

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

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

.angle-line {
  stroke: var(--angle-line-color);
  stroke-width: var(--angle-stroke-width);
  stroke-linecap: round;
}

.angle-arc {
  fill: none;
  stroke: var(--angle-arc-color);
  stroke-width: var(--angle-stroke-width);
  stroke-dasharray: 5 3;
  opacity: 0.95;
}

.angle-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--bg-deep);
  cursor: grab;
  box-shadow: 0 0 6px var(--marker-shadow);
  z-index: 1;
}

.angle-handle:active {
  cursor: grabbing;
}

.angle-handle-end {
  background: var(--angle-end-handle-color);
  border: 1px solid var(--marker-border);
}

.angle-handle-mid {
  width: 18px;
  height: 18px;
  background: var(--angle-mid-handle-color);
  border: 2px solid var(--marker-border);
}

.angle-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--angle-badge-border-color);
  color: var(--angle-badge-text-color);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
  cursor: grab;
  user-select: none;
  z-index: 1;
}

.angle-badge:active {
  cursor: grabbing;
}

.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;
}

.lineplot-marker-label {
  fill: var(--bg-deep);
  font-weight: 700;
  user-select: none;
}

.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;
}

.is-panning .cs-overlay,
.is-panning .angle-overlay,
.is-panning .lineplot-overlay,
.is-panning .crop-overlay,
.is-panning .mask-paint-overlay,
.is-panning .markup-overlay {
  pointer-events: none;
}

.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-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.surface-view-container {
  width: 100%;
  height: 100%;
  cursor: grab;
  overflow: hidden;
}
.surface-view-container:active {
  cursor: grabbing;
}
.surface-view-container canvas {
  display: block;
}

.surface-view-home {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  min-width: 54px;
  padding: 4px 10px;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.86);
  color: var(--text-bright);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(2, 6, 23, 0.28);
}

.surface-view-home:hover {
  background: rgba(30, 41, 59, 0.94);
  border-color: rgba(125, 211, 252, 0.55);
}

.surface-view-diagnostics {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  max-width: calc(100% - 84px);
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.82);
  color: rgba(226, 232, 240, 0.92);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 9px;
  line-height: 1.35;
  pointer-events: none;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.24);
  white-space: normal;
  overflow-wrap: anywhere;
}

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

.node-table-search {
  padding: 0 0 4px;
}

.node-table-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 7px;
  font-size: 11px;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  color: var(--text-primary);
  outline: none;
}

.node-table-search-input:focus {
  border-color: var(--accent);
}

.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: fixed;
  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;
  overflow: hidden;
  text-overflow: ellipsis;
  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;
}

/* ── Executing node glow ───────────────────────────────────────────── */
.node-executing-glow {
  position: absolute;
  inset: -3px;
  border-radius: 9px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.node-executing-glow::before {
  content: '';
  position: absolute;
  /* large centered square so conic sweep stays circular on any node size */
  width: 800px;
  height: 800px;
  top: 50%;
  left: 50%;
  margin-top: -400px;
  margin-left: -400px;
  background: conic-gradient(
    from 0deg,
    transparent       0deg,
    transparent     310deg,
    rgba(59, 130, 246, 0.12) 330deg,
    rgba(99, 102, 241, 0.55) 348deg,
    rgba(167, 139, 250, 1)   354deg,
    rgba(255, 255, 255, 0.9) 357deg,
    rgba(167, 139, 250, 0.7) 360deg
  );
  animation: node-glow-rotate 1.4s linear infinite;
  transform-origin: center center;
}
@keyframes node-glow-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Text Note node ────────────────────────────────────────────────── */
.text-note-node {
  width: 100%;
  height: 100%;
  border: 1px solid;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: grab;
  box-sizing: border-box;
}
.text-note-node.selected {
  outline: 2px solid var(--selection);
  outline-offset: 1px;
}
.text-note-toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.text-note-color-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.text-note-color-btn:hover { transform: scale(1.25); }
.text-note-color-btn.active {
  border-color: rgba(255,255,255,0.7);
}
.text-note-fold-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 9px;
  padding: 0 3px;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.12s;
}
.text-note-fold-btn:hover { opacity: 1; }
.text-note-hint {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-faint);
  user-select: none;
  white-space: nowrap;
}
.text-note-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  cursor: text;
  font-size: 13px;
  line-height: 1.55;
  color: inherit;
  min-height: 0;
}
.text-note-content h1 { font-size: 17px; font-weight: 700; margin: 0 0 6px; color: inherit; }
.text-note-content h2 { font-size: 15px; font-weight: 600; margin: 8px 0 4px; color: inherit; }
.text-note-content h3 { font-size: 13px; font-weight: 600; margin: 6px 0 3px; color: inherit; }
.text-note-content p  { margin: 0 0 5px; }
.text-note-content ul,
.text-note-content ol { margin: 0 0 5px; padding-left: 18px; }
.text-note-content li { margin-bottom: 2px; }
.text-note-content code {
  font-family: monospace;
  font-size: 11px;
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
  padding: 1px 4px;
}
.text-note-content strong { font-weight: 600; }
.text-note-content em { font-style: italic; opacity: 0.85; }
.text-note-content hr { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 8px 0; }
.text-note-content blockquote {
  border-left: 3px solid rgba(255,255,255,0.2);
  margin: 4px 0;
  padding-left: 10px;
  opacity: 0.8;
}
.text-note-placeholder { color: var(--text-faint); font-style: italic; }
.text-note-textarea {
  flex: 1;
  background: rgba(0,0,0,0.25);
  border: none;
  outline: none;
  color: inherit;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  resize: none;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
}

/* ── 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,
.context-item--selected {
  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;
}
