/* ============================================================================
   SchemaSight — live SQLite schema visualiser
   Design system: dark developer instrument, teal accent, crisp mono data.
   ========================================================================== */

:root {
  --bg-0: #0a0e15;
  --bg-1: #0d1220;
  --bg-2: #121928;
  --bg-3: #17202f;
  --bg-4: #1d2739;
  --border-1: #1e2839;
  --border-2: #27334a;
  --border-3: #33415c;

  --text-hi: #dee7f3;
  --text: #a9b7cb;
  --text-dim: #6b7a92;
  --text-faint: #4a5a72;

  --accent: #43d9c2;
  --accent-hi: #7ceeda;
  --accent-dim: #2c9d8c;
  --accent-ink: #062522;
  --accent-glow: rgba(67, 217, 194, 0.16);

  --blue: #7aa2f7;
  --amber: #e7b661;
  --violet: #b78bf9;
  --red: #ef6b73;
  --green: #71c98d;
  --orange: #e6916e;

  --t-integer: #7aa2f7;
  --t-text: #7fd18b;
  --t-real: #c39bff;
  --t-blob: #9aa7ba;
  --t-numeric: #e7b661;
  --t-other: #9aa7ba;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --radius-sm: 7px;
  --topbar-h: 50px;
  --rail-w: 248px;
  --dock-w: 500px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 10px 30px rgba(2, 6, 14, 0.55), 0 2px 8px rgba(2, 6, 14, 0.5);
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: rgba(67, 217, 194, 0.28); }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
  white-space: nowrap;
}
code { font-family: var(--font-mono); font-size: 0.92em; }

:focus-visible { outline: 2px solid var(--accent-dim); outline-offset: 1px; border-radius: 4px; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232e42; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #31405c; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ============================================================================
   Buttons, badges, chips
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--text-hi);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 550;
  transition: background 0.15s var(--ease-out), border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-4); border-color: var(--border-3); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #04201c;
  font-weight: 650;
}
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: var(--border-2); color: var(--text); }
.btn--ghost:hover { color: var(--text-hi); background: var(--bg-3); }
.btn--danger:hover { border-color: var(--red); color: var(--red); background: rgba(239, 107, 115, 0.08); }
.btn--small { padding: 3px 8px; font-size: 11px; }
.btn--icon { padding: 5px 8px; font-size: 13px; color: var(--text-dim); }
.btn--icon:hover { color: var(--text-hi); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  border-radius: 4px;
  padding: 1px 5px;
  border: 1px solid transparent;
  line-height: 1.5;
  white-space: nowrap;
}
.badge--dim { background: var(--bg-4); color: var(--text-dim); border-color: var(--border-2); }
.badge--count { background: var(--bg-3); color: var(--text-dim); border-color: var(--border-2); }

.chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 99px;
  padding: 2px 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.chip:hover { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-glow); }

/* ============================================================================
   Boot overlay — engine initialisation states
   ========================================================================== */
.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background:
    radial-gradient(1100px 500px at 50% -10%, rgba(67, 217, 194, 0.07), transparent 60%),
    var(--bg-0);
  transition: opacity 0.5s var(--ease-out), visibility 0.5s;
}
.boot--done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot__card {
  width: min(400px, calc(100vw - 48px));
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: 14px;
  padding: 30px 34px 26px;
  box-shadow: var(--shadow-2);
  text-align: left;
}
.boot__mark { margin-bottom: 10px; }
.boot__title { margin: 0; font-size: 21px; font-weight: 700; color: var(--text-hi); letter-spacing: 0.2px; }
.boot__sub { margin: 3px 0 22px; color: var(--text-dim); font-size: 12px; }
.boot__steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.boot__steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-faint);
  transition: color 0.2s;
}
.boot__steps li .boot__label { flex: 1; display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.boot__detail { color: var(--text-dim); font-family: var(--font-mono); font-size: 10.5px; }
.boot__steps li.is-active { color: var(--text-hi); }
.boot__steps li.is-done { color: var(--text); }
.boot__steps li.is-done .boot__dot::after { content: "✓"; }
.boot__dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-3);
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--accent);
  position: relative;
}
.boot__steps li.is-active .boot__dot { border-color: var(--accent-dim); }
.boot__steps li.is-active .boot__dot::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: bootPulse 1s ease-in-out infinite;
}
.boot__steps li.is-done .boot__dot { border-color: var(--accent-dim); background: var(--accent-glow); }
.boot__steps li.is-error { color: var(--red); }
.boot__steps li.is-error .boot__dot { border-color: var(--red); }
.boot__steps li.is-error .boot__dot::before { content: "✕"; color: var(--red); font-size: 9px; animation: none; }
@keyframes bootPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.boot__bar {
  flex-basis: 100%;
  height: 3px;
  border-radius: 3px;
  background: var(--bg-3);
  overflow: hidden;
  margin-left: 26px;
}
.boot__bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.12s linear;
}
.boot__error { margin-top: 18px; padding: 13px 15px; border: 1px solid rgba(239, 107, 115, 0.35); background: rgba(239, 107, 115, 0.07); border-radius: var(--radius-sm); }
.boot__error-title { margin: 0 0 4px; font-weight: 650; color: var(--red); font-size: 13px; }
.boot__error-msg { margin: 0 0 12px; font-size: 12px; color: var(--text); font-family: var(--font-mono); word-break: break-word; }
.boot__foot { color: var(--text-faint); font-size: 11.5px; margin: 0; }

/* ============================================================================
   App frame
   ========================================================================== */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; opacity: 0; transition: opacity 0.45s var(--ease-out); }
.app.is-ready { opacity: 1; }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  background: linear-gradient(180deg, #0f1523, #0c111c);
  border-bottom: 1px solid var(--border-1);
  z-index: 20;
}
.topbar__brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.topbar__logo { flex: none; filter: drop-shadow(0 0 8px rgba(67, 217, 194, 0.35)); }
.topbar__name { font-weight: 700; font-size: 14px; color: var(--text-hi); letter-spacing: 0.2px; }
.topbar__tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  padding: 1.5px 6px;
  letter-spacing: 0.6px;
}
.topbar__stats { display: flex; gap: 18px; margin-left: 10px; flex: 1; min-width: 0; overflow: hidden; }
.stat { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.stat__value { font-family: var(--font-mono); font-size: 13px; color: var(--text-hi); font-weight: 600; }
.stat__label { font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.5px; text-transform: uppercase; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  border-radius: 99px;
  padding: 4px 12px 4px 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  transition: border-color 0.15s;
}
.engine-pill:hover { border-color: var(--accent-dim); color: var(--text-hi); }
.engine-pill__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }
.engine-pill__dot--loading { background: var(--amber); box-shadow: 0 0 6px var(--amber); animation: bootPulse 1s infinite; }

/* ---- Menus ---- */
.menu { position: relative; }
.menu__caret { opacity: 0.6; }
.menu__list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 5px;
  z-index: 60;
  animation: menuIn 0.13s var(--ease-out);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu__list button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
}
.menu__list button:hover { background: var(--bg-4); color: var(--text-hi); }
.menu__list button code { color: var(--accent); }
.menu__sep { height: 1px; background: var(--border-1); margin: 5px 6px; }

/* ---- Layout ---- */
.layout { flex: 1; display: flex; min-height: 0; }

/* ============================================================================
   Left rail
   ========================================================================== */
.rail {
  width: var(--rail-w);
  flex: none;
  background: var(--bg-1);
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 10;
}
.rail__search {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 10px 6px;
  padding: 0 9px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  transition: border-color 0.15s;
}
.rail__search:focus-within { border-color: var(--accent-dim); color: var(--text-dim); }
.rail__search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-hi);
  min-width: 0;
}
.rail__search input::placeholder { color: var(--text-faint); }
.rail__section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px 5px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.rail__count { font-family: var(--font-mono); color: var(--text-faint); font-weight: 500; }
.rail__list { list-style: none; margin: 0; padding: 0 7px; overflow-y: auto; flex: 1; min-height: 0; }
.rail__list--small { flex: none; max-height: 140px; }
.rail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 9px;
  border-radius: 7px;
  color: var(--text);
  transition: background 0.12s;
  cursor: pointer;
}
.rail-item:hover { background: var(--bg-3); }
.rail-item.is-selected { background: var(--accent-glow); color: var(--text-hi); box-shadow: inset 0 0 0 1px var(--accent-dim); }
.rail-item__icon {
  width: 15px; height: 15px; flex: none;
  border-radius: 4px;
  border: 1.5px solid var(--blue);
  display: inline-flex; align-items: center; justify-content: center;
}
.rail-item__icon--view { border-color: var(--violet); border-radius: 50%; }
.rail-item__icon--trigger { border-color: var(--orange); }
.rail-item__name { flex: 1; font-family: var(--font-mono); font-size: 12px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item.is-match-dim { opacity: 0.4; }
.rail__stats {
  flex: none;
  border-top: 1px solid var(--border-1);
  padding: 10px 14px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 10px;
}
.rail-stat { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.rail-stat__k { font-size: 10.5px; color: var(--text-faint); }
.rail-stat__v { font-family: var(--font-mono); font-size: 11.5px; color: var(--text); }
.rail-stat__v--accent { color: var(--accent); }

/* ============================================================================
   Stage / canvas
   ========================================================================== */
.stage { flex: 1; min-width: 0; position: relative; }
.canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 70% -10%, rgba(122, 162, 247, 0.05), transparent 60%),
    radial-gradient(700px 420px at 10% 110%, rgba(67, 217, 194, 0.045), transparent 55%),
    var(--bg-0);
  cursor: grab;
  outline: none;
}
.canvas.is-panning { cursor: grabbing; }
.canvas.is-dragging-card { cursor: grabbing; }
.canvas__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(126, 158, 205, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 158, 205, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.6;
}
.world {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.world.is-animated { transition: transform 0.5s var(--ease-out); }
.wires { position: absolute; top: 0; left: 0; width: 0; height: 0; overflow: visible; }

/* ---- Entity cards ---- */
.entity {
  position: absolute;
  width: 264px;
  background: linear-gradient(180deg, #151d2d 0%, #101724 100%);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  user-select: none;
  cursor: grab;
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s, opacity 0.3s;
}
.entity.is-animated { transition: left 0.4s var(--ease-out), top 0.4s var(--ease-out), border-color 0.18s, box-shadow 0.18s, opacity 0.3s; }
.entity:hover { border-color: var(--border-3); }
.entity__glow { position: absolute; inset: -1px; border-radius: var(--radius); pointer-events: none; box-shadow: 0 0 0 1px var(--accent-dim), 0 0 24px rgba(67, 217, 194, 0.14); opacity: 0; transition: opacity 0.18s; }
.entity.is-selected { border-color: var(--accent-dim); z-index: 30; }
.entity.is-selected .entity__glow { opacity: 1; }
.entity.is-neighbor { border-color: rgba(67, 217, 194, 0.4); }
.entity.is-neighbor .entity__glow { opacity: 0.45; }
.entity.is-dimmed { opacity: 0.28; }
.entity.is-dimmed:hover { opacity: 0.7; }
.entity__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px 8px;
  border-bottom: 1px solid var(--border-1);
  background: linear-gradient(180deg, rgba(122, 162, 247, 0.06), transparent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.entity__icon { width: 13px; height: 13px; flex: none; border: 1.6px solid var(--blue); border-radius: 3.5px; opacity: 0.9; }
.entity__name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl; text-align: left;
}
.entity.is-selected .entity__name { color: var(--accent-hi); }
.entity__rows { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-faint); background: var(--bg-3); padding: 1.5px 6px; border-radius: 4px; border: 1px solid var(--border-1); }
.entity__cols { padding: 4px 0 6px; }
.entity__col {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 25px;
  padding: 0 10px;
  font-size: 11.5px;
  position: relative;
  transition: background 0.12s;
}
.entity__col:hover { background: rgba(122, 162, 247, 0.05); }
.entity__col.is-key { background: rgba(231, 182, 97, 0.05); }
.entity__col-name {
  font-family: var(--font-mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.entity__col.is-fk .entity__col-name { color: #a7c1ff; }
.entity__col-type {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.3px;
  color: var(--t-other);
  flex: none;
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entity__badges { display: inline-flex; gap: 3px; flex: none; align-items: center; }
.ebadge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  border-radius: 3px;
  padding: 0.5px 3.5px;
  line-height: 1.6;
  cursor: default;
}
.ebadge--pk { color: var(--amber); background: rgba(231, 182, 97, 0.13); border: 1px solid rgba(231, 182, 97, 0.25); }
.ebadge--fk { color: #9dbcff; background: rgba(122, 162, 247, 0.12); border: 1px solid rgba(122, 162, 247, 0.25); }
.ebadge--nn { color: var(--text-dim); background: var(--bg-4); border: 1px solid var(--border-2); }
.ebadge--uq { color: var(--violet); background: rgba(183, 139, 249, 0.12); border: 1px solid rgba(183, 139, 249, 0.25); }
.ebadge--def { color: var(--orange); background: rgba(230, 145, 110, 0.1); border: 1px solid rgba(230, 145, 110, 0.22); }
.entity__foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px 6px;
  border-top: 1px solid var(--border-1);
  color: var(--text-faint);
  font-size: 9.5px;
  font-family: var(--font-mono);
}
.entity__foot .badge { font-size: 9px; }
.entity--enter { animation: cardIn 0.34s var(--ease-out); }
@keyframes cardIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.entity--exit { opacity: 0 !important; transform: scale(0.94); pointer-events: none; }

/* ---- Edges ---- */
.wire { transition: opacity 0.25s; }
.wire__hit { stroke: transparent; stroke-width: 14px; fill: none; cursor: pointer; }
.wire__line {
  stroke: #3d4d6b;
  stroke-width: 1.6px;
  fill: none;
  transition: stroke 0.15s, stroke-width 0.15s, opacity 0.25s;
}
.wire__line--hover, .wire:hover .wire__line { stroke: var(--accent); stroke-width: 2.2px; }
.wire.is-active .wire__line { stroke: var(--accent); stroke-width: 2.4px; filter: drop-shadow(0 0 4px rgba(67, 217, 194, 0.45)); }
.wire.is-dimmed { opacity: 0.12; }
.wire.is-dimmed .wire__hit { pointer-events: none; }
.wire__port { fill: var(--bg-1); stroke: #3d4d6b; stroke-width: 1.2; transition: stroke 0.15s, fill 0.15s; }
.wire.is-active .wire__port { stroke: var(--accent); fill: rgba(67, 217, 194, 0.2); }
.wire__card-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  fill: var(--text-dim);
  paint-order: stroke;
  stroke: var(--bg-0);
  stroke-width: 3px;
  transition: fill 0.15s;
}
.wire.is-active .wire__card-label, .wire:hover .wire__card-label { fill: var(--accent-hi); }
.wire__mid {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--text-dim);
  paint-order: stroke;
  stroke: var(--bg-0);
  stroke-width: 3.5px;
  opacity: 0;
  transition: opacity 0.15s;
}
.wire:hover .wire__mid, .wire.is-active .wire__mid { opacity: 1; }

/* ---- Canvas tools ---- */
.canvas-tools {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(13, 18, 32, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  padding: 3px;
  box-shadow: var(--shadow-1);
  z-index: 15;
}
.ctool {
  min-width: 28px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 14px;
  font-family: var(--font-mono);
  transition: background 0.12s, color 0.12s;
}
.ctool:hover { background: var(--bg-4); color: var(--text-hi); }
.ctool--wide { padding: 0 8px; font-size: 10.5px; min-width: 44px; }
.ctool__sep { width: 1px; height: 16px; background: var(--border-2); margin: 0 3px; }

.canvas__hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-faint);
  font-size: 11px;
  display: flex;
  gap: 5px;
  align-items: center;
  background: rgba(13, 18, 32, 0.8);
  border: 1px solid var(--border-1);
  padding: 5px 12px;
  border-radius: 99px;
  backdrop-filter: blur(6px);
  z-index: 12;
  white-space: nowrap;
  transition: opacity 0.4s;
}
.canvas__hint kbd { padding: 0 4px; font-size: 9px; }
.canvas.has-minimap .canvas__hint { left: calc(50% - 118px); }

/* ---- Minimap ---- */
.minimap {
  position: absolute;
  right: 14px;
  bottom: 14px;
  border: 1px solid var(--border-2);
  border-radius: 9px;
  overflow: hidden;
  background: rgba(10, 14, 22, 0.92);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-1);
  z-index: 14;
  opacity: 0;
  transition: opacity 0.35s, transform 0.35s;
  transform: translateY(6px);
  pointer-events: none;
}
.minimap.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.minimap canvas { display: block; }

/* ---- Canvas empty state ---- */
.canvas__empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  z-index: 13;
  color: var(--text-dim);
  background: radial-gradient(600px 300px at 50% 45%, rgba(122, 162, 247, 0.05), transparent 70%);
}
.canvas__empty-icon { color: var(--text-faint); margin-bottom: 8px; }
.canvas__empty h2 { margin: 0; color: var(--text-hi); font-size: 16px; }
.canvas__empty p { margin: 0 0 14px; max-width: 380px; }
.canvas__empty-actions { display: flex; gap: 10px; }

/* ============================================================================
   Right dock
   ========================================================================== */
.dock {
  width: var(--dock-w);
  flex: none;
  background: var(--bg-1);
  border-left: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 10;
  transition: margin-right 0.3s var(--ease-out);
}
.dock.is-hidden { margin-right: calc(-1 * var(--dock-w)); }
.dock__tabs {
  display: flex;
  gap: 2px;
  padding: 7px 10px 0;
  border-bottom: 1px solid var(--border-1);
  flex: none;
}
.dock__tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.dock__tab:hover { color: var(--text); }
.dock__tab[aria-selected="true"] { color: var(--accent-hi); border-bottom-color: var(--accent); }
.kbd-compact { font-size: 9px; padding: 0 4px; color: var(--text-faint); }
.dock__pane { flex: 1; min-height: 0; display: none; flex-direction: column; }
.dock__pane--active { display: flex; }

/* ---- SQL editor ---- */
.sqledit {
  position: relative;
  margin: 10px 10px 0;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: #0a0f19;
  transition: border-color 0.15s;
  flex: none;
}
.sqledit:focus-within { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(67, 217, 194, 0.08); }
.sqledit__mirror, .sqledit__input {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  padding: 10px 12px;
  white-space: pre;
  tab-size: 2;
  word-wrap: normal;
  overflow-x: auto;
  overflow-y: hidden;
}
.sqledit__mirror {
  position: absolute;
  inset: 0;
  color: transparent;
  pointer-events: none;
  z-index: 1;
}
.sqledit__input {
  position: relative;
  display: block;
  width: 100%;
  min-height: 76px;
  max-height: 240px;
  resize: vertical;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-hi);
  caret-color: var(--accent);
  z-index: 2;
}
.tok-kw { color: #7fd0f7; font-weight: 600; }
.tok-str { color: #9dd98a; }
.tok-num { color: #e7b661; }
.tok-com { color: #5a6a83; font-style: italic; }
.tok-fn { color: #d0a9f7; }
.tok-punc { color: #74869f; }

.console__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  flex: none;
  flex-wrap: nowrap;
  overflow: hidden;
}
.btn--run { padding: 5px 14px; }
.chips { display: flex; gap: 5px; overflow-x: auto; flex: 1; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.console__history { position: relative; flex: none; }
.history__list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 400px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 5px;
  z-index: 50;
}
.history__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 9px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history__item:hover { background: var(--bg-4); color: var(--text-hi); }
.history__item .meta { color: var(--text-faint); font-size: 10px; margin-right: 6px; }
.history__item .ok { color: var(--green); }
.history__item .err { color: var(--red); }
.history__empty { padding: 10px; color: var(--text-faint); font-size: 12px; text-align: center; }

/* ---- Results area ---- */
.console__results { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 10px 10px; overflow: hidden; }
.results__placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 12px;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm);
  margin-top: 2px;
}
.query-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 2px;
  font-size: 11.5px;
  color: var(--text-dim);
  flex: none;
}
.query-meta__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.query-meta__dot--error { background: var(--red); }
.query-meta strong { color: var(--text-hi); font-weight: 600; font-family: var(--font-mono); font-size: 11px; }
.query-meta .mono { font-family: var(--font-mono); font-size: 11px; }
.query-meta__spacer { flex: 1; }

/* ---- Error panel ---- */
.sql-error {
  background: rgba(239, 107, 115, 0.07);
  border: 1px solid rgba(239, 107, 115, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  margin-top: 6px;
  flex: none;
}
.sql-error__title { display: flex; align-items: center; gap: 7px; color: var(--red); font-weight: 650; font-size: 12px; margin: 0 0 5px; }
.sql-error__msg { margin: 0; font-family: var(--font-mono); font-size: 11.5px; color: #f0a7ab; word-break: break-word; white-space: pre-wrap; }
.sql-error__hint { margin: 7px 0 0; font-size: 11px; color: var(--text-dim); }

/* ============================================================================
   Data grid (console results + inspector)
   ========================================================================== */
.grid-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  background: #0b101b;
  position: relative;
}
.datagrid {
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  min-width: 100%;
}
.datagrid th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #131a29;
  border-bottom: 1px solid var(--border-2);
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-align: left;
  padding: 0;
  white-space: nowrap;
}
.datagrid th .th-inner {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  transition: color 0.12s, background 0.12s;
}
.datagrid th .th-inner:hover { color: var(--text-hi); background: var(--bg-4); }
.datagrid th.is-sorted { color: var(--accent-hi); }
.datagrid th .sort-arrow { font-size: 8px; opacity: 0.9; }
.datagrid th.rownum-h .th-inner { cursor: default; }
.datagrid th.rownum-h .th-inner:hover { background: none; }
.datagrid td {
  padding: 4.5px 10px;
  border-bottom: 1px solid rgba(30, 40, 57, 0.6);
  color: var(--text);
  white-space: nowrap;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
.datagrid td.rownum {
  color: var(--text-faint);
  font-size: 10px;
  text-align: right;
  background: rgba(13, 18, 32, 0.5);
  user-select: none;
}
.datagrid tbody tr { transition: background 0.1s; }
.datagrid tbody tr:hover { background: rgba(122, 162, 247, 0.05); }
.datagrid tbody tr.is-flash { animation: rowFlash 1.6s var(--ease-out); }
@keyframes rowFlash { 0%, 40% { background: rgba(67, 217, 194, 0.22); } 100% { background: transparent; } }
.cell-null { color: var(--text-faint); font-style: italic; }
.cell-num { color: var(--amber); }
.cell-blob { color: var(--violet); }
.cell-link {
  color: #9dbcff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cell-link:hover { color: var(--accent-hi); text-decoration: underline; }
.cell-link .link-ico { opacity: 0; font-size: 9px; transition: opacity 0.12s; }
.cell-link:hover .link-ico { opacity: 1; }
.grid-truncated { padding: 8px 12px; color: var(--text-faint); font-size: 11px; border-top: 1px solid var(--border-1); font-family: var(--font-mono); }

.grid-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 34px 20px;
  color: var(--text-dim);
  text-align: center;
}
.grid-empty .big { font-size: 20px; color: var(--text-faint); }
.grid-empty .why { color: var(--text-faint); font-size: 11px; }

/* ============================================================================
   Inspector
   ========================================================================== */
.inspector__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  text-align: center;
  padding: 30px;
}
.inspector__empty-icon { color: var(--text-faint); }
.inspector { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.inspector__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-1);
  flex: none;
  flex-wrap: wrap;
}
.inspector__title { font-family: var(--font-mono); font-size: 15px; font-weight: 650; color: var(--text-hi); word-break: break-all; }
.inspector__chips { display: flex; gap: 5px; flex-wrap: wrap; }
.inspector__tabs { display: flex; gap: 4px; padding: 8px 10px 0; flex: none; }
.itab {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  border: 1px solid transparent;
  transition: all 0.13s;
}
.itab:hover { color: var(--text-hi); }
.itab.is-active { color: var(--accent-hi); background: var(--accent-glow); border-color: rgba(67, 217, 194, 0.25); }
.inspector__body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px; overflow: hidden; }
.inspector__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  flex: none;
  flex-wrap: nowrap;
  font-size: 11.5px;
  color: var(--text-dim);
}
.pager { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.pager__info { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); margin-right: 6px; white-space: nowrap; }
.pager__btn {
  min-width: 24px;
  height: 24px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.pager__btn:hover:not([disabled]) { color: var(--text-hi); border-color: var(--border-3); background: var(--bg-3); }
.pager__btn[disabled] { opacity: 0.35; cursor: default; }
select.mini-select {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: 6px;
  font-size: 11px;
  padding: 3px 6px;
  outline: none;
}
.ddl-view { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.ddl-view pre {
  flex: 1;
  margin: 0;
  overflow: auto;
  background: #0a0f19;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-hi);
  white-space: pre-wrap;
  word-break: break-word;
}
.ddl-note { font-size: 11px; color: var(--text-faint); display: flex; align-items: center; gap: 7px; }
.idx-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.idx-card {
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--bg-2);
}
.idx-card__name { font-family: var(--font-mono); font-size: 12px; color: var(--text-hi); display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.idx-card__cols { margin-top: 5px; color: var(--text-dim); font-family: var(--font-mono); font-size: 11px; word-break: break-all; }
.idx-card__meta { margin-top: 5px; display: flex; gap: 8px; font-size: 10.5px; color: var(--text-faint); flex-wrap: wrap; }
.idx-empty { color: var(--text-faint); font-size: 12px; padding: 14px; text-align: center; }

/* ============================================================================
   Schema pane
   ========================================================================== */
.schemapane { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 20px; display: flex; flex-direction: column; gap: 14px; }
.schema-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary-tile {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.summary-tile__v { font-family: var(--font-mono); font-size: 17px; font-weight: 650; color: var(--text-hi); }
.summary-tile__k { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.7px; margin-top: 1px; }
.section-label {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border-1); }
.schema-table-list { display: flex; flex-direction: column; gap: 6px; }
.schema-table-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.13s, background 0.13s;
}
.schema-table-row:hover { border-color: var(--border-3); background: var(--bg-3); }
.schema-table-row__name { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-hi); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schema-table-row__meta { display: flex; gap: 6px; align-items: center; flex: none; }
.schema-table-row .inspect-btn { color: var(--text-faint); font-size: 10.5px; border: 1px solid var(--border-2); padding: 2px 7px; border-radius: 5px; }
.schema-table-row .inspect-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.export-card { display: flex; flex-direction: column; gap: 9px; background: var(--bg-2); border: 1px solid var(--border-1); border-radius: var(--radius-sm); padding: 13px; }
.export-card p { margin: 0; color: var(--text-dim); font-size: 11.5px; }
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.engine-details { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 11.5px; }
.engine-details dt { color: var(--text-faint); }
.engine-details dd { margin: 0; font-family: var(--font-mono); color: var(--text); text-align: right; }

/* ============================================================================
   Popover, toasts, modal
   ========================================================================== */
.popover {
  position: fixed;
  z-index: 80;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 13px 16px;
  min-width: 230px;
  animation: menuIn 0.14s var(--ease-out);
}
.popover h3 { margin: 0 0 10px; font-size: 12px; color: var(--text-hi); }
.popover__row { display: flex; justify-content: space-between; gap: 14px; padding: 2.5px 0; font-size: 11.5px; }
.popover__row span:first-child { color: var(--text-faint); }
.popover__row span:last-child { font-family: var(--font-mono); color: var(--text); }

.toasts {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(18, 25, 40, 0.96);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 12.5px;
  color: var(--text-hi);
  box-shadow: var(--shadow-2);
  animation: toastIn 0.28s var(--ease-out);
  backdrop-filter: blur(8px);
}
.toast.is-leaving { animation: toastOut 0.3s var(--ease-out) forwards; }
.toast__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.toast--error .toast__dot { background: var(--red); }
.toast--warn .toast__dot { background: var(--amber); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

.modal-root { position: fixed; inset: 0; z-index: 95; pointer-events: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.66);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(560px, calc(100vw - 40px));
  max-height: min(640px, calc(100vh - 60px));
  overflow-y: auto;
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  padding: 22px 26px;
  animation: menuIn 0.2s var(--ease-out);
}
.modal h2 { margin: 0 0 4px; font-size: 16px; color: var(--text-hi); }
.modal__sub { margin: 0 0 16px; color: var(--text-dim); font-size: 12px; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 26px; }
.sc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 12.5px; color: var(--text); }
.sc-keys { display: flex; gap: 4px; align-items: center; flex: none; }
.modal__actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* ============================================================================
   Responsive behaviour
   ========================================================================== */
@media (max-width: 1420px) {
  .topbar__stats .stat:nth-child(n+4) { display: none; }
}
@media (max-width: 1280px) {
  :root { --dock-w: 430px; --rail-w: 216px; }
  .topbar__stats { display: none; }
}
@media (max-width: 1100px) {
  .layout { position: relative; }
  .rail {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease-out);
    box-shadow: var(--shadow-2);
  }
  .rail.is-open { transform: none; }
  .rail-toggle {
    position: absolute;
    left: 12px;
    top: 56px;
    z-index: 31;
    display: inline-flex;
  }
}
.rail-toggle { display: none; }
@media (max-width: 980px) {
  :root { --dock-w: min(420px, 88vw); }
  .canvas__hint { display: none; }
}

/* Canvas coordinate origin marker for debugging — intentionally empty */
