:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c232c;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent-2: #79c0ff;
  --good: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand .logo { font-size: 30px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 600; }
.brand .tag { margin: 0; color: var(--muted); font-size: 12px; }

.status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#room-selector {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
#room-selector:focus { border-color: var(--accent); outline: none; }

.pill {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.loading { color: var(--warn); border-color: var(--warn); }
.pill.ready { color: var(--good); border-color: var(--good); }
.pill.error { color: var(--bad); border-color: var(--bad); }
.pill.mode { color: var(--accent); border-color: var(--accent); }

main { padding: 20px 24px; max-width: 1500px; margin: 0 auto; }

.room {
  background: var(--panel);
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.room h2 { margin: 0 0 4px; font-size: 16px; }
.room .goal { margin: 0; color: var(--muted); font-size: 13px; }
.room details { margin-top: 10px; cursor: pointer; }
.room summary { color: var(--accent); font-size: 13px; }
.room ol { margin: 8px 0 0 22px; color: var(--muted); font-size: 13px; }
.room ol li { margin: 4px 0; }
.room code { background: var(--panel-2); padding: 1px 5px; border-radius: 3px; font-family: var(--mono); }

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.schema-pane {
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 14px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.schema-pane h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.schema-pane h3:not(:first-child) { margin-top: 16px; }
.schema-pane pre {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--panel-2);
  padding: 10px;
  border-radius: 4px;
  margin: 0;
  white-space: pre-wrap;
  color: var(--accent-2);
}
.query-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 8px;
  font-style: italic;
}

.categories details {
  margin-bottom: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0;
}
.categories summary {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}
.categories summary::-webkit-details-marker { display: none; }
.categories summary::before {
  content: '▶';
  font-size: 9px;
  color: var(--muted);
  margin-right: 6px;
  transition: transform 0.15s;
}
.categories details[open] summary::before { transform: rotate(90deg); }
.categories .count {
  background: var(--bg);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
}

.samples {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-top: 1px solid var(--border);
}
.samples button {
  text-align: left;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 9px;
  border-radius: 3px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
}
.samples button:hover { background: var(--panel); border-color: var(--accent); color: var(--accent-2); }

.editor-pane {
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.editor-header, .results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.results-header { border-bottom: none; border-top: 1px solid var(--border); }
.editor-header kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11px;
}

#run {
  background: var(--accent);
  color: #001a3d;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
#run:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
#run:hover:not(:disabled) { background: var(--accent-2); }

#editor { height: 240px; border-bottom: 1px solid var(--border); }

#results {
  flex: 1;
  overflow: auto;
  padding: 0;
  min-height: 250px;
  max-height: 500px;
}
#results table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
#results th, #results td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
#results th {
  background: var(--panel-2);
  position: sticky;
  top: 0;
  color: var(--accent-2);
  font-weight: 600;
}
#results tr:hover td { background: var(--panel-2); }
#results .empty, #results .error {
  padding: 20px;
  color: var(--muted);
  text-align: center;
}
#results .error { color: var(--bad); font-family: var(--mono); text-align: left; white-space: pre-wrap; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 24px;
  padding: 12px;
}
footer a { color: var(--accent); text-decoration: none; }
footer p { margin: 4px 0; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .schema-pane { order: 2; max-height: none; }
}
