:root {
  --bg-base: #0a0d14;
  --bg-surface: #101623;
  --bg-surface-elevated: #161f30;
  --bg-card: #1b263b;
  --border-subtle: #24324d;
  --border-accent: #3b82f6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── Top Navbar ─────────────────────────────────── */
header.top-nav {
  height: 58px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: white;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
}

.version-pill {
  font-size: 11px;
  font-family: var(--font-mono);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  padding: 2px 8px;
  border-radius: 12px;
}

.nav-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.stat-badge b {
  color: var(--accent-cyan);
}

/* ─── Main Studio Layout ─────────────────────────── */
.studio-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 58px);
  overflow: hidden;
}

/* ─── Sidebar: Toolbox (Domain-Driven) ───────────── */
aside.toolbox-sidebar {
  width: 300px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.search-container {
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.toolbox-header-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 14px 14px 6px 14px;
}

.domain-step-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.domain-step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.domain-step-item:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
}

.domain-step-item.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent-primary);
}

.domain-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.domain-step-item.active .domain-icon-box {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.domain-item-info {
  flex: 1;
  min-width: 0;
}

.domain-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.domain-item-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.domain-ops-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(6, 182, 212, 0.12);
  color: #67e8f9;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* ─── Center: Step Editor Canvas ─────────────────── */
main.step-editor-panel {
  flex: 1;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
}

.editor-header {
  padding: 20px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.domain-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-domain {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #67e8f9;
}

.pill-category {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
}

.step-name-input {
  font-size: 18px;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  color: white;
  outline: none;
  padding: 4px 6px;
  border-radius: 4px;
  width: 100%;
  transition: all 0.2s;
}

.step-name-input:focus, .step-name-input:hover {
  background: var(--bg-base);
  border-color: var(--border-subtle);
}

.step-description {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* ─── Operation Selector Section ─────────────────── */
.operation-selector-section {
  padding: 20px 24px 0 24px;
}

.operation-card {
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.operation-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.operation-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-cyan);
}

.operation-select {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}

.operation-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.operation-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

/* ─── Form Parameters ────────────────────────────── */
.editor-body {
  padding: 24px;
  flex: 1;
}

.parameters-header-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.form-group {
  margin-bottom: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px;
  transition: all 0.2s;
}

.form-group:focus-within {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.required-star {
  color: var(--accent-rose);
  font-weight: bold;
}

.param-type-tag {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.form-description {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.widget-input, .widget-textarea, .widget-select {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--text-main);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s;
}

.widget-input:focus, .widget-textarea:focus, .widget-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.widget-textarea {
  min-height: 80px;
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
}

/* ─── Multi-Select Field Tag Picker ──────────────── */
.field-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.field-chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.field-chip-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--text-main);
}

.field-chip-toggle.selected {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-primary);
  color: #c7d2fe;
  font-weight: 500;
}

.field-chip-toggle.selected .chip-check {
  color: var(--accent-cyan);
}

.field-picker-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-mini {
  font-size: 11px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-mini:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* ─── Visual Condition Query Builder with Recursive AND/OR Groups ── */
.condition-builder-container {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Recursive Condition Group Tree */
.condition-group-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: all 0.2s;
}

.condition-group-card.depth-0 {
  background: var(--bg-base);
  border: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.condition-group-card.depth-1 {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-left: 3px solid #6366f1;
}

.condition-group-card.depth-2 {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(236, 72, 153, 0.25);
  border-left: 3px solid #ec4899;
}

.condition-group-card.depth-3 {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-left: 3px solid #f59e0b;
}

.group-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.group-title-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.btn-delete-group {
  font-size: 11px;
  color: #fb7185;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-delete-group:hover {
  background: var(--accent-rose);
  color: white;
}

.group-children-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.combinator-toggle-group {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}

.combinator-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.combinator-btn.active.and {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.combinator-btn.active.or {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.combinator-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* Conjunction Pill between rows */
.conjunction-badge {
  align-self: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 1px 8px;
  border-radius: 10px;
  margin: 1px 0;
  text-transform: uppercase;
}

.conjunction-badge.and {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.conjunction-badge.or {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.condition-rule-row {
  display: grid;
  grid-template-columns: 140px 140px 1fr 32px;
  gap: 8px;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.rule-field-select, .rule-operator-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text-main);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
}

.rule-value-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--text-main);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
}

.rule-value-input:focus {
  border-color: var(--accent-primary);
}

.btn-delete-rule {
  height: 28px;
  width: 28px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-delete-rule:hover {
  background: var(--accent-rose);
  color: white;
}

.condition-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.btn-add-condition {
  font-size: 11px;
  font-weight: 500;
  background: rgba(6, 182, 212, 0.1);
  border: 1px dashed rgba(6, 182, 212, 0.4);
  color: #67e8f9;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-add-condition:hover {
  background: var(--accent-cyan);
  color: #0b0f17;
  font-weight: 600;
}

.btn-add-group {
  font-size: 11px;
  font-weight: 500;
  background: rgba(147, 51, 234, 0.1);
  border: 1px dashed rgba(147, 51, 234, 0.4);
  color: #c084fc;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-add-group:hover {
  background: #9333ea;
  color: white;
  font-weight: 600;
}

/* Chips for quick variable suggestions */
.quick-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.quick-chip {
  font-size: 11px;
  font-family: var(--font-mono);
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-chip:hover {
  background: var(--accent-primary);
  color: white;
}

/* ─── Visual Order By / Sort Builder ──────────────────────── */
.order-by-builder-container {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-by-rule-row {
  display: grid;
  grid-template-columns: 46px 1fr 125px 32px;
  gap: 8px;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sort-rank-badge {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-align: center;
  padding: 3px 4px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}

.sort-field-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text-main);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
}

.sort-direction-group {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}

.btn-sort-dir {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-sort-dir.active.asc {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.btn-sort-dir.active.desc {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.btn-delete-sort {
  height: 28px;
  width: 28px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-delete-sort:hover {
  background: var(--accent-rose);
  color: white;
}

.btn-add-sort {
  font-size: 11px;
  font-weight: 500;
  background: rgba(6, 182, 212, 0.1);
  border: 1px dashed rgba(6, 182, 212, 0.4);
  color: #67e8f9;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
}

.btn-add-sort:hover {
  background: var(--accent-cyan);
  color: #0b0f17;
  font-weight: 600;
}

/* ─── Visual Record Field Mapping Builder (CREATE / UPDATE / UPSERT) ─ */
.record-builder-container {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-mode-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 8px;
}

.record-mode-toggle-group {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}

.btn-record-mode {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-record-mode.active {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.record-actions-quick {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-auto-map {
  font-size: 11px;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-auto-map:hover {
  background: #10b981;
  color: #064e3b;
  font-weight: 700;
}

.record-fields-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-field-row {
  display: grid;
  grid-template-columns: 24px 130px 75px 1fr 28px;
  gap: 8px;
  align-items: center;
  background: rgba(0, 0, 0, 0.22);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.15s;
}

.record-field-row.disabled {
  opacity: 0.4;
  background: transparent;
}

.field-checkbox-toggle {
  cursor: pointer;
  accent-color: var(--accent-primary);
  width: 15px;
  height: 15px;
}

.field-name-label {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-type-pill {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.field-type-pill.string { color: #67e8f9; border-color: rgba(6, 182, 212, 0.3); }
.field-type-pill.number { color: #f59e0b; border-color: rgba(245, 158, 11, 0.3); }
.field-type-pill.boolean { color: #ec4899; border-color: rgba(236, 72, 153, 0.3); }
.field-type-pill.datetime { color: #a855f7; border-color: rgba(168, 85, 247, 0.3); }

.record-val-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--text-main);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  width: 100%;
}

.record-val-input:focus {
  border-color: var(--accent-primary);
}

.btn-custom-field-delete {
  height: 26px;
  width: 26px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fb7185;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-custom-field-delete:hover {
  background: var(--accent-rose);
  color: white;
}

.btn-add-custom-field {
  font-size: 11px;
  font-weight: 500;
  background: rgba(6, 182, 212, 0.1);
  border: 1px dashed rgba(6, 182, 212, 0.4);
  color: #67e8f9;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
}

.btn-add-custom-field:hover {
  background: var(--accent-cyan);
  color: #0b0f17;
  font-weight: 600;
}

/* ─── Right: Live Code & Diagnostics Inspector ───── */
aside.inspector-sidebar {
  width: 440px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.tabs-header {
  display: flex;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 10px;
}

.tab-btn {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  font-weight: 600;
}

.tab-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: none;
}

.tab-content.active {
  display: block;
}

.code-preview-box {
  background: #07090e;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: var(--accent-primary);
  color: white;
}

.validation-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 6px;
  color: #34d399;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 14px;
}

.validation-status.invalid {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

.output-schema-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  margin-top: 12px;
}

.schema-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.schema-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── Visual Aggregation Metrics Builder ────────────────────────── */
.aggregate-builder-container {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aggregate-metrics-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aggregate-metric-row {
  display: grid;
  grid-template-columns: 160px 170px 1fr 32px;
  gap: 8px;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.metric-fn-select {
  background: var(--bg-surface);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 4px;
  padding: 6px 8px;
  color: #a5b4fc;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  outline: none;
}

.metric-field-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text-main);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
}

.metric-alias-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 8px;
}

.alias-as-tag {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  text-transform: uppercase;
}

.metric-alias-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 12px;
  font-family: var(--font-mono);
  width: 100%;
  padding: 4px 0;
}

.btn-delete-metric {
  height: 28px;
  width: 28px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-delete-metric:hover {
  background: var(--accent-rose);
  color: white;
}

.aggregate-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.btn-add-metric {
  font-size: 11px;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  border: 1px dashed rgba(16, 185, 129, 0.45);
  color: #34d399;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-add-metric:hover {
  background: var(--accent-emerald);
  color: #022c22;
  font-weight: 700;
}

/* ─── Responsive Viewport & Device Support ───────────────────────── */
@media (max-width: 1200px) {
  aside.toolbox-sidebar {
    width: 260px;
  }
  aside.inspector-sidebar {
    width: 380px;
  }
}

@media (max-width: 992px) {
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
  }

  .studio-container {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  aside.toolbox-sidebar {
    width: 100%;
    max-height: 260px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .domain-step-list {
    max-height: 180px;
    overflow-y: auto;
  }

  main.step-editor-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    overflow: visible;
  }

  aside.inspector-sidebar {
    width: 100%;
    overflow: visible;
  }

  .aggregate-metric-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  header.top-nav {
    padding: 0 12px;
  }

  .brand-title {
    font-size: 13px;
  }

  .version-pill {
    display: none;
  }

  .nav-meta .stat-badge:nth-child(2) {
    display: none;
  }

  .stat-badge {
    font-size: 11px;
    padding: 3px 6px;
  }

  .editor-header {
    padding: 14px 16px;
  }

  .editor-body {
    padding: 14px 16px;
  }

  .operation-selector-section {
    padding: 12px 16px;
  }

  .tabs-header {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs-header::-webkit-scrollbar {
    display: none;
  }
}


