html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1000px 520px at 20% 0%, #1b2a6b20, transparent 60%), var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

header,
main {
  width: min(1240px, 100% - 28px);
  margin: 14px auto;
}

main {
  margin-top: 0;
}

.panel {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.controls {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.url {
  flex: 1 1 360px;
  min-width: 220px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  outline: none;
}

.status {
  margin-top: 10px;
  white-space: pre-wrap;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
  line-height: 1.4;
}

.log {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.16);
  color: var(--muted);
  padding: 10px;
  max-height: 170px;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
  display: none;
}

.stack {
  display: grid;
  gap: 12px;
}

.stage,
.metadata,
.footerCard {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.04));
  padding: 12px;
}

.stage {
  display: none;
}

.stageTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

.decode {
  color: var(--muted);
  font-size: 12px;
}

.viewport {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.12);
}

.grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 540px;
}

.tablesPane {
  border-right: 1px solid var(--line);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tablesHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.tablesList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 0;
}

.tableBtn {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.14);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  padding: 8px;
  text-align: left;
}

.tableBtn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tableBtn.active {
  border-color: rgba(86, 142, 245, 0.9);
  box-shadow: inset 0 0 0 1px rgba(86, 142, 245, 0.45);
}

.tableBtn .meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.resultsPane {
  padding: 10px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  min-height: 0;
}

.queryTools {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.14);
  display: grid;
  gap: 8px;
}

.queryInput {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  padding: 10px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  box-sizing: border-box;
}

.queryActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.queryInfo {
  color: var(--muted);
  font-size: 12px;
}

.tableTools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tableWrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  min-height: 220px;
  max-height: 520px;
  background: rgba(0, 0, 0, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.38);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  font-size: 12px;
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.metadata h2,
.footerCard h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.metadata {
  display: none;
}

.metaGrid {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(120px, 200px) 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

.metaGrid dt {
  color: var(--muted);
}

.metaGrid dd {
  margin: 0;
  word-break: break-word;
}

.footerCard {
  font-size: 13px;
}

.footerCard p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.45;
}

.footerCard details {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.footerCard summary {
  cursor: pointer;
}

#dropOverlay {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

#dropOverlay.active {
  display: flex;
}

.dropCard {
  border: 2px dashed rgba(255, 255, 255, 0.42);
  border-radius: 20px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  min-width: min(90vw, 560px);
  text-align: center;
}

@media (max-width: 980px) {
  header,
  main {
    width: min(1240px, 100% - 20px);
  }

  .grid {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .tablesPane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 220px;
  }

  .resultsPane {
    grid-template-rows: auto auto minmax(220px, 1fr);
  }

  .tableWrap {
    max-height: 56vh;
  }

  .metaGrid {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
