:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --hot: #fb923c;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

a { color: var(--accent); }

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

header.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
}

header .sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.15rem 0 0;
}

.badge.ok {
  background: #1a3d2e;
  color: #8fd6b0;
  border-color: #2f6b4f;
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: #7c2d12;
  color: #fed7aa;
  border: 1px solid #ea580c;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

button, .btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

button:hover, .btn:hover { border-color: var(--accent); }
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #0c1220;
  font-weight: 650;
}

button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.danger { border-color: #991b1b; color: #fecaca; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.stat {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.stat .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: 0.15rem; }

/* Exam chrome */
.exam-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(6px);
  padding: 0.75rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.timer {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.timer.warn { border-color: var(--warn); color: var(--warn); }
.timer.critical { border-color: var(--bad); color: var(--bad); animation: pulse 1s infinite; }

@keyframes pulse {
  50% { opacity: 0.7; }
}

.progress-text { color: var(--muted); font-size: 0.9rem; }

.stem {
  font-size: 1.05rem;
  margin: 0.5rem 0 1rem;
}

.choices {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.choices label {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.choices label:hover { border-color: var(--accent); }
.choices label.selected {
  border-color: var(--accent);
  background: #0c4a6e33;
}

.choices input { margin-top: 0.2rem; accent-color: var(--accent); }

.choice-letter {
  font-weight: 700;
  color: var(--accent);
  min-width: 1.25rem;
}

.nav-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 1rem;
}

.nav-dots button {
  width: 2rem;
  height: 2rem;
  padding: 0;
  justify-content: center;
  font-size: 0.8rem;
  border-radius: 6px;
}

.nav-dots button.answered { background: #164e63; border-color: #22d3ee; }
.nav-dots button.current { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Results */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.view-toggle button {
  border: none;
  border-radius: 0;
  background: var(--surface);
}

.view-toggle button.active {
  background: var(--accent-dim);
  color: #0c1220;
  font-weight: 650;
}

.tag-list, .path-list, .miss-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag-list li, .path-list li, .miss-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.tag-list li:last-child, .path-list li:last-child, .miss-list li:last-child {
  border-bottom: none;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.tag-id {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
}

.hot-flag {
  font-size: 0.7rem;
  color: var(--hot);
  font-weight: 650;
  margin-left: 0.35rem;
}

.bar {
  height: 8px;
  background: #1e293b;
  border-radius: 4px;
  margin-top: 0.4rem;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--good);
  border-radius: 4px;
}

.bar.weak > span { background: var(--bad); }
.bar.mid > span { background: var(--warn); }

.heatmap {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.heat-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) 1fr auto;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
}

.heat-row .pct { font-family: var(--mono); min-width: 3.5rem; text-align: right; }

.domain-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .domain-cards { grid-template-columns: 1fr; }
  .heat-row { grid-template-columns: 1fr; }
}

pre.json-preview {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  max-height: 320px;
  color: #cbd5e1;
}

.hidden { display: none !important; }

.calc-panel {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.calc-panel input {
  width: 100%;
  max-width: 280px;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
}

footer.site-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

/* ——— Auth / account ——— */
.header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.auth-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-status .auth-name {
  color: var(--text);
  font-weight: 600;
}

.auth-status .auth-role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--accent);
}

button.compact, .btn.compact {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.auth-tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.auth-tabs button {
  border: none;
  border-radius: 0;
  background: var(--surface);
}

.auth-tabs button.active {
  background: var(--accent-dim);
  color: #0c1220;
  font-weight: 650;
}

.auth-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.auth-form .field span {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-form input {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-error {
  color: var(--bad);
  margin: 0 0 0.5rem;
}

.auth-form.inline-auth {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.auth-form.inline-auth .btn-row {
  grid-column: 1 / -1;
}

.save-banner {
  border-color: var(--warn);
  background: #2a2410;
}

.save-ok { color: var(--good); }
.save-fail { color: var(--bad); }

.learners-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.learners-list li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.learners-list li:last-child { border-bottom: none; }

.toast {
  position: sticky;
  top: 0.5rem;
  z-index: 40;
  margin-bottom: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.toast.toast-ok {
  border-color: #2f6b4f;
  background: #1a3d2e;
  color: #8fd6b0;
}

.toast.toast-err {
  border-color: #991b1b;
  background: #3f1515;
  color: #fecaca;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--accent);
}
