:root {
  --bg: #0b1220;
  --card: #141c2e;
  --border: #243049;
  --text: #e8eef9;
  --muted: #8b9bb8;
  --primary: #3b82f6;
  --accent: #8b5cf6;
  --ok: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

.top {
  padding: 1rem 1.1rem 0.75rem;
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
  z-index: 5;
}
.top h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.top.bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 0.85rem; margin: 0.2rem 0 0; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.content { padding: 0 1.1rem 1rem; flex: 1; }
.list { padding: 0.5rem 1.1rem 1rem; display: flex; flex-direction: column; gap: 0.75rem; }

.card-btn {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.card-btn strong { font-size: 1rem; }
.card-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}
.badge {
  font-size: 0.72rem;
  background: #1e3a5f;
  color: #93c5fd;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.xp { font-size: 0.8rem; color: #c4b5fd; font-weight: 600; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.panel.tight { margin: 0.5rem 1.1rem; padding: 0.65rem 0.85rem; }
.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.statement { white-space: pre-wrap; line-height: 1.45; margin: 0; font-size: 0.95rem; }
ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.9rem; }

.editor-wrap {
  flex: 1;
  min-height: 220px;
  margin: 0 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0a101c;
  display: flex;
}
.editor-wrap .line-editor {
  flex: 1;
  min-height: 220px;
}
.editor-wrap textarea,
#editor {
  width: 100%;
  height: 100%;
  min-height: 220px;
  border: none;
  resize: none;
  padding: 0.85rem;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  outline: none;
}

.small { font-size: 0.72rem; color: var(--muted); display: block; margin-bottom: 0.3rem; }
#inputs-json {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.diag {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  margin: 0.25rem 0;
  background: var(--bg);
  border-left: 3px solid var(--bad);
}
.diag.warning { border-left-color: var(--warn); }
.diag.error { border-left-color: var(--bad); }
.ok { color: var(--ok); font-size: 0.88rem; margin: 0; }

.pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: #1f2937;
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { background: #14532d; color: #86efac; }
.pill.bad { background: #7f1d1d; color: #fecaca; }

.footer-actions {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  padding: 0.75rem 1.1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  display: flex;
  gap: 0.5rem;
}
.footer-actions.row { flex-direction: row; }
.footer-actions .btn.block { width: 100%; }

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.accent { background: var(--accent); border-color: var(--accent); }

.code {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.code.out { color: #a5f3fc; }

.success-banner, .fail-banner {
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 1.1rem 0.75rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}
.success-banner { background: #14532d; color: #bbf7d0; }
.fail-banner { background: #7f1d1d; color: #fecaca; }

.test-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.test-row small { color: var(--muted); font-size: 0.78rem; }
.test-row.pass { color: #86efac; }
.test-row.fail { color: #fca5a5; }
