:root {
  --bg: #0f1419;
  --bg-card: #1a2027;
  --bg-elev: #232b35;
  --border: #2d3748;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --success-bg: #064e3b;
  --danger: #ef4444;
  --danger-bg: #7f1d1d;
  --warning: #f59e0b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
}

header h1 { font-size: 1.5rem; color: var(--text); }
header .subtitle { color: var(--text-dim); font-size: 0.9rem; margin-top: 0.25rem; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.view { display: none; }
.view.active { display: block; }

h2 { margin-bottom: 1.5rem; font-size: 1.25rem; }

/* Exam list */
.exam-list {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.exam-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
}

.exam-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.exam-card h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.exam-card .meta {
  color: var(--text-dim);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
}

.exam-card .best-score {
  color: var(--success);
  font-weight: 600;
}

/* Quiz header */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.quiz-header h2 { margin: 0; flex: 1; min-width: 200px; }

.quiz-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  cursor: pointer;
}

.toggle input { cursor: pointer; }

/* Progress */
.progress-bar {
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

#progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s;
}

.quiz-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Question */
#question-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.question-text {
  font-size: 1.05rem;
  margin-bottom: 1.25rem;
  font-weight: 500;
}

.options { display: flex; flex-direction: column; gap: 0.6rem; }

.option {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.option:hover:not(.disabled) {
  border-color: var(--primary);
  background: #2a3441;
}

.option.selected {
  border-color: var(--primary);
  background: #1e3a5f;
}

.option.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.option.wrong {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.option.disabled { cursor: not-allowed; }

.option-letter {
  font-weight: 700;
  color: var(--text-dim);
  min-width: 24px;
}

.option.correct .option-letter,
.option.correct .option-text { color: #d1fae5; }
.option.wrong .option-letter,
.option.wrong .option-text { color: #fecaca; }

.feedback {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #2d2410;
  border-left: 3px solid var(--warning);
  color: #fde68a;
}

/* Buttons */
.btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #2a3441;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-ghost { background: transparent; }

.quiz-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* Question nav grid */
.question-nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.q-num {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.q-num:hover { border-color: var(--primary); }
.q-num.current { border: 2px solid var(--primary); }
.q-num.answered-correct { background: var(--success-bg); border-color: var(--success); }
.q-num.answered-wrong { background: var(--danger-bg); border-color: var(--danger); }
.q-num.answered { background: #1e3a5f; border-color: var(--primary); }

/* Results */
#results-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.score-big {
  font-size: 3rem;
  font-weight: 700;
  margin: 0.5rem 0;
}

.score-big.pass { color: var(--success); }
.score-big.fail { color: var(--danger); }

.score-detail {
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
  header { padding: 1rem; }
  header h1 { font-size: 1.2rem; }
  main { padding: 1rem 0.75rem; }
  #question-container { padding: 1rem; }
  .quiz-nav .btn { flex: 1; }
}
