/* Toolbar background — opaque in dark mode */
:root { --toolbar-bg: #ffffff; }
[data-theme="dark"] { --toolbar-bg: #1c1e28; }

/* Connector toolbar — positioned in viewport space, not element space */
.el-toolbar.conn-toolbar {
  bottom: unset;
  z-index: 20;
}

/* Element toolbar — also lifted to viewport space so it escapes overflow:hidden */
.el-toolbar.el-toolbar-float {
  bottom: unset;
  left: unset;
  z-index: 20;
}

/* Color swatches inside connector toolbar */
.conn-swatch-btn { width: 24px; }
.conn-swatch {
  display: block;
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

[data-theme="dark"] .el-toolbar {
  background: var(--toolbar-bg);
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 4px 20px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.3);
}
[data-theme="dark"] .el-toolbar-btn { color: rgba(255,255,255,0.55); }
[data-theme="dark"] .el-toolbar-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
[data-theme="dark"] .el-toolbar-divider { background: rgba(255,255,255,0.10); }

/* ---------- Elements on canvas ---------- */
.el {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  user-select: none;
  /* Force every canvas element into its own GPU compositor layer so Chrome
     composites them strictly by z-index inside the CSS-zoom canvas.
     Without this, image content inside imageframes can get promoted to a
     higher-tier compositor layer and paint above sibling elements regardless
     of z-index assignment. translateZ(0) is a visual no-op. */
  transform: translateZ(0);
}
.el.dragging { cursor: grabbing; }

.el .el-body {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.el .sel-ring {
  position: absolute;
  inset: -3px;
  border: 2px solid var(--accent-1);
  border-radius: inherit;
  pointer-events: none;
  box-shadow: var(--ring);
}
.el .handle {
  position: absolute;
  width: 12px; height: 12px;
  background: var(--bg-surface);
  border: 1.5px solid var(--accent-1);
  border-radius: 2px;
  pointer-events: all;
  z-index: 3;
}
.el .handle.tl { top: -7px;    left: -7px;    cursor: nw-resize; }
.el .handle.tr { top: -7px;    right: -7px;   cursor: ne-resize; }
.el .handle.bl { bottom: -7px; left: -7px;    cursor: sw-resize; }
.el .handle.br { bottom: -7px; right: -7px;   cursor: se-resize; }

/* ── Per-element floating toolbar (shown when selected) ─── */
.el-toolbar {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  background: var(--toolbar-bg, #fff);
  border: 1px solid var(--bd-1, #e0e1e6);
  border-radius: 10px; padding: 3px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  pointer-events: all; white-space: nowrap; z-index: 10;
}
.el-toolbar-btn {
  width: 28px; height: 28px; border: none; border-radius: 7px;
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-muted, #888);
  transition: background 100ms, color 100ms; padding: 0; flex-shrink: 0;
}
.el-toolbar-btn:hover { background: var(--bg-subtle); color: var(--fg-default); }
.el-toolbar-btn.danger:hover { background: #fee2e2; color: #ef4444; }
/* Active state — placed AFTER :hover rules so same-specificity cascade order favours active.
   Dark-mode counterparts needed because [data-theme="dark"] .el-toolbar-btn:hover has the
   same specificity (0,3,0) as .el-toolbar-btn.active:hover and appeared earlier in the file. */
.el-toolbar-btn.active                              { background: #0D5284; color: #fff; }
.el-toolbar-btn.active:hover                        { background: #0a4270; color: #fff; }
[data-theme="dark"] .el-toolbar-btn.active          { background: #0D5284; color: #fff; }
[data-theme="dark"] .el-toolbar-btn.active:hover    { background: #0a4270; color: #fff; }
.el-toolbar-divider { width: 1px; height: 18px; background: var(--bd-1, #e0e1e6); margin: 0 1px; flex-shrink: 0; }
/* ── Canvas diagram elements — fixed design system, independent of app theme ──
   These values MUST NOT use theme CSS variables. The canvas is a self-contained
   artwork area; only the canvas background setting (White/Sand/Dark) may change
   diagram element appearance (via .canvas.bg-dark overrides below).          */

/* Element variants */
.el-iconblock .el-body {
  background: #ffffff;
  border: 1px solid #e0e1e6;
  border-radius: 14px;
  flex-direction: column;
  gap: 12px;
  padding: 16px 12px 14px;
}
.el-iconblock .ic {
  width: 60px; height: 60px;
  background: #fffb63;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #0a0e1f;
}
.el-iconblock .ic svg { width: 28px; height: 28px; }
.el-iconblock .lbl {
  font-size: 12px; font-weight: 600; letter-spacing: -0.15px;
  color: #15171e;
  white-space: normal; word-break: break-word;
  text-align: center; width: 100%;
  padding: 0 4px; box-sizing: border-box;
}

.el-text .el-body {
  background: transparent;
  padding: 0;
  width: auto;   /* don't inherit 100% from .el .el-body — outer element controls width */
  height: auto;  /* override .el .el-body height:100% so hugHeight can work correctly */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: #15171e;
  text-align: center;
  overflow-wrap: break-word;
  line-height: 1.3;
}

.el-origin .el-body {
  background: var(--cdn-navy);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.el-origin .el-body::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-2);
  border-radius: 14px 14px 0 0;
}
.el-origin .ic {
  width: 36px; height: 36px;
  background: rgba(255,251,99,0.15);
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent-2);
}
.el-origin .ic svg { width: 18px; height: 18px; }
.el-origin .lbl {
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #fff;
}
.el-origin .meta {
  font-size: 10px; font-weight: 500; letter-spacing: -0.1px;
  color: rgba(255,255,255,0.5);
  font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

/* Icon component — bare icon container + optional label, no outer card */
.el-icon .el-body {
  background: transparent;
  border: none;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 7px;
  padding: 0;
}
.el-icon .ic {
  width: 60px; height: 60px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
/* .el-icon .ic svg size is set via the Icon component's size prop; no CSS override */
.el-icon .lbl {
  font-size: 12px; font-weight: 600; letter-spacing: -0.15px;
  color: #15171e;
  white-space: normal; word-break: break-word;
  text-align: center; width: 100%;
  box-sizing: border-box;
  line-height: 1.3;
}
.canvas.bg-dark .el-icon .lbl { color: rgba(255,255,255,0.92); }

/* Group component — fixed-size container; background fills 100%/100% */
.el-group .el-body {
  /* Reset centering defaults — group is a column layout, not centered display */
  align-items: stretch;
  justify-content: flex-start;
}

/* Label input bar — appears below selected element in viewport space */
.el-label-bar {
  position: absolute;
  z-index: 20;
  pointer-events: all;
}
.el-label-bar-input {
  font-family: inherit;
  font-size: 12px; font-weight: 600; letter-spacing: -0.15px;
  text-align: center;
  color: var(--fg-strong);
  background: var(--toolbar-bg, #fff);
  border: 1.5px solid var(--accent-1, #3B59CE);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-1-soft, rgba(59,89,206,0.15)), var(--shadow-pop);
  width: 140px;
  box-sizing: border-box;
}

/* ---------- Snippet element ---------- */
/* Override base .el-body height:100% so content drives element height (hugHeight). */
.el-snippet .el-body {
  background: transparent;
  padding: 0;
  height: auto;
  display: block;
}

/* Dark canvas — element overrides */
.canvas.bg-dark { background: #0a0e1f; }
.canvas.bg-dark .el-iconblock .el-body {
  background: #131929;
  border-color: rgba(255,255,255,0.10);
  box-shadow: 0 1px 3px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.4);
}
.canvas.bg-dark .el-iconblock .lbl { color: rgba(255,255,255,0.92); }
.canvas.bg-dark .el-text .el-body { color: rgba(255,255,255,0.9); }

/* ---------- Node Card element ---------- */
.el-nodecard .el-body {
  /* Override base .el .el-body { width: 100%; height: 100% } so the card
     hugs its content rather than filling the outer element's dimensions. */
  width: auto;
  height: auto;
}
.el-nodecard .lbl {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.1px;
  line-height: 1.3;
  white-space: pre-wrap;
  word-break: break-word;
}
/* Dark-canvas label override */
.canvas.bg-dark .el-nodecard .lbl { color: rgba(255,255,255,0.92); }

/* Snippet inline code editor overlay */
.snippet-inline-editor {
  cursor: text;
  tab-size: 2;
}

/* ---------- Web Frame element ---------- */
/* Override el-body defaults so the SVG fills the element without flex centering */
.el-webframe .el-body {
  padding: 0;
  display: block;
  background: transparent;
  border: none;
  align-items: initial;
  justify-content: initial;
}
