:root {
  --navy: #0B1F2A;
  --teal: #16A88F;
  --teal-dark: #0E8571;
  --ink: #0B1F2A;
  --muted: #5A7383;
  --line: #E1EAEF;
  --bg: #F6F9FB;
  --card: #FFFFFF;
  --amber: #D97706;
  --amber-bg: #FEF3C7;
  --red: #C0392B;
  --red-bg: #FDECEA;
  --green-bg: #EAFBF6;
}
html.dark {
  --ink: #E8F0F5;
  --muted: #93AAB8;
  --line: #213746;
  --bg: #08151E;
  --card: #0E202C;
  --amber-bg: rgba(217, 119, 6, 0.18);
  --red-bg: rgba(192, 57, 43, 0.18);
  --green-bg: rgba(22, 168, 143, 0.18);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
.ex-wrap { max-width: 1120px; margin: 0 auto; padding: 20px 20px 60px; }

/* Loading / Error */
.ex-state {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  margin-top: 24px;
}
.ex-state h2 { margin: 0 0 8px; font-size: 20px; }
.ex-state p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* Topbar */
.ex-topbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.ex-title-area h1 { margin: 0; font-size: 19px; line-height: 1.3; }
.ex-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.ex-timer {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.ex-timer.warn { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.ex-timer.danger { background: var(--red-bg); border-color: var(--red); color: var(--red); animation: exPulse 1s infinite; }
@keyframes exPulse { 0%,100% { opacity: 1; } 50% { opacity: .7; } }

.ex-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  transition: all .15s ease;
}
.ex-btn:hover { border-color: var(--teal); }
.ex-btn:disabled { opacity: .45; cursor: not-allowed; }
.ex-btn.primary { background: var(--teal); border-color: var(--teal); color: #06201B; font-weight: 700; }
.ex-btn.primary:hover { background: #149680; }
.ex-btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.ex-btn.flag-on { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }

/* Progress bar */
.ex-prog-wrap { margin-bottom: 18px; }
.ex-prog-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.ex-prog-bar { height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; }
.ex-prog-bar > i { display: block; height: 100%; background: var(--teal); transition: width .25s ease; }

/* Main 2-col layout */
.ex-grid {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 880px) {
  .ex-grid { grid-template-columns: 1fr; }
}

/* Question Card */
.ex-qcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}
.ex-qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.ex-qhead-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ex-mod-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--teal-dark);
}
html.dark .ex-mod-badge { color: #4BE3C4; }
.ex-qnum { font-size: 13px; font-weight: 600; color: var(--muted); }
.ex-stem { font-size: 17px; font-weight: 500; line-height: 1.5; margin: 0 0 20px; }

.ex-opts { display: flex; flex-direction: column; gap: 10px; }
.ex-opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  transition: all .14s ease;
}
.ex-opt:hover { border-color: var(--teal); }
.ex-opt .ex-k {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  flex: 0 0 26px;
  text-transform: uppercase;
}
.ex-opt.selected {
  border-color: var(--teal);
  background: var(--green-bg);
}
.ex-opt.selected .ex-k {
  background: var(--teal);
  border-color: var(--teal);
  color: #06201B;
}

.ex-qfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.ex-kbd-hint { font-size: 11.5px; color: var(--muted); margin-top: 12px; }

/* Sidebar Navigator */
.ex-side {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  position: sticky;
  top: 80px;
}
.ex-side h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.ex-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}
.ex-nbtn {
  position: relative;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
}
.ex-nbtn:hover { border-color: var(--teal); }
.ex-nbtn.ans { background: var(--teal); border-color: var(--teal); color: #06201B; }
.ex-nbtn.flag { border-color: var(--amber); background: var(--amber-bg); color: var(--amber); }
.ex-nbtn.ans.flag { background: var(--teal); border-color: var(--amber); color: #06201B; }
.ex-nbtn.flag::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
}
.ex-nbtn.cur { box-shadow: 0 0 0 2.5px var(--navy); }
html.dark .ex-nbtn.cur { box-shadow: 0 0 0 2.5px #fff; }

.ex-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.ex-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ex-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); background: var(--bg); }
.ex-dot.ans { background: var(--teal); border-color: var(--teal); }
.ex-dot.flag { background: var(--amber-bg); border-color: var(--amber); }

.ex-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  text-align: center;
}
.ex-stat { background: var(--bg); border-radius: 10px; padding: 8px 4px; }
.ex-stat b { display: block; font-size: 16px; }
.ex-stat span { font-size: 11px; color: var(--muted); }

/* Results Screen */
.ex-res-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
  margin-bottom: 20px;
}
.ex-res-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.ex-score-kpis { display: flex; flex-wrap: wrap; gap: 14px; }
.ex-kpi {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
  min-width: 120px;
}
.ex-kpi .val { font-size: 24px; font-weight: 700; color: var(--teal-dark); }
html.dark .ex-kpi .val { color: #2BD9B4; }
.ex-kpi .lbl { font-size: 12px; color: var(--muted); }
.ex-res-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.ex-mod-breakdown {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}
.ex-mod-breakdown h3 { margin: 0 0 14px; font-size: 15px; }
.ex-mod-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.ex-mod-row { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.ex-mod-row-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.ex-mod-bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.ex-mod-bar > i { display: block; height: 100%; background: var(--teal); }

.ex-rev-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.ex-pill {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.ex-pill.active { background: var(--teal); border-color: var(--teal); color: #06201B; }

.ex-rev-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 14px;
}
.ex-rev-status {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.ex-rev-status.ok { background: var(--green-bg); color: var(--teal-dark); }
html.dark .ex-rev-status.ok { color: #4BE3C4; }
.ex-rev-status.ko { background: var(--red-bg); color: var(--red); }
.ex-rev-status.skip { background: var(--amber-bg); color: var(--amber); }

.ex-opt.rev-right { border-color: var(--teal); background: var(--green-bg); }
.ex-opt.rev-right .ex-k { background: var(--teal); border-color: var(--teal); color: #06201B; }
.ex-opt.rev-wrong { border-color: var(--red); background: var(--red-bg); }
.ex-opt.rev-wrong .ex-k { background: var(--red); border-color: var(--red); color: #fff; }
.ex-opt.rev-static { cursor: default; }

.ex-why {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.ex-takeaway {
  margin-top: 10px;
  background: var(--amber-bg);
  border-left: 4px solid var(--amber);
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 13.5px;
}

/* Modal confirm */
.ex-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(8, 21, 30, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}
.ex-modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  max-width: 420px;
  width: 100%;
  padding: 24px;
}
.ex-modal h3 { margin: 0 0 8px; font-size: 18px; }
.ex-modal p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.ex-modal-act { display: flex; justify-content: flex-end; gap: 10px; }

/* Print Sheet */
#printSheet { display: none; }
@media print {
  header.dct-hd, #examApp, .dct-tutor-fab, .dct-tutor-panel { display: none !important; }
  body { background: #fff !important; color: #0B1F2A !important; font: 10.5pt/1.45 "DejaVu Serif", Georgia, serif; }
  #printSheet { display: block !important; padding: 0; }
  #printSheet h1 { font: 700 18pt/1.2 "DejaVu Sans", Arial, sans-serif; margin: 0 0 4px; }
  #printSheet .p-meta { font: 9.5pt "DejaVu Sans", Arial, sans-serif; color: #5A7383; margin: 0 0 14px; }
  #printSheet .p-q { break-inside: avoid; margin: 0 0 11px; }
  #printSheet .p-mod { font: 600 8.5pt "DejaVu Sans", Arial, sans-serif; color: #0E8571; text-transform: uppercase; }
  #printSheet .p-opts { list-style: none; padding-left: 16px; margin: 3px 0 0; }
  #printSheet .p-break { break-before: page; }
  #printSheet .p-corr { font-size: 9.5pt; margin: 0 0 7px; break-inside: avoid; }
}
