:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f7f8fa;
  --surface-dark: #12201f;
  --line: #dfe4e8;
  --line-strong: #c9d1d6;
  --text: #172321;
  --text-muted: #66736f;
  --text-faint: #5f6d69;
  --accent: #12a87f;
  --accent-dark: #08775d;
  --accent-soft: #dff7ef;
  --blue: #3978df;
  --amber: #b77812;
  --danger: #c54545;
  --shadow: 0 14px 44px rgb(24 45 40 / 10%);
  --shadow-small: 0 5px 18px rgb(24 45 40 / 8%);
  --radius: 10px;
  --font-ui: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111817;
    --surface: #17201f;
    --surface-raised: #1b2624;
    --surface-muted: #202b29;
    --surface-dark: #0b1211;
    --line: #2c3936;
    --line-strong: #3a4946;
    --text: #e8eeec;
    --text-muted: #a6b2ae;
    --text-faint: #a6b2ae;
    --accent: #31c99d;
    --accent-dark: #5ed8b4;
    --accent-soft: #173d33;
    --blue: #78a7f4;
    --amber: #e1a744;
    --danger: #ed7777;
    --shadow: 0 18px 50px rgb(0 0 0 / 30%);
    --shadow-small: 0 5px 18px rgb(0 0 0 / 24%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111817;
  --surface: #17201f;
  --surface-raised: #1b2624;
  --surface-muted: #202b29;
  --surface-dark: #0b1211;
  --line: #2c3936;
  --line-strong: #3a4946;
  --text: #e8eeec;
  --text-muted: #a6b2ae;
  --text-faint: #a6b2ae;
  --accent: #31c99d;
  --accent-dark: #5ed8b4;
  --accent-soft: #173d33;
  --blue: #78a7f4;
  --amber: #e1a744;
  --danger: #ed7777;
  --shadow: 0 18px 50px rgb(0 0 0 / 30%);
  --shadow-small: 0 5px 18px rgb(0 0 0 / 24%);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .52;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  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;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 9px 14px;
  transform: translateY(-150%);
  border-radius: 7px;
  background: var(--surface-dark);
  color: #fff;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template:
    "bar bar" 64px
    "explorer workspace" minmax(0, 1fr)
    "status status" 29px / 268px minmax(0, 1fr);
  height: 100%;
}

.app-bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 0 rgb(0 0 0 / 2%);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 230px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  transform: rotate(-8deg);
}

.brand-mark span {
  position: absolute;
  left: 3px;
  width: 26px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface);
}

.brand-mark span:nth-child(1) { top: 3px; }
.brand-mark span:nth-child(2) { top: 11px; }
.brand-mark span:nth-child(3) { top: 19px; }

.brand-copy {
  display: flex;
  align-items: baseline;
  gap: 5px;
  letter-spacing: -.02em;
}

.brand-copy strong {
  font-size: 18px;
}

.brand-copy span {
  color: var(--text-muted);
  font-size: 17px;
  font-weight: 500;
}

.connection-summary {
  display: flex;
  align-items: stretch;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.connection-button {
  display: flex;
  min-width: 184px;
  align-items: center;
  gap: 9px;
  padding: 5px 11px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.connection-button small,
.database-context small {
  display: block;
  margin-bottom: 1px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.connection-button strong,
.database-context strong {
  display: block;
  max-width: 132px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  margin-left: auto;
  color: var(--text-muted);
}

.database-context {
  min-width: 112px;
  padding: 6px 12px;
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}

.status-offline {
  background: var(--text-faint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-faint) 15%, transparent);
}

.status-ready {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.global-search {
  display: flex;
  width: min(420px, 32vw);
  height: 38px;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.global-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.global-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
}

.global-search input::placeholder {
  color: var(--text-faint);
}

.global-search kbd {
  padding: 2px 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--text-faint);
  font-family: var(--font-ui);
  font-size: 10px;
}

.search-icon {
  color: var(--text-muted);
  font-size: 18px;
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.icon-button {
  position: relative;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 17px;
}

.icon-button:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.icon-button.compact {
  width: 30px;
  height: 30px;
}

.activity-count {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  line-height: 15px;
}

.explorer {
  grid-area: explorer;
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 14px 12px 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.eyebrow.accent {
  color: var(--accent-dark);
}

.panel-heading h1 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -.01em;
}

.tree {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 3px 8px 12px;
}

.tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree [role="group"] {
  margin-left: 21px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.tree-row {
  display: flex;
  width: 100%;
  height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.tree-row:hover {
  background: var(--surface-muted);
}

.tree-row.selected {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 650;
}

.root-row {
  font-weight: 650;
}

.tree-caret {
  width: 10px;
  color: var(--text-faint);
}

.object-icon {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: var(--accent-soft);
}

.connection-icon {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
}

.connection-icon::before,
.connection-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  width: 8px;
  height: 3px;
  border-radius: 50%;
  border: 1px solid var(--accent);
}

.connection-icon::before { top: 3px; }
.connection-icon::after { top: 8px; }

.tree-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count {
  min-width: 21px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text-faint);
  font-size: 10px;
  text-align: center;
}

.tree-empty {
  padding: 28px 10px;
  color: var(--text-muted);
  text-align: center;
}

.tree-empty p {
  margin: 8px 0;
  font-size: 12px;
}

.empty-illustration {
  display: grid;
  width: 38px;
  height: 38px;
  margin: auto;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--accent);
  font-size: 20px;
}

.text-button {
  padding: 3px 5px;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 650;
}

.explorer-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 10px;
}

.security-mark {
  color: var(--accent);
  font-size: 14px;
}

.workspace {
  grid-area: workspace;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--bg);
}

.tab-strip {
  display: flex;
  height: 42px;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.open-tabs {
  display: contents;
}

.tab {
  position: relative;
  display: flex;
  height: 42px;
  min-width: 128px;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text-muted);
}

.tab.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 650;
}

.tab.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.tab-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-title-editor {
  width: 108px;
  min-width: 0;
  padding: 2px 4px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
}

.tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.tab:hover .tab-close {
  opacity: 1;
}

.tab-close:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.tab-close:active {
  background: var(--line);
}

/* Active database indicator in tree */
.tree-row.database-active {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding-left: 5px;
}

.tree-row.database-active .tree-label {
  color: var(--accent-dark);
  font-weight: 650;
}

.new-tab-button,
.workbench-menu {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
}

.new-tab-button:hover,
.workbench-menu:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.tab-spacer {
  flex: 1;
}

.workbench-menu {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.welcome-panel {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: clamp(28px, 5vw, 66px);
  background:
    radial-gradient(circle at 80% 14%,
      color-mix(in srgb, var(--accent) 8%, transparent), transparent 34%),
    var(--bg);
}

.welcome-content {
  display: grid;
  max-width: 1120px;
  align-items: center;
  gap: 40px;
  margin: 0 auto 46px;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
}

.welcome-copy h2 {
  max-width: 720px;
  margin: 9px 0 18px;
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 720;
  letter-spacing: -.055em;
  line-height: 1.02;
}

.welcome-lead {
  max-width: 620px;
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.6;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.primary-button,
.secondary-button,
.toolbar-button,
.run-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 650;
}

.primary-button,
.run-button {
  background: var(--accent-dark);
  color: #fff;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 20%, transparent);
}

.primary-button:hover,
.run-button:hover {
  background: color-mix(in srgb, var(--accent-dark) 88%, #000);
}

.secondary-button,
.toolbar-button {
  border-color: var(--line);
  background: var(--surface);
}

.secondary-button:hover,
.toolbar-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.ridge-visual {
  position: relative;
  min-height: 290px;
  transform: rotate(-2deg);
}

.visual-glow {
  position: absolute;
  inset: 40px;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(80px);
  opacity: .15;
}

.ridge-layer {
  position: absolute;
  left: 50%;
  width: 260px;
  height: 82px;
  transform: translateX(-50%) skewX(-13deg);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 50%;
  background:
    linear-gradient(150deg,
      color-mix(in srgb, var(--surface) 90%, var(--accent)),
      var(--surface));
  box-shadow: var(--shadow);
}

.ridge-layer::after {
  content: "";
  position: absolute;
  inset: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: 50%;
}

.ridge-layer span {
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 12%, transparent);
}

.ridge-layer span:nth-child(1) { top: 31px; left: 58px; }
.ridge-layer span:nth-child(2) { top: 19px; left: 128px; }
.ridge-layer span:nth-child(3) { top: 38px; right: 48px; }
.layer-back { top: 36px; opacity: .52; }
.layer-middle { top: 102px; opacity: .76; }
.layer-front { top: 168px; }

.data-node {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 4px 10px rgb(0 0 0 / 16%);
}

.node-one { top: 46px; left: 24%; }
.node-two { top: 139px; right: 17%; background: var(--amber); }
.node-three { bottom: 28px; left: 36%; background: var(--accent); }

.feature-grid {
  display: grid;
  max-width: 1120px;
  gap: 12px;
  margin: 0 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.feature-card {
  position: relative;
  display: flex;
  min-height: 142px;
  flex-direction: column;
  gap: 14px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.feature-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.feature-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.feature-card code {
  color: var(--text);
  font-family: var(--font-mono);
}

.feature-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 18px;
}

.tunnel-icon { background: color-mix(in srgb, var(--blue) 12%, var(--surface)); color: var(--blue); }
.query-icon { background: color-mix(in srgb, var(--amber) 12%, var(--surface)); color: var(--amber); }
.grid-icon { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); color: var(--danger); }

.feature-state {
  position: absolute;
  top: 18px;
  right: 16px;
  padding: 3px 7px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.feature-state.available {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.feature-state.planned {
  background: var(--surface-muted);
  color: var(--text-faint);
}

.system-strip {
  display: grid;
  max-width: 1120px;
  gap: 1px;
  margin: 18px auto 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  grid-template-columns: repeat(4, 1fr);
}

.system-strip > div {
  padding: 13px 16px;
  background: var(--surface);
}

.system-label {
  display: block;
  margin-bottom: 3px;
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.system-strip strong {
  font-size: 11px;
}

.status-bar {
  grid-area: status;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 11px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  background: var(--surface-dark);
  color: #cbd6d3;
  font-size: 10px;
}

.status-bar > div {
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-details {
  color: #96a6a2;
}

.status-bar button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.separator {
  color: #566763;
}

.connection-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: 0 30px 90px rgb(0 0 0 / 32%);
}

.connection-dialog::backdrop {
  background: rgb(7 20 17 / 48%);
  backdrop-filter: blur(3px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  padding: 25px 27px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 4px 0 5px;
  font-size: 23px;
  letter-spacing: -.03em;
}

.dialog-header p:last-child {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.dialog-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 24px;
}

.dialog-close:hover {
  background: var(--surface-muted);
}

.connection-modes {
  display: grid;
  gap: 10px;
  padding: 20px 27px 10px;
  grid-template-columns: 1fr 1fr;
}

.mode-card {
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-muted);
  cursor: pointer;
}

.mode-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.mode-card:has(input:disabled) {
  cursor: not-allowed;
  opacity: .58;
}

.mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface);
  color: var(--accent-dark);
  font-size: 19px;
}

.mode-card strong,
.mode-card small {
  display: block;
}

.mode-card small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.form-grid {
  display: grid;
  gap: 15px;
  padding: 14px 27px 20px;
  grid-template-columns: 1fr 1fr;
}

.ssh-fields {
  padding: 2px 0;
  border-block: 1px solid var(--line);
}

.nested-grid {
  padding: 16px 0;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: 0;
  background: var(--surface);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent);
}

.field input[readonly] {
  background: var(--surface-muted);
  color: var(--text-muted);
}

/* Password toggle eye */
.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 38px !important;
}

.password-toggle {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  transition: color 0.15s, background 0.15s;
}

.password-toggle:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.field-wide {
  grid-column: 1 / -1;
}

.check-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.check-field input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.check-field strong,
.check-field small {
  display: block;
}

.check-field strong {
  font-size: 12px;
}

.check-field small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
}

.dialog-notice {
  display: flex;
  gap: 9px;
  margin: 0 27px 20px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--blue) 24%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--blue) 7%, var(--surface));
  color: var(--text-muted);
}

.dialog-notice span {
  color: var(--blue);
}

.dialog-notice p {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 27px;
  border-top: 1px solid var(--line);
  background: var(--surface-muted);
}

.dialog-footer > span {
  color: var(--text-faint);
  font-size: 10px;
}

.dialog-footer > div {
  display: flex;
  gap: 8px;
}

.sql-panel {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-rows: 46px minmax(180px, 1fr) minmax(180px, 1fr);
}

.object-panel {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 28px;
  background: var(--surface-muted);
}

.catalog-panel {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 28px;
  background: var(--surface-muted);
}

.catalog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.catalog-header h2 {
  margin: 3px 0 4px;
  font-size: 24px;
}

.catalog-header p {
  margin: 0;
  color: var(--text-muted);
}

.catalog-actions,
.catalog-table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.catalog-summary {
  display: grid;
  gap: 10px;
  margin: 24px 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.catalog-summary > div {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.catalog-summary span {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.catalog-summary strong {
  font-family: var(--font-mono);
  font-size: 18px;
}

.catalog-objects {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.catalog-objects > header,
.catalog-table-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.catalog-objects > header {
  margin-bottom: 12px;
}

.catalog-objects h3 {
  margin: 2px 0 0;
  font-size: 14px;
}

.catalog-objects > header > span {
  color: var(--text-muted);
  font-size: 11px;
}

.catalog-table-list {
  display: grid;
  gap: 8px;
}

.catalog-table-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.catalog-table-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.catalog-table-identity > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.catalog-table-identity strong {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  text-overflow: ellipsis;
}

.catalog-table-identity span:last-child {
  color: var(--text-muted);
  font-size: 10px;
}

.catalog-table-actions .secondary-button {
  min-height: 30px;
  padding: 6px 10px;
}

.catalog-empty {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--text-muted);
  text-align: center;
}

.catalog-empty strong {
  color: var(--text);
}

.catalog-empty p {
  margin: 6px 0 0;
  font-size: 12px;
}

.object-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.object-header h2 {
  margin: 3px 0 4px;
}

.object-header p {
  margin: 0;
  color: var(--text-muted);
}

.object-summary {
  display: grid;
  gap: 10px;
  margin: 24px 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.object-summary div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.object-summary span {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.object-summary strong {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  text-overflow: ellipsis;
}

.object-sections {
  display: grid;
  gap: 16px;
}

.object-sections > section {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.object-sections h3 {
  margin: 0 0 12px;
  font-size: 13px;
}

.metadata-grid {
  overflow: auto;
}

.metadata-table {
  width: 100%;
}

.metadata-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.history-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-large);
}

.history-list {
  display: grid;
  max-height: 540px;
  gap: 6px;
  overflow: auto;
  padding: 16px 20px;
}

.history-entry {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--text);
  text-align: left;
}

.history-entry:hover {
  border-color: var(--accent);
}

.history-entry code {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-entry span {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: capitalize;
}

.diagnostics-output {
  max-height: 540px;
  margin: 0;
  overflow: auto;
  padding: 20px;
  background: var(--surface-muted);
  color: var(--text);
  font: 12px/1.6 var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.operation-list {
  display: grid;
  gap: 12px;
  padding: 20px 24px 0;
}

.operation-card {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 16px;
}

.operation-card p {
  color: var(--text-muted);
  margin: 5px 0 0;
}

.operation-card.unavailable {
  opacity: .72;
}

.operation-card > div:first-child {
  flex: 1;
}

.operation-input {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 11px;
  gap: 8px;
  margin-top: 12px;
}

.operation-input input {
  flex: 1;
  min-width: 220px;
}

.operation-actions {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.data-filter {
  align-items: center;
  display: flex;
  gap: 8px;
}

.data-filter label {
  align-items: center;
  display: flex;
  gap: 6px;
}

.data-filter span {
  color: var(--text-muted);
  font-size: 12px;
}

.data-filter input,
.data-filter select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font: 13px var(--font-mono);
  max-width: 145px;
  padding: 7px 9px;
}

.data-filter-list {
  align-items: center;
  display: flex;
  flex: none;
  gap: 6px;
}

.data-filter-chip {
  align-items: center;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  font: 11px var(--font-mono);
  gap: 5px;
  max-width: 280px;
  padding: 4px 5px 4px 9px;
  white-space: nowrap;
}

.data-filter-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-filter-chip button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  height: 20px;
  justify-content: center;
  padding: 0;
  width: 20px;
}

.data-filter-chip button:hover,
.data-filter-chip button:focus-visible {
  background: var(--surface-raised);
  color: var(--danger);
  outline: 1px solid var(--line-strong);
}

.danger-action {
  color: var(--danger);
}

.insert-fields {
  display: grid;
  gap: 10px;
  max-height: min(58vh, 620px);
  overflow: auto;
  padding: 20px 24px;
}

.insert-field {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(140px, 1fr) 110px minmax(180px, 1.4fr);
  padding: 0 0 10px;
}

.insert-field > div {
  display: grid;
  gap: 3px;
}

.insert-field small {
  color: var(--text-muted);
}

.insert-field input,
.insert-field select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  min-width: 0;
  padding: 8px 9px;
}

.data-panel {
  display: grid;
  min-height: 0;
  flex: 1;
  background: var(--surface);
  grid-template-rows: 48px minmax(0, 1fr) 42px;
}

.data-toolbar,
.data-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.data-toolbar {
  overflow-x: auto;
  overflow-y: hidden;
}

.data-toolbar > button,
.data-filter {
  flex: none;
}

.data-toolbar > div:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.data-toolbar strong {
  font-size: 12px;
}

.data-toolbar span,
.data-footer {
  color: var(--text-muted);
  font-size: 10px;
}

.data-grid-wrap {
  min-height: 0;
  overflow: auto;
}

.editable-grid {
  width: max-content;
  min-width: 100%;
}

.editable-grid th small {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 400;
}

.editable-grid td[contenteditable] {
  min-width: 140px;
  outline: none;
}

.editable-grid td[contenteditable]:focus {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.editable-grid .staged-cell {
  background: color-mix(in srgb, var(--amber) 16%, var(--surface));
  box-shadow: inset 3px 0 var(--amber);
}

.editable-grid .staged-delete-row {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  text-decoration: line-through;
}

.editable-grid .staged-delete-row td:last-child {
  text-decoration: none;
}

.data-footer {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.data-footer > div {
  display: flex;
  gap: 6px;
}

.sql-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.toolbar-group {
  display: flex;
  gap: 5px;
}

.run-button,
.toolbar-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 11px;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--line);
}

.toolbar-spacer {
  flex: 1;
}

.transaction-select,
.row-limit {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 10px;
}

.transaction-select select,
.row-limit input {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.transaction-select select {
  padding: 0 7px;
}

.transaction-state {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}

.transaction-state[data-state="active"] {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.transaction-state[data-state="failed"] {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
}

.row-limit input {
  width: 64px;
  padding: 0 6px;
}

.editor-area {
  display: grid;
  min-height: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  grid-template-columns: 44px 1fr;
}

.line-numbers {
  padding: 15px 10px;
  border-right: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}

#sql-editor {
  width: 100%;
  height: 100%;
  resize: none;
  padding: 14px 16px;
  border: 0;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 4;
}

.result-area {
  display: flex;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
}

.result-heading {
  display: flex;
  height: 38px;
  align-items: center;
  justify-content: space-between;
  padding-right: 13px;
  border-bottom: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 10px;
}

.result-heading > div {
  height: 100%;
}

.result-tab {
  position: relative;
  height: 100%;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
}

.result-tab.active {
  color: var(--text);
  font-weight: 650;
}

.result-tab.active::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  background: var(--accent);
}

.result-empty {
  display: grid;
  flex: 1;
  place-content: center;
  color: var(--text-faint);
  text-align: center;
}

.result-empty span {
  font-size: 28px;
}

.result-empty p {
  margin: 8px 0 0;
  font-size: 11px;
}

.result-grid {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.result-table-wrap {
  min-width: 100%;
  width: max-content;
}

.result-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-mono);
  font-size: 11px;
}

.result-table th,
.result-table td {
  min-width: 120px;
  max-width: 420px;
  padding: 8px 10px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.result-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-muted) 55%, transparent);
}

.result-table .null-value {
  color: var(--text-faint);
  font-style: italic;
}

.command-result {
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
}

.command-result > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
}

.command-result strong {
  font-family: var(--font-mono);
  font-size: 12px;
}

.command-result p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 11px;
}

.hidden {
  display: none !important;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 45px;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  font-size: 12px;
}

.toast.error {
  border-left-color: var(--danger);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template:
      "bar bar" 64px
      "explorer workspace" minmax(0, 1fr)
      "status status" 29px / 226px minmax(0, 1fr);
  }

  .brand {
    width: 188px;
  }

  .database-context,
  .global-search kbd {
    display: none;
  }

  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .welcome-content {
    grid-template-columns: 1fr;
  }

  .ridge-visual {
    display: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    grid-template:
      "bar" 58px
      "workspace" minmax(0, 1fr)
      "status" 29px / minmax(0, 1fr);
  }

  .app-bar {
    gap: 8px;
    padding: 0 8px;
  }

  .brand {
    width: auto;
  }

  .brand-copy,
  .database-context,
  .global-search,
  .app-actions .icon-button:not(:first-child) {
    display: none;
  }

  .connection-summary {
    flex: 1;
    max-width: 230px;
  }

  .connection-button {
    min-width: 0;
    flex: 1;
    border-right: 0;
  }

  .explorer {
    display: none;
  }

  .welcome-panel {
    padding: 28px 18px;
  }

  .catalog-panel {
    padding: 20px 16px;
  }

  .catalog-header,
  .catalog-table-card {
    align-items: stretch;
    flex-direction: column;
  }

  .catalog-actions,
  .catalog-table-actions {
    align-items: stretch;
  }

  .catalog-actions > *,
  .catalog-table-actions > * {
    flex: 1;
  }

  .catalog-summary {
    grid-template-columns: 1fr;
  }

  .welcome-copy h2 {
    font-size: 36px;
  }

  .feature-grid,
  .system-strip,
  .form-grid,
  .connection-modes {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .system-strip {
    gap: 1px;
  }

  .dialog-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-footer > div {
    justify-content: flex-end;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .status-dot,
  .feature-icon,
  .object-icon {
    border: 1px solid CanvasText;
  }

  .ridge-visual {
    display: none;
  }
}
