:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #5f6c80;
  --line: #d9e0ea;
  --accent: #185abc;
  --accent-dark: #123f86;
  --good: #126b45;
  --bad: #a12828;
  --shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #101827;
  color: white;
  border-bottom: 1px solid #0a1020;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.subtle,
.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar .subtle {
  color: #c3cada;
  margin: 0.35rem 0 0;
}

.status {
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  white-space: nowrap;
  font-size: 0.9rem;
}

.status.ok {
  color: #b8f5d5;
}

.status.error {
  color: #ffd0d0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 1rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
}

.steps li {
  margin: 0.35rem 0;
}

.field-stack,
.field-grid {
  display: grid;
  gap: 0.75rem;
}

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

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}

input,
select {
  min-height: 2.35rem;
  padding: 0.45rem 0.55rem;
}

textarea {
  min-height: 17rem;
  padding: 0.75rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

button {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  border-radius: 6px;
  min-height: 2.35rem;
  padding: 0.45rem 0.8rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #eef3fa;
}

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

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

.workbench {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.controls,
.editor-panel,
.result-panel,
.grid-panel {
  padding: 1rem;
}

.button-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.hint {
  margin: 0.85rem 0 0;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, var(--query-pane, 1fr)) 1rem minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.two-column.resizing {
  cursor: col-resize;
  user-select: none;
}

.editor-panel,
.result-panel {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-panel {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.result-panel {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.pane-resizer {
  position: relative;
  align-self: stretch;
  min-width: 1rem;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #eef3fa;
  cursor: col-resize;
  box-shadow: none;
}

.pane-resizer::before {
  content: "";
  position: absolute;
  top: 1rem;
  bottom: 1rem;
  left: 50%;
  width: 2px;
  border-radius: 2px;
  background: #b9c5d5;
  transform: translateX(-50%);
}

.pane-resizer:hover::before,
.pane-resizer:focus-visible::before,
.two-column.resizing .pane-resizer::before {
  width: 3px;
  background: var(--accent);
}

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

.result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}

#resultMeta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.json {
  margin: 0;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 39rem;
  max-height: 39rem;
  overflow: auto;
  background: #0f172a;
  color: #dbeafe;
  border-radius: 6px;
  padding: 0.85rem;
  font-size: 0.82rem;
  line-height: 1.4;
}

.feature-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.feature {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem;
  background: #fbfcfe;
}

.feature strong {
  display: block;
  font-size: 0.88rem;
}

.feature span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

.table-wrap {
  overflow: auto;
  max-height: 34rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  background: white;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #edf2f9;
  z-index: 1;
}

td {
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1100px) {
  .layout,
  .two-column,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .pane-resizer {
    display: none;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .json {
    min-height: 22rem;
    max-height: 22rem;
  }
}
