/* CUI Data Flow Editor */
#dh-dataflow-host {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: calc(100dvh - 7.5rem);
  overflow: hidden;
}

#diagram-hub-content.dh-view-dataflow:has(.dfe-root) {
  overflow: hidden;
  height: calc(100dvh - var(--dfe-hub-top, 8rem));
  max-height: calc(100dvh - var(--dfe-hub-top, 8rem));
}

#diagram-hub-content.dh-view-dataflow:has(.dfe-root) .dh-header {
  display: none;
}

#diagram-hub-content.dh-view-dataflow:has(.dfe-root) .dh-tabs {
  margin-bottom: 6px;
}

.dfe-root {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  min-height: 0;
  max-height: calc(100dvh - 10.5rem);
  overflow: hidden;
  --dfe-bg: var(--bg-secondary, #1e2128);
  --dfe-panel: var(--bg-tertiary, #2c313a);
  --dfe-border: var(--border-color, #3e4452);
  --dfe-text: var(--text-primary, #abb2bf);
  --dfe-muted: var(--text-muted, #5c6370);
  --dfe-accent: var(--accent-blue, #7aa2f7);
  color: var(--dfe-text);
  font-size: 0.85rem;
}

.dfe-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--dfe-panel);
  border: 1px solid var(--dfe-border);
  border-radius: 8px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.dfe-toolbar-spacer { flex: 1; min-width: 8px; }

.dfe-field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--dfe-muted);
}

.dfe-field-inline .dfe-input { width: 200px; }

.dfe-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.dfe-speed input[type="range"] { width: 100px; }

.dfe-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 280px);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "canvas panels";
  gap: 10px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
  position: relative;
  overflow: hidden;
}

.dfe-canvas-wrap {
  grid-area: canvas;
  position: relative;
  background: var(--dfe-bg);
  border: 1px solid var(--dfe-border);
  border-radius: 8px;
  overflow: visible;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

@media (max-width: 960px) {
  .dfe-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(96px, min(30vh, 240px)) minmax(0, 1fr);
    grid-template-areas:
      "canvas"
      "panels";
  }

  .dfe-root {
    max-height: calc(100dvh - 5.5rem);
  }

  #dh-dataflow-host {
    max-height: calc(100dvh - 5.5rem);
  }
}

.dfe-svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 220px;
  max-height: 100%;
  background: radial-gradient(ellipse at 30% 20%, rgba(122, 162, 247, 0.06), transparent 55%),
    var(--dfe-bg);
  touch-action: none;
}

.dfe-marker { fill: #828997; }

.dfe-zone-rect {
  fill: rgba(122, 162, 247, 0.04);
  stroke: #4b5263;
  stroke-width: 1.5;
  stroke-dasharray: 8 6;
}

.dfe-zone-label {
  fill: var(--dfe-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dfe-boundary-rect {
  fill: none;
  stroke-width: 2;
  stroke-dasharray: 10 6;
  opacity: 0.95;
}

.dfe-boundary.is-oos .dfe-boundary-rect { opacity: 0.45; }

.dfe-boundary-label {
  fill: var(--dfe-text);
  font-size: 12px;
  font-weight: 600;
}

.dfe-boundary-flag {
  fill: #8B5CF6;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.dfe-edge-path {
  stroke: #565c69;
  stroke-width: 2;
}

.dfe-edge-label {
  fill: #9da5b4;
  font-size: 11px;
  pointer-events: none;
}

.dfe-edge-flow {
  stroke: var(--dfe-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 8 14;
  opacity: 0.85;
  pointer-events: none;
  animation: dfe-flow-anim var(--dfe-flow-speed, 1.2s) linear infinite;
}

@keyframes dfe-flow-anim {
  to { stroke-dashoffset: -44; }
}

.dfe-node { cursor: grab; }
.dfe-node:active { cursor: grabbing; }

.dfe-node.is-selected .dfe-node-rect {
  stroke-width: 3;
  filter: drop-shadow(0 0 10px rgba(122, 162, 247, 0.45));
}

.dfe-node-rect {
  stroke-width: 2;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.dfe-node-type {
  fill: var(--dfe-muted);
  font-size: 10px;
  pointer-events: none;
}

.dfe-node-label {
  fill: var(--dfe-text);
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

.dfe-node-cat {
  fill: #828997;
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}

.dfe-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 12px;
  border-top: 1px solid var(--dfe-border);
  font-size: 0.75rem;
  color: var(--dfe-muted);
}

.dfe-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}


.dfe-legend-scope {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.dfe-legend-heading {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dfe-muted);
}

.dfe-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.dfe-scope-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
}

.dfe-scope-hint {
  margin: -2px 0 8px;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--dfe-muted);
}

.dfe-node-cat {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  pointer-events: none;
}

.dfe-node-type {
  opacity: 0.9;
}

.dfe-swatch-ext { background: #61afef; }
.dfe-swatch-proc { background: #7aa2f7; }
.dfe-swatch-data { background: #98c379; }
.dfe-swatch-sec { background: #e5c07b; }

.dfe-panels {
  grid-area: panels;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.dfe-panel {
  background: var(--dfe-panel);
  border: 1px solid var(--dfe-border);
  border-radius: 8px;
  padding: 12px;
}

.dfe-panel h3 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dfe-text);
}

.dfe-panel label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.75rem;
  color: var(--dfe-muted);
}

.dfe-panel-scroll { max-height: none; overflow-y: visible; }

.dfe-input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--dfe-border);
  background: var(--dfe-bg);
  color: var(--dfe-text);
  font-size: 0.82rem;
  box-sizing: border-box;
}

.dfe-input-sm { margin-top: 0; padding: 4px 8px; font-size: 0.78rem; }

.dfe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.dfe-btn-block { width: 100%; margin-top: 4px; }

.dfe-btn-primary {
  background: var(--dfe-accent);
  color: #fff;
}

.dfe-btn-primary:hover { filter: brightness(1.08); }

.dfe-btn-secondary {
  background: #353b45;
  color: var(--dfe-text);
  border-color: var(--dfe-border);
}

.dfe-btn-ghost {
  background: transparent;
  color: var(--dfe-text);
  border-color: var(--dfe-border);
}

.dfe-btn-ghost:hover { background: rgba(255, 255, 255, 0.04); }

.dfe-btn-icon {
  border: none;
  background: transparent;
  color: #e06c75;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.dfe-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.dfe-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(62, 68, 82, 0.6);
}

.dfe-list-item .dfe-list-meta {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  color: var(--dfe-muted);
}

.dfe-count {
  font-weight: 400;
  color: var(--dfe-muted);
  font-size: 0.75rem;
}

.dfe-boundary-bar {
  cursor: move;
  opacity: 0.92;
}

.dfe-boundary-resize {
  cursor: nwse-resize;
  opacity: 0.95;
}

.dfe-boundary.is-selected .dfe-boundary-rect {
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(198, 120, 221, 0.35));
}

.dfe-list-item.is-selected {
  background: rgba(122, 162, 247, 0.08);
  border-radius: 6px;
  margin: 0 -4px;
  padding-left: 4px;
  padding-right: 4px;
}

.dfe-bnd-color {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--dfe-border);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

.dfe-toggle-sm {
  font-size: 0.68rem;
  white-space: nowrap;
}

.dfe-list-item[data-bound-item] {
  grid-template-columns: auto 1fr auto auto;
  gap: 6px;
}

.dfe-list-empty {
  color: var(--dfe-muted);
  font-size: 0.78rem;
  padding: 8px 4px;
  list-style: none;
}


/* ── Canvas chrome & grid ── */
/* layout positioning handled above */

.dfe-canvas-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(108, 138, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108, 138, 255, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 20%, transparent 100%);
}

.dfe-canvas-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: rgba(171, 178, 191, 0.85);
  background: rgba(30, 33, 40, 0.72);
  border: 1px solid rgba(108, 138, 255, 0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: none;
  white-space: nowrap;
}

/* ── Inline inspector popover ── */
.dfe-inspector-host {
  position: absolute;
  z-index: 20;
  width: min(300px, calc(100% - 24px));
  animation: dfe-inspector-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes dfe-inspector-in {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dfe-inspector {
  background: rgba(36, 40, 48, 0.92);
  border: 1px solid rgba(108, 138, 255, 0.35);
  border-radius: 14px;
  padding: 14px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 18px 48px rgba(0, 0, 0, 0.45),
    0 0 32px rgba(108, 138, 255, 0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.dfe-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dfe-inspector-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dfe-inspector-close {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--dfe-muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.dfe-inspector-close:hover { color: var(--dfe-text); background: rgba(255, 255, 255, 0.1); }

.dfe-inspector-field {
  display: block;
  margin-bottom: 10px;
}

.dfe-inspector-field > span {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dfe-muted);
  margin-bottom: 5px;
}

.dfe-inspector-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid rgba(108, 138, 255, 0.2);
  background: rgba(20, 22, 28, 0.85);
  color: var(--dfe-text);
  font-size: 0.84rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dfe-inspector-input:focus {
  outline: none;
  border-color: var(--accent-blue, #6c8aff);
  box-shadow: 0 0 0 3px rgba(108, 138, 255, 0.18);
}

.dfe-inspector-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.dfe-inspector-color {
  width: 44px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--dfe-border);
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
}

.dfe-inspector-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  margin-bottom: 10px;
  cursor: pointer;
}

.dfe-inspector-route {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: var(--dfe-muted);
}

.dfe-inspector-route span { color: var(--accent-blue, #6c8aff); }

.dfe-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dfe-scope-pill,
.dfe-type-pill {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--dfe-text);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.dfe-scope-pill i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pill-color, #8B5CF6);
  margin-right: 5px;
  vertical-align: middle;
}

.dfe-scope-pill.is-active,
.dfe-type-pill.is-active {
  border-color: var(--pill-color, var(--accent-blue, #6c8aff));
  box-shadow: 0 0 0 2px rgba(108, 138, 255, 0.2);
  background: rgba(108, 138, 255, 0.12);
}

.dfe-inspector-foot {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.dfe-inspector-primary,
.dfe-inspector-danger {
  flex: 1;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.dfe-inspector-primary {
  background: linear-gradient(135deg, rgba(108, 138, 255, 0.95), rgba(88, 118, 235, 0.95));
  color: #fff;
}

.dfe-inspector-danger {
  background: transparent;
  border-color: rgba(224, 108, 117, 0.35);
  color: #e06c75;
}

/* ── Edge hit targets & selection ── */
.dfe-edge-hit {
  stroke: transparent;
  stroke-width: 14;
  cursor: pointer;
}

.dfe-edge.is-selected .dfe-edge-path {
  stroke: var(--accent-blue, #6c8aff);
  stroke-width: 2.5;
}

.dfe-node:hover .dfe-node-rect {
  filter: drop-shadow(0 0 12px rgba(108, 138, 255, 0.25));
}

/* ── AI panel ── */
.dfe-btn-ai {
  background: linear-gradient(135deg, rgba(108, 138, 255, 0.18), rgba(168, 85, 247, 0.14));
  border: 1px solid rgba(108, 138, 255, 0.45);
  color: #c4d0ff;
  box-shadow: 0 0 20px rgba(108, 138, 255, 0.08);
}

.dfe-btn-ai.is-active,
.dfe-btn-ai:hover {
  background: linear-gradient(135deg, rgba(108, 138, 255, 0.28), rgba(168, 85, 247, 0.22));
  border-color: rgba(168, 85, 247, 0.5);
}

.dfe-ai-panel {
  position: absolute;
  top: 0;
  right: 330px;
  width: min(340px, calc(100vw - 380px));
  max-height: calc(100vh - 240px);
  overflow: auto;
  z-index: 30;
  padding: 16px;
  border-radius: 16px;
  background: rgba(28, 31, 38, 0.94);
  border: 1px solid rgba(108, 138, 255, 0.28);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: dfe-inspector-in 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 1100px) {
  .dfe-ai-panel {
    right: 12px;
    top: auto;
    bottom: 12px;
    width: min(360px, calc(100% - 24px));
  }
}

.dfe-ai-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.dfe-ai-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.dfe-ai-sub {
  margin: 4px 0 0;
  font-size: 0.72rem;
  color: var(--dfe-muted);
}

.dfe-ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.dfe-ai-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(108, 138, 255, 0.25);
  background: rgba(108, 138, 255, 0.08);
  color: var(--dfe-text);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.dfe-ai-chip:hover {
  background: rgba(108, 138, 255, 0.16);
  border-color: rgba(108, 138, 255, 0.45);
}

.dfe-ai-prompt {
  width: 100%;
  box-sizing: border-box;
  min-height: 72px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--dfe-border);
  background: rgba(20, 22, 28, 0.85);
  color: var(--dfe-text);
  font-size: 0.8rem;
  resize: vertical;
}

.dfe-btn-ai-block {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(135deg, #6c8aff, #a855f7);
  color: #fff;
  border: none;
  font-weight: 600;
}

.dfe-ai-status {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--dfe-muted);
  min-height: 1em;
}

.dfe-ai-result {
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
}

.dfe-ai-result pre {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.dfe-ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--dfe-muted);
}

.dfe-ai-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-blue, #6c8aff);
  animation: dfe-ai-pulse 1s ease-in-out infinite;
}

@keyframes dfe-ai-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.dfe-ai-error {
  padding: 10px;
  border-radius: 10px;
  background: rgba(224, 108, 117, 0.12);
  border: 1px solid rgba(224, 108, 117, 0.35);
  color: #e06c75;
  font-size: 0.78rem;
}


/* ── Viewport-fitted builder layout ── */
.dfe-canvas-stage {
  position: relative;
  flex: 1;
  min-height: 220px;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
}

.dfe-panel-palette {
  flex-shrink: 0;
}

.dfe-panel-inventory {
  flex-shrink: 0;
}

.dfe-panel-inventory > summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dfe-text);
  user-select: none;
}

.dfe-panel-inventory > summary::-webkit-details-marker {
  display: none;
}

.dfe-panel-inventory > summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  margin-right: 6px;
  color: var(--dfe-muted);
  transition: transform 0.15s ease;
}

.dfe-panel-inventory[open] > summary::before {
  transform: rotate(90deg);
}

.dfe-inventory-scroll {
  padding-right: 2px;
}

.dfe-node-palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.dfe-palette-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 8px;
  border: 1px solid var(--dfe-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--dfe-text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.dfe-palette-btn:hover {
  background: rgba(108, 138, 255, 0.08);
  border-color: rgba(108, 138, 255, 0.35);
}

.dfe-palette-btn.is-active {
  border-color: var(--palette-stroke, var(--dfe-accent));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--palette-stroke, var(--dfe-accent)) 25%, transparent);
  background: rgba(108, 138, 255, 0.12);
}

.dfe-palette-icon {
  font-size: 1rem;
  line-height: 1;
  color: var(--palette-stroke, var(--dfe-accent));
}

.dfe-palette-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--dfe-muted);
}

.dfe-panel-body-flat {
  padding: 0;
}

.dfe-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dfe-add-grid .dfe-span-2 {
  grid-column: 1 / -1;
}

.dfe-toolbar-menu {
  position: relative;
}

.dfe-toolbar-menu > summary {
  list-style: none;
  cursor: pointer;
}

.dfe-toolbar-menu > summary::-webkit-details-marker {
  display: none;
}

.dfe-toolbar-menu-body {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 168px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--dfe-border);
  background: var(--dfe-panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.dfe-toolbar-menu:not([open]) .dfe-toolbar-menu-body {
  display: none;
}

.dfe-toggle-compact {
  font-size: 0.76rem;
}

.dfe-speed-inline input[type="range"] {
  width: 72px;
}

@media (max-width: 960px) {
  .dfe-root {
    max-height: calc(100dvh - 5.5rem);
  }

  .dfe-toolbar {
    padding: 6px 10px;
    gap: 6px;
  }

  .dfe-field-inline .dfe-input {
    width: 120px;
  }

  .dfe-speed-inline {
    display: none;
  }

  .dfe-node-palette {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dfe-palette-label {
    font-size: 0.58rem;
  }
}

.dfe-inventory-label {
  margin: 8px 0 4px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dfe-muted);
}

.dfe-inventory-label:first-child {
  margin-top: 0;
}

.dfe-panel-add {
  padding: 0;
}

.dfe-panel-add > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dfe-text);
  user-select: none;
}

.dfe-panel-add > summary::-webkit-details-marker {
  display: none;
}

.dfe-panel-add > summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  margin-right: 6px;
  color: var(--dfe-muted);
  transition: transform 0.15s ease;
}

.dfe-panel-add[open] > summary::before {
  transform: rotate(90deg);
}

.dfe-panel-body {
  padding: 0 12px 12px;
}

.dfe-panel-body label {
  margin-bottom: 8px;
}

.dfe-inspector-host {
  pointer-events: none;
}

.dfe-inspector-host:not([hidden]) {
  pointer-events: auto;
}

@media (max-width: 960px) {
  .dfe-ai-panel {
    right: 12px;
    top: auto;
    bottom: 12px;
    width: min(360px, calc(100% - 24px));
  }
}
