:root {
  --exam-primary: #0d6efd;
  --exam-bg: #f4f6f9;
  --exam-card: #fff;
  --exam-timer-warn: #ffc107;
  --exam-timer-danger: #dc3545;
  --exam-footer-h: 64px;
  --exam-footer-h-mobile: 120px;
}

body.exam-app-body {
  min-height: 100vh;
}

.exam-timer-bar {
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  border-left: 4px solid var(--primary-color, #3498db) !important;
}

.exam-timer-bar {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.question-card {
  border-left: 4px solid var(--exam-primary);
}

.option-btn.active {
  background: var(--exam-primary);
  color: #fff;
  border-color: var(--exam-primary);
}

.view-hidden {
  display: none !important;
}

/* Exam room layout (aligned with examV2/take_exam.php) */
.exam-room-flex {
  align-items: flex-start;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.q-num {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.q-num:hover {
  border-color: var(--exam-primary);
  background: #e7f1ff;
}

.q-num.answered {
  background: #198754 !important;
  color: #fff !important;
  border-color: #198754 !important;
}

.q-num.viewed:not(.answered) {
  background: var(--exam-primary) !important;
  color: #fff !important;
  border-color: var(--exam-primary) !important;
}

.q-num.current {
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.35);
}

.palette-desktop {
  position: sticky;
  top: 12px;
  height: fit-content;
}

.palette-card {
  background: #fff;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.palette-card h6 {
  font-size: 13px;
  font-weight: 600;
}

.palette-legend {
  font-size: 11px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.legend-box {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid #dee2e6;
}

.question-exam-card {
  display: none;
  border-radius: 10px;
  overflow: hidden;
  border: none;
}

.question-exam-card.active {
  display: block;
}

.q-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 15px;
}

.q-body {
  padding: 20px 18px;
}

.q-text {
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 20px;
  color: #2c3e50;
  font-weight: 500;
}

.option {
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.option:hover {
  border-color: var(--exam-primary) !important;
  background: #e7f1ff !important;
  transform: translateX(2px);
}

.option input[type='radio'] {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.option.selected {
  background: linear-gradient(135deg, #d4f4dd 0%, #a8e6cf 100%) !important;
  border-color: #198754 !important;
  font-weight: 500;
}

.exam-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 2px solid #e9ecef;
  padding: 10px 15px;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

.footer-content {
  display: flex;
  gap: 10px;
  max-width: 1400px;
  margin: 0 auto;
}

.btn-nav {
  flex: 1;
  padding: 10px;
  font-weight: 600;
  border-radius: 6px;
}

.save-msg {
  position: fixed;
  bottom: calc(var(--exam-footer-h) + 16px);
  right: 15px;
  background: #198754;
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  display: none;
  z-index: 1050;
  box-shadow: 0 4px 12px rgba(25, 135, 84, 0.3);
}

#view-exam {
  padding-bottom: calc(var(--exam-footer-h) + 24px) !important;
}

@media (max-width: 991.98px) {
  .save-msg {
    bottom: calc(var(--exam-footer-h-mobile) + 16px);
  }

  #view-exam {
    padding-bottom: calc(var(--exam-footer-h-mobile) + 24px) !important;
  }

  .exam-footer {
    padding: 12px 10px;
  }

  .footer-content {
    flex-direction: column;
    gap: 8px;
  }

  .btn-nav {
    width: 100%;
    padding: 12px;
    font-size: 15px;
  }

  .q-header {
    padding: 12px 14px;
    font-size: 14px;
  }

  .q-body {
    padding: 16px 14px;
  }

  .q-text {
    font-size: 16px;
    margin-bottom: 16px;
  }

  .option {
    padding: 12px !important;
    font-size: 15px;
    min-height: 50px;
  }
}
