:root {
  --bg: #1f1f24;
  --bg-2: #26262d;
  --bg-3: #2e2e36;
  --panel: #2a2a31;
  --line: #3a3a44;
  --line-strong: #50505e;
  --text: #e6e6ea;
  --muted: #8f8f9a;
  --accent: #4cc38a;
  --accent-2: #5aa8ff;
  --ok: #4cc38a;
  --danger: #ef6f6f;
  --warn: #f0a850;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  --node-core: #4cc38a;
  --node-input: #5aa8ff;
  --node-panel: #f0a850;
  --node-function: #bdbdc8;
  --node-output: #f472b6;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { color: var(--accent); font-size: 18px; }
.topbar-controls { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.inline-label { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

input, select, textarea {
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  padding: 7px 10px;
  outline: none;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 168, 255, 0.18);
}
textarea { resize: vertical; }

.btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-3);
  cursor: pointer;
}
.btn:hover { background: #353541; }
.btn.primary { background: var(--accent-2); color: white; border-color: transparent; }
.btn.ghost { background: var(--bg-3); }
.btn.danger { background: rgba(239, 111, 111, 0.18); color: #ffd2d2; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: saturate(0.7);
}
.btn:disabled:hover { background: inherit; }

.status {
  margin-left: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(148, 163, 184, 0.15);
}
.status.idle { background: rgba(148, 163, 184, 0.18); }
.status.busy { background: rgba(240, 168, 80, 0.22); color: #fde68a; }
.status.ok { background: rgba(76, 195, 138, 0.2); color: #baf7da; }
.status.err { background: rgba(239, 111, 111, 0.22); color: #ffd2d2; }

/* ---------- workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: 240px 1fr minmax(280px, 340px);
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.palette, .inspector {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.inspector { border-right: 0; border-left: 1px solid var(--line); }

.palette-head, .inspector-head, .results-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.palette-head h2, .inspector-head h2, .results-head h2 {
  margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted);
}
.palette-search { display: grid; gap: 6px; margin-bottom: 12px; }
.badge { padding: 3px 8px; border-radius: 999px; background: rgba(148, 163, 184, 0.18); font-size: 12px; }

.palette-groups { display: flex; flex-direction: column; gap: 14px; }
.palette-group h3 {
  margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted);
}
.palette-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-3);
  cursor: grab;
  user-select: none;
}
.palette-item:hover { border-color: var(--accent-2); background: #353541; }
.palette-item:active { cursor: grabbing; }
.palette-item .pi-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.palette-item .pi-desc { color: var(--muted); font-size: 12px; }
.palette-item .pi-tag {
  padding: 1px 6px; border-radius: 999px; font-size: 10px;
  background: rgba(148, 163, 184, 0.2); color: var(--muted);
}
.palette-item.kind-core .pi-tag { background: rgba(76, 195, 138, 0.2); color: #baf7da; }
.palette-item.kind-input .pi-tag { background: rgba(90, 168, 255, 0.2); color: #dbeafe; }
.palette-item.kind-panel .pi-tag { background: rgba(240, 168, 80, 0.22); color: #fde68a; }
.palette-item.kind-output .pi-tag { background: rgba(244, 114, 182, 0.22); color: #fbcfe8; }
.palette-empty { padding: 12px; color: var(--muted); text-align: center; }

/* ---------- canvas ---------- */
.canvas-region {
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.canvas {
  position: absolute; inset: 0;
  outline: none;
  cursor: default;
  touch-action: none;
  user-select: none;
  background:
    radial-gradient(circle, rgba(58, 58, 68, 0.9) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(circle, rgba(58, 58, 68, 0.5) 1px, transparent 1px) 12px 12px / 24px 24px,
    linear-gradient(180deg, rgba(31, 31, 36, 0.96), rgba(31, 31, 36, 0.88));
}
.wires {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform-origin: 0 0;
  will-change: transform;
}
.wires path { fill: none; stroke: #d0d7e6; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.wires path.preview { stroke: #7dd3fc; stroke-dasharray: 6 5; opacity: 0.9; }
.wires path.selected { stroke: var(--accent-2); stroke-width: 3; }
.nodes-layer { position: absolute; inset: 0; z-index: 2; transform-origin: 0 0; will-change: transform; }
.canvas.panning,
.canvas.panning * { cursor: grabbing !important; }

.selection-box {
  position: absolute;
  z-index: 4;
  border: 1px solid rgba(90, 168, 255, 0.9);
  background: rgba(90, 168, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.selection-box.active {
  border-color: rgba(76, 195, 138, 0.95);
  background: rgba(76, 195, 138, 0.14);
}
.selection-box.hidden { display: none; }

.canvas-hint {
  position: absolute;
  z-index: 1;
  left: 12px; bottom: 12px;
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted); pointer-events: none; font-size: 12px;
  max-width: min(520px, calc(100% - 24px));
}
.canvas.has-nodes .canvas-hint { display: none; }

.node {
  position: absolute;
  min-width: 160px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid #1f1f24;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  user-select: none;
}

/* compact collapsed node: keep it tiny but still show a short visible label */
.node.collapsed {
  min-width: 48px;
  width: 48px;
  border-radius: 8px;
  padding: 0;
}
.node.collapsed .node-header {
  padding: 4px 5px;
  gap: 4px;
  justify-content: center;
}
.node.collapsed .node-title,
.node.collapsed .node-id {
  display: none;
}
.node.collapsed .node-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px 2px 5px;
}
.node.collapsed .port-col {
  width: 100%;
  gap: 2px;
}
.node.collapsed .port {
  padding: 0;
  gap: 3px;
}
.node.collapsed .port-type { display: none; }
.node.collapsed .port-name {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1;
  min-width: 14px;
}
.node.collapsed { overflow: visible; }
.node.collapsed .port { position: relative; width: 100%; }
.node.collapsed .port-dot {
  width: 10px;
  height: 10px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: -6px;
}
.node.collapsed .port.output .port-dot { left: auto; right: -6px; }
.node.collapsed .port-col.inputs,
.node.collapsed .port-col.outputs {
  margin-left: 0;
  margin-right: 0;
  align-items: center;
}
.node-toggle {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  padding: 0;
}
.node-toggle:hover { background: #353541; }
.node.selected { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(90, 168, 255, 0.35); }
.node.kind-core { border-left: 3px solid var(--node-core); }
.node.kind-input { border-left: 3px solid var(--node-input); }
.node.kind-panel { border-left: 3px solid var(--node-panel); }
.node.kind-function { border-left: 3px solid var(--node-function); }
.node.kind-output { border-left: 3px solid var(--node-output); }

.node-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
  cursor: move;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  gap: 8px;
}
.node-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node.preview-off .node-title { color: var(--muted); }
.node-header .node-id { color: var(--muted); font-size: 11px; font-weight: 400; }
.node-body { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px 0; }
.node-footer-ports {
  display: flex;
  justify-content: center;
  padding: 4px 8px 8px;
  border-top: 1px solid rgba(80, 80, 94, 0.45);
}
.port-col { display: flex; flex-direction: column; gap: 4px; }
.port-col.inputs { margin-left: -1px; }
.port-col.outputs { align-items: flex-end; margin-right: -1px; }
.port {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 6px; font-size: 12px;
}
.port.output { flex-direction: row-reverse; }
.port.input { padding-left: 0; }
.port.output { padding-right: 0; }
.port.bottom {
  justify-content: center;
  gap: 8px;
  padding: 4px 8px 0;
}
.port.bottom .port-dot {
  margin-left: 0;
}
.port-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(148, 163, 184, 0.4);
  border: 2px solid #1f1f24;
  cursor: crosshair;
  flex: none;
}
.port.input .port-dot { margin-left: -10px; }
.port.output .port-dot { margin-right: -10px; }
.port-dot:hover { background: var(--accent-2); box-shadow: 0 0 0 4px rgba(90, 168, 255, 0.16); }
.port-dot.active { background: var(--accent); box-shadow: 0 0 0 5px rgba(76, 195, 138, 0.2); }
.port-name { color: var(--muted); }
.port-type { font-size: 10px; color: var(--muted); opacity: 0.6; }

/* ---------- inspector ---------- */
.inspector-body { margin-bottom: 12px; }
.inspector-section { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.inspector-section h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.inspector-section label, .inspector-body label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prompt-block {
  display: grid;
  gap: 10px;
}
.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.prompt-actions .btn {
  min-width: 104px;
}
.prompt-field textarea {
  min-height: 140px;
}
.prompt-generate {
  justify-self: start;
}
.muted { color: var(--muted); }

/* ---------- results ---------- */
.results {
  background: rgba(2, 6, 23, 0.7);
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  max-height: 28vh;
  overflow: auto;
}
.results-actions { display: flex; gap: 6px; }
.agent-run-card {
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(7, 11, 24, 0.96)),
    radial-gradient(circle at top right, rgba(96, 165, 250, 0.14), transparent 44%);
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.28);
}
.agent-run-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
}
.agent-run-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.agent-run-meta {
  margin-top: 2px;
  font-size: 12px;
}
.agent-run-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.3);
  color: #bfdbfe;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.agent-run-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-run-card.kind-build {
  border-color: rgba(34, 197, 94, 0.4);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(7, 11, 24, 0.96)),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.16), transparent 44%);
}
.agent-run-card.kind-build .agent-run-pill {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}
.agent-run-card.kind-post {
  border-color: rgba(244, 114, 182, 0.4);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(7, 11, 24, 0.96)),
    radial-gradient(circle at top right, rgba(244, 114, 182, 0.16), transparent 44%);
}
.agent-run-card.kind-post .agent-run-pill {
  background: rgba(244, 114, 182, 0.16);
  border-color: rgba(244, 114, 182, 0.35);
  color: #fbcfe8;
}
.agent-run-card.kind-test {
  border-color: rgba(250, 204, 21, 0.4);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(7, 11, 24, 0.96)),
    radial-gradient(circle at top right, rgba(250, 204, 21, 0.16), transparent 44%);
}
.agent-run-card.kind-test .agent-run-pill {
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(250, 204, 21, 0.35);
  color: #fde68a;
}
.agent-run-body {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 24vh;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
}
.result-pane {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 22vh;
  overflow: auto;
  color: var(--text);
}
.result-pane.error { border-color: rgba(239, 68, 68, 0.5); }

.preview-pane {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.preview-summary {
  font-size: 12px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-viewports {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.52);
}

.preview-view-btn {
  border: 0;
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.preview-view-btn:hover { color: var(--text); background: rgba(148, 163, 184, 0.12); }
.preview-view-btn.active { color: #fff; background: var(--accent-2); }

.preview-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.preview-toggle-button {
  min-width: 116px;
  justify-content: space-between;
}

.preview-toggle-count {
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text);
  font-size: 11px;
  text-align: center;
}

.preview-point-names {
  position: relative;
  display: inline-flex;
}

.preview-point-names-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 8;
  min-width: 280px;
  max-width: min(420px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(17, 20, 24, 0.98);
  box-shadow: var(--shadow);
}

.preview-point-names-menu.hidden { display: none; }

.preview-point-names-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.preview-point-names-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.preview-point-names-actions button:hover {
  border-color: var(--accent-2);
  background: rgba(90, 168, 255, 0.12);
}

.preview-point-names-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.preview-point-names-list {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.preview-point-name-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 4px 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.62);
  cursor: pointer;
}

.preview-point-name-item:hover {
  border-color: rgba(90, 168, 255, 0.38);
  background: rgba(30, 41, 59, 0.8);
}

.preview-point-name-item input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent-2);
}

.preview-point-name-text {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
}

.preview-point-name-meta {
  grid-column: 2;
  font-size: 10px;
  color: var(--muted);
}

.preview-point-names-empty {
  padding: 8px 2px 2px;
  color: var(--muted);
  font-size: 12px;
}

.preview-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent-2);
}

.preview-stage {
  position: relative;
  min-height: 240px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #9fa7ad;
  overflow: hidden;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  z-index: 1;
}

.preview-stage.has-geometry .preview-empty {
  display: none;
}

.preview-svg {
  display: block;
  width: 100%;
  height: 240px;
}

.preview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.preview-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.preview-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: none;
}

.preview-legend-swatch.point { background: #fbbf24; }
.preview-legend-swatch.line { background: #7dd3fc; }
.preview-legend-swatch.polyline { background: #5eead4; }

.preview-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text);
  font-size: 11px;
  line-height: 1.2;
}

.preview-badge.kind {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.preview-grid {
  stroke: rgba(85, 96, 104, 0.32);
  stroke-width: 1;
}

.preview-grid.major {
  stroke: rgba(66, 75, 82, 0.5);
}

.preview-world-axis {
  stroke-width: 1.4;
  stroke-linecap: square;
}

.preview-world-axis.x { stroke: #9d2f2f; }
.preview-world-axis.y { stroke: #29953d; }
.preview-world-axis.z { stroke: #2f67a8; }

.preview-axis {
  stroke-width: 2.2;
  stroke-linecap: round;
}

.preview-axis.x { stroke: #ef4444; }
.preview-axis.y { stroke: #22c55e; }
.preview-axis.z { stroke: #3b82f6; }

.preview-axis-label {
  font-size: 12px;
  font-weight: 700;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.preview-axis-label.x { fill: #fca5a5; }
.preview-axis-label.y { fill: #86efac; }
.preview-axis-label.z { fill: #93c5fd; }

.preview-origin {
  fill: rgba(230, 230, 234, 0.82);
}

.preview-viewport-label {
  fill: rgba(230, 230, 234, 0.7);
  font-size: 12px;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.preview-polyline {
  fill: none;
  stroke: #5eead4;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-plane-surface {
  stroke-width: 1.6;
  stroke-linejoin: round;
  fill-opacity: 0.28;
}

.preview-plane-centroid {
  fill: #f8fafc;
  stroke: rgba(9, 12, 16, 0.96);
  stroke-width: 1.2;
}

.preview-plane-axis {
  stroke-width: 2.2;
  stroke-linecap: round;
}

.preview-plane-axis-label {
  font-size: 11px;
  font-weight: 700;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  paint-order: stroke;
  stroke: rgba(9, 12, 16, 0.96);
  stroke-width: 2px;
  stroke-linejoin: round;
}

.preview-plane-axis-label.x { fill: #fca5a5; }
.preview-plane-axis-label.y { fill: #86efac; }
.preview-plane-axis-label.z { fill: #93c5fd; }

.preview-line {
  stroke: #111418;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.preview-point {
  fill: #111418;
  stroke: #f1f5f9;
  stroke-width: 1.2;
}

.preview-label {
  fill: rgba(230, 230, 234, 0.82);
  font-size: 11px;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.preview-point-label {
  fill: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  stroke-linejoin: round;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.preview-point-name-bg {
  fill: rgba(9, 12, 16, 0.76);
  stroke: rgba(148, 163, 184, 0.22);
  stroke-width: 1;
}

.preview-point-name {
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.32));
}

.ctx-menu {
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 4px;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(31, 31, 36, 0.98);
  box-shadow: var(--shadow);
}

.ctx-menu.hidden { display: none; }

.ctx-item {
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  text-align: left;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.ctx-item:hover { background: #353541; }

.ctx-item:disabled { color: var(--muted); cursor: default; }
.ctx-item.danger { color: #ffd2d2; }
.ctx-item.danger:hover { background: rgba(239, 111, 111, 0.14); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
}
.modal.hidden { display: none; }
.modal-card {
  width: min(720px, calc(100vw - 24px));
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.modal-body {
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.usage-modal-body {
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
  color: var(--text);
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
.close {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
}
.close:hover { background: #353541; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 220px 1fr 280px; }
}
@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 220px 1fr 220px; }
  .palette, .inspector { border: 0; border-bottom: 1px solid var(--line); }
}
