: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;
  --gold: #f0b429;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand .logo { font-size: 28px; }
.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  gap: 8px;
  align-items: center;
}
.brand .beta {
  font-size: 9px;
  background: var(--gold);
  color: #1a1300;
  padding: 1px 6px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}
.brand .tag { margin: 0; color: var(--muted); font-size: 11.5px; }

.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;
  max-width: 240px;
}
#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); }
.pill-btn { cursor: pointer; font-family: inherit; }
.pill-btn:hover { background: var(--bg); }

.icon-btn {
  width: 28px;
  height: 28px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-2); }

.user-info { font-size: 13px; }
.user-info a {
  color: var(--accent);
  text-decoration: none;
  background: var(--panel-2);
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.user-info a:hover { border-color: var(--accent); background: var(--bg); }

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;
  position: sticky;
  top: 80px;
}
.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: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  gap: 10px;
  flex-wrap: wrap;
}
.results-header { border-bottom: none; border-top: 1px solid var(--border); }
.ed-left, .ed-actions, #result-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.editor-header kbd, .help-content kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
}
.kbd-hint { font-size: 11px; color: var(--muted); }
.lang-toggle {
  background: var(--panel-2);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.lang-toggle:hover { background: var(--bg); }

#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); }

.ghost-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
}
.ghost-btn:hover { border-color: var(--accent); color: 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; }

#verify-result .ok { color: var(--good); font-weight: 600; }
#verify-result .fail { color: var(--bad); }

.saved-item {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.saved-load {
  flex: 1;
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.saved-load:hover { border-color: var(--gold); color: var(--gold); }
.saved-del {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  width: 20px;
  height: 22px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1;
}
.saved-del:hover { color: var(--bad); border-color: var(--bad); }

/* ── Why section ─────────────────────────────────────────── */
.why-section, .pricing-section {
  margin-top: 40px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}
.why-section h2, .pricing-section h2 {
  font-size: 22px;
  margin: 0 0 6px;
  text-align: center;
}
.pricing-sub {
  text-align: center;
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 13px;
}
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.why-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}
.why-icon { font-size: 28px; margin-bottom: 8px; }
.why-card h3 { margin: 0 0 6px; font-size: 14px; }
.why-card p { margin: 0; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 11px; }

/* ── Pricing ─────────────────────────────────────────────── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.pricing-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.pricing-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15);
}
.pricing-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pricing-card .price {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
}
.pricing-card .price span {
  font-size: 26px;
  color: var(--text);
  font-weight: 700;
}
.pricing-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text);
  flex: 1;
}
.pricing-card li {
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.pricing-card li:last-child { border-bottom: none; }
.cta-note {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.cta-note a { color: var(--accent); text-decoration: none; }

/* ── Footer ──────────────────────────────────────────────── */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 40px;
  padding: 20px 12px 30px;
  border-top: 1px solid var(--border);
}
footer a { color: var(--accent); text-decoration: none; }
footer p { margin: 4px 0; }

/* ── Modal ───────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 60px 20px;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  max-width: 600px;
  width: 100%;
  position: relative;
}
.modal-card h2 { margin: 0 0 14px; font-size: 20px; }
.modal-card h3 { margin: 18px 0 6px; font-size: 14px; color: var(--accent); }
.modal-card p, .modal-card li { font-size: 13.5px; color: var(--text); }
.modal-card ol { padding-left: 22px; }
.modal-card li { padding: 5px 0; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 28px;
  height: 28px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); border-color: var(--accent); }
.modal-card a { color: var(--accent); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .schema-pane { order: 2; max-height: none; position: static; }
  header { padding: 12px 14px; }
  .brand h1 { font-size: 15px; }
  main { padding: 14px; }
}
