/* ============================================================================
   CANVAS STYLES
   ============================================================================ */

/* Canvas - Consolidated: Uses .flex-col-hidden utility */
section.canvas,
.flex-col-hidden.section.canvas {
  padding: 0;

  /* display: flex; flex-direction: column; min-height: 0; overflow: hidden; now from .flex-col-hidden */
}

.canvas-header {
  padding: 12px;
  border-bottom: 2px solid var(--blue-opacity-30);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-12);
  font-weight: 600;
  min-height: 48px;
  box-sizing: border-box;
  background: var(--space-opacity-40);
  color: var(--text-primary);
}

/* Consolidated: Uses .flex-row-center utility */
.canvas-header-left,
.flex-row-center.canvas-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Canvas Zoom Controls
 * All values follow 3-6-9 digital root rule:
 * - gap: 0.3rem (digital root: 3)
 * - padding: 0.3rem (digital root: 3)
 * - border-radius: 6px (digital root: 6)
 * - font-size: 0.75rem (75 = 7+5 = 12 = 1+2 = 3)
 * - min-width: 3.6rem (36 = 3+6 = 9)
 */
.canvas-zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem; /* 0.3rem: digital root = 3 */
  padding: 0.3rem; /* 0.3rem: digital root = 3 */

  /* OPTIMIZED: Removed backdrop-filter - nested control doesn't need it */
  background: var(--space-mid-opacity-92);
  border-radius: 6px; /* 6px: digital root = 6 */
  border: 1px solid var(--blue-opacity-30);
  box-shadow: 0 0.3rem 0.6rem rgb(0 0 0 / 30%); /* 0.3rem, 0.6rem: digital roots = 3, 6 */
}

.canvas-zoom-level {
  font-size: 0.75rem; /* 0.75rem: 75 = 7+5 = 12 = 1+2 = 3 ✓ */
  color: #94a3b8;
  min-width: 3.6rem; /* 3.6rem: 36 = 3+6 = 9 ✓ */
  text-align: center;
  font-weight: 600;
  user-select: none;
}

/* Consolidated: Uses .flex-row-center utility */
.canvas-header-right,
.flex-row-center.canvas-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Context expanded content styles moved to sidebar */
.context-expanded-content {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
}

.context-expanded-content::-webkit-scrollbar {
  width: 8px;
}

.context-expanded-content::-webkit-scrollbar-track {
  background: var(--space-opacity-60);
}

.context-expanded-content::-webkit-scrollbar-thumb {
  background: var(--blue-opacity-40);
  border-radius: 4px;
}

.context-expanded-content::-webkit-scrollbar-thumb:hover {
  background: var(--blue-opacity-60);
}

/* MANDATORY: Canvas Layout control styles (current prompt only) */

/* Consolidated: Uses .flex-row-center utility */
.canvas-layout-control,
.flex-row-center.canvas-layout-control {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.canvas-layout-control span {
  font-size: var(--font-12);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.canvas-layout-control select {
  padding: var(--space-6) var(--space-9);
  padding-right: var(--space-27);
  border-radius: var(--space-9);
  border: 2px solid var(--blue-opacity-30);

  /* OPTIMIZED: Removed backdrop-filter - nested form control doesn't need it */
  background: var(--space-opacity-80);
  color: var(--text-primary);
  font-size: var(--font-12);
  cursor: pointer;
  transition: all var(--timing-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230099FF' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-9) center;
  background-size: var(--space-12);
  min-width: 120px;
  height: var(--space-30);
  box-shadow: 0 0 var(--space-6) var(--blue-opacity-10);
}

.canvas-layout-control select:hover {
  border-color: var(--blue-electric);
  background: var(--blue-opacity-10);
  box-shadow: 0 0 var(--space-12) var(--blue-opacity-30);
}

.canvas-layout-control select:focus {
  outline: none;
  border-color: var(--blue-electric);
  box-shadow: 
    0 0 0 2px var(--blue-opacity-30),
    0 0 var(--space-18) var(--glow-blue);
  background: var(--blue-opacity-15);
}

/* Consolidated: Uses .flex-row-center utility */
.canvas-bg-control,
.flex-row-center.canvas-bg-control {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.canvas-bg-control span {
  font-size: var(--font-12);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.canvas-bg-control input[type="color"] {
  width: var(--space-30);
  height: var(--space-30);
  padding: 0;
  border-radius: var(--space-9);
  border: 2px solid var(--blue-opacity-30);

  /* OPTIMIZED: Removed backdrop-filter - nested form control doesn't need it */
  background: var(--space-opacity-80);
  cursor: pointer;
  transition: all var(--timing-fast) ease;
  box-shadow: 0 0 var(--space-6) var(--blue-opacity-10);
}

.canvas-bg-control input[type="color"]:hover {
  border-color: var(--blue-electric);
  transform: scale(1.1);
  box-shadow: 
    0 0 var(--space-12) var(--blue-opacity-60),
    0 0 var(--space-24) var(--blue-opacity-30);
}

.canvas-tag {
  font-size: var(--font-9);
  padding: 3px 9px;
  border-radius: 27px;
  border: 2px dashed var(--blue-opacity-30);
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Consolidated: Uses .flex-grow utility */
.canvas-body,
.flex-grow.canvas-body {
  position: relative;

  /* flex: 1; min-height: 0; now from .flex-grow */
  padding: 0; /* Removed padding - content fills entire viewport */
  overflow: hidden;
  min-height: 0;
  background: var(--space-deep);
  background-image: 
    /* Starfield grid pattern */
    radial-gradient(circle at 3px 3px, var(--green-opacity-15-alt) 1px, transparent 0),
    radial-gradient(circle at 9px 9px, var(--blue-opacity-10) 1px, transparent 0),
    radial-gradient(circle at 18px 18px, var(--cyan-opacity-08) 1px, transparent 0),
    radial-gradient(circle at 27px 27px, var(--green-opacity-05) 1px, transparent 0),
    /* Guide lines */
    linear-gradient(90deg, var(--blue-opacity-03) 1px, transparent 1px),
    linear-gradient(var(--green-opacity-05) 1px, transparent 1px);
  background-size: 
    18px 18px,
    18px 18px,
    18px 18px,
    18px 18px,
    18px 18px,
    18px 18px;
  background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
}

/* Canvas Command Bar - positioned at top center of canvasDropZone */

/* Command Bar Container - Wraps command bar */

/* Unified Toolbar - Two rows in single container, fit to content */
.canvas-unified-toolbar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-popover);
  pointer-events: auto;
  display: inline-flex;
  flex-direction: column;

  /* OPTIMIZED: Removed backdrop-filter - using solid background for better performance */
  background: var(--space-mid-opacity-98);
  border: 2px solid var(--blue-opacity-40);
  border-radius: 0 0 var(--space-12, 12px) var(--space-12, 12px);
  box-shadow: 
    0 18px 48px var(--black-opacity-70),
    0 0 36px var(--blue-opacity-15),
    inset 0 0 18px var(--blue-opacity-10);
  overflow: visible;
  box-sizing: border-box;

  /* OPTIMIZED: CSS containment - isolate toolbar (frequently updated) */
  contain: layout style;
}

/* Toolbar rows - Consolidated: Uses .flex-center utility */
.toolbar-row,
.flex-center.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;

  /* OPTIMIZED: CSS containment - isolate toolbar rows */
  contain: layout style;
}

.toolbar-row.toolbar-commands {
  gap: 4px;
}

/* View Toggle Bar - jh3y-style (CodePen vEEZxOM): radio + label segments, sliding indicator */
.toolbar-row.toolbar-views.control {
  padding: 0;
  contain: none;
  width: 100%;
  justify-content: stretch;
}

#viewToggleBar .control__track {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 5px;
  width: 100%;
  box-sizing: border-box;
  background: linear-gradient(180deg, var(--space-opacity-90) 0%, var(--space-opacity-80) 100%);
  border-radius: 21px;
  border: none;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 6%),
    inset 0 0 18px var(--blue-opacity-08),
    0 0 18px var(--blue-opacity-10);
}

/* Sliding pill indicator - position/width set via JS from checked input's label */
#viewToggleBar .indicator {
  position: absolute;
  top: 4px;
  left: 5px;
  height: 30px;
  width: 33px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--blue-opacity-20) 0%, var(--cyan-opacity-20) 100%);
  border: 1px solid var(--blue-opacity-40);
  box-shadow: 0 0 12px var(--blue-opacity-30), inset 0 1px 0 rgb(255 255 255 / 12%);
  z-index: 0;
  pointer-events: none;
  transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Row divider */
.toolbar-row-divider {
  height: 1px;
  background: rgb(255 255 255 / 8%);
  margin: 0;
}

/* Toolbar groups */

/* Consolidated: Uses .flex-row utility */
.toolbar-group,
.flex-row.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Toolbar separator */
.toolbar-separator {
  width: 1px;
  height: 20px;
  background: rgb(255 255 255 / 12%);
  margin: 0 6px;
}

/* PHASE 6: Toolbar buttons - Uses .flex-center utility, similar to .btn-icon utility */
.toolbar-btn,
.flex-center.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  min-width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: rgb(255 255 255 / 60%);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toolbar-btn i {
  font-size: 1rem;
}

.toolbar-btn:hover {
  background: rgb(255 255 255 / 10%);
  color: #fff;
}

.toolbar-btn.primary {
  background: var(--green-opacity-20);
  color: var(--green-ghost, #0f9);
}

.toolbar-btn.primary:hover {
  background: rgb(0 255 153 / 30%);
}

/* Toolbar input */
.toolbar-input {
  background: rgb(255 255 255 / 5%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 6px;
  padding: 4px 10px;
  color: rgb(255 255 255 / 90%);
  font-size: 0.8rem;
  min-width: 140px;
  height: 28px;
}

.toolbar-input:focus {
  outline: none;
  border-color: var(--blue-opacity-50);
  background: rgb(255 255 255 / 8%);
}

.toolbar-input::placeholder {
  color: rgb(255 255 255 / 40%);
}

/* Widget Name Input - Special green styling */
.toolbar-input.widget-name-input {
  color: #0f9;
  text-shadow: 0 0 9px rgb(0 255 153 / 36%);
  border-color: rgb(0 255 153 / 27%);
  background: rgb(0 255 153 / 6%);
  font-weight: 600;
  letter-spacing: 0.03em;
  min-width: 160px;
}

.toolbar-input.widget-name-input:focus {
  border-color: rgb(0 255 153 / 54%);
  background: rgb(0 255 153 / 12%);
  box-shadow: 0 0 12px rgb(0 255 153 / 18%);
}

.toolbar-input.widget-name-input::placeholder {
  color: rgb(0 255 153 / 45%);
  text-shadow: none;
}

/* Row 2: Controls Bar (Undo/Redo | Mode Toggle | Zoom) */
.canvas-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px 10px;
  background: rgb(20 24 33 / 85%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 10px;
  backdrop-filter: blur(8px);
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.controls-group.controls-zoom,
.controls-group.controls-save {
  gap: 2px;
}

.controls-group.controls-left {
  padding-right: 10px;
  border-right: 1px solid rgb(255 255 255 / 10%);
}

.controls-group.controls-center {
  padding: 0 10px;
}

.controls-group.controls-right {
  padding-left: 10px;
  border-left: 1px solid rgb(255 255 255 / 10%);
}

.canvas-controls-bar .btn.ghost.header-control-btn {
  padding: 6px 8px;
  min-width: 28px;
  height: 28px;
}

/* Command bar controls groups */
.canvas-command-bar .controls-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.canvas-controls-bar .mode-toggle {
  gap: 6px;
}

.canvas-controls-bar .mode-label {
  font-size: 0.7rem;
}

/* View Toggle separator - used by other toolbar rows (code, node, params, stages) */
.view-toggle-separated {
  position: relative;
  margin-left: 9px;
}

.view-toggle-separated::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 18px;
  background: rgb(255 255 255 / 12%);
  border-radius: 1px;
}

/* View Toggle Bar segment separator */
#viewToggleBar .segment--sep {
  position: relative;
  margin-left: 9px;
}

#viewToggleBar .segment--sep::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 18px;
  background: var(--blue-opacity-20);
  border-radius: 1px;
}

/* Segment = label (replaces .view-toggle-btn); active via input:checked + .segment */
#viewToggleBar .segment {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 33px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
}

#viewToggleBar .segment i {
  font-size: 1rem;
  transition: transform 0.2s ease;
}

#viewToggleBar .segment:hover {
  background: var(--blue-opacity-10);
  color: var(--text-primary);
}

#viewToggleBar .segment:hover i {
  transform: scale(1.08);
}

/* Active (input:checked + .segment): default green */
#viewToggleBar input:checked + .segment {
  color: var(--green-ghost, #0f9);
}

#viewToggleBar input:checked + .segment i {
  filter: drop-shadow(0 0 4px rgb(0 255 153 / 36%));
}

/* Builder/Live mode segments: cyan when active */
#viewToggleBar input#btnModeBuilder:checked + .segment,
#viewToggleBar input#btnModeLive:checked + .segment {
  color: var(--cyan-bright, #3cf);
}

#viewToggleBar input#btnModeBuilder:checked + .segment i,
#viewToggleBar input#btnModeLive:checked + .segment i {
  filter: drop-shadow(0 0 4px rgb(0 153 255 / 36%));
}

/* Flow segment: when unchecked shows head (icon); when checked expands to sub-tabs inline */
#viewToggleBar .flow-segment {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 30px;
}

/* When Flow is selected, shrink Builder/Live so Flow gets the remaining space */
#viewToggleBar .control__track:has(#btnFlowView:checked) .segment {
  flex: 0 0 44px;
  min-width: 44px;
}

#viewToggleBar .control__track:has(#btnFlowView:checked) .flow-segment {
  flex: 1 1 0;
  min-width: 200px;
}

#viewToggleBar .flow-segment-head {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
}

#viewToggleBar .flow-segment-head i {
  font-size: 1rem;
}

#viewToggleBar .flow-segment-head:hover {
  background: var(--blue-opacity-10);
  color: var(--text-primary);
}

/* When Flow checked: hide head, show sub-tabs */
#viewToggleBar #btnFlowView:checked + .flow-segment .flow-segment-head {
  display: none;
}

#viewToggleBar .flow-sub-tabs {
  display: none;
  flex: 1;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  min-width: 0;
}

#viewToggleBar #btnFlowView:checked + .flow-segment .flow-sub-tabs {
  display: flex;
}

#viewToggleBar .flow-sub-tabs .flow-toolbar-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 8px;
}

#viewToggleBar .flow-sub-tabs .flow-toolbar-tab span {
  font-size: 0.6rem;
}

#viewToggleBar .flow-sub-tabs .flow-tab-count {
  margin-left: 2px;
  font-weight: 700;
  opacity: 0.9;
}

#viewToggleBar .flow-stages-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
}

#viewToggleBar .flow-stages-dropdown {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  font-size: 0.65rem;
  background: rgb(30 41 59 / 80%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
}

/* ============================================================================
   CODE VIEW TOOLBAR TABS - Row 3 submenu for code view
   ============================================================================ */

.toolbar-row.toolbar-code-tabs {
  gap: 4px;
  background: rgb(0 0 0 / 30%);
  border-top: 1px solid rgb(0 153 255 / 20%);
}

.code-toolbar-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 12px;
  min-width: 50px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: rgb(255 255 255 / 50%);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.code-toolbar-tab i {
  font-size: 0.95rem;
  transition: transform 0.2s ease;
}

.code-toolbar-tab span {
  line-height: 1;
}

.code-toolbar-tab:hover {
  background: rgb(255 255 255 / 8%);
  color: rgb(255 255 255 / 85%);
}

.code-toolbar-tab:hover i {
  transform: scale(1.1);
}

.code-toolbar-tab.active {
  background: var(--blue-opacity-20);
  color: var(--cyan-bright, #3cf);
  box-shadow: 
    0 0 10px rgb(0 153 255 / 15%),
    inset 0 0 6px var(--blue-opacity-08);
}

.code-toolbar-tab.active i {
  filter: drop-shadow(0 0 4px rgb(0 153 255 / 40%));
}

/* ============================================================================
   BASE TOOLBAR ACTION BUTTON - Consolidated toolbar button styles
   ============================================================================ */

/* Base toolbar action button - shared across all toolbar action buttons */
.toolbar-action-base,
.code-toolbar-action,
.node-toolbar-action,
.params-toolbar-action,
.stages-toolbar-action,
.flow-toolbar-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 50%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-action-base i,
.code-toolbar-action i,
.node-toolbar-action i,
.params-toolbar-action i,
.stages-toolbar-action i,
.flow-toolbar-action i {
  font-size: 1rem;
}

.toolbar-action-base:active,
.code-toolbar-action:active,
.node-toolbar-action:active,
.params-toolbar-action:active,
.stages-toolbar-action:active,
.flow-toolbar-action:active {
  transform: scale(0.95);
}

/* Variant: Code toolbar uses lighter background */
.code-toolbar-action {
  width: 31px;
  height: 31px;
  background: rgb(255 255 255 / 5%);
  border: 1px solid rgb(255 255 255 / 10%);
}

.code-toolbar-action i {
  font-size: 0.9rem;
}

/* Hover variants - different accent colors per toolbar type */
.code-toolbar-action:hover {
  background: var(--blue-opacity-15);
  border-color: rgb(0 153 255 / 30%);
  color: var(--cyan-bright, #3cf);
}

.node-toolbar-action:hover {
  background: var(--green-opacity-20);
  color: #fff;
  border-color: rgb(0 255 153 / 40%);
}

.params-toolbar-action:hover {
  background: rgb(255 153 0 / 20%);
  color: #fff;
  border-color: rgb(255 153 0 / 40%);
}

.stages-toolbar-action:hover {
  background: rgb(153 0 255 / 20%);
  color: #fff;
  border-color: rgb(153 0 255 / 40%);
}

/* Close button variant - red accent on hover */
.code-toolbar-action.code-close-btn:hover,
.node-toolbar-action.node-close-btn:hover,
.params-toolbar-action.params-close-btn:hover,
.stages-toolbar-action.stages-close-btn:hover,
.flow-toolbar-action.flow-close-btn:hover {
  background: rgb(255 80 80 / 20%);
  border-color: rgb(255 80 80 / 40%);
  color: #ff5050;
}

/* Canvas Top Right Controls - Export button and Mode toggle */
.canvas-top-right-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: var(--z-popover);
  pointer-events: auto;
}

/* Canvas Content - viewport only; always covers the full canvas. Pan/zoom applied to inner. */
#canvasContent {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Inner: fixed at (0,0) of viewport; only scale(zoom) applied, no translate */
#canvasContentInner {
  transform-origin: 0 0;
  position: relative;
  top: 0;
  left: 0;
}

/* Canvas drop zone centering */
#canvasDropZone {
  position: relative; /* Positioning context for floating panels */
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%; /* Full height for proper vertical centering of floating panels */
}

/* Scrollbar styling removed - canvas now uses drag-and-move panning instead of scrolling */

/* .canvas-body::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.canvas-body::-webkit-scrollbar-track {
  background: var(--space-opacity-60);
}

.canvas-body::-webkit-scrollbar-thumb {
  background: var(--blue-opacity-40);
  border-radius: 6px;
  border: 1px solid rgba(0, 153, 255, 0.2);
  box-shadow: 0 0 6px var(--blue-opacity-30);
}

.canvas-body::-webkit-scrollbar-thumb:hover {
  background: var(--blue-opacity-60);
  box-shadow: 0 0 12px var(--blue-opacity-60);
} */

.canvas-body::-webkit-scrollbar-corner {
  background: var(--space-opacity-60);
}

.canvas-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* Center both horizontally and vertically */
  border: 2px dashed var(--blue-opacity-30);
  border-radius: 12px;
  padding: 36px 48px; /* Increased padding for larger size */
  display: flex;
  flex-direction: column; /* Stack logo above text */
  align-items: center;
  justify-content: center;
  gap: 18px; /* Space between logo and text */
  text-align: center;
  font-size: var(--font-14);
  color: var(--text-muted);

  /* OPTIMIZED: Removed backdrop-filter - nested element doesn't need it */
  background: radial-gradient(circle at top, var(--blue-opacity-20), var(--space-opacity-90));
  box-shadow: 0 0 18px rgb(0 153 255 / 10%); /* 18px: 1+8 = 9 ✓ */
}

.canvas-empty-logo {
  width: 72px; /* 7+2 = 9 ✓ */
  height: auto;
  opacity: 0.72;
  filter: drop-shadow(0 0 18px rgb(0 153 255 / 36%));
  transition: all var(--timing-normal) ease;
}

/* Element cards inside canvas */

/* PHASE 6: Consolidated - Uses .card-base + .card-border-success + .card-shadow-sm + .card-scanline + .card-sm utilities */
.field-card { /* Card-specific: absolute positioning for canvas */
  border-radius: var(--space-12);
  border: 2px solid rgb(0 255 153 / 30%);
  padding: 0;

  /* OPTIMIZED: Removed backdrop-filter - element card doesn't need it */
  background: var(--space-opacity-95);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-size: var(--font-12);
  box-sizing: border-box;
  min-width: var(--space-120);
  min-height: var(--space-60);
  box-shadow: 
    0 var(--space-6) var(--space-18) rgb(0 0 0 / 40%),
    0 0 var(--space-12) rgb(0 255 153 / 10%),
    inset 0 0 var(--space-18) rgb(0 255 153 / 5%);
  transition: all var(--timing-fast) ease;
  overflow: hidden;
  position: relative;

  /* OPTIMIZED: CSS containment - isolate element card rendering (many cards on canvas) */
  contain: layout style paint;
}

:root {
  --space-120: 120px; /* 6×20 */
  --space-60: 60px;
}

/* Live Mode Styling - Hide builder UI and show clean widget elements */
.canvas-live-mode .field-card {
  display: none; /* Hide builder cards in live mode */
}

.canvas-live-mode .element-header,
.canvas-live-mode .element-header.compact {
  display: none !important; /* Hide element headers in live mode */
}

.canvas-live-mode .resize-handle {
  display: none !important; /* Hide resize handles in live mode */
}

.canvas-live-mode .connection-handle {
  display: none !important; /* Hide connection handles in live mode */
}

.canvas-live-mode .element-connection-icon {
  display: none !important; /* Hide connection icons in live mode */
}

/* Live mode widget elements should render cleanly */
.canvas-live-mode .widget-element {
  position: absolute;
  box-sizing: border-box;
}

/* Ensure live mode elements don't have builder styling */
.canvas-live-mode [id^="element-"] {
  border: none;
  box-shadow: none;
  background: transparent;
  cursor: default;
}

/* In node mode, allow handles to extend beyond card */
.canvas-node-mode .field-card {
  overflow: visible;
}

/* PHASE 6: Scanline effect uses .card-scanline utility pattern */
.field-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--green-ghost) 50%, 
    transparent 100%);
  opacity: 0;
  transition: opacity var(--timing-fast) ease;
}

/* PHASE 6: Hover state uses .card-hover utility pattern */
.field-card:hover {
  border-color: var(--green-ghost);
  box-shadow: 
    0 var(--space-9) var(--space-24) rgb(0 0 0 / 50%),
    0 0 var(--space-6) var(--glow-green),
    0 0 var(--space-12) rgb(0 255 153 / 20%);
  transform: translateY(-3px);
  background: rgb(0 255 153 / 5%);
}

.field-card:hover::before {
  opacity: 1;
}

/* PHASE 6: Selected state uses .card-selected utility pattern (with animation) */
.field-card.selected {
  border-color: var(--green-ghost);
  border-width: 3px;
  box-shadow: 
    0 0 0 3px rgb(0 255 153 / 30%),
    0 var(--space-12) var(--space-36) rgb(0 255 153 / 30%),
    0 0 var(--space-18) var(--glow-green-strong);
  background: linear-gradient(135deg, 
    var(--green-opacity-15-alt) 0%, 
    var(--space-opacity-90) 100%);
  animation: ghost-pulse 6s ease-in-out infinite;
}

.field-card.selected::before {
  opacity: 1;
  animation: scanline 1.5s linear infinite;
}

@keyframes ghost-pulse {
  0%, 100% {
    box-shadow: 
      0 0 0 3px rgb(0 255 153 / 30%),
      0 var(--space-12) var(--space-36) rgb(0 255 153 / 30%),
      0 0 var(--space-18) var(--glow-green-strong);
  }

  50% {
    box-shadow: 
      0 0 0 3px rgb(0 255 153 / 50%),
      0 var(--space-18) var(--space-48) rgb(0 255 153 / 50%),
      0 0 var(--space-24) var(--glow-green-strong);
  }
}

.field-card-label {
  font-weight: 500;
}

.field-card-meta {
  font-size: var(--font-9);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* PHASE 6: Consolidated - Can use .badge-base utility (with margin-left override if needed) */
.field-badge {
  font-size: var(--font-9);
  padding: 3px 9px;
  border-radius: 27px;
  border: 2px solid var(--blue-opacity-30);

  /* OPTIMIZED: Removed backdrop-filter - nested badge doesn't need it */
  background: var(--space-opacity-85);
  color: var(--text-secondary);
  margin-left: 6px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 0 6px rgb(0 153 255 / 10%);
}

.field-card-controls {
  display: flex;
  gap: 0.25rem;
}

.icon-btn {
  border-radius: 27px;
  border: 2px solid var(--blue-opacity-30);

  /* OPTIMIZED: Removed backdrop-filter - nested button doesn't need it */
  background: var(--space-opacity-85);
  color: var(--text-secondary);
  font-size: var(--font-9);
  padding: 3px 9px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 6px rgb(0 153 255 / 10%);
}

/* Compact Element Header */
.element-header.compact {
  padding: 12px;
  border-bottom: 2px solid rgb(0 153 255 / 30%);

  /* OPTIMIZED: Removed backdrop-filter - nested header doesn't need it */
  background: var(--space-opacity-90);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  flex-shrink: 0;
  box-shadow: 0 0 9px var(--blue-opacity-10);
}

.element-header.compact .element-label {
  font-weight: 700;
  font-size: var(--font-12);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  letter-spacing: 0.03em;
}

/* Parameter Badges */
.param-badges-container,
.connection-badges-container {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.param-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid;
}

/* PHASE 6: Can use .badge-param-input utility (hover states maintained here) */
.param-badge-input {
  background: var(--blue-opacity-20);
  border-color: var(--blue-electric);
  color: var(--blue-electric);
}

.param-badge-input:hover {
  background: rgb(0 153 255 / 30%);
  box-shadow: 0 0 6px var(--glow-blue);
}

/* PHASE 6: Can use .badge-param-output utility (hover states maintained here) */
.param-badge-output {
  background: var(--green-opacity-20);
  border-color: var(--green-ghost);
  color: var(--green-ghost);
}

.param-badge-output:hover {
  background: rgb(0 255 153 / 30%);
  box-shadow: 0 0 6px var(--glow-green);
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid;
}

/* PHASE 6: Can use .badge-connection-incoming utility */
.connection-badge-incoming {
  background: var(--cyan-opacity-20);
  border-color: var(--cyan-bright);
  color: var(--cyan-bright);
}

/* PHASE 6: Can use .badge-connection-outgoing utility */
.connection-badge-outgoing {
  background: var(--blue-opacity-20);
  border-color: var(--blue-electric);
  color: var(--blue-electric);
}

.element-body.compact {
  padding: 12px;
  flex: 1;
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* Field card body - fills remaining space in element container */
.field-card-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* In live mode, body should fill entire element */
.canvas-live-mode .field-card-body {
  height: 100%;
}

/* Form preview styling */
.form-preview {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.form-field-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-field-row label {
  font-size: var(--font-9);
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* Consolidated: Form input styles moved to index.css .form-input-base */

/* Note: Canvas-specific form inputs use border-radius: 9px variant */
.form-field-row input {
  border-radius: var(--space-9); /* Canvas variant uses larger radius */
}

/* Report preview styling */
.report-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.report-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-12);
}

.report-preview th,
.report-preview td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 2px solid rgb(0 153 255 / 20%);
}

.report-preview th {
  /* OPTIMIZED: Removed backdrop-filter - nested table header doesn't need it */
  background: var(--space-opacity-90);
  color: var(--text-primary);
  font-weight: 700;
  font-size: var(--font-9);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 0 0 9px rgb(0 153 255 / 30%);
  border-color: rgb(0 153 255 / 30%);
}

.report-preview td {
  color: var(--text-secondary);
}

.report-preview tr:hover {
  background: var(--blue-opacity-10);
  box-shadow: inset 0 0 12px rgb(0 153 255 / 10%);
}

/* Lookup preview */
.lookup-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lookup-preview select {
  padding: 9px 12px;
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;

  /* OPTIMIZED: Removed backdrop-filter - nested form element doesn't need it */
  background: var(--space-opacity-80);
  color: var(--text-primary);
  font-size: var(--font-12);
  width: 100%;
  box-sizing: border-box;
  transition: all 0.3s ease;
  box-shadow: 0 0 6px rgb(0 153 255 / 10%);
}

.lookup-preview select:focus {
  outline: none;
  border-color: var(--blue-electric);
  box-shadow: 
    0 0 12px rgb(0 153 255 / 40%),
    0 0 24px rgb(0 153 255 / 20%);
  background: rgb(0 153 255 / 5%);
}

/* Page preview */
.page-preview {
  padding: 12px;

  /* OPTIMIZED: Removed backdrop-filter - nested preview element doesn't need it */
  background: var(--space-opacity-80);
  border-radius: 9px;
  border: 2px dashed var(--blue-opacity-30);
  box-shadow: 0 0 9px var(--blue-opacity-10);
}

/* Muted text styling */
.muted {
  color: var(--text-muted);
}

.muted.small {
  font-size: var(--font-9);
  color: var(--text-muted);
}

/* Element header - legacy */
.element-header {
  padding: 6px 9px;
  min-height: 27px;

  /* OPTIMIZED: Removed backdrop-filter - nested header doesn't need it */
  background: var(--space-opacity-90);
  border-bottom: 2px solid rgb(0 153 255 / 30%);
  box-shadow: 0 0 9px var(--blue-opacity-10);
}

.element-title-group {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  overflow: hidden;
}

.element-type-badge {
  font-size: var(--font-9);
  padding: 3px 6px;

  /* OPTIMIZED: Removed backdrop-filter - small badge doesn't need it */
  background: rgb(0 153 255 / 25%);
  border-radius: 6px;
  border: 2px solid var(--blue-opacity-30);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  box-shadow: 0 0 6px rgb(0 153 255 / 20%);
}


/* Resize Handles */
.field-card .resize-handle,
.frame-container .resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: transparent;
  z-index: var(--z-dropdown);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

/* Show resize handles on hover */
.field-card:hover .resize-handle,
.frame-container:hover .resize-handle {
  opacity: 1;
  pointer-events: all;
}

/* Keep handles visible when actively resizing */
.field-card.resizing .resize-handle,
.frame-container.resizing .resize-handle {
  opacity: 1;
  pointer-events: all;
}

.resize-n {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: n-resize;
  height: 12px;
  width: 100%;
}

.resize-s {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: s-resize;
  height: 12px;
  width: 100%;
}

.resize-e {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  cursor: e-resize;
  width: 12px;
  height: 100%;
}

.resize-w {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  cursor: w-resize;
  width: 12px;
  height: 100%;
}

.resize-ne {
  top: -6px;
  right: -6px;
  cursor: ne-resize;
}

.resize-nw {
  top: -6px;
  left: -6px;
  cursor: nw-resize;
}

.resize-se {
  bottom: -6px;
  right: -6px;
  cursor: se-resize;
}

.resize-sw {
  bottom: -6px;
  left: -6px;
  cursor: sw-resize;
}

/* Stylish Corner Arrows - Cyberpunk Style */
.resize-ne::after,
.resize-nw::after,
.resize-se::after,
.resize-sw::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border: 2px solid var(--blue-electric);
  transition: all 0.3s ease;
  box-shadow: 0 0 6px rgb(0 153 255 / 60%);
}

.resize-ne::after {
  top: 2px;
  right: 2px;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 2px;
}

.resize-nw::after {
  top: 2px;
  left: 2px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 2px;
}

.resize-se::after {
  bottom: 2px;
  right: 2px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 2px;
}

.resize-sw::after {
  bottom: 2px;
  left: 2px;
  border-right: none;
  border-top: none;
  border-bottom-left-radius: 2px;
}

/* Hover effects for handles */
.resize-handle:hover::after {
  border-color: var(--green-ghost);
  width: 12px;
  height: 12px;
  box-shadow: 0 0 12px rgb(0 255 153 / 90%);
}

/* Edge resize handles - show visual indicators (dots/lines) on hover */
.resize-n::before,
.resize-s::before,
.resize-e::before,
.resize-w::before {
  content: "";
  position: absolute;
  background: var(--blue-electric);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 0 6px rgb(0 153 255 / 60%);
}

.resize-n::before,
.resize-s::before {
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
}

.resize-e::before,
.resize-w::before {
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60px;
}

.resize-n::before {
  top: 4px;
}

.resize-s::before {
  bottom: 4px;
}

.resize-e::before {
  right: 4px;
}

.resize-w::before {
  left: 4px;
}

/* Show edge indicators on parent hover */
.field-card:hover .resize-n::before,
.field-card:hover .resize-s::before,
.field-card:hover .resize-e::before,
.field-card:hover .resize-w::before,
.frame-container:hover .resize-n::before,
.frame-container:hover .resize-s::before,
.frame-container:hover .resize-e::before,
.frame-container:hover .resize-w::before {
  opacity: 1;
}

/* Arrow indicators for edge handles on hover */
.field-card:hover .resize-n,
.frame-container:hover .resize-n {
  background: radial-gradient(circle at center, rgb(0 153 255 / 20%) 0%, transparent 70%);
}

.field-card:hover .resize-s,
.frame-container:hover .resize-s {
  background: radial-gradient(circle at center, rgb(0 153 255 / 20%) 0%, transparent 70%);
}

.field-card:hover .resize-e,
.frame-container:hover .resize-e {
  background: radial-gradient(circle at center, rgb(0 153 255 / 20%) 0%, transparent 70%);
}

.field-card:hover .resize-w,
.frame-container:hover .resize-w {
  background: radial-gradient(circle at center, rgb(0 153 255 / 20%) 0%, transparent 70%);
}

/* Element Header Styles */

/* Duplicate removed - using the improved styles above */

.element-label {
  color: var(--text-primary);
  letter-spacing: 0.03em;
  font-weight: 600;
}

.element-name {
  color: var(--text-secondary);
  font-family: monospace;
  font-size: var(--font-9);
}


/* Report preview */

.report-preview {
  width: 100%;
  border-collapse: collapse;
  margin-top: 9px;
  font-size: var(--font-12);
}

.report-preview th,
.report-preview td {
  border: 2px solid rgb(0 153 255 / 20%);
  padding: 6px 9px;
}

.report-preview th {
  /* OPTIMIZED: Removed backdrop-filter - nested table header doesn't need it */
  background: var(--space-opacity-90);
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 9px rgb(0 153 255 / 30%);
  border-color: rgb(0 153 255 / 30%);
}

.report-preview tbody tr:nth-child(odd) {
  background: var(--blue-opacity-03);
}

.report-preview tbody tr:hover {
  background: var(--blue-opacity-10);
  box-shadow: inset 0 0 12px rgb(0 153 255 / 10%);
}

/* Blueprint Frozen State */
.canvas-drop-target.frozen-state {
  pointer-events: none;

  /* Disable interactions with UI elements */
  filter: grayscale(0.8) opacity(0.6);
  transition: all 0.3s ease;
}

.canvas-drop-target.frozen-state .field-card {
  border-color: #4b5563;
}

/* Ensure Blueprint SVG is on top */
#blueprintCanvasContainer {
  pointer-events: none;

  /* Let clicks pass through empty areas if needed, but we set auto in JS for the container */
}

#blueprintSvg {
  background: transparent !important;

  /* Make SVG background transparent to show layout */
}

/* Frame container styles */
.frame-container {
  position: absolute;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.frame-container.frame-element-added {
  animation: framePulse 0.6s ease;
}

@keyframes framePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgb(0 255 153 / 70%);
  }

  50% {
    transform: scale(1.02);
    box-shadow: 0 0 20px 10px rgb(0 255 153 / 40%);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgb(0 255 153 / 0%);
  }
}

/* Frame Stage Select Dropdown */
.frame-stage-select {
  font-size: 0.75rem !important;
  padding: 4px 24px 4px 8px !important;
  background: rgb(59 130 246 / 20%) !important;
  border: 1px solid rgb(59 130 246 / 40%) !important;
  border-radius: 4px !important;
  color: #93c5fd !important;
  cursor: pointer !important;
  min-width: 140px !important;
  max-width: 180px !important;
  outline: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2393c5fd' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 6px center !important;
  background-size: 12px !important;
  transition: all 0.2s !important;
  font-family: inherit !important;
}

/* PHASE 7: Removed !important from hover/focus - increased specificity with parent */
.field-card .frame-stage-select:hover,
.frame-section-content .frame-stage-select:hover {
  background-color: rgb(59 130 246 / 30%);
  border-color: rgb(59 130 246 / 50%);
}

.field-card .frame-stage-select:focus,
.frame-section-content .frame-stage-select:focus {
  background-color: rgb(59 130 246 / 30%);
  border-color: rgb(59 130 246 / 60%);
  box-shadow: 0 0 0 2px rgb(59 130 246 / 20%);
}

.frame-stage-select option {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  padding: 8px !important;
}

.frame-stage-select option:disabled {
  color: #475569 !important;
  font-style: italic !important;
}

.frame-stage-select option[value="__create_new__"] {
  color: #60a5fa !important;
  font-weight: 600 !important;
  background: rgb(59 130 246 / 10%) !important;
}

.frame-child-counter {
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.frame-child-counter.counter-updated {
  animation: counterBounce 0.4s ease;
}

@keyframes counterBounce {
  0%, 100% {
    transform: scale(1);
    background-color: rgb(0 255 153 / 20%);
  }

  50% {
    transform: scale(1.2);
    background-color: rgb(0 255 153 / 40%);
  }
}

/* Prevent frame from moving when dragging children */
.frame-content {
  pointer-events: auto;
}

.frame-container .frame-content .field-card {
  pointer-events: auto;
}

/* Only disable pointer events on frame-content when actively dragging the frame */

/* Using .dragging class instead of :active to avoid blocking child element clicks */
.frame-container.dragging .frame-content {
  pointer-events: none;
}

/* Stage Menu Styles */
.stage-menu-container {
  position: relative;
}

.stage-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 280px;
  max-width: 400px;
  max-height: 500px;

  /* OPTIMIZED: Removed backdrop-filter - dropdown menu doesn't need it */
  background: var(--space-opacity-99);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 12px;
  box-shadow: 
    0 18px 48px rgb(0 0 0 / 60%),
    0 0 36px rgb(0 153 255 / 15%);
  z-index: var(--z-notification);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stage-menu-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgb(0 153 255 / 20%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgb(0 153 255 / 5%);
}

.stage-menu-header span {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.stage-menu-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.stage-menu-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
}

.stage-menu-item {
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  border: 1px solid rgb(0 153 255 / 10%);
  background: var(--space-opacity-60);
  transition: all 0.2s ease;
}

.stage-menu-item:hover {
  background: var(--blue-opacity-10);
  border-color: rgb(0 153 255 / 30%);
}

.stage-menu-item.active {
  background: var(--blue-opacity-15);
  border-color: rgb(0 153 255 / 40%);
  box-shadow: 0 0 12px rgb(0 153 255 / 20%);
}

.stage-menu-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-menu-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.stage-menu-item-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.stage-menu-item-label strong {
  font-size: 0.875rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-menu-item-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.stage-menu-item-description {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgb(0 153 255 / 10%);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.stage-menu-item-actions {
  display: flex;
  gap: 4px;
}

.stage-menu-footer {
  padding: 12px 16px;
  border-top: 1px solid rgb(0 153 255 / 20%);
  background: rgb(0 153 255 / 5%);
}

.stage-menu-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
}

.stage-menu-toggle input[type="checkbox"] {
  cursor: pointer;
}

/* Frame disabled state */
.frame-container.frame-disabled {
  opacity: 0.3;
  pointer-events: none;
  filter: grayscale(0.5);
}

.frame-container.frame-disabled .frame-content {
  pointer-events: none;
}

.frame-container.frame-disabled .frame-content .field-card {
  pointer-events: none;
}

/* Delete Animation */
.canvas-element.deleting {
  animation: deleteBlink 1s ease forwards;
}

@keyframes deleteBlink {
  0% {
    box-shadow: 0 0 0 0 rgb(239 68 68 / 0%);
    opacity: 1;
  }

  20% {
    box-shadow: 0 0 20px 5px rgb(239 68 68 / 80%);
    border-color: #ef4444;
    opacity: 1;
  }

  100% {
    box-shadow: 0 0 40px 10px rgb(239 68 68 / 0%);
    opacity: 0;
    transform: scale(0.9);
  }
}

/* -------------------------
   Centered Canvas Code Editor
   ------------------------- */

/* PHASE 6: Consolidated - Uses .panel-base + .panel-solid + .panel-overlay utilities */
.canvas-editor-overlay {
  position: absolute;
  inset: 0;
  background: var(--space-opacity-95);
  backdrop-filter: blur(18px);
  z-index: var(--z-popover);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--timing-fast) ease;

  /* OPTIMIZED: CSS containment - isolate canvas editor overlay */
  contain: strict;
}

/* PHASE 6: Consolidated - Uses .panel-base + .panel-gradient + .panel-border-accent + .panel-shadow-modal utilities */
.canvas-editor-modal {
  width: 80%;
  height: 80%;
  background: linear-gradient(135deg, var(--space-opacity-99) 0%, var(--space-mid-alt-opacity-98) 100%);
  border: 2px solid var(--glow-blue);
  border-radius: var(--space-18);
  box-shadow: 
    0 var(--space-27) var(--space-54) rgb(0 0 0 / 90%),
    0 0 var(--space-72) var(--glow-blue);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleIn var(--timing-fast) cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(18px);
}

.editor-header {
  height: var(--space-48);
  background: var(--space-mid-alt-opacity-90);
  border-bottom: 2px solid var(--space-mid);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-18);
  box-shadow: 0 var(--space-6) var(--space-12) rgb(0 0 0 / 30%);
}

.editor-tabs {
  display: flex;
  gap: 2px;
  height: 100%;
  align-items: flex-end;
}

.editor-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-9) var(--space-18);
  font-size: var(--font-12);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--timing-fast);
  height: 100%;
  display: flex;
  align-items: center;
  letter-spacing: 0.03em;
}

.editor-tab:hover {
  color: var(--text-primary);
  background: var(--blue-opacity-10);
  border-bottom-color: var(--glow-blue);
}

.editor-tab.active {
  color: var(--cyan-bright);
  border-bottom-color: var(--blue-electric);
  background: var(--blue-opacity-15);
  box-shadow: 0 0 var(--space-12) rgb(0 153 255 / 20%);
}

/* Consolidated: Uses .flex-grow utility */
.editor-body,
.flex-grow.editor-body {
  /* flex: 1; min-height: 0; now from .flex-grow */
  position: relative;
  background: var(--space-deep);
}

.editor-body .monaco-editor {
  position: absolute;
  inset: 0;
}

/* =================================
  Element Toolbar (REMOVED)
  Toolbar functionality moved to Context Review panel
================================= */


/* ============================================================================
   CANVAS HEADER RESPONSIVENESS
   ============================================================================ */

@media (width <= 767px) {
  .canvas-header {
    flex-wrap: wrap;
    padding: 9px;
    gap: var(--space-6);
  }
  
  .canvas-header-left {
    flex: 1 1 100%;
    gap: var(--space-6);
  }
  
  .canvas-header-right {
    flex: 1 1 100%;
    justify-content: flex-end;
  }
}

@media (width <= 479px) {
  .canvas-header {
    padding: 6px;
  }
  
  .canvas-zoom-controls {
    gap: 0.2rem;
    padding: 0.2rem;
  }
  
  .canvas-zoom-level {
    min-width: 2.5rem;
    font-size: 0.7rem;
  }
}

/* ============================================================================
   CODE VIEW PANEL
   Full widget code viewer overlay - positioned below unified toolbar
   ============================================================================ */

/* PHASE 6: Consolidated - Uses .panel-base + .panel-solid + .panel-overlay + .panel-fade-in utilities */
.code-view-panel {
  position: absolute;
  inset: 180px 0 0; /* Panel-specific: Below the unified toolbar with code tabs row */

  /* OPTIMIZED: Removed backdrop-filter - panel overlay doesn't need it */
  background: rgb(3 6 9 / 99%);
  z-index: var(--z-overlay); /* Code view panel - needs to be above floating panels */
  display: flex;
  flex-direction: column;
  animation: panelFadeIn 0.25s ease-out; /* Uses .panel-fade-in animation */
  border: 2px solid var(--blue-opacity-40); /* Debug border to see the panel */

  /* OPTIMIZED: CSS containment - isolate code view panel */
  contain: layout style paint;
}

/* PHASE 6: Animation consolidated into .panel-fade-in utility */
@keyframes codeViewFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* REMOVED: .code-view-header - header moved to toolbar */

.code-view-tabs {
  display: flex;
  gap: 4px;
}

.code-view-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 8px;
  color: rgb(255 255 255 / 60%);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-view-tab i {
  font-size: 1rem;
}

.code-view-tab:hover {
  background: var(--blue-opacity-15);
  color: rgb(255 255 255 / 90%);
  border-color: rgb(0 153 255 / 30%);
}

.code-view-tab.active {
  background: rgb(0 153 255 / 25%);
  color: var(--cyan-bright, #3cf);
  border-color: var(--blue-opacity-50);
  box-shadow: 
    0 0 12px rgb(0 153 255 / 20%),
    inset 0 0 8px rgb(0 153 255 / 10%);
}

.code-view-actions {
  display: flex;
  gap: 8px;
}

.code-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 8px;
  color: rgb(255 255 255 / 60%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-view-btn i {
  font-size: 1.1rem;
}

.code-view-btn:hover {
  background: var(--blue-opacity-20);
  color: #fff;
  border-color: rgb(0 153 255 / 40%);
}

.code-view-btn:active {
  transform: scale(0.95);
}

.code-view-body {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background: linear-gradient(180deg, var(--space-opacity-95) 0%, var(--space-mid-opacity-92) 100%);

  /* OPTIMIZED: CSS containment - isolate code view scroll area */
  contain: layout style;
}

.code-view-content {
  margin: 0;
  padding: 18px;
  background: rgb(0 0 0 / 40%);
  border: 1px solid rgb(0 153 255 / 20%);
  border-radius: 12px;
  font-family: 'Fira Code', Monaco, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-x: auto;
  tab-size: 2;
}

.code-view-content code {
  display: block;
}

/* Syntax highlighting classes */
.code-view-content .code-keyword {
  color: #c792ea;
  font-weight: 600;
}

.code-view-content .code-string {
  color: #c3e88d;
}

.code-view-content .code-number {
  color: #f78c6c;
}

.code-view-content .code-comment {
  color: #546e7a;
  font-style: italic;
}

.code-view-content .code-tag {
  color: #f07178;
}

.code-view-content .code-attr {
  color: #ffcb6b;
}

.code-view-content .code-value {
  color: #82aaff;
}

.code-view-content .code-function {
  color: #82aaff;
}

.code-view-content .code-property {
  color: #89ddff;
}

.code-view-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: rgb(15 23 42 / 95%);
  border-top: 1px solid rgb(0 153 255 / 20%);
  font-size: 0.75rem;
  color: rgb(255 255 255 / 50%);
}

.code-view-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-view-info.success {
  color: var(--green-ghost, #0f9);
}

.code-view-info.error {
  color: #ef4444;
}

/* Custom scrollbar for code view */
.code-view-body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.code-view-body::-webkit-scrollbar-track {
  background: var(--space-opacity-60);
  border-radius: 5px;
}

.code-view-body::-webkit-scrollbar-thumb {
  background: var(--blue-opacity-40);
  border-radius: 5px;
  border: 2px solid rgb(3 6 9 / 60%);
}

.code-view-body::-webkit-scrollbar-thumb:hover {
  background: var(--blue-opacity-60);
}

.code-view-content::-webkit-scrollbar {
  height: 8px;
}

.code-view-content::-webkit-scrollbar-track {
  background: rgb(0 0 0 / 30%);
  border-radius: 4px;
}

.code-view-content::-webkit-scrollbar-thumb {
  background: rgb(0 153 255 / 30%);
  border-radius: 4px;
}

.code-view-content::-webkit-scrollbar-thumb:hover {
  background: rgb(0 153 255 / 50%);
}

/* ============================================================================
   CODE VIEW TOOLBAR TABS (Submenu in unified toolbar)
   ============================================================================ */

.toolbar-code-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgb(0 153 255 / 5%);
  border-top: 1px solid rgb(0 153 255 / 20%);
}

.code-toolbar-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 60%);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-toolbar-tab i {
  font-size: 0.9rem;
}

.code-toolbar-tab span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-toolbar-tab:hover {
  background: var(--blue-opacity-15);
  color: rgb(255 255 255 / 90%);
  border-color: rgb(0 153 255 / 30%);
}

.code-toolbar-tab.active {
  background: rgb(0 153 255 / 25%);
  color: var(--cyan-bright, #3cf);
  border-color: var(--blue-opacity-50);
  box-shadow: 
    0 0 12px rgb(0 153 255 / 20%),
    inset 0 0 8px rgb(0 153 255 / 10%);
}

.code-toolbar-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 50%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-toolbar-action i {
  font-size: 1rem;
}

.code-toolbar-action:hover {
  background: var(--blue-opacity-20);
  color: #fff;
  border-color: rgb(0 153 255 / 40%);
}

.code-toolbar-action:active {
  transform: scale(0.95);
}

/* ============================================================================
   NODE VIEW TOOLBAR TABS (Submenu in unified toolbar)
   ============================================================================ */

.toolbar-node-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgb(0 255 153 / 5%);
  border-top: 1px solid rgb(0 255 153 / 20%);
}

.node-toolbar-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 60%);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.node-toolbar-tab i {
  font-size: 0.9rem;
}

.node-toolbar-tab span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.node-toolbar-tab:hover {
  background: rgb(0 255 153 / 15%);
  color: rgb(255 255 255 / 90%);
  border-color: rgb(0 255 153 / 30%);
}

.node-toolbar-tab.active {
  background: rgb(0 255 153 / 25%);
  color: var(--green-ghost, #0f9);
  border-color: rgb(0 255 153 / 50%);
  box-shadow: 
    0 0 12px rgb(0 255 153 / 20%),
    inset 0 0 8px rgb(0 255 153 / 10%);
}

/* Consolidated: Node toolbar action styles moved to .toolbar-action-base above */

/* ============================================================================
   FLOW VIEW TOOLBAR TABS (Parameters | Node | Stages)
   ============================================================================ */

.toolbar-flow-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--blue-opacity-10);
  border-top: 1px solid var(--blue-opacity-30);
}

.flow-toolbar-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 60%);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.flow-toolbar-tab i {
  font-size: 0.9rem;
}

.flow-toolbar-tab span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.flow-toolbar-tab:hover {
  background: var(--blue-opacity-15);
  color: var(--text-primary);
  border-color: var(--blue-opacity-40);
}

.flow-toolbar-tab.active {
  background: var(--blue-opacity-20);
  color: var(--cyan-bright, #3cf);
  border-color: var(--blue-opacity-50);
  box-shadow: 0 0 12px var(--blue-opacity-30), inset 0 0 8px var(--blue-opacity-10);
}

.flow-toolbar-action {
  margin-left: 8px;
}

/* ============================================================================
   PARAMETERS VIEW TOOLBAR TABS (Submenu in unified toolbar)
   ============================================================================ */

.toolbar-params-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgb(255 153 0 / 5%);
  border-top: 1px solid rgb(255 153 0 / 20%);
}

.params-toolbar-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 60%);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.params-toolbar-tab i {
  font-size: 0.9rem;
}

.params-toolbar-tab span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.params-toolbar-tab:hover {
  background: rgb(255 153 0 / 15%);
  color: rgb(255 255 255 / 90%);
  border-color: rgb(255 153 0 / 30%);
}

.params-toolbar-tab.active {
  background: rgb(255 153 0 / 25%);
  color: #f90;
  border-color: rgb(255 153 0 / 50%);
  box-shadow: 
    0 0 12px rgb(255 153 0 / 20%),
    inset 0 0 8px rgb(255 153 0 / 10%);
}

/* Consolidated: Params toolbar action styles moved to .toolbar-action-base above */

/* ============================================================================
   PARAMETERS VIEW PANEL
   ============================================================================ */

/* PHASE 6: Consolidated - Uses .panel-base + .panel-solid + .panel-border-top + .panel-fade-in utilities */
.params-view-panel {
  /* Flows as submenu inside toolbar - not absolute */
  width: 100%;
  max-height: 400px;

  /* OPTIMIZED: Removed backdrop-filter - submenu panel doesn't need it */
  background: rgb(3 6 9 / 99%);
  display: flex;
  flex-direction: column;
  animation: panelFadeIn 0.25s ease-out; /* Uses .panel-fade-in animation */
  border-top: 1px solid rgb(255 153 0 / 40%);
  border-radius: 0 0 12px 12px;

  /* OPTIMIZED: CSS containment - isolate params view panel */
  contain: layout style paint;
}

/* PHASE 6: Animation consolidated into .panel-fade-in utility */
@keyframes paramsViewFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.params-view-add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: rgb(30 41 59 / 60%);
  border-bottom: 1px solid rgb(255 153 0 / 20%);
  flex-wrap: wrap;
}

.params-view-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 50%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.params-view-close:hover {
  background: rgb(255 80 80 / 20%);
  border-color: rgb(255 80 80 / 40%);
  color: #ff5050;
}

.params-view-close i {
  font-size: 1rem;
}

.stages-view-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 50%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.stages-view-close:hover {
  background: rgb(255 80 80 / 20%);
  border-color: rgb(255 80 80 / 40%);
  color: #ff5050;
}

.stages-view-close i {
  font-size: 1rem;
}

.params-input,
.params-select {
  padding: 8px 12px;
  background: rgb(15 23 42 / 80%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.params-input {
  flex: 1;
  min-width: 140px;
}

.params-input-small {
  flex: 0.5;
  min-width: 100px;
}

.params-select {
  min-width: 100px;
}

.params-input:focus,
.params-select:focus {
  outline: none;
  border-color: rgb(255 153 0 / 50%);
  box-shadow: 0 0 8px rgb(255 153 0 / 20%);
}

.params-view-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;

  /* OPTIMIZED: CSS containment - isolate params list scroll area */
  contain: layout style;
}

.params-view-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: rgb(255 255 255 / 40%);
  text-align: center;
}

.params-view-empty i {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.params-view-empty p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.params-view-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgb(30 41 59 / 40%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.params-view-item:hover {
  background: rgb(255 153 0 / 10%);
  border-color: rgb(255 153 0 / 30%);
}

.params-view-item-name {
  flex: 1;
  font-weight: 600;
  color: #e2e8f0;
}

.params-view-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.params-view-item-badge {
  padding: 3px 8px;
  background: rgb(255 153 0 / 20%);
  border: 1px solid rgb(255 153 0 / 30%);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #f90;
}

.params-view-item-badge.input {
  background: var(--blue-opacity-20);
  border-color: rgb(0 153 255 / 30%);
  color: #3cf;
}

.params-view-item-badge.output {
  background: var(--green-opacity-20);
  border-color: rgb(0 255 153 / 30%);
  color: #0f9;
}

.params-view-item-default {
  font-size: 0.8rem;
  color: rgb(255 255 255 / 50%);
  font-style: italic;
}

.params-view-item-actions {
  display: flex;
  gap: 4px;
}

.params-view-item-actions button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 4px;
  color: rgb(255 255 255 / 50%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.params-view-item-actions button:hover {
  background: rgb(255 80 80 / 20%);
  border-color: rgb(255 80 80 / 40%);
  color: #ff5050;
}

.params-view-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgb(15 23 42 / 60%);
  border-top: 1px solid rgb(255 153 0 / 20%);
  font-size: 0.8rem;
  color: rgb(255 255 255 / 50%);
}

/* ============================================================================
   STAGES VIEW TOOLBAR TABS (Submenu in unified toolbar)
   ============================================================================ */

.toolbar-stages-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgb(153 0 255 / 5%);
  border-top: 1px solid rgb(153 0 255 / 20%);
}

.stages-toolbar-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 60%);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stages-toolbar-tab i {
  font-size: 0.9rem;
}

.stages-toolbar-tab span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stages-toolbar-tab:hover {
  background: rgb(153 0 255 / 15%);
  color: rgb(255 255 255 / 90%);
  border-color: rgb(153 0 255 / 30%);
}

.stages-toolbar-tab.active {
  background: rgb(153 0 255 / 25%);
  color: #c6f;
  border-color: rgb(153 0 255 / 50%);
  box-shadow: 
    0 0 12px rgb(153 0 255 / 20%),
    inset 0 0 8px rgb(153 0 255 / 10%);
}

/* Consolidated: Stages toolbar action styles moved to .toolbar-action-base above */

/* ============================================================================
   STAGES VIEW PANEL
   ============================================================================ */

/* PHASE 6: Consolidated - Uses .panel-base + .panel-solid + .panel-border-top + .panel-fade-in utilities */
.stages-view-panel {
  /* Flows as submenu inside toolbar - not absolute */
  width: 100%;
  max-height: 400px;

  /* OPTIMIZED: Removed backdrop-filter - submenu panel doesn't need it */
  background: rgb(3 6 9 / 99%);
  display: flex;
  flex-direction: column;
  animation: panelFadeIn 0.25s ease-out; /* Uses .panel-fade-in animation */
  border-top: 1px solid rgb(153 0 255 / 40%);
  border-radius: 0 0 12px 12px;

  /* OPTIMIZED: CSS containment - isolate stages view panel */
  contain: layout style paint;
}

@keyframes stagesViewFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stages-view-add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: rgb(30 41 59 / 60%);
  border-bottom: 1px solid rgb(153 0 255 / 20%);
  flex-wrap: wrap;
}

.stages-input {
  padding: 8px 12px;
  background: rgb(15 23 42 / 80%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  min-width: 150px;
}

.stages-input-wide {
  flex: 1;
  min-width: 200px;
}

.stages-input:focus {
  outline: none;
  border-color: rgb(153 0 255 / 50%);
  box-shadow: 0 0 8px rgb(153 0 255 / 20%);
}

.stages-view-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;

  /* OPTIMIZED: CSS containment - isolate stages list scroll area */
  contain: layout style;
}

/* Scaffolding: less=bottom-left, more=top-right; each level one row lower, incremental left-to-right */
.stages-view-list--cascade {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 0;
}

.stages-view-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: rgb(255 255 255 / 40%);
  text-align: center;
}

.stages-view-empty i {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.stages-view-empty p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.stages-view-group {
  margin-bottom: 16px;
  margin-left: var(--cascade-offset, 0);
  border-left: 2px solid rgb(153 0 255 / 35%);
  padding-left: 12px;
  min-width: 0;
}

.stages-view-group:last-child {
  margin-bottom: 0;
}

.stages-view-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(255 255 255 / 50%);
  margin-bottom: 8px;
  padding-left: 0;
}

.stages-view-group .stages-view-item:last-child {
  margin-bottom: 0;
}

.stages-view-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgb(30 41 59 / 40%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.stages-view-item:hover {
  background: rgb(153 0 255 / 10%);
  border-color: rgb(153 0 255 / 30%);
}

.stages-view-item.active {
  background: rgb(153 0 255 / 15%);
  border-color: rgb(153 0 255 / 50%);
  box-shadow: 0 0 12px rgb(153 0 255 / 20%);
}

.stages-view-item-radio {
  width: 18px;
  height: 18px;
  accent-color: #c6f;
}

.stages-view-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stages-view-item-name {
  font-weight: 600;
  color: #e2e8f0;
}

.stages-view-item-meta {
  font-size: 0.75rem;
  color: rgb(255 255 255 / 50%);
}

.stages-view-item-actions {
  display: flex;
  gap: 4px;
}

.stages-view-item-actions button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(30 41 59 / 60%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 4px;
  color: rgb(255 255 255 / 50%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.stages-view-item-actions button:hover {
  background: rgb(153 0 255 / 20%);
  border-color: rgb(153 0 255 / 40%);
  color: #c6f;
}

.stages-view-item-actions button.danger:hover {
  background: rgb(255 80 80 / 20%);
  border-color: rgb(255 80 80 / 40%);
  color: #ff5050;
}

.stages-view-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgb(15 23 42 / 60%);
  border-top: 1px solid rgb(153 0 255 / 20%);
  font-size: 0.8rem;
  color: rgb(255 255 255 / 50%);
}

.stages-show-all-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.stages-show-all-toggle input {
  accent-color: #c6f;
}

.stages-show-all-toggle span {
  color: rgb(255 255 255 / 60%);
}

/* Element Inspector Mode - Global cursor override */
body.inspector-active,
body.inspector-active * {
  cursor: crosshair !important;
}

/* Element Inspector Mode - Clean, no blue overlay */
#canvasContent.inspector-mode,
#canvasDropZone.inspector-mode {
  position: relative;
}

#canvasContent.inspector-mode *,
#canvasDropZone.inspector-mode * {
  cursor: crosshair !important;
}

/* JS-driven hover in clip mode: .inspector-hover applied to element under cursor */
.inspector-hover {
  outline: 2px solid #10b981 !important;
  outline-offset: 1px !important;
  box-shadow: 0 0 0 3px rgb(16 185 129 / 20%) !important;
  cursor: crosshair !important;
  z-index: 9999;
}

#canvasContent.inspector-mode .element:hover,
#canvasContent.inspector-mode .field-card:hover,
#canvasContent.inspector-mode .widget-element:hover,
#canvasContent.inspector-mode > *:hover,
#canvasDropZone.inspector-mode .element:hover,
#canvasDropZone.inspector-mode .field-card:hover,
#canvasDropZone.inspector-mode .widget-element:hover,
#canvasDropZone.inspector-mode > *:hover {
  outline: 2px solid #10b981 !important;
  outline-offset: 1px !important;
  box-shadow: 0 0 0 3px rgb(16 185 129 / 20%) !important;
  cursor: crosshair !important;
  z-index: 9999;
}

.element-inspected {
  outline: 3px solid #10b981 !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgb(16 185 129 / 30%) !important;
  animation: inspectPulse 1s ease-in-out;
  z-index: 9999 !important;
}

@keyframes inspectPulse {
  0%, 100% {
    box-shadow: 0 0 0 4px rgb(16 185 129 / 30%);
  }

  50% {
    box-shadow: 0 0 0 8px rgb(16 185 129 / 50%);
  }
}

/* Inspector Toggle Button */
#inspectorToggleBtn {
  position: relative;
}

#inspectorToggleBtn.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 30%);
}

#inspectorToggleBtn.active::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid white;
  animation: pulse 2s infinite;
}

/* Iframe Overlay for Inspector Mode */
.inspector-iframe-overlay {
  position: absolute;
  background: rgb(59 130 246 / 10%);
  border: 2px dashed rgb(59 130 246 / 50%);
  cursor: crosshair;
  pointer-events: auto;
  z-index: 9998;
  transition: background 0.2s ease;
}

.inspector-iframe-overlay:hover {
  background: rgb(59 130 246 / 20%);
  border-color: rgb(59 130 246 / 80%);
}

.inspector-iframe-overlay::before {
  content: '✂️ Click to clip embedded content';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgb(15 23 42 / 95%);
  color: #60a5fa;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
}

.inspector-iframe-overlay:hover::before {
  opacity: 1;
}

/* Inspector Copy Button Animations */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

