.sqlite-result-scroll {
  width: 100%;
  overflow-x: auto;
  max-width: 100%;
}

.sqlite-pagination {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.sqlite-pagination button {
  width: auto;
  min-width: 0;
  padding: 0.25rem 0.65rem;
}

[data-role="sqlite-explorer"] {
  width: calc(100vw - 2rem);
  margin-left: calc(50% - 50vw + 1rem);
  box-sizing: border-box;
}

[data-role="sqlite-query-panel"] {
  width: calc(100vw - 2rem);
  margin-left: calc(50% - 50vw + 1rem);
  box-sizing: border-box;
}

.sqlite-query-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sqlite-query-editor,
.sqlite-query-output {
  min-width: 0;
}

/* Explicit overrides reserved for a future front-end layout toggle. */
.sqlite-query-layout[data-query-layout="stacked"] {
  display: flex;
  flex-direction: column;
}

.sqlite-query-layout[data-query-layout="split"] {
  display: grid;
  grid-template-columns: minmax(360px, 560px) 1fr;
  align-items: start;
  gap: 1.5rem;
}

@media (min-width: 960px) {
  .sqlite-query-layout:not([data-query-layout="stacked"]) {
    display: grid;
    grid-template-columns: minmax(360px, 560px) 1fr;
    align-items: start;
    gap: 1.5rem;
  }
}

.sqlite-result-scroll table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

[data-role="sqlite-table-details"] table {
  min-width: 0;
}

.sqlite-result-scroll th,
.sqlite-result-scroll td {
  padding: 0.4rem 0.55rem;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.sqlite-cell-toggle {
  display: block;
  max-width: min(28rem, 70vw);
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Keep theme button chrome from changing the height of text-only cells. */
:root[data-theme] [data-sqlite-viewer] .sqlite-result-scroll button.sqlite-cell-toggle {
  border: 0;
  box-shadow: none;
  line-height: inherit;
}

.sqlite-cell-toggle.is-expanded {
  max-width: min(48rem, 70vw);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

[data-role="sqlite-query-status"][data-state="error"] {
  color: var(--status-error);
  font-weight: 700;
}

[data-role="sqlite-effective-query"] {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  margin: 0;
}

[data-role="sqlite-effective-query"] summary {
  text-align: right;
}

.sqlite-query-bottom {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

[data-role="sqlite-query-pagination"] {
  flex: 0 0 auto;
  max-width: 100%;
  min-width: 0;
}

[data-role="sqlite-effective-query"] pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 0.75rem;
  background: var(--input-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sqlite-sort-button {
  margin: -0.4rem -0.55rem;
  padding: 0.4rem 0.55rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
}

[data-role="sqlite-table-preview"] th[aria-sort="ascending"] .sqlite-sort-button::after {
  content: " ▲";
}

[data-role="sqlite-table-preview"] th[aria-sort="descending"] .sqlite-sort-button::after {
  content: " ▼";
}

[data-role="sqlite-query-input"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  width: 100%;
  box-sizing: border-box;
}

[data-role="sqlite-query-select"] {
  width: 100%;
  box-sizing: border-box;
}

.sqlite-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0.8rem 0 0.55rem;
  border-bottom: 1px solid var(--line);
}

.sqlite-tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-top: 0;
}

.sqlite-tab.is-active {
  background: var(--active-bg);
  color: var(--active-ink);
}

.sqlite-tab-panel[hidden] {
  display: none;
}
.sqlite-dialog {
  width: calc(100vw - 2rem);
  max-width: 1600px;
  max-height: calc(100dvh - 2rem);
  box-sizing: border-box;
  overflow: auto;
  color: inherit;
  background: var(--page-bg, Canvas);
}
.sqlite-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.sqlite-dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--page-bg, Canvas);
}
.sqlite-dialog-header h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sqlite-dialog-header button { flex: 0 0 auto; width: auto; }
.sqlite-dialog [data-role="sqlite-explorer"],
.sqlite-dialog [data-role="sqlite-query-panel"] { width: 100%; margin-left: 0; }
.sqlite-dialog textarea { width: 100%; box-sizing: border-box; }
.sqlite-dialog pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.sqlite-dialog p { overflow-wrap: anywhere; }
.sqlite-dialog .sqlite-query-bottom > * { max-width: 100%; min-width: 0; }
