/* ==========================================================================
   Exam section — flat, no glow/blur/gradient effects
   ========================================================================== */
.exam-shell { min-height: 60vh; }
.exam-list-view { display: flex; flex-direction: column; gap: var(--page-gap); }
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: var(--sp-4); }
.exs-back-btn { color: var(--text-muted); font-size: var(--fs-md); font-weight: 600; min-height: 36px; margin-bottom: var(--sp-1); display: inline-flex; align-items: center; gap: 6px; }
.exs-back-btn:hover { color: var(--text-primary); }

/* ---------- Course picker cards ---------- */
.exs-course-card {
  display: flex; align-items: center; gap: 14px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px; transition: border-color .15s;
}
.exs-course-card:hover { border-color: var(--accent-soft); }
.exs-course-cover {
  width: 60px; height: 60px; border-radius: var(--radius-sm); background: var(--bg-elevated-2) center/cover no-repeat;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1.3rem;
}
.exs-course-body { flex: 1; min-width: 0; }
.exs-course-body h3 { font-size: 1.02rem; margin-bottom: 6px; }
.exs-meta-row { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-muted); font-size: 0.83rem; }
.exs-meta-row span { display: flex; align-items: center; gap: 6px; }
.exs-course-open-tag { color: var(--accent-green); font-weight: 600; }
.exs-course-arrow { color: var(--text-muted); flex-shrink: 0; }

/* ---------- Course hub — Upcoming / Live / Practice buttons ---------- */
.exs-hub-grid { grid-template-columns: 1fr; max-width: 560px; margin: 0 auto; gap: 14px; }
.exs-hub-btn {
  display: flex; align-items: center; gap: 16px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px 20px; transition: border-color .15s, background .15s;
}
.exs-hub-btn:hover { border-color: var(--accent-soft); background: var(--bg-elevated-2); }
.exs-hub-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
  background: var(--bg-elevated-2); border: 1px solid var(--border-strong); color: var(--text-muted);
}
.exs-hub-btn--upcoming .exs-hub-icon { color: var(--accent-amber); }
.exs-hub-btn--live .exs-hub-icon { color: var(--accent-green); }
.exs-hub-btn--practice .exs-hub-icon { color: var(--accent-soft); }
.exs-hub-body { flex: 1; min-width: 0; }
.exs-hub-body h3 { font-size: 1.05rem; margin-bottom: 3px; }
.exs-hub-body p { color: var(--text-muted); font-size: 0.83rem; }
.exs-hub-count {
  min-width: 30px; text-align: center; padding: 4px 9px; border-radius: 999px; font-weight: 700; font-size: 0.85rem;
  background: var(--bg-elevated-2); border: 1px solid var(--border-strong); color: var(--text-primary); flex-shrink: 0;
}
.exs-hub-arrow { color: var(--text-muted); flex-shrink: 0; }
@media (max-width: 560px) {
  .exs-hub-btn { padding: 14px 16px; gap: 12px; }
  .exs-hub-icon { width: 40px; height: 40px; font-size: 1.1rem; }
}

/* ---------- Exam cards ---------- */
.exs-type-row { display: flex; justify-content: flex-end; margin-bottom: -4px; }
.exs-type-badge {
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; line-height: 1.5;
}
.exs-type-badge--live { background: rgba(34,168,98,0.14); color: var(--accent-green); border: 1px solid rgba(34,168,98,0.35); }
.exs-type-badge--practice { background: rgba(139,124,255,0.14); color: var(--accent-soft); border: 1px solid rgba(139,124,255,0.35); }

/* ---------- Practice score-history sparkline ---------- */
.exs-spark { background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px 10px; }
.exs-spark-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.78rem; margin-bottom: 10px; }
.exs-spark-label { color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.exs-spark-best { color: var(--accent-green); font-weight: 700; }
.exs-spark-bars { display: flex; align-items: flex-end; gap: 5px; height: 42px; }
.exs-spark-bar {
  flex: 1; height: calc(var(--pct) * 1%); min-height: 4px; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--accent-soft), rgba(139,124,255,0.3));
  transition: transform .15s ease;
}
.exs-spark-bar:hover { transform: scaleY(1.06); }
.exs-spark-bar.is-latest { background: linear-gradient(180deg, var(--accent-green), rgba(34,168,98,0.35)); }

.exs-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.exs-card h3 { font-size: 1.08rem; }
.exs-card--locked { opacity: 0.85; }
.exs-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.exs-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bg-elevated-2); border: 1px solid var(--border-strong); color: var(--text-muted); }
.exs-chip-course { color: var(--accent-soft); }
.exs-countdown { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: rgba(108,92,231,0.14); border: 1px solid var(--border-strong); color: var(--accent-soft); font-size: 0.72rem; font-weight: 700; white-space: nowrap; }

/* ---------- Verification / rules gate ---------- */
.exs-verify-wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 0; }
.exs-verify-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 26px; }
.exs-verify-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
.exs-verify-head i { font-size: 1.5rem; color: var(--accent-soft); flex-shrink: 0; margin-top: 3px; }
.exs-verify-head h2 { font-size: 1.15rem; margin-bottom: 4px; }
.exs-verify-head p { color: var(--text-muted); font-size: 0.88rem; }
.exs-verify-head--fail i { color: var(--accent-coral); }
.exs-verify-card--fail .exs-verify-head { margin-bottom: 20px; }
.exs-verify-steps { display: flex; flex-direction: column; gap: 4px; }
.exs-verify-step { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.exs-verify-step:last-child { border-bottom: none; }
.exs-verify-step-icon { width: 20px; text-align: center; color: var(--text-muted); }
.exs-verify-step--ok .exs-verify-step-icon { color: var(--accent-green); }
.exs-verify-step--fail .exs-verify-step-icon { color: var(--accent-coral); }
.exs-verify-step--fail .exs-verify-step-label { color: var(--accent-coral); }

.exs-rules-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.exs-rules-stat { background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.exs-rules-stat span { display: block; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 5px; }
.exs-rules-stat b { font-family: var(--font-display); font-size: 1.1rem; }
.exs-rules-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.exs-rules-list li { position: relative; padding-inline-start: 20px; font-size: 0.87rem; line-height: 1.55; color: var(--text-muted); }
.exs-rules-list li::before { content: "\f058"; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; left: 0; top: 2px; color: var(--accent-teal); font-size: 0.8rem; }
.exs-rules-actions { display: flex; gap: 10px; }
.exs-rules-actions .btn { flex: 1; }

/* ---------- Exam loading (the instant "Start" is pressed) ----------
   fetchQuestions() is one Firestore read with no real progress to report, so
   this is an honest simulation: 12 flat accent ticks chase around a ring,
   the % eases up to 92 and only snaps to 100 once beginAttempt() has the
   real data, and the caption line rotates through short status text. Flat
   colors only — no blur/glow/gradient, same as the rest of this section. */
.exs-loading-body { padding-top: 2px; }
.exs-loading-ring { position: relative; width: 116px; height: 116px; margin: 6px auto 22px; }
.exs-loading-tick {
  position: absolute; top: 6px; left: 50%; width: 4px; height: 17px; margin-left: -2px;
  border-radius: 3px; background: var(--accent-soft); opacity: 0.16;
  transform-origin: 2px 52px; transform: rotate(calc(var(--i) * 30deg));
  animation: exs-tick-chase 1.15s ease-in-out infinite; animation-delay: calc(var(--i) * -0.096s);
}
@keyframes exs-tick-chase { 0%, 55%, 100% { opacity: 0.16; } 12% { opacity: 1; } }
.exs-loading-pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.55rem; color: var(--text-primary);
}
.exs-loading-bar-track { height: 8px; border-radius: 999px; background: var(--bg-elevated-2); border: 1px solid var(--border); overflow: hidden; }
.exs-loading-bar-fill { height: 100%; width: 0%; background: var(--accent); border-radius: inherit; transition: width .25s ease-out, background-color .3s ease; }
.exs-loading-bar-fill.is-done { background: var(--accent-green); }
.exs-loading-caption { text-align: center; color: var(--text-muted); font-size: 0.88rem; margin-top: 14px; min-height: 1.3em; transition: opacity .2s ease, transform .2s ease; }
.exs-loading-caption.exs-caption-out { opacity: 0; transform: translateY(-4px); }

@media (prefers-reduced-motion: reduce) {
  .exs-loading-tick { animation: none; opacity: 0.55; }
  .exs-loading-caption, .exs-loading-bar-fill { transition: none; }
}
@media (max-width: 380px) {
  .exs-loading-ring { width: 100px; height: 100px; }
  .exs-loading-tick { height: 15px; transform-origin: 2px 44px; }
  .exs-loading-pct { font-size: 1.32rem; }
}

/* ---------- Taking the exam ---------- */
.exam-take-wrap { width: 100%; max-width: 700px; margin: 0 auto; padding: 0 0 var(--sp-6); }
.exam-sticky-bar { position: sticky; top: calc(var(--nav-h) + env(safe-area-inset-top, 0px)); z-index: 30; background: var(--bg); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); }
.exam-top-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.exam-top-bar h2 { font-size: 1.05rem; }
.exam-timer { font-family: var(--font-utility); font-weight: 700; font-size: 1.08rem; background: var(--bg-elevated-2); border: 1.5px solid var(--border-strong); padding: 8px 18px; border-radius: 999px; display: flex; align-items: center; gap: 8px; }
.exam-timer i { color: var(--accent-soft); }
.exam-timer.low { color: var(--accent-coral); border-color: var(--accent-coral); }
.exam-timer.low i { color: var(--accent-coral); }
.q-progress-track { height: 6px; background: var(--bg-elevated-2); border-radius: 999px; overflow: hidden; }
.q-progress-fill { height: 100%; background: var(--accent); transition: width .3s ease; }

.exs-question-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 24px; }
.exs-mb { margin-bottom: 18px; }
.exs-q-index { color: var(--accent-soft); font-family: var(--font-utility); font-weight: 700; font-size: 0.84rem; margin-bottom: 10px; }
.exs-question-card h2 { font-size: 1.18rem; line-height: 1.5; margin-bottom: 20px; }
.exs-options { display: flex; flex-direction: column; gap: 10px; }
.exs-option { display: flex; align-items: center; gap: 12px; padding: 13px 15px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-strong); cursor: pointer; transition: border-color .15s, background .15s; }
.exs-option:hover { border-color: var(--accent-teal); }
.exs-option.is-selected { border-color: var(--accent); background: rgba(108,92,231,0.12); }
.exs-option-letter { width: 26px; height: 26px; border-radius: 50%; background: var(--bg-elevated-2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; }
.exs-option.is-selected .exs-option-letter { background: var(--accent); color: #fff; }
.exs-option.is-disabled { cursor: not-allowed; }
.exs-options.is-locked .exs-option:not(.is-selected) { opacity: 0.5; }
.exs-option-lock { margin-inline-start: auto; color: var(--accent-teal); }
.exs-locked-hint { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 0.82rem; color: var(--text-muted); }
.exam-nav-row { display: flex; justify-content: space-between; margin-top: 22px; }

/* ---------- Result ----------
   The result screen itself (hero, stat cards, analytics, light/dark theme, motion) lives in exam-result.css
   (markup: js/exam-result.js). What stays here is shared with My Activity: the review list below. */

/* Save status chip — the result is shown at once, the save runs in the background */
.exs-save-status { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding: 7px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; line-height: 1.4; }
.exs-save-status:empty { display: none; }
.exs-save-status.is-saving { background: rgba(232,163,61,0.14); color: var(--accent-amber); }
.exs-save-status.is-saved { background: rgba(34,168,98,0.14); color: var(--accent-green); }
.exs-save-status.is-failed, .exs-save-status.is-blocked { background: rgba(225,95,82,0.14); color: var(--accent-coral); }
.exs-save-retry { font-family: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer; padding: 4px 12px; border-radius: 999px; border: 1px solid currentColor; background: transparent; color: inherit; }
.exs-save-retry:hover { background: rgba(225,95,82,0.2); }
.exs-review-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 22px; line-height: 1.55; }
.exs-review-note i { margin-top: 3px; flex-shrink: 0; }

.exs-review-list { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.exs-review-item { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px 18px; }
.exs-review-q { font-weight: 600; margin-bottom: 10px; }
.exs-review-answer { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; padding: 3px 0; }
.exs-review-answer.is-correct { color: var(--accent-teal); }
.exs-review-answer.is-wrong { color: var(--accent-coral); }
.exs-review-explain { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-elevated-2); font-size: 0.87rem; line-height: 1.5; }
.exs-review-explain i { margin-top: 3px; color: var(--accent-amber); flex-shrink: 0; }

/* ==========================================================================
   Student result PDF report (built in exam-report.js)
   Hidden on screen. While the result screen is showing, <body> carries
   .exs-has-report and this block is the ONLY thing the print view shows — a
   light, self-contained report, so none of the dark theme leaks into the PDF.
   ========================================================================== */
.exs-report { display: none; }

@page {
  size: A4;
  margin: 14mm 12mm 17mm;
  @bottom-right { content: counter(page) " / " counter(pages); font-family: 'Hind Siliguri', 'Noto Sans Bengali', sans-serif; font-size: 9pt; color: #9497AB; }
}

@media print {
  body.exs-has-report > *:not(.exs-report) { display: none !important; }
  body.exs-has-report { background: #fff !important; color: #1C1D26 !important; padding: 0 !important; min-height: 0 !important; overflow: visible !important; }

  .exs-report {
    display: block !important;
    position: relative;
    font-family: 'Hind Siliguri', 'Noto Sans Bengali', 'Segoe UI', sans-serif;
    font-size: 10.5pt; line-height: 1.55; color: #1C1D26; background: #fff;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .exs-report *, .exs-report *::before, .exs-report *::after { box-sizing: border-box; }

  .exs-report-watermark { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-28deg); opacity: 0.05; z-index: 0; pointer-events: none; }
  .exs-report-watermark img { width: 440px; height: auto; display: block; }
  .exs-report > *:not(.exs-report-watermark) { position: relative; z-index: 1; }

  .exs-report-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 3px solid #0047AB; }
  .exs-report-logo { height: 40px; width: auto; display: block; flex-shrink: 0; }
  .exs-report-title { text-align: right; min-width: 0; }
  .exs-report-title h1 { font-family: 'Hind Siliguri', 'Noto Sans Bengali', sans-serif; font-size: 17pt; line-height: 1.25; margin: 0; color: #0B1B3F; }
  .exs-report-title p { margin: 2px 0 0; font-size: 10.5pt; color: #4A5B84; word-break: break-word; }

  .exs-report-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 26px; margin-bottom: 14px; }
  .exs-report-meta-row { display: flex; gap: 10px; align-items: baseline; padding-bottom: 4px; border-bottom: 1px dashed #CCD7EC; font-size: 10pt; min-width: 0; }
  .exs-report-meta-row span { color: #4A5B84; flex-shrink: 0; min-width: 76px; }
  .exs-report-meta-row b { font-weight: 600; word-break: break-word; }

  .exs-report-summary { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-bottom: 10px; }
  .exs-report-tile { border: 1px solid #CCD7EC; border-radius: 6px; padding: 8px 4px 7px; text-align: center; background: #F2F5FB; }
  .exs-report-tile span { display: block; font-size: 8.5pt; line-height: 1.3; color: #4A5B84; }
  .exs-report-tile b { display: block; font-size: 13.5pt; line-height: 1.35; margin-top: 2px; }
  .exs-report-tile.is-good b { color: #15803D; }
  .exs-report-tile.is-bad b { color: #C62828; }
  .exs-report-tile.is-info b { color: #0047AB; }
  .exs-report-tile.is-neutral b { color: #4A5B84; }
  .exs-report-note { margin: 0 0 6px; font-size: 9pt; color: #4A5B84; }

  /* analysis block: only what is really known (see exam-analytics.js) */
  .exs-report-analysis { margin-bottom: 4px; }
  .exs-report-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 22px; }
  .exs-report-row { display: flex; flex-direction: column; gap: 1px; padding: 5px 0 6px; border-bottom: 1px dashed #CCD7EC; break-inside: avoid; page-break-inside: avoid; min-width: 0; }
  .exs-report-row span { font-size: 9pt; color: #4A5B84; }
  .exs-report-row b { font-size: 11pt; font-weight: 700; color: #0B1B3F; word-break: break-word; }
  .exs-report-row small { font-size: 8.5pt; line-height: 1.4; color: #4A5B84; word-break: break-word; }
  .exs-report-h3 { font-family: 'Hind Siliguri', 'Noto Sans Bengali', sans-serif; font-size: 11pt; margin: 12px 0 6px; color: #0B1B3F; break-after: avoid; page-break-after: avoid; }
  .exs-report-subj { list-style: none; margin: 0; padding: 0; }
  .exs-report-subj li { display: grid; grid-template-columns: 1fr auto auto 78px; align-items: baseline; gap: 4px 10px; padding: 4px 0; border-bottom: 1px dashed #CCD7EC; font-size: 10pt; break-inside: avoid; page-break-inside: avoid; }
  .exs-report-subj li span { font-weight: 600; word-break: break-word; }
  .exs-report-subj li em { font-style: normal; font-size: 8.5pt; color: #4A5B84; }
  .exs-report-subj li b { font-weight: 700; color: #0B1B3F; }
  .exs-report-subj li small { font-size: 8.5pt; color: #4A5B84; text-align: right; }
  .exs-report-tips { list-style: none; margin: 0; padding: 0; }
  .exs-report-tips li { position: relative; padding: 0 0 0 14px; margin-bottom: 4px; font-size: 10pt; line-height: 1.5; break-inside: avoid; page-break-inside: avoid; word-break: break-word; }
  .exs-report-tips li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: #0047AB; }

  .exs-report-h2 { font-family: 'Hind Siliguri', 'Noto Sans Bengali', sans-serif; font-size: 12.5pt; margin: 16px 0 9px; padding: 1px 0 1px 10px; border-left: 4px solid #0047AB; color: #0B1B3F; break-after: avoid; page-break-after: avoid; }
  .exs-report-q { border: 1px solid #CCD7EC; border-radius: 6px; padding: 9px 12px; margin-bottom: 8px; background: #fff; break-inside: avoid; page-break-inside: avoid; }
  .exs-report-q-text { font-weight: 700; margin-bottom: 5px; word-break: break-word; }
  .exs-report-ans { font-size: 10pt; padding: 1px 0 1px 10px; border-left: 3px solid transparent; word-break: break-word; }
  .exs-report-ans span { font-weight: 600; }
  .exs-report-ans.is-wrong { color: #B42318; border-left-color: #C62828; }
  .exs-report-ans.is-right { color: #0F7A3E; border-left-color: #15803D; margin-top: 2px; }
  .exs-report-explain { margin-top: 7px; padding: 6px 10px; border-left: 3px solid #0047AB; border-radius: 3px; background: #E6EEFB; color: #0B1B3F; font-size: 9.5pt; line-height: 1.5; word-break: break-word; }
  .exs-report-clear { padding: 14px; border: 1px solid #BFE0CD; border-radius: 6px; background: #E6F4EC; color: #0F7A3E; font-weight: 600; text-align: center; }
  .exs-report-foot { margin-top: 14px; padding-top: 8px; border-top: 1px solid #CCD7EC; font-size: 8.5pt; color: #9497AB; text-align: center; }
}

@media (max-width: 640px) {
  .exam-grid { grid-template-columns: 1fr; }
  .exs-rules-stats { grid-template-columns: 1fr 1fr; }
}
