.logic-builder {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.logic-body {
  display: flex;
  flex: 1;
  min-height: max(620px, calc(100vh - 190px));
  min-height: max(620px, calc(100dvh - 190px));
  overflow: auto;
}

.logic-toolbox {
  width: 220px;
  padding: 12px;
  border-right: 1px solid #ddd;
  background: #f8fafc;
}

.logic-item {
  padding: 10px;
  margin-bottom: 10px;
  background: white;
  border-radius: 8px;
  cursor: grab;
  border: 1px solid #ddd;
}

.logic-save-status {
  margin-top: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef2f7;
  color: #64748b;
  font-size: 12px;
  line-height: 1.3;
}

.logic-save-status[data-state="saving"] {
  color: #2563eb;
}

.logic-save-status[data-state="saved"] {
  color: #15803d;
}

.logic-save-status[data-state="error"] {
  background: #fef2f2;
  color: #dc2626;
}

.logic-canvas {
  flex: 1;
  min-width: 900px;
  min-height: 100%;
  position: relative;
  background: #f1f5f9;
}

.logic-connections {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: auto
}

.logic-line {
  stroke: #3b82f6;
  stroke-width: 2;
  fill: none;
  cursor: pointer;
}

.logic-node {
  position: absolute;
  padding: 10px 20px;
  background: white;
  border-radius: 10px;
  border: 1px solid #ccc;
  cursor: grab;
  user-select: none;
}

.logic-node-delete {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  font-size: 19px;
  line-height: 1;
}

.logic-node-delete:hover {
  background: #fee2e2;
  color: #dc2626;
}

.logic-entity-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.logic-create-entity,
.logic-edit-entity {
  flex: 1 1 0;
  padding: 5px 8px;
  border: 1px dashed #93c5fd;
  border-radius: 7px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
}

.logic-edit-entity {
  border-style: solid;
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #475569;
}

.logic-node.dragging {
  cursor: grabbing;
}

.logic-node select,
.logic-node input,
.logic-node button {
  cursor: pointer;
  user-select: auto;
}

/* Text */
.node-label {
  pointer-events: none;
}

/* 🔵 Output Punkt */
.node-output {
  width: 10px;
  height: 10px;
  background: #3b82f6;
  border-radius: 50%;
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  cursor: crosshair;
}

.node-input {
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  position: absolute;
  left: -5px;
  cursor: crosshair;
}

.node-input.top {
  top: 30%;
}

.node-input.bottom {
  top: 70%;
}

.node-input.center {
  top: 50%;
  transform: translateY(-50%);
}

.connecting .node-output {
  opacity: 0.3;
  pointer-events: none;   /* 🔥 kann nicht mehr geklickt werden */
}

.connecting .node-input {
  opacity: 1;
  cursor: crosshair;
}

.operator-select {
  width: 100%;
  margin-top: 5px;
}

.entity-select {
  width: 220px;
  max-width: 220px;
}

.logic-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.48);
}

.logic-dialog {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

.logic-dialog h3 {
  margin: 0 0 18px;
}

.logic-dialog label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
}

.logic-dialog input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
}

.logic-dialog-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.logic-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .logic-body {
    min-height: calc(100dvh - 150px);
  }

  .logic-toolbox {
    width: 180px;
    flex: 0 0 180px;
  }
}
