/* ─── Center (editor + results) ───────────────────── */
.center {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  min-width: 0;
}
.tab-bar { grid-row: 1; }
.editor-wrap {
  grid-row: 2;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.results { grid-row: 3; }
.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.editor-toolbar .state-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim); margin-right: 6px;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.03);
}
.editor-toolbar .state-dot.on { background: var(--success); box-shadow: 0 0 12px rgba(163, 201, 104, 0.5); }
.editor-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.CodeMirror {
  flex: 1;
  height: 100%;
  width: 100%;
  background: var(--bg) !important;
  color: var(--text);
  font-family: var(--mono) !important;
  font-size: 13.5px;
  line-height: 1.9;
  padding: 8px 0;
}
.cm-s-querylab .CodeMirror-gutters {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding-right: 6px;
}
.cm-s-querylab .CodeMirror-linenumber { color: var(--text-dim); font-size: 11.5px; }
.cm-s-querylab .CodeMirror-cursor { border-left: 1.5px solid var(--accent-bright); }
.cm-s-querylab .CodeMirror-selected { background: rgba(224, 138, 60, 0.15) !important; }
.cm-s-querylab .cm-keyword { color: var(--accent-bright); font-weight: 500; }
.cm-s-querylab .cm-operator { color: var(--text); }
.cm-s-querylab .cm-variable, .cm-s-querylab .cm-variable-2 { color: var(--text); }
.cm-s-querylab .cm-string { color: #a3c968; }
.cm-s-querylab .cm-number { color: #c5a3e0; }
.cm-s-querylab .cm-comment { color: var(--text-dim); font-style: italic; }
.cm-s-querylab .cm-bracket { color: var(--text-muted); }
.cm-s-querylab .cm-atom { color: var(--info); }
.cm-s-querylab .CodeMirror-activeline-background { background: rgba(255,255,255,0.02) !important; }

/* ─── Autocomplete popup ─────────────────────────── */
.CodeMirror-hints {
  position: absolute;
  z-index: 500;
  overflow-y: auto;
  max-height: 260px;
  margin: 2px 0 0;
  padding: 4px 0;
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  box-shadow: 0 14px 40px -10px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,0,0,0.3);
  font-family: var(--mono);
  font-size: 12.5px;
  list-style: none;
  min-width: 180px;
}
.CodeMirror-hint {
  padding: 5px 14px 5px 12px;
  color: var(--text-muted);
  cursor: pointer;
  border-left: 2px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.CodeMirror-hint-active {
  background: var(--accent-soft);
  color: var(--accent-bright);
  border-left-color: var(--accent);
}

/* Live query execution state */
.editor-wrap.editor-running {
  animation: pulse-border 1.5s ease-in-out infinite;
}
@keyframes pulse-border {
  0%, 100% { border-color: var(--border); }
  50% { border-color: var(--accent); }
}
#btn-cancel {
  background: var(--error-soft);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 4px 12px;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}
#btn-cancel:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
#btn-cancel:not(:disabled):hover {
  background: var(--error);
  color: var(--bg);
}

/* ─── Search Bar (CodeMirror dialog) ── */
.CodeMirror-dialog {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 13px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}

.CodeMirror-dialog input[type="text"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 12px;
  border-radius: 3px;
  outline: none;
}

.CodeMirror-dialog input[type="text"]:focus {
  border-color: var(--accent);
}

.CodeMirror-dialog button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 12px;
}

.CodeMirror-dialog button:hover {
  background: var(--surface-2);
  color: var(--text);
}
