/* ── Design Tokens ── */
:root {
  --bg: #f9f8f6;
  --surface: #ffffff;
  --primary: #2d5016;
  --primary-dark: #1e3a0e;
  --primary-light: #edf5e8;
  --accent: #b8965a;
  --accent-light: #f7f1e6;
  --text: #2d3436;
  --text-secondary: #636e72;
  --text-muted: #9ba3a7;
  --border: #e2ddd5;
  --border-light: #eee9e2;
  --success: #2d6a4f;
  --success-light: #f0f7f4;
  --fail: #943333;
  --fail-light: #fdf2f2;
  --header-bg: #1a2e12;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ── */
.header {
  background: var(--header-bg);
  color: #fff;
  padding: 36px 24px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(45,80,22,0.15) 0%, rgba(184,150,90,0.08) 100%);
  pointer-events: none;
}
.header h1 {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  position: relative;
}
.header p {
  font-size: 13px;
  opacity: 0.65;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  position: relative;
}

/* ── Navigation ── */
.nav {
  display: flex;
  justify-content: center;
  gap: 4px;
  background: rgba(26,46,18,0.95);
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.nav a {
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 100px;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}
.nav a:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.08);
}
.nav a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

/* ── App Container ── */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ── Exam List ── */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.list-header h2 {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 26px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.01em;
}
.list-stats {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.exam-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 8px 14px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
}
.exam-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.exam-card .exam-num {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--primary);
  line-height: 1;
}
.exam-card .exam-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.exam-card .exam-status {
  font-size: 11px;
  margin-top: 8px;
  padding: 2px 10px;
  border-radius: 100px;
  display: inline-block;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.exam-card.passed {
  border-color: var(--success);
  background: var(--success-light);
}
.exam-card.passed .exam-num {
  color: var(--success);
}
.exam-card.passed .exam-status {
  background: var(--success);
  color: #fff;
}
.exam-card.failed {
  border-color: var(--fail);
  background: var(--fail-light);
}
.exam-card.failed .exam-num {
  color: var(--fail);
}
.exam-card.failed .exam-status {
  background: var(--fail);
  color: #fff;
}
.exam-card.not-attempted .exam-status {
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Exam Runner ── */
.exam-runner {
  max-width: 680px;
  margin: 0 auto;
}

.progress-bar-container {
  background: var(--border);
  border-radius: 100px;
  height: 6px;
  margin-bottom: 24px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-counter {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.question-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}
.question-text {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 19px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 28px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.option-item {
  display: block;
}
.option-label {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 15px;
  line-height: 1.5;
}
.option-label:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.option-label input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  transition: all var(--transition);
}
.option-label:hover input[type="radio"] {
  border-color: var(--primary);
}
.option-label input[type="radio"]:checked {
  border-color: var(--primary);
  background: var(--primary);
}
.option-label input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
}
.option-label.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}
.option-label.selected input[type="radio"] {
  border-color: var(--primary);
}

/* ── Buttons ── */
.exam-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(45,80,22,0.3);
}
.btn-secondary {
  background: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: #d4cfc7;
}
.btn-submit {
  background: var(--success);
  color: #fff;
}
.btn-submit:hover {
  background: #245a42;
  box-shadow: 0 4px 12px rgba(45,106,79,0.3);
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn-back {
  background: none;
  color: var(--text-secondary);
  padding: 10px 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}
.btn-back:hover {
  background: var(--border-light);
  color: var(--text);
}

.unanswered-warning {
  background: #fef9ef;
  border: 1px solid #e8d5a8;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-top: 18px;
  font-size: 13px;
  color: #8a6914;
  line-height: 1.5;
}

/* ── Results ── */
.results {
  max-width: 680px;
  margin: 0 auto;
}

.score-banner {
  text-align: center;
  padding: 40px 28px;
  border-radius: var(--radius-xl);
  margin-bottom: 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.score-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at top right, rgba(255,255,255,0.1) 0%, transparent 60%);
  pointer-events: none;
}
.score-banner.pass {
  background: linear-gradient(135deg, #2d6a4f, #40916c);
}
.score-banner.fail {
  background: linear-gradient(135deg, #943333, #b84444);
}
.score-number {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 52px;
  font-weight: 400;
  line-height: 1;
  position: relative;
}
.score-label {
  font-size: 14px;
  margin-top: 6px;
  opacity: 0.8;
  letter-spacing: 0.04em;
  font-weight: 500;
  position: relative;
}
.score-verdict {
  font-size: 13px;
  font-weight: 700;
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  position: relative;
}

.chapter-breakdown {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}
.chapter-breakdown h3 {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 16px;
}
.chapter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-secondary);
}
.chapter-row:last-child {
  border-bottom: none;
}
.chapter-bar-bg {
  width: 80px;
  height: 5px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-left: 12px;
  display: inline-block;
  vertical-align: middle;
}
.chapter-bar {
  height: 100%;
  border-radius: 100px;
  transition: width 0.4s ease;
}
.chapter-bar.good { background: var(--success); }
.chapter-bar.mid { background: var(--accent); }
.chapter-bar.bad { background: var(--fail); }

/* ── Question Review ── */
.review-section h3 {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 20px;
}

.review-question {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  border-left: 4px solid transparent;
  transition: border-color var(--transition);
}
.review-question.correct {
  border-left-color: var(--success);
}
.review-question.incorrect {
  border-left-color: var(--fail);
}
.review-q-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.review-q-num {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.review-q-badge {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 100px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.review-q-badge.correct {
  background: var(--success-light);
  color: var(--success);
}
.review-q-badge.incorrect {
  background: var(--fail-light);
  color: var(--fail);
}
.review-q-text {
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.5;
}
.review-answer {
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.5;
}
.review-answer .label {
  font-weight: 600;
  color: var(--text-secondary);
}
.review-answer.your-wrong .value {
  color: var(--fail);
  text-decoration: line-through;
}
.review-answer.correct-answer .value {
  color: var(--success);
  font-weight: 600;
}
.review-explanation {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  border: 1px solid var(--border-light);
}
.review-explanation strong {
  color: var(--primary);
  font-weight: 700;
}

.results-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .header {
    padding: 28px 16px 24px;
  }
  .header h1 {
    font-size: 22px;
  }
  .exam-grid {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 8px;
  }
  .question-card {
    padding: 20px 18px;
  }
  .exam-nav {
    flex-wrap: wrap;
  }
  .score-number {
    font-size: 40px;
  }
  #app {
    padding: 20px 14px 36px;
  }
  .chapter-breakdown {
    padding: 18px 20px;
  }
  .review-question {
    padding: 16px 18px;
  }
}
