:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--bg-page);
  --bg-page: #071624;
  --bg-header: #081827;
  --bg-panel: #0B2032;
  --bg-panel-raised: #0E263A;
  --bg-editor: #061321;
  --bg-hover: #123149;
  --bg-selected: #153B55;
  --border-default: #234158;
  --border-subtle: #19354A;
  --border-active: #4FC3E8;
  --text-primary: #E7EEF5;
  --text-secondary: #A9BAC9;
  --text-muted: #71879A;
  --text-heading: #77D6F5;
  --accent-primary: #59C8EC;
  --accent-primary-hover: #76D5F2;
  --accent-primary-text: #04131F;
  --status-success: #49D18D;
  --status-warning: #F1B85B;
  --status-danger: #F06D78;
  --code-keyword: #68D5F4;
  --code-function: #D8A8FF;
  --code-number: #F0A6D2;
  --code-string: #B9DE89;
  --code-operator: #E8C572;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-small: 6px;
  --radius-medium: 8px;
  --radius-large: 12px;
  --bg: var(--bg-page);
  --panel: var(--bg-panel);
  --panel-soft: var(--bg-panel-raised);
  --panel-strong: var(--bg-selected);
  --line: var(--border-default);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --accent: var(--accent-primary);
  --accent-strong: var(--accent-primary-hover);
  --warn: var(--status-warning);
  --danger: var(--status-danger);
  --ai-panel-width: minmax(360px, 34vw);
  --schema-pane-height: 65%;
  --page-gutter: var(--space-2);
  --workspace-gutter-horizontal: 0px;
  --main-column-gap: 10px;
  --resize-handle-size: var(--main-column-gap);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #46738F transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: #46738F;
}

*::-webkit-scrollbar-thumb:hover {
  background: #59C8EC;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-page);
}

.login-page {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  overflow: auto;
  padding: var(--space-5);
}

.login-panel {
  width: min(460px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  padding: var(--space-4);
  backdrop-filter: blur(18px);
}

h1 {
  margin: 0;
  color: var(--text-heading);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-logo {
  display: block;
  width: auto;
  object-fit: contain;
}

.login-logo {
  height: 64px;
  margin-bottom: var(--space-3);
}

.header-logo {
  height: 54px;
}

.login-intro {
  margin: 0 0 var(--space-5);
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

label {
  display: block;
  margin-top: var(--space-4);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

input,
textarea {
  width: 100%;
  margin-top: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  padding: var(--space-3);
  font: inherit;
  color: var(--text);
  background: var(--bg-editor);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--border-active);
  outline: 3px solid var(--bg-selected);
}

button {
  font: inherit;
  cursor: pointer;
  transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;
}

.primary-button {
  display: inline-flex;
  height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-4);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-small);
  color: var(--accent-primary-text);
  background: var(--accent-primary);
  font-size: 13px;
  font-weight: 700;
}

.primary-button:hover {
  border-color: var(--accent-primary-hover);
  background: var(--accent-primary-hover);
}

.run-query-button {
  gap: var(--space-2);
}

.button-icon {
  flex: 0 0 auto;
}

.primary-icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  position: relative;
}

.run-query-button.is-loading .button-icon,
.primary-icon-button.is-loading .ai-submit-icon {
  display: none;
}

.primary-icon-button.is-cancellable::after {
  width: 6px;
  height: 6px;
  position: absolute;
  border-radius: 1px;
  background: currentColor;
  content: "";
}

.secondary-button {
  display: inline-flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid #365269;
  border-radius: var(--radius-small);
  color: #DCE7EF;
  background: var(--bg-panel-raised);
  font-size: 12px;
  font-weight: 600;
}

.secondary-button:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
}

.login-button {
  width: 100%;
  margin-top: var(--space-5);
}

.error {
  margin: 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--status-danger);
  border-radius: var(--radius-medium);
  background: var(--bg-panel-raised);
  color: var(--status-danger);
  font-size: calc(16px - 2pt);
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  height: 78px;
  padding: 0 40px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-header);
  backdrop-filter: blur(18px);
  position: relative;
  z-index: 10;
}

.header-brand-lockup {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.header-title {
  margin: 0;
  color: var(--text-heading);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.8px;
  line-height: 1.3;
}

.query-main {
  display: grid;
  width: 100%;
  max-width: none;
  grid-template-columns: minmax(0, 1fr) var(--main-column-gap) var(--ai-panel-width);
  gap: 0;
  min-height: 0;
  overflow: hidden;
  border: 0;
  padding: var(--page-gutter) var(--workspace-gutter-horizontal) 0;
}

.query-main.panel-closed {
  grid-template-columns: minmax(0, 1fr) 0 0;
}

.query-main.panel-drag-collapsed {
  grid-template-columns: minmax(0, 1fr) var(--main-column-gap) 0;
}

.query-main.panel-expanded {
  grid-template-columns: 0 var(--main-column-gap) minmax(0, 1fr);
}

.query-main.is-resizing {
  cursor: col-resize;
  user-select: none;
}

.database-workspace.is-resizing-workspace {
  cursor: row-resize;
  user-select: none;
}

.database-workspace,
.ai-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-large);
  background: var(--bg-panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.ai-query-options {
  position: absolute;
  left: var(--space-3);
  bottom: var(--space-3);
  z-index: 3;
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin: 0;
}

.ai-mode-control {
  display: inline-flex;
  height: 28px;
  align-items: center;
  margin: 0;
  position: relative;
}

.ai-mode-control::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 3px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  pointer-events: none;
  transform: translateY(-65%) rotate(45deg);
}

.ai-mode-control select {
  width: 78px;
  height: 28px;
  min-height: 28px;
  margin: 0;
  border: 0;
  padding: 0 var(--space-4) 0 0;
  color: var(--text-secondary);
  background-color: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 28px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.ai-mode-control select.is-conversation {
  width: 142px;
}

.ai-mode-control select:focus-visible {
  border-radius: var(--radius-small);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ai-mode-control select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.sql-option-toggle {
  display: inline-flex;
  height: 28px;
  gap: 6px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  cursor: pointer;
  position: relative;
}

.sql-option-toggle[hidden] {
  display: none;
}

.sql-option-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.sql-option-toggle.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-settings {
  display: inline-flex;
  height: 28px;
  align-items: center;
  position: relative;
  z-index: 60;
}

.ai-settings[hidden] {
  display: none;
}

.ai-settings-button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: var(--radius-small);
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.ai-settings-button:hover,
.ai-settings-button[aria-expanded="true"] {
  color: var(--text-heading);
  background: var(--bg-hover);
}

.ai-settings-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.ai-settings-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-settings-menu {
  display: grid;
  position: fixed;
  z-index: 900;
  width: max-content;
  min-width: 210px;
  gap: var(--space-2);
  overflow: visible;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-medium);
  padding: var(--space-3);
  background: var(--bg-panel-raised);
}

.ai-settings-menu[hidden] {
  display: none;
}

.ai-setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px 20px;
  gap: 6px;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
}

.ai-setting-row.is-disabled {
  opacity: 0.5;
}

.reasoning-effort-setting {
  grid-template-columns: minmax(0, 1fr) minmax(112px, auto) 20px;
}

.ai-settings-menu .sql-option-toggle {
  justify-self: end;
}

.ai-setting-select {
  display: inline-flex;
  height: 28px;
  align-items: center;
  justify-self: end;
  margin: 0;
}

.ai-setting-select select {
  width: 112px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 0 24px 0 8px;
  color: var(--text-secondary);
  background: var(--bg-panel);
  font: inherit;
  font-size: 12px;
}

.ai-setting-select select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.setting-help-button {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.setting-help-button:hover,
.setting-help-button:focus-visible {
  border-color: var(--border-active);
  color: var(--text-heading);
  background: var(--bg-hover);
  outline: none;
  transform: none;
}

.floating-tooltip {
  position: fixed;
  z-index: 1000;
  width: max-content;
  max-width: min(260px, calc(100vw - 16px));
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-medium);
  color: var(--text);
  background: var(--bg-panel-raised);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  pointer-events: none;
  text-align: left;
}

.database-workspace {
  display: grid;
  grid-template-rows: var(--schema-pane-height) var(--resize-handle-size) minmax(0, 1fr);
  overflow: hidden;
  border-left: 0;
  border-radius: 0 var(--radius-large) var(--radius-large) 0;
  padding: 0;
}

.database-workspace > .navigator-panel {
  grid-row: 1;
}

.database-workspace > .workspace-resizer {
  grid-row: 2;
}

.database-workspace > .sql-console {
  grid-row: 3;
}

.database-workspace.navigator-collapsed .navigator-content {
  display: none;
  overflow: hidden;
  pointer-events: none;
}

.database-workspace.navigator-collapsed .workspace-header {
  margin-bottom: 0;
}

.database-workspace.navigator-collapsed .navigator-panel {
  overflow: hidden;
  padding-bottom: 0;
}

.database-workspace.navigator-collapsed {
  grid-template-rows:
    var(--schema-pane-height)
    0
    minmax(0, 1fr);
}

.database-workspace.navigator-collapsed .workspace-resizer {
  height: 0;
  visibility: hidden;
  pointer-events: none;
}

.database-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  padding: var(--space-4);
  background: var(--bg-panel);
  backdrop-filter: blur(18px) saturate(115%);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
}

.navigator-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.panel-resizer {
  align-self: stretch;
  width: var(--resize-handle-size);
  min-height: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  cursor: col-resize;
  position: relative;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 44px;
  border-radius: 2px;
  background: #2A495F;
  transform: translate(-50%, -50%);
  transition: background-color 120ms ease-out;
}

.panel-resizer:hover::before,
.panel-resizer:focus-visible::before,
.query-main.is-resizing .panel-resizer::before {
  background: #59C8EC;
}

.panel-resizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -5px;
}

.console-header {
  height: 40px;
  min-height: 40px;
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.sql-section-resizer {
  display: grid;
  position: absolute;
  bottom: 3px;
  left: 50%;
  z-index: 4;
  width: 52px;
  height: 12px;
  place-items: center;
  cursor: row-resize;
  touch-action: none;
  transform: translateX(-50%);
}

.sql-section-resizer::before {
  content: "";
  width: 44px;
  height: 3px;
  border-radius: 2px;
  background: #2A495F;
  transition: background-color 120ms ease-out;
}

.sql-section-resizer:hover::before,
.sql-section-resizer:focus-visible::before,
.database-workspace.is-resizing-workspace .sql-section-resizer::before {
  background: #59C8EC;
}

.sql-section-resizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.workspace-header,
.panel-header {
  display: flex;
  min-height: 54px;
  align-items: center;
  margin: -16px -16px 16px;
  border-bottom: 0;
  padding: 8px 14px 12px;
  position: relative;
}

.workspace-header::after,
.panel-header::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 1px;
  background: #19354A;
}

.workspace-header .eyebrow,
.panel-header .eyebrow,
.console-header .eyebrow {
  margin-bottom: 0;
  color: var(--text-heading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.6px;
  line-height: 16px;
  text-transform: uppercase;
}

.panel-title-line {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.workspace-header {
  justify-content: space-between;
  gap: var(--space-4);
  z-index: 40;
}

.db-header-controls {
  display: block;
  position: static;
  margin-left: auto;
  transform: none;
}

.db-header-controls .panel-control-row {
  gap: 0;
}

.safety-status-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.hide-ai-panel-button {
  margin-left: var(--space-2);
  align-self: center;
}

.db-header-controls .info-icon {
  margin-left: var(--space-2);
}

.panel-header {
  flex-direction: row;
  justify-content: space-between;
  gap: var(--space-4);
}

.panel-header .panel-control-row {
  align-self: center;
}

.panel-header .section-title {
  display: flex;
  min-height: 32px;
  align-items: center;
}

.clear-chat-button {
  height: 28px;
  padding: 0 6px;
  border: 0;
  color: #8EA3B5;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
}

.clear-chat-button:hover {
  color: #77D6F5;
  background: transparent;
}

.clear-chat-button.is-confirming {
  color: var(--status-danger);
  background: transparent;
}

.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.header-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.section-title {
  min-width: 0;
}

.navigator-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.navigator-title-row .eyebrow,
.sql-console-title-row .eyebrow {
  margin-bottom: 0;
}

.sql-console-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

h2 {
  margin: 0;
  color: var(--text-heading);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-tools,
.navigator-connection {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.section-tools {
  justify-content: flex-end;
}

.panel-control-row {
  width: auto;
  min-height: 32px;
  gap: var(--space-3);
  flex-wrap: nowrap;
}

.status-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  height: 30px;
  min-height: 30px;
  padding: 0 var(--space-3);
  border: 1px solid #2A495F;
  border-radius: 15px;
  color: #D7E2EB;
  background: var(--bg-panel-raised);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

.model-status-select {
  display: inline-flex;
  flex: 0 0 auto;
  height: 28px;
  align-items: center;
  margin: 0;
}

.model-status-select select {
  width: auto;
  min-width: max-content;
  max-width: none;
  height: 28px;
  min-height: 28px;
  margin: 0;
  border: 0;
  padding: 0 18px 0 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: 700;
  line-height: 28px;
  cursor: pointer;
}

.model-status-select select:focus-visible {
  border-radius: var(--radius-small);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.model-status-select select:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.session-stats {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.session-stats-button::before {
  display: none;
}

.session-stats-button svg {
  width: 17px;
  height: 17px;
}

.session-stats-button[aria-expanded="true"] {
  border-color: #365269;
  color: var(--accent);
  background: var(--bg-hover);
}

.session-stats-menu {
  display: grid;
  position: fixed;
  z-index: 900;
  width: 238px;
  gap: var(--space-3);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-medium);
  padding: var(--space-3);
  color: var(--text);
  background: var(--bg-panel-raised);
}

.session-stats-menu[hidden] {
  display: none;
}

.session-stats-heading {
  color: var(--text-heading);
  font-size: 12px;
  font-weight: 800;
}

.session-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
}

.session-stats-grid div {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: var(--space-2);
  background: var(--bg-panel);
}

.session-stats-grid dt,
.session-cost-row span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.session-stats-grid dd {
  margin: 0;
  color: var(--text-heading);
  font-size: 14px;
  font-weight: 800;
}

.session-cost-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: var(--space-2);
}

.session-cost-row strong {
  color: var(--status-success);
  font-size: 16px;
}

.session-stats-note {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.connection-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.connection-dot.is-pending { background: var(--status-warning); }
.connection-dot.is-connected {
  width: 8px;
  height: 8px;
  background: var(--status-success);
  box-shadow: 0 0 0 3px rgba(73, 209, 141, 0.14);
}
.connection-dot.is-unavailable {
  background: var(--status-danger);
}

.connection-dot.is-starting {
  background: var(--status-warning);
}

.connection-dot.is-stopped {
  background: var(--status-danger);
}

.privacy-status-badge {
  position: relative;
  cursor: help;
}

.privacy-status-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--status-success);
}

.privacy-status-badge::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  z-index: 30;
  width: max-content;
  max-width: min(320px, 78vw);
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-medium);
  color: var(--text-primary);
  background: var(--bg-panel-raised);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  white-space: normal;
  transform: translateY(-2px);
}

.privacy-status-badge:hover::after,
.privacy-status-badge:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.privacy-status-badge:focus-visible {
  outline: 2px solid var(--border-active);
  outline-offset: 2px;
}

.ai-panel-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.info-icon {
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  text-transform: none;
  cursor: help;
  position: relative;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  z-index: 30;
  width: max-content;
  max-width: min(280px, 78vw);
  padding: var(--space-3);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-medium);
  color: var(--text);
  background: var(--bg-panel-raised);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  text-transform: none;
  transform: translateY(-2px);
}

.info-icon:hover::after,
.info-icon:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.info-icon:focus-visible {
  outline: 2px solid var(--border-active);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 32px;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  color: var(--text-heading);
  background: transparent;
  position: relative;
}

.icon-button:hover {
  border-color: #365269;
  background: var(--bg-hover);
}

.icon-button:not(.info-icon)::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  clip-path: polygon(0 62.5%, 12.5% 75%, 50% 37.5%, 87.5% 75%, 100% 62.5%, 50% 12.5%);
}

.icon-button:not(.info-icon):not(.panel-toggle)[aria-expanded="false"]::before {
  transform: rotate(180deg);
}

.schema-tree {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  min-height: 0;
  overflow: auto;
  padding-right: var(--space-1);
}

.navigator-content {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.catalog-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 18px;
  margin: 0 0 var(--space-4);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

.catalog-status:not(.is-error)::after {
  content: "";
  order: 1;
  flex: 1;
  height: 1px;
  background: var(--line);
}

.catalog-status.is-error {
  color: var(--danger);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.schema-view-toggle {
  display: inline-flex;
  order: 2;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
}

.schema-view-toggle[hidden] {
  display: none;
}

.schema-view-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.schema-toggle-track {
  width: 30px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--bg-editor);
  position: relative;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}

.schema-toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  transition: background-color 120ms ease-out;
}

.schema-view-toggle input:checked + .schema-toggle-track,
.sql-option-toggle input:checked + .schema-toggle-track {
  border-color: var(--border-active);
  background: var(--bg-selected);
}

.schema-view-toggle input:checked + .schema-toggle-track::after,
.sql-option-toggle input:checked + .schema-toggle-track::after {
  background: var(--accent);
  transform: translateX(14px);
}

.schema-view-toggle input:focus-visible + .schema-toggle-track,
.sql-option-toggle input:focus-visible + .schema-toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.schema-diagram {
  display: grid;
  place-items: start;
  min-height: 0;
  overflow: auto;
  padding-right: var(--space-1);
}

.schema-diagram[hidden],
.schema-tree[hidden] {
  display: none;
}

.schema-diagram img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: clamp(520px, 60vw, 760px);
  min-height: clamp(293px, 33.75vw, 428px);
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--bg-editor);
  object-fit: contain;
}

.workspace-resizer {
  height: var(--resize-handle-size);
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  cursor: row-resize;
  position: relative;
}

.workspace-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 3px;
  border-radius: 2px;
  background: #2A495F;
  transform: translate(-50%, calc(-50% + 7px));
  transition: background-color 120ms ease-out;
}

.workspace-resizer:hover::before,
.workspace-resizer:focus-visible::before,
.database-workspace.is-resizing-workspace .workspace-resizer::before {
  background: #59C8EC;
}

.workspace-resizer:focus-visible {
  outline: none;
}

.schema-card,
.table-card {
  background: var(--bg-editor);
}

.schema-card {
  border: 0;
  border-radius: var(--radius-medium);
}

.table-card {
  border-radius: 0;
  background: transparent;
}

.schema-card summary,
.table-card summary {
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  list-style: none;
  min-height: 46px;
  padding: var(--space-3) var(--space-4);
  font-weight: 800;
}

.schema-card summary::-webkit-details-marker,
.table-card summary::-webkit-details-marker {
  display: none;
}

.chevron {
  flex: 0 0 13px;
  color: var(--accent);
  font-size: 13px;
}

.schema-name {
  margin-left: var(--space-2);
}

.table-name {
  min-width: 0;
  margin-left: var(--space-3);
  color: #E7EEF5;
  font-size: 14px;
  font-weight: 650;
}

.table-meta {
  color: #8EA3B5;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.schema-count,
.column-type,
.column-flags {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.schema-count,
.table-meta {
  margin-left: auto;
}

.tables,
.columns {
  display: grid;
  gap: var(--space-2);
  padding: 0 var(--space-2) var(--space-2);
}

.tables {
  gap: 0;
}

.table-card > summary {
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid #19354A;
  background: transparent;
}

.table-card > summary:hover {
  background: #123149;
}

.table-card[open] > summary,
.table-card.is-selected > summary {
  padding-left: 11px;
  border-left: 3px solid #59C8EC;
  background: #102A3D;
}

.columns {
  padding-left: var(--space-6);
}

.column-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--space-3);
  align-items: center;
  padding: 12px;
  border: 0;
  border-left: 2px solid #234158;
  border-radius: 0 6px 6px 0;
  background: #081827;
}

.column-identity {
  min-width: 0;
}

.column-name {
  display: block;
  overflow: hidden;
  color: #DCE7EF;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.object-description {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: 12px;
}

.object-description-label {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.4;
}

.object-description p {
  max-width: 72ch;
  margin: var(--space-1) 0 0;
  color: var(--text-secondary);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.table-description {
  margin: 0 0 var(--space-1) var(--space-5);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-editor);
}

.column-description {
  margin-top: 6px;
  padding: 0;
  background: transparent;
}

.column-description p {
  margin: 0;
  color: #A9BAC9;
  font-size: 12px;
  line-height: 18px;
}

.column-type,
.column-flags {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
}

.column-type {
  color: #8EA3B5;
}

.column-flags.is-required {
  color: #F1B85B;
}

.column-flags.is-nullable {
  color: #D9A45C;
}

.empty-state {
  padding: var(--space-5);
  border-radius: var(--radius-medium);
  color: var(--muted);
  background: var(--bg-editor);
}

.ai-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 0;
  border-radius: var(--radius-large) 0 0 var(--radius-large);
  padding: var(--space-4);
  background: var(--bg-panel);
  backdrop-filter: blur(18px) saturate(115%);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
  transform: translateX(0);
  opacity: 1;
}

.query-main.panel-closed .ai-panel,
.query-main.panel-drag-collapsed .ai-panel {
  transform: translateX(24px);
  opacity: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  pointer-events: none;
}

.query-main.panel-closed .panel-resizer {
  display: none;
}

.query-main.panel-expanded .database-workspace {
  opacity: 0;
  pointer-events: none;
}

textarea {
  min-height: 150px;
  resize: none;
  overflow-y: hidden;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.sql-console {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  align-self: stretch;
  overflow: hidden;
}

.sql-console-content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}

.sql-console.is-collapsed {
  overflow: hidden;
}

.sql-console.is-collapsed .console-header {
  margin-bottom: 0;
}

.sql-console.is-collapsed .sql-console-content {
  display: none;
}

.chat-history {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 80px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 0 var(--space-4);
}

.chat-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  min-height: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: var(--space-4);
  color: var(--muted);
  text-align: center;
}

.chat-empty-title {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 22px;
}

.chat-empty-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 18px;
}

.chat-message {
  display: grid;
  gap: var(--space-2);
  width: min(92%, 620px);
}

.chat-message.is-user {
  align-self: flex-end;
}

.chat-message.is-assistant {
  align-self: flex-start;
}

.chat-message-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.chat-message.is-user .chat-message-header {
  justify-content: flex-end;
}

.chat-speaker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-timestamp {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chat-bubble {
  margin: 0;
  border-radius: var(--radius-medium);
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  background: var(--bg-editor);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-message.is-user .chat-bubble {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-3);
  border-radius: var(--radius-medium);
  background: var(--bg-selected);
}

.chat-question-elapsed,
.chat-pending-elapsed,
.chat-explanation-elapsed {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chat-message.is-error .chat-bubble {
  color: var(--status-danger);
  background: var(--bg-panel-raised);
}

.chat-sql {
  overflow: auto;
  margin: 0;
  font: calc(13px - 2pt)/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  tab-size: 4;
  white-space: pre-wrap;
}

.chat-prose,
.chat-explanation-section p,
.chat-explanation-section ul {
  margin: 0;
  white-space: pre-wrap;
}

.chat-prose {
  line-height: 1.55;
}

.chat-sql-explanation {
  display: grid;
  gap: 18px;
  margin-top: var(--space-3);
  padding: 16px;
  border: 1px solid #234158;
  border-radius: var(--radius-medium);
  background: #081827;
}

.chat-explanation-section h4 {
  margin: 0 0 6px;
  color: #65BCD8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.chat-explanation-section p,
.chat-explanation-section ul {
  color: #D7E2EB;
  font-size: calc(14px - 2pt);
  line-height: 21px;
}

.chat-explanation-pending {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: #D7E2EB;
  font-size: calc(14px - 2pt);
  line-height: 21px;
}

.chat-explanation-pending::before {
  content: "";
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.chat-explanation-elapsed {
  margin-left: auto;
}

.chat-message-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: 1em;
  border-top: 1px solid #19354A;
  padding-top: var(--space-3);
  flex-wrap: wrap;
}

.chat-pending-text {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-2);
}

.chat-pending-label {
  margin-right: auto;
}

.chat-pending-text::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.chat-composer {
  flex: 0 0 auto;
  margin-top: var(--space-2);
  padding-top: 0;
  position: relative;
}

.question-editor {
  display: block;
  height: 190px;
  overflow: visible;
  border: 1px solid #2A495F;
  border-radius: 8px;
  padding: 0;
  background: #061321;
  position: relative;
}

.question-editor:focus-within {
  border-color: #4FC3E8;
  box-shadow: 0 0 0 2px rgba(79, 195, 232, 0.12);
}

.chat-composer .status {
  margin-bottom: 0;
}

.chat-composer textarea {
  display: block;
  position: relative;
  z-index: 2;
  height: 100%;
  min-height: 0;
  max-height: none;
  margin-top: 0;
  border: 0;
  border-radius: 0;
  padding: 14px 14px 58px;
  scroll-padding-bottom: 58px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  line-height: 20px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.ai-prompt-hint {
  display: flex;
  position: absolute;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 1;
  flex-direction: column;
  color: #71879A;
  font-size: 13px;
  line-height: 20px;
  pointer-events: none;
}

.ai-prompt-hint-suggest {
  font-style: italic;
}

.ai-prompt-input:not(:placeholder-shown) + .ai-prompt-hint {
  display: none;
}

.question-editor textarea:focus {
  border-color: transparent;
  outline: none;
}

.ai-prompt-footer {
  display: flex;
  height: 52px;
  align-items: flex-end;
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  border-radius: 0 0 7px 7px;
  padding: 0 var(--space-3) var(--space-3) 14px;
  background: #061321;
}

.ai-mode-controls {
  display: flex;
  height: 28px;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  position: static;
  left: auto;
  bottom: auto;
  z-index: auto;
  min-height: 0;
  padding: 0;
}

.ai-submit-button {
  display: flex;
  height: 28px;
  align-self: flex-end;
  align-items: center;
  min-height: 0;
  margin: 0 0 0 auto;
  position: static;
  right: auto;
  bottom: auto;
  padding: 0;
}

.chat-composer textarea::placeholder {
  color: #71879A;
  font-family: inherit;
  font-size: 13px;
  line-height: 20px;
  opacity: 1;
  -webkit-text-fill-color: #71879A;
}

.autocomplete-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 26px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.autocomplete-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

#sql-input {
  height: 100%;
  min-height: 100%;
  max-height: none;
}

.sql-editor {
  --sql-gutter-width: 26px;
  flex: 1 1 auto;
  min-height: 172px;
  position: relative;
  border: 1px solid #2A495F;
  border-radius: var(--radius-medium);
  background: var(--bg-editor);
}

.sql-editor.has-results {
  min-height: 170px;
}

.sql-active-line {
  position: absolute;
  left: var(--sql-gutter-width);
  right: 0;
  top: 0;
  z-index: 0;
  height: 22px;
  background: rgba(89, 200, 236, 0.055);
  pointer-events: none;
}

.sql-active-line[hidden] {
  display: none;
}

.sql-line-numbers {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  width: var(--sql-gutter-width);
  overflow: hidden;
  border-right: 1px solid var(--border-subtle);
  border-radius: var(--radius-medium) 0 0 var(--radius-medium);
  padding: 14px var(--space-1) 14px 0;
  color: #536B7E;
  background: var(--bg-editor);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 22px;
  text-align: right;
  white-space: pre;
  pointer-events: none;
}

.sql-highlight,
.sql-editor textarea {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 22px;
  font-variant-ligatures: none;
  letter-spacing: normal;
  overflow-wrap: normal;
  tab-size: 4;
  white-space: pre;
  word-spacing: normal;
}

.sql-highlight code,
.sql-highlight span {
  font: inherit;
  font-variant-ligatures: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
}

.sql-highlight {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-medium);
  padding: 14px 16px;
  padding-left: calc(var(--sql-gutter-width) + 16px);
  color: var(--text);
  background: transparent;
  background-clip: padding-box;
  pointer-events: none;
}

.sql-editor textarea {
  position: relative;
  z-index: 1;
  margin-top: 0;
  border: 0;
  border-radius: var(--radius-medium);
  padding: 14px 16px;
  padding-left: calc(var(--sql-gutter-width) + 16px);
  color: transparent;
  background: transparent;
  background-clip: padding-box;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  caret-color: var(--text);
  -webkit-text-fill-color: transparent;
}

.sql-editor:focus-within {
  border-color: #4FC3E8;
  box-shadow: 0 0 0 2px rgba(79, 195, 232, 0.12);
}

.sql-editor textarea:focus {
  border-color: transparent;
  outline: none;
}

.sql-editor textarea::placeholder {
  color: var(--muted);
  opacity: 1;
  -webkit-text-fill-color: var(--muted);
}

.sql-token-keyword { color: var(--code-keyword); }
.sql-token-function { color: var(--code-function); }
.sql-token-string { color: var(--code-string); }
.sql-token-number { color: var(--code-number); }
.sql-token-comment { color: var(--text-muted); }
.sql-token-operator { color: var(--code-operator); }

.sql-autocomplete {
  display: none;
  position: absolute;
  z-index: 25;
  width: min(240px, calc(100% - var(--space-4)));
  max-height: 210px;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-medium);
  background: var(--bg-panel-raised);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--space-1);
}

.sql-autocomplete.is-open {
  display: grid;
  gap: var(--space-1);
}

.sql-autocomplete-option {
  width: 100%;
  border-radius: var(--radius-small);
  padding: var(--space-2);
  color: var(--text-primary);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.sql-autocomplete-option:hover,
.sql-autocomplete-option[aria-selected="true"] {
  color: var(--accent-primary-text);
  background: var(--accent-primary);
  transform: none;
}

.sql-results {
  flex: 0 0 auto;
  max-width: 100%;
  min-height: 0;
  margin-top: 0;
  margin-bottom: var(--space-3);
  position: relative;
}

.sql-results.has-overflowing-results {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 120px;
  overflow: hidden;
}

.sql-results.has-overflowing-results .result-frame {
  flex: 1 1 auto;
  min-height: 0;
}

.sql-results.has-overflowing-results .result-table-scroll {
  height: 100%;
  max-height: none;
  overflow-x: scroll;
  overflow-y: auto;
}

.sql-results.has-overflowing-results .result-footer {
  flex: 0 0 auto;
}

.sql-results.has-overflowing-results ~ .sql-editor {
  flex: 0 0 170px;
}

.sql-results:empty {
  margin-top: 0;
  margin-bottom: 0;
}

.sql-results-summary {
  display: flex;
  flex: 0 0 auto;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 0;
  margin-bottom: var(--space-4);
  flex-wrap: nowrap;
  position: relative;
  z-index: 2;
}

.sql-results-summary[hidden] {
  display: none;
}

.result-metadata {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.read-only-query {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.result-shield-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--status-success);
}

#sql-result-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0;
}

.sql-editor-resizer {
  display: grid;
  flex: 0 0 var(--resize-handle-size);
  place-items: center;
  min-height: var(--resize-handle-size);
  cursor: row-resize;
  touch-action: none;
}

.sql-results-resizer[hidden] {
  display: none;
}

.sql-editor-resizer::before {
  content: "";
  width: 44px;
  height: 3px;
  border-radius: 2px;
  background: #2A495F;
  transition: background-color 120ms ease-out;
}

.sql-editor-resizer:hover::before,
.sql-editor-resizer:focus-visible::before,
.sql-console.is-resizing-sql-editor .sql-editor-resizer::before {
  background: #59C8EC;
}

.sql-editor-resizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sql-diagnosis-resizer {
  margin: 0;
}

.sql-console.is-resizing-sql-editor {
  cursor: row-resize;
  user-select: none;
}

.result-frame {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-medium);
  background: #081827;
  contain: paint;
}

.result-frame.single-column {
  width: fit-content;
}

.result-table-scroll {
  width: 100%;
  max-width: 100%;
  max-height: min(48vh, 520px);
  overflow-x: scroll;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.result-table {
  width: max-content;
  min-width: 0;
  border-collapse: collapse;
  background: #081827;
}

.result-table.single-column {
  width: max-content;
  min-width: 220px;
}

.result-table th,
.result-table td {
  height: 36px;
  max-width: 260px;
  padding: 0 var(--space-3);
  color: #DCE7EF;
  font-size: 13px;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 38px;
  color: #77D6F5;
  background: #0E2B40;
  font-size: 12px;
  font-weight: 700;
}

.result-table tbody tr {
  border-top: 1px solid #19354A;
}

.result-table tbody tr:nth-child(odd) {
  background: #081827;
}

.result-table tbody tr:nth-child(even) {
  background: #0A1C2B;
}

.result-table tbody tr:hover {
  background: #123149;
}

.result-table .is-numeric {
  text-align: right;
}

.result-table td.is-numeric {
  font-variant-numeric: tabular-nums;
}

.result-table .result-empty-cell {
  height: 72px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
  flex-wrap: wrap-reverse;
}

.result-footer .result-notice {
  flex: 0 0 auto;
  margin: 0;
}

.result-pagination {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.sql-editor > .editor-actions {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  z-index: 3;
  margin: 0;
}

.ai-prompt-footer .ai-submit-button {
  height: 100%;
  align-self: stretch;
  align-items: flex-end;
  margin: 0 0 0 auto;
  position: static;
  flex-wrap: nowrap;
}

#sql-status:empty,
#status:empty {
  min-height: 0;
  margin: 0;
}

#sql-status.has-diagnosis {
  flex: 0 1 auto;
  min-height: 120px;
  margin-bottom: 0;
  overflow: hidden;
}

.sql-debug-alert,
.sql-debug-card {
  display: flex;
  gap: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--status-danger) 45%, transparent);
  border-radius: var(--radius-medium);
  background: color-mix(in srgb, var(--status-danger) 9%, var(--panel));
  padding: var(--space-3);
  color: var(--text);
}

.sql-debug-alert {
  align-items: center;
  justify-content: space-between;
}

.sql-debug-alert-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-3);
}

.sql-debug-effort-control {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sql-debug-effort-control select {
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 0 8px;
  color: var(--text-secondary);
  background: var(--bg-panel);
  font: inherit;
}

.sql-debug-thinking-toggle {
  height: auto;
  white-space: nowrap;
}

.sql-debug-alert.is-pending {
  justify-content: flex-start;
  color: var(--muted);
}

.sql-debug-pending {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
}

.sql-debug-pending::before {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  content: "";
}

.sql-debug-alert-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sql-debug-alert-copy span {
  color: var(--muted);
  font-size: 12px;
}

.sql-debug-card {
  display: grid;
  gap: var(--space-2);
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: 100%;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  padding: 0;
}

#sql-status.has-diagnosis .sql-debug-card {
  height: 100%;
}

.sql-debug-card p {
  margin: 0;
  white-space: pre-wrap;
}

.sql-debug-heading {
  z-index: 1;
  margin: 0;
  border-radius: var(--radius-medium) var(--radius-medium) 0 0;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  padding: var(--space-3) var(--space-3) var(--space-1);
}

.sql-debug-content {
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--space-3) var(--space-3);
}

.sql-debug-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sql-diagnosis-problem {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: var(--space-2) !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.sql-diagnosis-disclosure {
  margin-bottom: var(--space-2);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-2);
}

.sql-diagnosis-disclosure summary {
  width: fit-content;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.sql-diagnosis-disclosure[open] summary {
  margin-bottom: var(--space-2);
  color: var(--text);
}

.sql-diagnosis-issue-list {
  display: grid;
  gap: var(--space-3);
}

.sql-diagnosis-issue {
  display: grid;
  gap: 3px;
  border-left: 2px solid var(--border-default);
  padding-left: var(--space-3);
}

.sql-diagnosis-issue > p {
  color: var(--text-secondary);
}

.sql-diagnosis-issue > strong {
  color: var(--status-danger);
}

.sql-diagnosis-fix > strong {
  color: var(--text);
}

.sql-diagnosis-caveat {
  margin-bottom: var(--space-3) !important;
  color: var(--text-secondary);
  font-size: 11px;
  font-style: italic;
}

.sql-diagnosis-recommendation {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin: 0 var(--space-3) var(--space-3) !important;
  border: 1px solid color-mix(in srgb, var(--status-warning) 45%, transparent);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, var(--status-warning) 9%, var(--panel));
  padding: var(--space-2) var(--space-3);
  color: var(--status-warning);
  font-size: 12px;
}

.sql-debug-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sql-debug-actions {
  margin-top: var(--space-2);
}

.sql-repair-summary {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
}

.sql-repair-summary li + li {
  margin-top: var(--space-1);
}

.sql-repair-intent-notice {
  margin: var(--space-3) 0 0;
  border-left: 2px solid var(--accent);
  padding-left: var(--space-3);
  color: var(--muted);
  font-size: 12px;
}

.sql-repair-diff {
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-small);
  background: var(--bg-editor);
  padding: var(--space-3);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  white-space: pre;
}

.sql-repair-diff-control {
  display: inline-flex;
  position: relative;
}

.sql-repair-diff-tooltip {
  width: min(560px, calc(100vw - 32px));
  max-height: 280px;
  position: fixed;
  z-index: 5000;
  overflow: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-medium);
  background: var(--bg-panel-raised);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  padding: var(--space-3);
  color: var(--text);
  pointer-events: auto;
}

.sql-repair-diff-tooltip > strong {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-size: 11px;
}

.sql-repair-diff {
  display: grid;
  gap: 1px;
  padding: var(--space-2) 0;
}

.sql-diff-line {
  display: block;
  min-height: 18px;
  padding: 1px var(--space-3) 1px 30px;
  position: relative;
  white-space: pre-wrap;
}

.sql-diff-line::before {
  width: 20px;
  position: absolute;
  left: var(--space-2);
  color: var(--muted);
  content: " ";
}

.sql-diff-line.is-removed {
  background: color-mix(in srgb, var(--status-danger) 13%, transparent);
}

.sql-diff-line.is-removed::before {
  color: var(--status-danger);
  content: "−";
}

.sql-diff-line.is-added {
  background: color-mix(in srgb, var(--status-success) 12%, transparent);
}

.sql-diff-line.is-added::before {
  color: var(--status-success);
  content: "+";
}

.sql-diff-line.is-skip {
  color: var(--muted);
}

.sql-repair-operation-error {
  color: var(--status-danger);
  font-size: 12px;
}

.sql-repair-limit {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 720px) {
  .sql-debug-alert {
    align-items: stretch;
    flex-direction: column;
  }

  .sql-debug-actions > button {
    flex: 1 1 auto;
  }
}

button:disabled {
  cursor: wait;
  opacity: 1;
  transform: none;
}

button.is-loading {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

button.is-loading::before {
  content: "";
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ai-panel button:disabled,
#execute-sql:disabled {
  cursor: not-allowed;
  border-color: #234158;
  color: #71879A;
  background: #0A1C2B;
  filter: none;
  opacity: 1;
}

.ai-panel button.is-loading:disabled,
#execute-sql.is-loading:disabled {
  cursor: wait;
  color: var(--accent-primary-text);
  background: var(--accent-primary);
  filter: none;
  opacity: 1;
}

.ai-panel .clear-chat-button:disabled {
  border: 0;
  color: #71879A;
  background: transparent;
}

.disabled-action {
  display: inline-flex;
  position: relative;
}

.disabled-action::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + var(--space-2));
  z-index: 35;
  width: max-content;
  max-width: min(280px, 78vw);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-medium);
  color: var(--text);
  background: var(--bg-panel-raised);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translateY(2px);
}

.disabled-action:hover::after,
.disabled-action:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}

.status {
  min-height: 22px;
  margin: var(--space-2) 0 var(--space-4);
  color: var(--muted);
  font-size: 14px;
}

.status.is-warning {
  width: fit-content;
  padding: 8px 12px;
  border-left: 3px solid #F1B85B;
  border-radius: 0 6px 6px 0;
  color: #F1C878;
  background: rgba(241, 184, 91, 0.08);
  font-size: 12px;
}

form.logout { margin: 0; }

.app-footer,
.login-copyright {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-align: center;
}

.app-footer {
  display: flex;
  width: 100%;
  height: 32px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  padding: 0 var(--space-5);
  color: #71879A;
  font-size: 11px;
  line-height: 1;
}

.login-copyright {
  padding: var(--space-3) var(--space-2) 0;
}

@media (max-width: 920px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .query-main,
  .query-main.panel-closed,
  .query-main.panel-drag-collapsed,
  .query-main.panel-expanded {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--main-column-gap);
  }

  .query-main.panel-closed,
  .query-main.panel-drag-collapsed {
    grid-template-rows: minmax(0, 1fr);
  }

  .panel-resizer {
    display: none;
  }

  .schema-tree {
    max-height: none;
  }

  .database-workspace {
    display: grid;
    grid-template-rows: var(--schema-pane-height) minmax(260px, 1fr);
    gap: var(--space-4);
  }

  .database-workspace.sql-collapsed {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .workspace-resizer {
    display: none;
  }

  .sql-console {
    margin-top: 0;
  }

  .query-main.panel-closed .ai-panel,
  .query-main.panel-drag-collapsed .ai-panel {
    display: none;
  }

  .query-main.panel-expanded .database-workspace {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 560px) {
  .header-actions {
    display: grid;
    justify-content: stretch;
  }

  .section-tools,
  .header-actions {
    justify-content: start;
  }

  .panel-control-row {
    flex-wrap: wrap;
  }

  .column-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
}
