/* ─── Tab Bar ─────────────────────────────────────── */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  min-height: 40px;
}
.tab-bar:empty {
  display: none;
}
.tab-bar::-webkit-scrollbar { height: 4px; }
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.12s;
  position: relative;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active {
  background: var(--surface-2);
  border-color: var(--border-bright);
  color: var(--text);
  font-weight: 500;
}
.tab.dirty::before {
  content: '*';
  color: var(--accent);
  font-weight: 700;
  margin-right: 2px;
}
.tab-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.6;
}
.tab-close:hover { color: var(--error); opacity: 1; }
.tab-new {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 16px;
  transition: all 0.12s;
  flex-shrink: 0;
}
.tab-new:hover { border-color: var(--accent); color: var(--accent); }
.tab.dragging { opacity: 0.4; }
.tab.drag-over { border-color: var(--accent); background: var(--accent-soft); }

/* ─── Main grid ─────────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: 260px 1fr 340px;
  overflow: hidden;
  min-height: 0;
}

/* ─── Left panel ──────────────────────────────────── */
.left {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--bg-elev), var(--bg));
  min-height: 0;
}
.left-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.left-tab {
  flex: 1;
  padding: 12px 10px;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 500;
  transition: all 0.15s;
}
.left-tab:hover { color: var(--text-muted); }
.left-tab.active {
  color: var(--accent-bright);
  border-bottom-color: var(--accent);
}
.left-content {
  flex: 1;
  overflow: auto;
  padding: 16px 14px 24px;
}
.left-content h3 {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 2px;
}
.left-content .sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

/* Schema explorer */
.schema-table {
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
}
.schema-table.open { border-color: var(--border); background: var(--surface-1); }
.schema-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  transition: background 0.12s;
}
.schema-head:hover { background: var(--surface-1); }
.schema-table.open .schema-head { background: var(--surface-2); }
.schema-head .arrow {
  color: var(--text-dim);
  font-size: 10px;
  transition: transform 0.15s;
}
.schema-table.open .schema-head .arrow { transform: rotate(90deg); color: var(--accent); }
.schema-cols { display: none; padding: 4px 0 6px; }
.schema-table.open .schema-cols { display: block; }
.schema-col {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 12px 3px 26px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}
.schema-col .type { color: var(--text-dim); font-size: 10.5px; }
.schema-col .pk { color: var(--accent); font-size: 10px; font-weight: 600; margin-left: 6px; }

/* Resources */
.resource {
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-1);
}
.resource h4 {
  font-family: var(--serif); font-size: 15px; font-style: italic; font-weight: 400;
  color: var(--accent-bright);
  margin-bottom: 3px;
}
.resource code {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: pre-wrap;
  margin-top: 4px;
}

/* History panel content */
.history-list { padding: 4px 0; }
.history-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
}
.history-item {
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
  transition: all 0.12s;
  position: relative;
  overflow: hidden;
}
.history-item:hover {
  border-color: var(--border-bright);
  background: var(--surface-1);
  color: var(--text);
}
.history-item .ts {
  display: block;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.history-item .preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}
.history-item .status-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  margin-right: 6px;
  background: var(--text-dim);
  vertical-align: middle;
}
.history-item .status-dot.ok { background: var(--success); }
.history-item .status-dot.err { background: var(--error); }
