:root {
  --black: #050505;
  --deep: #18232a;
  --line: #30434a;
  --green: #5d982f;
  --green-dark: #3f7a1c;
  --blue: #0d7ee8;
  --pale: #f6f8f8;
  --cream: #ffe7a7;
  --danger: #c93d37;
  --ok: #2e7d32;
  --text: #1f2a2f;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #eef2f3;
  color: var(--text);
}
button, select { font: inherit; }
.exam-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 76px 34px 1fr 74px;
  background: white;
}
.topbar {
  background: var(--black);
  color: white;
  display: grid;
  grid-template-columns: 210px 1fr 210px;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
}
.top-left { font-weight: 700; line-height: 1.2; }
.practice-pill {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #666;
  border-radius: 6px;
  padding: 8px 16px;
  background: #111;
  font-weight: 700;
}
.practice-pill small { color: #d6d6d6; font-weight: 400; }
.practice-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  color: var(--black);
}
.finish-btn {
  justify-self: end;
  background: var(--cream);
  border: 1px solid #caa555;
  border-radius: 4px;
  padding: 13px 28px;
  font-weight: 700;
  cursor: pointer;
}
.greenbar {
  background: linear-gradient(90deg, #57972f, #6aa33b);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
  font-size: 18px;
}
.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 70px 132px minmax(0, 1fr);
  border-top: 1px solid #b5c4b1;
}
.section-rail {
  background: #f1f4f4;
  border-right: 1px solid #d5dddd;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rail-section {
  border: 1px solid #d3dada;
  background: white;
  border-radius: 8px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.rail-section.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(13,126,232,.2); color: var(--blue); }
.question-nav {
  border-right: 1px solid #d5dddd;
  padding: 10px 8px;
  overflow-y: auto;
  background: #fbfcfc;
}
.nav-title { font-size: 12px; font-weight: 700; color: #59666b; margin-bottom: 8px; text-transform: uppercase; }
.question-buttons { display: grid; gap: 7px; }
.qbtn {
  background: var(--green);
  color: white;
  border: 1px solid #4b7b27;
  border-radius: 7px;
  height: 34px;
  cursor: pointer;
  font-weight: 700;
  position: relative;
}
.qbtn.active { outline: 3px solid var(--blue); outline-offset: 1px; }
.qbtn.correct { background: var(--ok); }
.qbtn.incorrect { background: var(--danger); border-color: #9f2f2a; }
.qbtn.unanswered { opacity: .72; }
.question-panel {
  min-width: 0;
  padding: 26px 38px;
  overflow: auto;
}
.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 16px;
}
.question-counter { color: #5b676d; font-weight: 700; margin-bottom: 8px; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  padding: 5px 9px;
  background: #eaf5e6;
  color: #35651d;
  border: 1px solid #c6dfbb;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.badge.muted { background: #eef4fa; color: #2a557c; border-color: #c6daec; }
.filters label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; color: #59666b; }
.filters select { min-width: 260px; padding: 7px 10px; border: 1px solid #bdc9cf; border-radius: 5px; background: white; }
.question-card {
  border: 1px solid #dfe6e8;
  border-radius: 6px;
  min-height: 520px;
  background: white;
  padding: 28px;
}
.prompt {
  font-size: 21px;
  line-height: 1.4;
  background: #f8f9fa;
  border-left: 5px solid #dfe6e8;
  padding: 18px 20px;
  margin-bottom: 24px;
}
.choices { display: grid; gap: 14px; }
.choice {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 12px;
  border: 3px solid var(--line);
  background: white;
  min-height: 58px;
  padding: 10px 18px;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s, transform .04s;
}
.choice:hover { background: #f7fafb; }
.choice:active { transform: translateY(1px); }
.choice .letter { font-weight: 700; color: #607078; }
.choice.selected { border-color: var(--blue); background: #eef7ff; }
.choice.correct-choice { border-color: var(--ok); background: #edf8ef; }
.choice.wrong-choice { border-color: var(--danger); background: #fff1f0; }
.feedback {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 6px;
  font-weight: 700;
}
.feedback.ok { background: #e9f6eb; color: #1c6720; border: 1px solid #bfe2c3; }
.feedback.bad { background: #fff0ee; color: #982a25; border: 1px solid #f1bbb7; }
.bottombar {
  background: var(--black);
  color: white;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
}
.footer-left, .footer-actions { display: flex; align-items: center; gap: 10px; }
.footer-actions { justify-content: flex-end; }
.footer-status { text-align: center; font-weight: 700; color: #d8e2e5; }
.nav-btn, .export-btn, .icon-btn, .primary-action {
  border: 0;
  border-radius: 5px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
}
.nav-btn { background: #6f8f66; color: white; }
.nav-btn.primary { background: var(--green); }
.export-btn { background: #e6f4ff; color: #0d4e83; }
.icon-btn { background: #2f3a40; color: white; }
.icon-btn.danger { background: #5a2424; }
button:disabled { opacity: .45; cursor: not-allowed; }
/* Respect the HTML hidden attribute.
   Without this rule, the author-level .modal { display: grid; } rule overrides
   the browser's default [hidden] { display: none; }, so the Result popup can
   remain visible even after OK is clicked. */
.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-card {
  width: min(460px, 100%);
  background: white;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
  padding: 28px;
  text-align: center;
}
.modal-card h2 { margin: 0 0 8px; }
.modal-card p { font-size: 18px; }
.primary-action { background: var(--blue); color: white; min-width: 120px; }
@media (max-width: 820px) {
  .exam-shell { grid-template-rows: auto 34px 1fr auto; }
  .topbar { grid-template-columns: 1fr; justify-items: stretch; }
  .practice-pill, .finish-btn { justify-self: stretch; justify-content: center; }
  .layout { grid-template-columns: 1fr; }
  .section-rail { flex-direction: row; overflow-x: auto; }
  .question-nav { max-height: 140px; border-right: 0; border-bottom: 1px solid #d5dddd; }
  .question-buttons { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
  .question-panel { padding: 18px; }
  .panel-toolbar { flex-direction: column; }
  .filters select { min-width: 100%; }
  .bottombar { grid-template-columns: 1fr; }
  .footer-left, .footer-actions { justify-content: center; flex-wrap: wrap; }
}
