/* varchar — console styles, ported from the design handoff.
   Warm paper + ink, single Clay accent. Structure from hairlines, not shadows. */

@import url("./fonts.css");

:root {
  --paper:    #f4efe6;
  --paper-2:  #efe8dc;
  --surface:  #faf6ef;
  --ink:      #2c2620;
  --ink-2:    #6e655a;
  --ink-3:    #a69c8c;
  --line:     #e2dacb;
  --line-2:   #d3c9b6;
  --danger:   #a23b2a;
  --ok:       #5f8c6a;
  --accent:   #b35a38; /* Clay */

  /* Compact density (locked for v1; mechanism kept for a future toggle). */
  --row-py:   4px;
  --cell-fs:  12.5px;

  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

  --r-input: 6px;
  --r-card:  8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: color-mix(in srgb, var(--accent) 16%, transparent); }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 3px solid var(--paper);
  border-radius: 999px;
}

button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

@keyframes vblink { 0%,48% { opacity: 1; } 49%,100% { opacity: 0; } }
@keyframes vpulse { 0%,100% { opacity: .4; } 50% { opacity: .82; } }

/* Respect a reduced-motion preference: no infinite blink, no sheet slide. */
@media (prefers-reduced-motion: reduce) {
  .cursor-block, .center-state .blink, .skel { animation: none; }
  .theme-lab { transition: none; }
}

/* ---------------------------------------------------------------- buttons */
.btn {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-input);
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  line-height: 1;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:disabled:hover { border-color: var(--line-2); }

.btn-primary {
  color: #faf7f1;
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 58%, #000);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, #000);
  border-color: transparent;
}

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 2px 5px;
  line-height: 1;
}

/* ---------------------------------------------------------------- login */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-card);
  padding: 28px 26px;
}
.login-mark {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.03em;
  margin: 0 0 2px;
}
.login-mark .semi { color: var(--accent); }
.login-sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 22px; }
.login label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-2);
  margin: 14px 0 6px;
}
.login input, .login select {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: var(--r-input);
  padding: 9px 11px;
}
.login select { cursor: pointer; }
.login input:focus, .login select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.login .btn-primary { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; }
/* Secondary login-card button (e.g. "Back to sign in") — quiet, full-width. */
.login .btn:not(.btn-primary) {
  width: 100%; justify-content: center; margin-top: 8px;
  background: none; border-color: transparent; color: var(--ink-2);
}
.login .btn:not(.btn-primary):hover { color: var(--ink); border-color: var(--line-2); }
.login-error {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 14px;
  min-height: 1em;
}

/* ---------------------------------------------------------------- shell */
.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-2);
}
.wordmark {
  display: flex;
  align-items: center;
  min-width: 220px;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.wordmark .semi { color: var(--accent); margin-left: 1px; }
.divider-v { width: 1px; height: 24px; background: var(--line-2); }
.dbctx { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.dbctx .db { color: var(--ink); }
.dbctx .sep { color: var(--ink-3); margin: 0 6px; }
.spacer { flex: 1; }
.conn { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.dot {
  width: 8px; height: 8px; border-radius: 999px; background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.chip {
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 2px 8px;
}
.burger {
  display: none;
  flex-direction: column;
  gap: 3px;
  background: none; border: none; padding: 6px;
}
.burger span { width: 18px; height: 2px; background: var(--ink-2); }

.body {
  display: grid;
  grid-template-columns: 266px 1fr;
  min-height: 0;
  position: relative;
}

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  background: var(--paper-2);
  border-right: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.filter { padding: 14px; }
.filter-wrap {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-input);
  padding: 7px 10px;
}
.filter-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.filter-wrap .slash { font-family: var(--mono); color: var(--ink-3); }
.filter input {
  border: none; background: none; outline: none; width: 100%;
  font-family: var(--mono); font-size: 12.5px; color: var(--ink);
}
.filter input::placeholder { color: var(--ink-3); }

.tree { flex: 1; overflow: auto; padding: 0 8px 8px; }
.section-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2);
  padding: 8px 6px 6px;
}
.section-actions { display: flex; gap: 4px; }
.mini {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-2);
  background: none; border: 1px solid transparent; border-radius: 4px; padding: 2px 5px;
}
.mini:hover { border-color: var(--line-2); color: var(--ink); }

.db-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: var(--r-input);
  font-size: 13px; font-weight: 600; color: var(--ink);
  user-select: none;
}
.db-row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.db-row.active { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.db-row .caret { color: var(--ink-3); width: 10px; font-size: 10px; }
.db-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-row .active-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--accent); }

.table-list { margin: 1px 0 4px 16px; border-left: 1px solid var(--line); padding-left: 0; }
.table-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 9px 5px 12px;
  cursor: pointer;
  border-radius: 0 var(--r-input) var(--r-input) 0;
}
.table-row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.table-row .tname { flex: 1; font-family: var(--mono); font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-row .tcount { font-family: var(--mono); font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.table-row.selected {
  background: color-mix(in srgb, var(--accent) 13%, var(--paper));
  box-shadow: inset 2px 0 0 var(--accent);
}
.table-row.selected .tname, .table-row.selected .tcount { color: var(--accent); }
.tree-empty { font-style: italic; color: var(--ink-3); font-size: 12px; padding: 6px 12px; }

.sidebar-footer {
  border-top: 1px solid var(--line-2);
  padding: 10px 14px;
  display: flex; gap: 14px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}

/* ---------------------------------------------------------------- main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line-2); }
.tab {
  background: none; border: none;
  padding: 12px 12px 10px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 7px;
}
.tab:hover:not(:disabled) { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.tab:disabled { color: var(--ink-3); cursor: default; }
.tab .count {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-2);
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px;
}

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.toolbar .tbl-name { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.where {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-input);
  padding: 4px 7px;
  flex: 0 1 auto; min-width: 0; max-width: 100%; /* shrink to fit narrow toolbars */
}
.where.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.where:focus-within { border-color: var(--accent); }
.where .lbl { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--accent); flex: none; }
.where-sel, .where-val {
  border: none; background: none; outline: none;
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  min-width: 0; /* allow the controls to shrink rather than clip the buttons */
}
.where-sel { cursor: pointer; max-width: 130px; padding: 1px 2px; flex: 0 1 auto; }
.where-val { flex: 1 1 70px; min-width: 36px; padding: 1px 2px; }
.where-val::placeholder { color: var(--ink-3); }
.where-btn {
  border: none; background: none; cursor: pointer; flex: none;
  font-family: var(--mono); font-size: 13px; line-height: 1; color: var(--ink-3);
  padding: 1px 4px; border-radius: 4px;
}
.where-btn:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* visually-hidden but available to assistive tech (live regions, labels) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.grid-empty {
  position: sticky; left: 0;
  padding: 22px 16px; font-family: var(--mono); font-size: 12.5px;
  color: var(--ink-3); font-style: italic;
}
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--paper)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 9%, var(--paper)); border-color: var(--danger); }

/* ---------------------------------------------------------------- grid */
.grid-wrap { flex: 1; overflow: auto; min-height: 0; }
.grid { display: grid; grid-template-columns: var(--gc, 1fr); width: max-content; min-width: 100%; }
.grid-head {
  display: contents;
}
.gh {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--line-2);
  border-right: 1px solid var(--line);
  padding: 6px 13px 6px 12px;
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer; user-select: none; overflow: hidden;
}
.gh:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.gh:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -2px;
}
/* Resize grip on the right edge: drag to resize, double-click to auto-fit. */
.gh-grip {
  position: absolute; top: 0; right: 0; width: 9px; height: 100%;
  cursor: col-resize; z-index: 4; touch-action: none;
}
.gh-grip:hover { background: color-mix(in srgb, var(--accent) 32%, transparent); }
.grid.resizing { user-select: none; cursor: col-resize; }
.gh-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.gh-spacer { flex: 1; }
.sort-caret {
  flex: none; width: 8px; text-align: right;
  font-family: var(--mono); font-size: 11px; line-height: 1; color: var(--accent);
}
.gh-name { font-size: 11.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-type { font-family: var(--mono); font-size: 10px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-family: var(--mono); font-size: 8.5px; font-weight: 600; text-transform: uppercase;
  border-radius: 2px; padding: 1px 4px; line-height: 1.3;
}
.badge-pk { color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent); }
.badge-fk { color: var(--ink-3); border: 1px solid var(--line-2); }

.row { display: contents; }
.cell {
  padding: var(--row-py) 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  font-family: var(--mono); font-size: var(--cell-fs); color: var(--ink);
  display: flex; align-items: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.cell.pk { color: var(--accent); font-weight: 500; }
.cell.fk { color: var(--ink-2); }
.cell .null { color: var(--ink-3); font-style: italic; }
.row.selected .cell { background: color-mix(in srgb, var(--accent) 12%, var(--paper)); }
.row.selected .cell:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* inline cell editor */
.cell.editing { position: relative; overflow: visible; padding: 0; z-index: 4; }
.cell-input {
  width: 100%; box-sizing: border-box; border: none;
  outline: 2px solid var(--accent); outline-offset: -2px;
  background: var(--surface); color: var(--ink);
  font-family: var(--mono); font-size: var(--cell-fs);
  padding: var(--row-py) 12px;
}
.edit-hint {
  position: absolute; top: calc(100% + 3px); left: 0; z-index: 6;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-size: 10.5px; padding: 3px 8px;
  border-radius: 4px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 3px 10px rgba(44, 38, 32, .22);
}
.cell.editing.hint-above .edit-hint { top: auto; bottom: calc(100% + 3px); }

/* Delete row: muted/cautious until a row is selected, danger when armed. */
.btn-deleterow { color: var(--ink-3); }
.btn-deleterow.armed {
  color: var(--danger); opacity: 1;
  border-color: color-mix(in srgb, var(--danger) 40%, var(--paper));
}
.btn-deleterow.armed:hover { background: color-mix(in srgb, var(--danger) 9%, var(--paper)); border-color: var(--danger); }

/* ---------------------------------------------------------------- modal */
.modal-scrim { position: fixed; inset: 0; z-index: 42; background: rgba(44, 38, 32, .24); }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 43;
  width: 520px; max-width: calc(100vw - 28px); max-height: 86vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 24px 64px rgba(44, 38, 32, .28);
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line); flex: none; }
.modal-title { flex: 1; font-family: var(--mono); font-weight: 600; font-size: 15px; }
.modal-close { background: none; border: 1px solid var(--line-2); border-radius: 6px; width: 28px; height: 28px; color: var(--ink-2); }
.modal-close:hover { border-color: var(--accent); color: var(--ink); }
.modal-body { padding: 18px 20px; overflow: auto; min-height: 0; flex: 1 1 auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex: none; }
.modal-form { display: flex; flex-direction: column; gap: 13px; }
.modal-field { display: flex; flex-direction: column; gap: 5px; }
.modal-field-head { display: flex; align-items: baseline; gap: 8px; }
.modal-field-label { font-size: 12px; font-weight: 600; color: var(--ink); }
.modal-field-type { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.modal-input {
  width: 100%; box-sizing: border-box;
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r-input); padding: 8px 10px;
}
.modal-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.modal-warn { font-size: 13px; line-height: 1.55; color: var(--ink-2); margin: 0 0 14px; }

/* create-table column builder */
.ct-cols { display: flex; flex-direction: column; gap: 7px; }
.ct-col { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ct-name { flex: 1; min-width: 96px; padding: 6px 9px; }
.ct-type {
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r-input); padding: 6px 6px; cursor: pointer;
}
.ct-flags { display: flex; gap: 9px; }
.ct-flag { display: flex; align-items: center; gap: 3px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); cursor: pointer; }
.ct-flag input { accent-color: var(--accent); cursor: pointer; }
.ct-rm { background: none; border: none; color: var(--ink-3); cursor: pointer; padding: 4px 6px; font-size: 12px; }
.ct-rm:hover { color: var(--danger); }
.ct-addcol { align-self: flex-start; }
.empty-actions { margin: 18px 0 4px; display: flex; gap: 8px; justify-content: center; }

/* create-table: source / import controls */
.ct-pills { display: flex; gap: 6px; }
.ct-pill {
  font-family: var(--sans); font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 13px;
}
.ct-pill:hover { border-color: var(--accent); }
.ct-pill.active { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--paper)); font-weight: 600; }
.ct-import { display: flex; flex-direction: column; gap: 9px; padding: 12px; border: 1px solid var(--line-2); border-radius: var(--r-card); background: var(--paper); }
.ct-file { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.ct-import-or { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.ct-paste {
  width: 100%; box-sizing: border-box; min-height: 90px; resize: vertical;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-input); padding: 8px 10px;
}
.ct-paste:focus { outline: none; border-color: var(--accent); }
.ct-parse-note { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.ct-parse-note.err { color: var(--danger); }

/* transient toast (write feedback) */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-size: 12.5px;
  padding: 9px 15px; border-radius: 8px; max-width: 86vw;
  box-shadow: 0 8px 24px rgba(44, 38, 32, .3);
}
.toast.err { background: var(--danger); }

/* loading skeleton */
.skel { height: 11px; border-radius: 3px; background: var(--line-2); animation: vpulse 1.25s ease-in-out infinite; }

.browse-footer {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; border-top: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}
.pager { display: flex; gap: 4px; align-items: center; }
.pager button {
  width: 28px; height: 28px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-input);
  color: var(--ink-2); font-family: var(--mono); font-size: 12px;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--ink); }
.pager button:disabled { opacity: .4; cursor: default; }
.density { color: var(--ink-3); }

/* Focusable scroll regions (keyboard users can focus to scroll). */
.structure:focus-visible, .grid-wrap:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -2px;
}

/* ---------------------------------------------------------------- structure */
.structure { flex: 1; overflow: auto; min-height: 0; padding: 22px 26px; }
.struct-inner { max-width: 980px; }
.struct-loading { font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); padding: 6px 2px; }
.struct-empty { font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); font-style: italic; padding: 6px 2px; }
.struct-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); margin: 0 2px 10px;
}
.struct-section-label:not(:first-child) { margin-top: 28px; }

/* table meta summary strip */
.struct-meta {
  display: flex; flex-wrap: wrap; gap: 16px 26px;
  padding: 12px 16px; margin-bottom: 22px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-card);
}
.sm-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; max-width: 280px; }
.sm-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.sm-val { font-family: var(--mono); font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.struct-table {
  display: grid; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-card); overflow: hidden;
}
.struct-cols { grid-template-columns: minmax(150px,1.2fr) minmax(160px,1.4fr) 90px 90px minmax(150px,1fr) 150px; }
.struct-idx  { grid-template-columns: minmax(180px,1.4fr) minmax(140px,1fr) 110px 110px; }

.struct-head { display: contents; }
.struct-head .sh {
  background: var(--paper-2);
  font-size: 11px; font-weight: 600; color: var(--ink-2);
  padding: 9px 12px; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line);
  white-space: nowrap;
}
.struct-head .sh:last-child { border-right: none; }
.struct-row { display: contents; }
.struct-row > div {
  padding: 8px 12px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-2);
  display: flex; align-items: center; gap: 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.struct-row > div:last-child { border-right: none; }
.struct-row:last-child > div { border-bottom: none; }
.struct-row > div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.struct-row > div.sc-name { color: var(--ink); font-weight: 500; }
.struct-row > div.sc-name.pk { color: var(--accent); }
.sc-type { color: var(--ink-2); }
.keychip {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 3px; padding: 1px 5px;
}
.sc-default .null { color: var(--ink-3); font-style: italic; }
.struct-row .dash { color: var(--ink-3); }

/* ---------------------------------------------------------------- SQL console */
.sqlpanel { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 16px; gap: 12px; overflow: hidden; }
.sql-card { flex: none; border: 1px solid var(--line-2); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.sql-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--paper-2);
}
.sql-head-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.sql-head-db { font-family: var(--mono); font-size: 12px; color: var(--ink-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sql-head .kbd { margin-left: 2px; }
.kbd-caret { font-size: 9px; color: var(--ink-3); margin-left: 2px; }
.sql-queries-wrap { position: relative; }
.sql-pop {
  position: fixed; z-index: 44; /* JS sets top/left/width; fixed escapes the card clip */
  max-width: calc(100vw - 24px); max-height: min(340px, 70vh); overflow: auto;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
  box-shadow: 0 14px 40px rgba(44, 38, 32, .2); padding: 6px;
}
.sql-pop-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 8px 6px 4px; }
.sql-pop-empty { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); padding: 4px 6px; font-style: italic; }
.sql-pop-item { display: flex; align-items: center; }
.sql-pop-item .sql-pop-load { flex: 1; min-width: 0; }
.sql-pop-load {
  display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 12px; color: var(--ink); padding: 6px; border-radius: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sql-pop-load:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.sql-pop-recent { color: var(--ink-2); }
.sql-pop-del { background: none; border: none; color: var(--ink-3); cursor: pointer; padding: 4px 7px; border-radius: 5px; }
.sql-pop-del:hover { color: var(--danger); }
.sql-body { display: flex; height: 200px; }
.sql-gutter {
  flex: none; width: 46px; overflow: hidden; padding: 10px 0;
  background: var(--paper-2); border-right: 1px solid var(--line);
}
.sql-lineno { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--ink-3); padding: 0 10px; text-align: right; }
.sql-input {
  flex: 1; border: none; outline: none; resize: none;
  padding: 10px 12px; background: var(--surface); color: var(--ink);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; tab-size: 2;
  caret-color: var(--accent);
  /* No soft-wrap: one logical line = one visual row, so the gutter stays aligned. */
  white-space: pre; overflow-x: auto;
}
.sql-input::placeholder { color: var(--ink-3); }

.sql-status { display: flex; align-items: center; gap: 8px; flex: none; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.sql-status.error { color: var(--danger); }
.sql-status .sql-dot {
  width: 8px; height: 8px; border-radius: 999px; background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.sql-status .sql-timing { color: var(--ink-3); }

/* The scroll container carries the border/radius; the grid inside has no
   overflow of its own so its sticky .gh header pins to this scroller. */
.sql-result { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line-2); border-radius: var(--r-card); }
.sql-result:empty { display: none; }
.sql-result:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -2px;
}
#sql-result .gh { cursor: default; }
#sql-result .gh:hover { background: var(--surface); }

/* ---------------------------------------------------------------- export */
.exportpanel { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; overflow: hidden; }
.export-controls {
  padding: 20px; border-right: 1px solid var(--line-2); overflow: auto;
  display: flex; flex-direction: column; gap: 22px;
}
.export-group { border: none; margin: 0; padding: 0; min-width: 0; }
.export-group legend {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); padding: 0; margin-bottom: 8px;
}
.export-group .radio, .export-group .check {
  display: flex; align-items: baseline; gap: 8px; padding: 6px 0;
  font-size: 13px; color: var(--ink); cursor: pointer;
}
.export-group input[type="radio"], .export-group input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.export-group .note { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.export-group.disabled, .export-group .disabled { opacity: .42; }
.export-group.disabled input, .export-group .disabled input { cursor: default; }
.export-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }

.export-preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.export-preview-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
}
.export-preview-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.export-filename { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.export-pre {
  flex: 1; margin: 0; min-height: 0; overflow: auto;
  padding: 14px 16px; background: var(--surface);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--ink);
  white-space: pre;
}
.export-pre:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: -2px; }
@media (max-width: 860px) {
  .exportpanel { grid-template-columns: 1fr; grid-template-rows: auto minmax(180px, 1fr); }
  .export-controls { border-right: none; border-bottom: 1px solid var(--line-2); }
}

/* ------------------------------------------------------- users & privileges */
.userspanel { flex: 1; overflow: auto; min-height: 0; padding: 22px 26px; }
.users-head { display: flex; align-items: baseline; gap: 12px; max-width: 980px; margin-bottom: 16px; }
.users-title { font-weight: 600; font-size: 15px; color: var(--ink); }
.users-sub { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }

.users-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 18px; max-width: 980px; align-items: start; }
.users-list { display: flex; flex-direction: column; gap: 2px; }
.user-row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; background: none; border: 1px solid transparent; border-radius: 6px;
  font-family: var(--sans); color: var(--ink-2); cursor: pointer;
}
.user-row:hover { background: var(--paper-2); }
.user-row.selected { background: color-mix(in srgb, var(--accent) 8%, var(--paper)); border-color: color-mix(in srgb, var(--accent) 40%, var(--line-2)); color: var(--ink); }
.ur-acct { display: flex; align-items: baseline; gap: 1px; min-width: 0; flex: 1; }
.ur-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ur-host { font-family: var(--mono); font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ur-you { background: color-mix(in srgb, var(--accent) 14%, var(--paper)); color: var(--accent); border-color: transparent; }

.users-detail { min-width: 0; }
.ud-head { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.ud-acct { display: flex; align-items: baseline; gap: 2px; font-size: 15px; }
.ud-name { font-weight: 600; color: var(--ink); }
.ud-host { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.ud-grants {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-card); padding: 12px 14px;
}
.ud-grant { font-family: var(--mono); font-size: 12px; color: var(--ink-2); line-height: 1.5; word-break: break-word; }
.ud-empty { font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); font-style: italic; padding: 6px 2px; }
.ud-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.users-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px; gap: 8px; min-height: 220px;
}
.users-empty-mark { font-weight: 600; font-size: 15px; }
.users-empty-msg { color: var(--ink-2); font-size: 13px; max-width: 420px; }

/* grant/revoke modal */
.priv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.priv-check span { font-family: var(--mono); font-size: 11.5px; }
.scope-row { display: flex; flex-direction: column; gap: 2px; }
.scope-sel-wrap { display: flex; flex-direction: column; gap: 4px; }
.scope-sel-label { font-size: 11px; font-weight: 600; color: var(--ink-2); }
.modal-warn { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
/* .check/.radio carry no layout outside .export-group — give the modal its own. */
.modal-form .check, .modal-form .radio {
  display: flex; align-items: center; gap: 7px; padding: 4px 0;
  font-size: 12.5px; color: var(--ink); cursor: pointer;
}
.modal-form input[type="checkbox"], .modal-form input[type="radio"] { accent-color: var(--accent); cursor: pointer; flex: none; }
.go-wrap { display: flex; flex-direction: column; }
.go-note { margin: 0 0 0 24px; }

@media (max-width: 860px) {
  .userspanel { padding: 16px; }
  .users-wrap { grid-template-columns: 1fr; }
  .users-list { flex-direction: row; flex-wrap: wrap; }
  .user-row { width: auto; }
  .priv-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- theme lab */
.accent-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); display: inline-block; }
.cursor-block {
  display: inline-block; width: 8px; height: 1em; background: var(--accent);
  margin-left: 3px; vertical-align: -2px; animation: vblink 1.05s step-end infinite;
}
.wordmark .cursor-block { height: 16px; }
.login-mark .cursor-block { height: 22px; }

.theme-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(44, 38, 32, .12); }
.theme-lab {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 78vh; overflow: auto;
  background: var(--surface); border-top: 1px solid var(--line-2);
  border-radius: 12px 12px 0 0; box-shadow: 0 -14px 44px rgba(44, 38, 32, .2);
  transform: translateY(101%); transition: transform .22s ease;
}
.theme-lab.open { transform: translateY(0); }
.theme-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.theme-title { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.theme-title .semi { color: var(--accent); }
.theme-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.theme-close {
  background: none; border: 1px solid var(--line-2); border-radius: 6px;
  width: 28px; height: 28px; color: var(--ink-2); font-size: 13px;
}
.theme-close:hover { border-color: var(--accent); color: var(--ink); }

.theme-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; padding: 20px 22px 26px; }
.theme-col-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 12px; }

.theme-opt {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; margin-bottom: 6px;
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 6px;
  font-family: var(--sans); font-size: 13px; color: var(--ink); text-align: left; cursor: pointer;
}
.theme-opt:hover { border-color: var(--accent); }
.theme-opt.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--paper)); }
.theme-opt .opt-name { flex: 1; }
.theme-opt .swatch { width: 20px; height: 20px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
.theme-opt .opt-hex { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.theme-opt .opt-check { color: var(--accent); font-weight: 600; }
.theme-opt .opt-preview { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.theme-opt .opt-preview .opt-accent { color: var(--accent); }
.color-picker { width: 18px; height: 18px; padding: 0; border: none; background: none; cursor: pointer; }

.token-row { display: flex; align-items: center; gap: 9px; padding: 4px 0; font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.token-row .token-sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line-2); }
.token-row .token-name { flex: 1; }
.token-row .token-hex { color: var(--ink-3); }

@media (max-width: 860px) { .theme-cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .theme-cols { grid-template-columns: 1fr; } }

/* empty / message states */
.center-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px; min-height: 0;
}
.center-state .mono { font-family: var(--mono); color: var(--ink-2); font-size: 14px; }
.center-state .blink { display: inline-block; width: 8px; height: 16px; background: var(--accent); vertical-align: middle; margin-left: 2px; animation: vblink 1.05s step-end infinite; }
.center-state .title { font-weight: 600; margin: 14px 0 6px; }
.center-state .hint { color: var(--ink-2); font-size: 13px; }
.center-state .quip { margin-top: 22px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }

/* ---------------------------------------------------------------- responsive */
.backdrop { display: none; }
@media (max-width: 860px) {
  .body { grid-template-columns: 1fr; }
  .sidebar {
    position: absolute; inset: 0 auto 0 0; width: 284px; max-width: 86%;
    z-index: 30; transform: translateX(-101%); transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop.show { display: block; position: absolute; inset: 0; z-index: 25; background: rgba(44,38,32,.24); }
  .burger { display: flex; }
  .hide-sm { display: none; }
  /* Free up the cramped top bar so Users + Theme + Sign out stay reachable. */
  .wordmark { min-width: 0; }
  .topbar { gap: 7px; padding: 0 10px; }
  .topbar .btn { padding: 7px 9px; }
}
