:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-2: #4f46e5;
  --correct: #22c55e;
  --partial: #eab308;
  --wrong: #ef4444;
  --border: #334155;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.brand { font-weight: 700; font-size: 1.05rem; }

.pill {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.container {
  max-width: 760px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.req { color: var(--wrong); }

form label {
  display: block;
  margin: 0.9rem 0 0;
  font-weight: 600;
  font-size: 0.9rem;
}

input, select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
}

input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.row { display: flex; gap: 1rem; }
.row label { flex: 1; }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--border);
  transition: transform 0.05s ease, background 0.15s ease;
}
button:hover { background: #31425c; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent-2);
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem;
  font-size: 1rem;
}
button.primary:hover { background: var(--accent-2); }

/* progress */
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.topic { font-weight: 700; font-size: 1.05rem; }
.progress-stats { display: flex; gap: 0.6rem; font-size: 0.9rem; }
.stat.correct { color: var(--correct); }
.stat.partial { color: var(--partial); }
.stat.wrong { color: var(--wrong); }

.progress-bar {
  height: 8px;
  background: var(--card-2);
  border-radius: 999px;
  margin: 0.9rem 0 0.35rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--correct));
  transition: width 0.4s ease;
}

.content { margin-top: 1.25rem; }

.question-text { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.35rem; }
.instructions { color: var(--muted); margin-bottom: 1rem; }

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice:hover { border-color: var(--accent); }
.choice input { width: auto; margin: 0.2rem 0 0; }
.choice.selected { border-color: var(--accent); background: #313f5e; }
.choice.correct { border-color: var(--correct); background: rgba(34, 197, 94, 0.12); }
.choice.wrong { border-color: var(--wrong); background: rgba(239, 68, 68, 0.12); }
.choice .choice-body { flex: 1; }
.choice .choice-text { font-weight: 500; }
.choice .choice-expl { margin-top: 0.4rem; font-size: 0.88rem; color: var(--muted); }
.choice .badge { font-size: 0.75rem; font-weight: 700; }
.badge.ok { color: var(--correct); }
.badge.no { color: var(--wrong); }

.footer-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1.25rem; }
.footer-actions button { flex: 0 0 auto; }
.spacer { flex: 1 1 auto; }

.result-banner {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  margin-bottom: 1rem;
}
.result-banner.correct { background: rgba(34, 197, 94, 0.18); color: var(--correct); }
.result-banner.partially_correct { background: rgba(234, 179, 8, 0.18); color: var(--partial); }
.result-banner.incorrect { background: rgba(239, 68, 68, 0.18); color: var(--wrong); }

.explanation { margin: 0.5rem 0 1rem; }
.takeaway {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.9rem;
  background: var(--card-2);
  border-radius: 0 10px 10px 0;
  margin-top: 1rem;
}
.takeaway b { color: var(--accent); }

.lesson-box, .example-box, .review-box, .hint-box, .completion-box {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  white-space: pre-wrap;
}
.lesson-box h2, .completion-box h2 { margin-top: 0; }
.hint-box { border-color: var(--partial); }

.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--wrong);
  color: #fecaca;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-top: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}
.summary-grid .box {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  text-align: center;
}
.summary-grid .box b { display: block; font-size: 1.6rem; }

@media (max-width: 560px) {
  .row { flex-direction: column; gap: 0; }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
}
