#content-container {
  max-width: none;
}

#page {
  padding: clamp(0.75rem, 1.2vw, 1.25rem);
}

.sql-er-tool {
  --sql-er-bg: #0e1116;
  --sql-er-panel: #141923;
  --sql-er-panel-2: #1b212b;
  --sql-er-border: #232a35;
  --sql-er-text: #e8edf4;
  --sql-er-muted: #8a95a3;
  --sql-er-accent: #5aa7ff;
  --sql-er-accent-weak: #1e2f47;
  --sql-er-ok: #5fbf83;
  --sql-er-warn: #e0a23c;
  --sql-er-danger: #e06c6c;
  --sql-er-topbar-h: 52px;
  --sql-er-editor-w: 420px;
  --tk-kw: #7aa2f7;
  --tk-type: #4ec9b0;
  --tk-str: #e2a073;
  --tk-com: #6a7385;
  --tk-num: #b5cea8;
  --tk-id: #d7c2ff;
  --tk-punct: #8a95a3;
  position: relative;
  display: flex;
  flex-direction: column;
  height: clamp(42rem, calc(100vh - 5.25rem), 82rem);
  min-height: 42rem;
  overflow: hidden;
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  background: var(--sql-er-bg);
  color: var(--sql-er-text);
  font-family: var(--font-ui), ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.sql-er-tool[data-sql-er-theme="light"] {
  --sql-er-bg: #f4f6fa;
  --sql-er-panel: #ffffff;
  --sql-er-panel-2: #f7f9fc;
  --sql-er-border: #d8e0ea;
  --sql-er-text: #1c2530;
  --sql-er-muted: #6b7686;
  --sql-er-accent: #2f6fd0;
  --sql-er-accent-weak: #e6effb;
  --tk-kw: #0b66d0;
  --tk-type: #0a7a6b;
  --tk-str: #b5570f;
  --tk-com: #7b8797;
  --tk-num: #2a7a2a;
  --tk-id: #6d3fc4;
  --tk-punct: #6b7686;
}

.sql-er-tool *,
.sql-er-tool *::before,
.sql-er-tool *::after {
  box-sizing: border-box;
}

.sql-er-tool .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sql-er-tool .topbar {
  flex: 0 0 var(--sql-er-topbar-h);
  min-height: var(--sql-er-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 0.875rem;
  background: var(--sql-er-panel);
  border-bottom: 1px solid var(--sql-er-border);
  user-select: none;
}

.sql-er-tool .brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.sql-er-tool .brand .logo {
  display: flex;
  color: var(--sql-er-accent);
  flex: none;
}

.sql-er-tool .brand .logo svg {
  width: 20px;
  height: 20px;
}

.sql-er-tool .brand .name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0;
  white-space: nowrap;
}

.sql-er-tool .actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.sql-er-tool .divider {
  width: 1px;
  height: 20px;
  background: var(--sql-er-border);
  margin: 0 0.3rem;
  flex: none;
}

.sql-er-tool .ico {
  width: 17px;
  height: 17px;
  display: block;
}

.sql-er-tool .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.42rem 0.68rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--sql-er-text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.sql-er-tool .btn.ghost:hover {
  background: var(--sql-er-panel-2);
  border-color: var(--sql-er-border);
}

.sql-er-tool .btn.icon {
  display: grid;
  place-items: center;
  min-width: 2rem;
  padding: 0.38rem;
}

.sql-er-tool .btn.primary {
  background: var(--sql-er-accent);
  border-color: var(--sql-er-accent);
  color: #ffffff;
}

.sql-er-tool .btn.primary:hover {
  filter: brightness(1.08);
}

.sql-er-tool .btn.caret {
  gap: 0.35rem;
}

.sql-er-tool .btn.caret::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 1px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.55;
}

.sql-er-tool .menu-wrap {
  position: relative;
  flex: none;
}

.sql-er-tool .menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 168px;
  z-index: 50;
  padding: 0.375rem;
  border: 1px solid var(--sql-er-border);
  border-radius: 0.625rem;
  background: var(--sql-er-panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.sql-er-tool .menu[hidden] {
  display: none;
}

.sql-er-tool .menu-label {
  padding: 0.4rem 0.5rem 0.25rem;
  color: var(--sql-er-muted);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sql-er-tool .menu-sep {
  height: 1px;
  margin: 0.3rem 0.125rem;
  background: var(--sql-er-border);
}

.sql-er-tool .menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.48rem 0.56rem;
  border: 0;
  border-radius: 0.44rem;
  background: transparent;
  color: var(--sql-er-text);
  font: inherit;
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}

.sql-er-tool .menu-item:hover {
  background: var(--sql-er-panel-2);
}

.sql-er-tool .menu-item.active {
  color: var(--sql-er-accent);
  font-weight: 700;
}

.sql-er-tool .menu-item.active::after {
  content: "*";
  font-size: 0.75rem;
}

.sql-er-tool .layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sql-er-tool .editor-pane {
  width: var(--sql-er-editor-w);
  min-width: 220px;
  display: flex;
  flex-direction: column;
  background: var(--sql-er-panel);
  border-right: 1px solid var(--sql-er-border);
}

.sql-er-tool .layout.sql-hidden .editor-pane,
.sql-er-tool .layout.sql-hidden .splitter {
  display: none;
}

.sql-er-tool .pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.44rem 0.5rem 0.44rem 0.875rem;
  border-bottom: 1px solid var(--sql-er-border);
  color: var(--sql-er-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sql-er-tool .pane-head-left {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  min-width: 0;
}

.sql-er-tool .status {
  color: var(--sql-er-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.sql-er-tool .status.ok {
  color: var(--sql-er-ok);
}

.sql-er-tool .status.warn {
  color: var(--sql-er-warn);
}

.sql-er-tool .status.err {
  color: var(--sql-er-danger);
}

.sql-er-tool .icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.44rem;
  background: transparent;
  color: var(--sql-er-muted);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.sql-er-tool .icon-btn:hover {
  background: var(--sql-er-panel-2);
  border-color: var(--sql-er-border);
  color: var(--sql-er-text);
}

.sql-er-tool .editor-stack {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--sql-er-bg);
}

.sql-er-tool .hl,
.sql-er-tool #sql {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0.875rem;
  border: 0;
  font-family: var(--font-mono), ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  overflow: auto;
}

.sql-er-tool .hl {
  z-index: 1;
  pointer-events: none;
  color: var(--sql-er-text);
}

.sql-er-tool .hl code {
  font: inherit;
}

.sql-er-tool #sql {
  z-index: 2;
  resize: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--sql-er-text);
}

.sql-er-tool #sql::placeholder {
  color: var(--sql-er-muted);
}

.sql-er-tool #sql::selection {
  background: rgba(90, 167, 255, 0.3);
}

.sql-er-tool textarea.anno-edit {
  resize: none;
  line-height: 1.3;
  white-space: pre-wrap;
  overflow: auto;
}

.sql-er-tool .t-kw {
  color: var(--tk-kw);
  font-weight: 700;
}

.sql-er-tool .t-type {
  color: var(--tk-type);
}

.sql-er-tool .t-str {
  color: var(--tk-str);
}

.sql-er-tool .t-com {
  color: var(--tk-com);
  font-style: italic;
}

.sql-er-tool .t-num {
  color: var(--tk-num);
}

.sql-er-tool .t-id {
  color: var(--tk-id);
}

.sql-er-tool .t-punct {
  color: var(--tk-punct);
}

.sql-er-tool .splitter {
  width: 6px;
  flex: 0 0 auto;
  margin: 0 -3px;
  z-index: 5;
  background: transparent;
  cursor: col-resize;
}

.sql-er-tool .splitter:hover {
  background: var(--sql-er-accent-weak);
}

.sql-er-tool .canvas-pane {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sql-er-tool #canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.sql-er-tool .reopen-sql {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 6;
  display: none;
  align-items: center;
  gap: 0.38rem;
  padding: 0.44rem 0.68rem 0.44rem 0.56rem;
  border: 1px solid var(--sql-er-border);
  border-radius: 0.56rem;
  background: var(--sql-er-panel);
  color: var(--sql-er-text);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.sql-er-tool .reopen-sql:hover {
  background: var(--sql-er-panel-2);
}

.sql-er-tool .layout.sql-hidden .reopen-sql {
  display: inline-flex;
}

.sql-er-tool .empty-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.sql-er-tool .empty-card {
  pointer-events: auto;
  max-width: 380px;
  padding: 1.75rem;
  border: 1px solid var(--sql-er-border);
  border-radius: 0.75rem;
  background: var(--sql-er-panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.sql-er-tool .empty-card h2 {
  margin: 0 0 0.5rem;
  color: var(--sql-er-text);
  font-size: 1.18rem;
  letter-spacing: 0;
}

.sql-er-tool .empty-card p {
  margin: 0 0 1.125rem;
  color: var(--sql-er-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.sql-er-tool .empty-card code {
  padding: 0.06rem 0.38rem;
  border-radius: 0.3rem;
  background: var(--sql-er-panel-2);
  font-family: var(--font-mono), ui-monospace, Menlo, monospace;
  font-size: 0.78rem;
}

.sql-er-tool .empty-card .privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.44rem;
  margin: 1.125rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--sql-er-border);
  color: var(--sql-er-muted);
  font-size: 0.78rem;
}

.sql-er-tool .empty-card .privacy .ico {
  width: 15px;
  height: 15px;
  color: var(--sql-er-ok);
  flex: none;
}

.sql-er-tool .inline-edit {
  position: absolute;
  z-index: 30;
  margin: 0;
  padding: 0 0.38rem;
  border: 2px solid var(--sql-er-accent);
  border-radius: 0.3rem;
  outline: none;
  background: var(--sql-er-panel);
  color: var(--sql-er-text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  font-family: var(--font-mono), ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1;
}

.sql-er-tool .zoom-controls,
.sql-er-tool .tool-palette {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.125rem;
  z-index: 8;
  padding: 0.18rem;
  border: 1px solid var(--sql-er-border);
  border-radius: 0.625rem;
  background: var(--sql-er-panel);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.sql-er-tool .zoom-controls {
  right: 1rem;
  bottom: 1rem;
}

.sql-er-tool .tool-palette {
  left: 1rem;
  bottom: 1rem;
}

.sql-er-tool .zoom-controls .btn {
  padding: 0.32rem 0.56rem;
}

.sql-er-tool #zoom-reset {
  min-width: 52px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sql-er-tool .tool-palette .btn.tool {
  gap: 0.38rem;
  padding: 0.38rem 0.68rem 0.38rem 0.56rem;
  font-weight: 700;
}

.sql-er-tool .tool-palette .ico {
  width: 16px;
  height: 16px;
  opacity: 0.85;
}

@media (max-width: 920px) {
  .sql-er-tool {
    --sql-er-editor-w: 100%;
    height: clamp(44rem, calc(100vh - 4.5rem), 76rem);
  }

  .sql-er-tool .topbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: auto;
    padding: 0.75rem;
  }

  .sql-er-tool .actions {
    width: 100%;
  }

  .sql-er-tool .layout {
    flex-direction: column;
  }

  .sql-er-tool .editor-pane {
    width: 100% !important;
    height: 38%;
    min-height: 17rem;
    border-right: 0;
    border-bottom: 1px solid var(--sql-er-border);
  }

  .sql-er-tool .splitter {
    display: none;
  }
}

@media (max-width: 640px) {
  .sql-er-tool {
    border-radius: 0;
    margin-inline: -0.75rem;
    height: calc(100vh - 3.25rem);
    min-height: 42rem;
  }

  .sql-er-tool .brand .name {
    font-size: 0.95rem;
  }

  .sql-er-tool .empty-card {
    max-width: min(92vw, 360px);
    padding: 1.25rem;
  }

  .sql-er-tool .tool-palette .btn.tool span {
    display: none;
  }
}
