/* === Action chips ============================================================ */
.node-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 4px; }
.node-actions a {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s;
  white-space: nowrap;
}
.action-edit         { background: #ede7f6; color: #4527a0; }
.action-edit:hover   { background: #d1c4e9; }
.action-edit--active { background: #4527a0; color: #fff; font-weight: 600; }
.action-edit--active:hover { background: #311b92; }
.action-add          { background: var(--c-primary-lt); color: var(--c-primary); }
.action-add:hover    { background: #bbdefb; }
.action-delete       { background: #ffebee; color: #c62828; }
.action-delete:hover { background: #ffcdd2; }
.action-add-wrap     { position: relative; display: inline-flex; }
.action-add-btn {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: var(--c-primary-lt);
  color: var(--c-primary);
  transition: background .12s;
  white-space: nowrap;
}
.action-add-btn:hover { background: #bbdefb; }
.action-add-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  min-width: 110px;
  overflow: hidden;
}
.action-add-menu-item {
  padding: 7px 14px;
  font-size: 12px;
  cursor: pointer;
  color: var(--c-primary);
  transition: background .1s;
}
.action-add-menu-item:hover { background: var(--c-primary-lt); }
.btn-node-delete {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #ccc;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  transition: color .15s;
}
.btn-node-delete:hover { color: #c62828; }

.btn-node-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #bbb;
  font-size: 13px;
  line-height: 1;
  padding: 0 3px;
  cursor: pointer;
  transition: color .15s;
  vertical-align: middle;
}
.btn-node-copy:hover { color: #4527a0; }

.btn-node-paste {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #4527a0;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  transition: color .15s, opacity .15s;
  vertical-align: middle;
}
.btn-node-paste:hover { color: #311b92; }
.btn-node-paste--hidden { display: none; }

/* === Collapsible action panels =============================================== */
.node-body {
  margin-top: 8px;
  padding-left: 10px;
  border-left: 2px solid var(--c-border);
}
.hidden-panel {
  margin-top: 6px;
  padding: 8px;
  background: #fafbfc;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--c-text-2);
}
.hidden-panel input[type=text],
.hidden-panel input[type=number],
.hidden-panel select {
  width: 100%;
  margin-top: 3px;
  padding: 4px 7px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--c-text);
  background: #fff;
}
.hidden-panel input[type=text]:focus,
.hidden-panel input[type=number]:focus,
.hidden-panel select:focus { outline: none; border-color: var(--c-primary); }
.hidden-panel input[type=checkbox] { width: auto; accent-color: var(--c-primary); }
.logic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-2);
  margin-bottom: 6px;
  letter-spacing: .2px;
}

/* === Visibility (enableWhen) panel ========================================== */
.vis-behavior-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  margin-bottom: 6px;
}
.vis-behavior-sel { min-width: 90px; }
.vis-cond-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 5px;
}
.vis-cond-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
/* Custom question picker */
.vis-q-sel {
  position: relative;
  min-width: 130px;
  max-width: 200px;
  flex-shrink: 1;
}
.vis-q-sel-trigger {
  height: 26px;
  padding: 0 20px 0 6px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 26px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 6px center;
  user-select: none;
}
.vis-q-sel-trigger:hover { border-color: var(--c-primary); }
.vis-q-sel-drop {
  position: fixed;
  max-width: 340px;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.14);
  z-index: 10200;
}
.vis-q-sel-opt {
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vis-q-sel-opt:hover { background: #f0f4ff; }
.vis-q-sel-opt--sel { background: #eef2ff; color: var(--c-primary); font-weight: 600; }
.vis-q-sel-search {
  display: block;
  position: sticky;
  top: 0;
  width: calc(100% - 16px);
  margin: 6px 8px 4px;
  padding: 3px 7px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 11px;
  background: #fff;
  outline: none;
  box-sizing: border-box;
  z-index: 1;
}
.vis-q-sel-search:focus { border-color: var(--c-primary); }
.vis-cond-op-wrap { min-width: 80px; max-width: 130px; }
.vis-cond-val-inp {
  height: 24px;
  padding: 0 5px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 11px;
  max-width: 120px;
}
.vis-cond-rm {
  height: 22px;
  padding: 0 6px;
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: var(--r-sm);
  color: #c0392b;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.vis-cond-rm:hover { background: #ffeaea; }
.vis-add-btn {
  height: 26px;
  padding: 0 10px;
  background: none;
  border: 1px dashed var(--c-primary);
  border-radius: var(--r-sm);
  color: var(--c-primary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}
.vis-add-btn:hover  { background: #eef2ff; }
.vis-add-btn--mt    { margin-top: 6px; }
.vis-expr-sep {
  margin: 8px 0 4px;
  font-size: 10px;
  color: var(--c-text-2);
  text-align: center;
}

/* === Constraint panel ======================================================== */
.constraint-empty-msg { color: var(--c-text-2); }
.constraint-card {
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  margin-bottom: 6px;
  background: #fafafa;
}
.constraint-card-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.constraint-key {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.constraint-sev-sel { min-width: 80px; max-width: 140px; }
.constraint-field-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.constraint-field-lbl {
  font-size: 10px;
  color: var(--c-text-2);
  width: 64px;
  flex-shrink: 0;
}
.constraint-inp {
  flex: 1;
  min-width: 0;
}
.constraint-expr-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.expr-explain-btn {
  align-self: flex-end;
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  border: 1px solid var(--c-primary);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-primary);
  cursor: pointer;
  white-space: nowrap;
}
.expr-explain-btn:hover { background: var(--c-primary-lt); }

/* === Panel element classes =================================================== */
.panel-raw-lbl     { margin-top: 8px; font-size: 10px; color: #aaa; text-transform: uppercase; letter-spacing: .05em; }
.panel-raw-lbl--sm { margin-top: 4px; }
.panel-inp-sm        { width: 70px; }
.panel-inp-textarea  { width: 100%; resize: none; min-height: 1.5em; max-height: 80px; overflow-y: auto; line-height: 1.4; box-sizing: border-box; }
.expr-textarea {
  width: 100%; box-sizing: border-box;
  padding: 4px 7px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 12px; font-family: 'SFMono-Regular', Consolas, monospace;
  color: var(--c-text); background: #fff;
  resize: vertical;
  line-height: 1.4;
  overflow-y: hidden;
}
.expr-textarea:focus { outline: none; border-color: var(--c-primary); }
.panel-sub-section { margin-top: 4px; }
.panel-color-inp   { width: 36px; height: 22px; padding: 1px; border: 1px solid #ccc; cursor: pointer; }
.panel-color-clear { font-size: 10px; padding: 1px 5px; }
.panel-hint        { color: var(--c-text-2); font-size: 10px; }
.panel-hint--mt    { margin-top: 8px; }

/* === Preview search ========================================================= */
.search-wrap { display: inline-flex; align-items: center; gap: 3px; }
.search-input {
  width: 140px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--c-text);
  background: var(--c-surface);
  transition: border-color .15s, width .2s;
  outline: none;
}
.search-input:focus { border-color: var(--c-primary); width: 200px; }
.search-input--empty { border-color: var(--c-err); background: var(--c-err-bg); }
.search-nav-btn {
  width: 24px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background .1s;
}
.search-nav-btn:hover { background: var(--c-primary-lt); color: var(--c-primary); }
.search-counter {
  font-size: 11px;
  color: var(--c-text-2);
  min-width: 44px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.search-counter--empty { color: var(--c-err); font-weight: 600; }
.search-match         { background: #fff9c4 !important; }
.search-match--active { background: #ffe082 !important; outline: 2px solid #f9a825; outline-offset: -1px; }
.panel-expr-lbl    { font-size: 11px; color: #666; margin-bottom: 4px; }
.panel-lbl-row     { display: flex; align-items: center; }

/* Live expression eval icon (shown in builder panels next to expression labels) */
.expr-live-icon { margin-left: auto; font-size: 11px; font-weight: 700; min-width: 14px; text-align: right; }
.expr-live-icon--ok   { color: #16a34a; }
.expr-live-icon--fail { color: #dc2626; }
.expr-live-icon--err  { color: #f59e0b; }
.panel-style-row   { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 12px; }
.panel-style-lbl   { min-width: 48px; color: #666; }
.panel-raw-inp     { width: 100%; margin-top: 4px; font-size: 11px; }

/* Navigate-from-preview flash */
@keyframes node-flash {
  0%   { box-shadow: 0 0 0 3px var(--c-teal); background: #e0f2f1; }
  70%  { box-shadow: 0 0 0 3px var(--c-teal); background: #e0f2f1; }
  100% { box-shadow: none; background: transparent; }
}
.node-flash { animation: node-flash .9s ease-out; }
