/* ==========================================================================
   COMPUTER-DELIVERED EXAM STYLES
   Split-screen test environment, question types, writing area, Task 1
   figures, modals, and the four contrast themes.
   ========================================================================== */

:root {
  --cd-header-bg: #1f2732;
  --cd-header-text: #ffffff;
  --cd-bg-main: #eef1f5;
  --cd-panel-bg: #ffffff;
  --cd-soft-bg: #f5f7fa;
  --cd-input-bg: #ffffff;
  --cd-text-color: #1a202c;
  --cd-text-muted: #55606f;
  --cd-border-color: #cfd8dc;
  --cd-accent: #0b6fb8;
  --cd-accent-hover: #095a96;
  --cd-accent-soft: rgba(11, 111, 184, 0.1);
  --cd-accent-text: #ffffff;
  --cd-highlight-bg: #fde68a;
  --cd-highlight-text: #1e293b;
  --cd-nav-bg: #ffffff;
  --cd-nav-border: #cbd5e1;
  --cd-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --cd-base-font-size: 15px;
  --cd-line-height: 1.65;
}

/* Contrast themes ---------------------------------------------------------- */
body.theme-black-on-yellow {
  --cd-bg-main: #fff799; --cd-panel-bg: #fffbbf; --cd-soft-bg: #fff4a3; --cd-input-bg: #fffde0;
  --cd-text-color: #000000; --cd-text-muted: #1a1a1a; --cd-border-color: #000000;
  --cd-header-bg: #000000; --cd-header-text: #fffbbf; --cd-nav-bg: #fff799; --cd-nav-border: #000000;
  --cd-accent: #000000; --cd-accent-hover: #222222; --cd-accent-soft: rgba(0, 0, 0, 0.12); --cd-accent-text: #fffbbf;
  --cd-highlight-bg: #f59e0b;
}
body.theme-yellow-on-black {
  --cd-bg-main: #000000; --cd-panel-bg: #0d0d0d; --cd-soft-bg: #1a1a1a; --cd-input-bg: #000000;
  --cd-text-color: #fde047; --cd-text-muted: #fef08a; --cd-border-color: #ca8a04;
  --cd-header-bg: #1e1e1e; --cd-header-text: #fde047; --cd-nav-bg: #0d0d0d; --cd-nav-border: #ca8a04;
  --cd-accent: #fde047; --cd-accent-hover: #facc15; --cd-accent-soft: rgba(253, 224, 71, 0.16); --cd-accent-text: #000000;
  --cd-highlight-bg: #854d0e; --cd-highlight-text: #ffffff;
}
body.theme-white-on-blue {
  --cd-bg-main: #0c4a6e; --cd-panel-bg: #075985; --cd-soft-bg: #0b4f78; --cd-input-bg: #0c4a6e;
  --cd-text-color: #ffffff; --cd-text-muted: #e0f2fe; --cd-border-color: #7dd3fc;
  --cd-header-bg: #082f49; --cd-header-text: #ffffff; --cd-nav-bg: #075985; --cd-nav-border: #7dd3fc;
  --cd-accent: #ffffff; --cd-accent-hover: #e0f2fe; --cd-accent-soft: rgba(255, 255, 255, 0.16); --cd-accent-text: #075985;
  --cd-highlight-bg: #0284c7; --cd-highlight-text: #ffffff;
}

body.text-regular { --cd-base-font-size: 15px; }
body.text-large { --cd-base-font-size: 17.5px; }
body.text-extra-large { --cd-base-font-size: 20px; }

/* Exam layout -------------------------------------------------------------- */
#exam-screen.active {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100%;
  overflow: hidden; background: var(--cd-bg-main); color: var(--cd-text-color);
  font-family: var(--cd-font-family); font-size: var(--cd-base-font-size); line-height: var(--cd-line-height);
}

.cd-header {
  min-height: 52px; background: var(--cd-header-bg); color: var(--cd-header-text);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 16px; flex-shrink: 0; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15); z-index: 50;
  font-size: 15px;
}
.cd-header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.cd-candidate-info { font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-candidate-info strong { font-weight: 650; }
.cd-test-badge {
  background: rgba(255, 255, 255, 0.15); padding: 3px 9px; border-radius: 4px; font-size: 0.8em;
  letter-spacing: 0.4px; text-transform: uppercase; white-space: nowrap;
}
.cd-header-center { display: flex; align-items: center; }
.cd-timer-box {
  background: rgba(0, 0, 0, 0.35); padding: 4px 14px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.25);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05em; font-weight: 700; color: #7dd3fc;
  cursor: pointer; white-space: nowrap;
}
.cd-timer-box.warning { background: rgba(220, 38, 38, 0.45); color: #fecaca; border-color: #ef4444; }
.cd-header-right { display: flex; align-items: center; gap: 8px; }
.cd-icon-btn {
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.25); color: var(--cd-header-text);
  padding: 5px 10px; border-radius: 4px; font-size: 0.85em; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.cd-icon-btn:hover { background: rgba(255, 255, 255, 0.25); }

.pane-switch { display: none; }

.cd-workspace { display: flex; flex: 1; overflow: hidden; position: relative; min-height: 0; }
.cd-pane-left, .cd-pane-right {
  flex: 1 1 50%; min-width: 0; overflow-y: auto; padding: 22px 30px 40px; background: var(--cd-panel-bg);
}
.cd-pane-left { border-right: 1px solid var(--cd-border-color); }
.cd-resizer {
  width: 9px; background: var(--cd-soft-bg); border-left: 1px solid var(--cd-border-color); border-right: 1px solid var(--cd-border-color);
  cursor: col-resize; flex-shrink: 0; display: flex; align-items: center; justify-content: center; touch-action: none;
}
.cd-resizer::after { content: "⋮"; color: var(--cd-text-muted); font-size: 16px; font-weight: bold; }
.cd-resizer:hover, .cd-resizer.is-dragging { background: var(--cd-accent); }
.cd-resizer:hover::after, .cd-resizer.is-dragging::after { color: var(--cd-accent-text); }

/* Passage ------------------------------------------------------------------ */
.passage-header { margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--cd-border-color); }
.passage-part-label { font-size: 0.8em; font-weight: 700; text-transform: uppercase; color: var(--cd-accent); letter-spacing: 0.8px; }
.passage-title { font-size: 1.55em; font-weight: 750; margin: 4px 0; line-height: 1.25; }
.passage-subtitle { font-style: italic; color: var(--cd-text-muted); }
.passage-instruction-bar {
  background: var(--cd-soft-bg); border-left: 4px solid var(--cd-accent); padding: 8px 12px; font-size: 0.92em; margin-bottom: 18px;
}
.passage-paragraph { margin-bottom: 16px; text-align: left; hyphens: auto; }
.paragraph-label { font-weight: 800; margin-right: 8px; color: var(--cd-accent); }

/* Question groups ---------------------------------------------------------- */
.q-group { margin-bottom: 28px; }
.question-group-header {
  background: var(--cd-soft-bg); border: 1px solid var(--cd-border-color); border-radius: 6px;
  padding: 12px 16px; margin-bottom: 14px;
}
.question-group-title { font-weight: 750; margin-bottom: 4px; }
.question-group-instruction { font-size: 0.93em; }
.question-card {
  background: var(--cd-panel-bg); border: 1px solid var(--cd-border-color); border-radius: 6px;
  padding: 14px 16px; margin-bottom: 12px; transition: border-color 0.15s, box-shadow 0.15s;
}
.question-card.active-question, .gap.active-question .gap-input, .gap.active-question .gap-select {
  border-color: var(--cd-accent); box-shadow: 0 0 0 2px var(--cd-accent-soft);
}
.q-line { display: flex; gap: 10px; align-items: baseline; }
.question-number-badge {
  display: inline-block; background: var(--cd-header-bg); color: var(--cd-header-text); font-weight: 700;
  font-size: 0.82em; padding: 1px 8px; border-radius: 4px; flex-shrink: 0; line-height: 1.6;
}
.question-prompt { font-weight: 500; }

/* Options (MCQ, choose-two) */
.options-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.option-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; border-radius: 6px;
  border: 1px solid var(--cd-border-color); cursor: pointer; background: var(--cd-panel-bg);
}
.option-item:hover { border-color: var(--cd-accent); background: var(--cd-accent-soft); }
.option-item input { margin-top: 5px; accent-color: var(--cd-accent); transform: scale(1.15); flex-shrink: 0; }
.option-item.selected { background: var(--cd-accent-soft); border-color: var(--cd-accent); font-weight: 550; }
.opt-key { font-weight: 800; min-width: 1.4em; color: var(--cd-accent); flex-shrink: 0; }

/* TRUE / FALSE / NOT GIVEN */
.tfng-buttons { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tfng-btn {
  flex: 1; min-width: 88px; padding: 8px 12px; border: 1px solid var(--cd-border-color); background: var(--cd-input-bg);
  color: var(--cd-text-color); border-radius: 6px; font-weight: 650; font-size: 0.88em; cursor: pointer; font-family: inherit;
}
.tfng-btn:hover { border-color: var(--cd-accent); }
.tfng-btn.active { background: var(--cd-accent); color: var(--cd-accent-text); border-color: var(--cd-accent); }

/* Options box (headings, features, endings, word list) */
.options-box { border: 1px solid var(--cd-border-color); border-radius: 6px; padding: 12px 16px; margin-bottom: 14px; background: var(--cd-soft-bg); }
.options-box-title { font-weight: 750; margin-bottom: 6px; }
.options-box ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.options-box li { display: flex; gap: 10px; }

.q-matching { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.matching-select, .gap-select {
  padding: 6px 10px; border: 1.5px solid var(--cd-border-color); border-radius: 4px; background: var(--cd-input-bg);
  color: var(--cd-text-color); font-size: 0.95em; cursor: pointer; font-family: inherit; min-width: 96px;
}
.matching-select.has-value, .gap-select.has-value { border-color: var(--cd-accent); }

/* Gap-fill completion */
.gap { display: inline-block; margin: 2px 3px; vertical-align: baseline; }
.gap-input {
  width: 160px; max-width: 100%; padding: 4px 8px; border: 1.5px solid var(--cd-border-color); border-radius: 4px;
  font-size: 0.95em; font-family: inherit; background: var(--cd-input-bg); color: var(--cd-text-color);
}
.gap-input::placeholder { color: var(--cd-text-muted); font-weight: 700; text-align: center; opacity: 0.9; }
.gap-input:focus, .matching-select:focus, .gap-select:focus { border-color: var(--cd-accent); outline: 2px solid var(--cd-accent-soft); }
.gap-input.has-value { border-color: var(--cd-accent); }
.short-input { display: block; margin-top: 10px; width: 260px; }

.notes-box { border: 1px solid var(--cd-border-color); border-radius: 6px; padding: 14px 18px; margin-bottom: 14px; line-height: 2; }
.box-title { text-align: center; font-size: 1.05em; margin-bottom: 6px; }
.notes-box h5 { font-size: 0.98em; margin-top: 6px; }
.notes-box ul { margin-left: 20px; }
.q-table { border-collapse: collapse; width: 100%; line-height: 1.8; }
.q-table th, .q-table td { border: 1px solid var(--cd-border-color); padding: 6px 10px; text-align: left; vertical-align: top; }
.q-table th { background: var(--cd-soft-bg); }
.q-table .gap-input { width: 120px; }
.flow-steps { list-style: none; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.flow-steps li { border: 1px solid var(--cd-border-color); border-radius: 6px; padding: 8px 14px; position: relative; width: 100%; }
.flow-steps li:not(:last-child)::after { content: "↓"; position: absolute; left: 50%; bottom: -24px; transform: translateX(-50%); }

/* Writing ------------------------------------------------------------------ */
.task-prompt { margin-bottom: 16px; }
.task-prompt p { margin-bottom: 10px; }
.writing-area { display: flex; flex-direction: column; height: 100%; min-height: 360px; }
.writing-input {
  flex: 1; width: 100%; min-height: 320px; resize: none; padding: 14px 16px; border: 1.5px solid var(--cd-border-color);
  border-radius: 6px; font-family: inherit; font-size: 1em; line-height: 1.7; background: var(--cd-input-bg); color: var(--cd-text-color);
}
.writing-input:focus { border-color: var(--cd-accent); outline: 2px solid var(--cd-accent-soft); }
.word-count { margin-top: 8px; font-size: 0.95em; }
.word-count.is-under strong { color: #c2410c; }
.word-target { color: var(--cd-text-muted); }

/* Task 1 figures: always drawn on a light "paper" surface ------------------ */
.task-figure {
  background: #fcfcfb; color: #0b0b0b; border: 1px solid #d6d5cf; border-radius: 8px;
  padding: 14px 14px 10px; margin: 6px 0 18px; font-size: 14px; line-height: 1.4;
}
.fig-title { font-weight: 700; text-align: center; font-size: 1.05em; }
.fig-subtitle { text-align: center; color: #52514e; font-size: 0.9em; margin-bottom: 4px; }
.fig-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin: 8px 0 4px; font-size: 0.92em; color: #0b0b0b; }
.fig-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.fig-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.fig-svg { width: 100%; height: auto; display: block; }
.fig-tick { font-size: 12px; fill: #52514e; font-variant-numeric: tabular-nums; }
.fig-axis-title { font-size: 12px; fill: #52514e; font-weight: 600; }
.fig-value { font-size: 11.5px; fill: #0b0b0b; font-weight: 600; }
.fig-end-label { font-size: 12.5px; fill: #0b0b0b; font-weight: 600; }
.fig-slice-label { font-size: 14px; font-weight: 700; }
.fig-pies { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.fig-pie { margin: 0; }
.fig-pie figcaption { text-align: center; font-weight: 700; margin-top: 6px; }
.fig-note { text-align: center; font-size: 0.8em; color: #52514e; margin-top: 6px; font-style: italic; }
.fig-table { border-collapse: collapse; width: 100%; margin-top: 8px; }
.fig-table th, .fig-table td { border: 1px solid #c3c2b7; padding: 6px 10px; text-align: left; }
.fig-table th { background: #f0efec; }
.task-figure { container-type: inline-size; }
.fig-process { list-style: none; display: grid; grid-template-columns: 1fr; gap: 22px; margin-top: 10px; }
.fig-step {
  position: relative; background: #fff; border: 1.5px solid #2a78d6; border-radius: 8px; padding: 10px 10px 10px 40px; min-height: 78px;
}
.fig-step strong { display: block; font-size: 0.95em; }
.fig-step span:last-child { font-size: 0.86em; color: #52514e; }
.fig-step-num {
  position: absolute; left: 9px; top: 10px; width: 22px; height: 22px; border-radius: 50%;
  background: #2a78d6; color: #fff; font-weight: 800; font-size: 0.8em; display: flex; align-items: center; justify-content: center;
}
.fig-step:not(:last-child)::after {
  content: "↓"; position: absolute; left: 50%; bottom: -21px; transform: translateX(-50%); color: #2a78d6; font-weight: 800;
}
/* Wide figure: four steps per row, arrows only between steps in the same row */
@container (min-width: 560px) {
  .fig-process { grid-template-columns: repeat(4, 1fr); gap: 16px 24px; }
  .fig-step:not(:last-child)::after { content: none; }
  .fig-step:not(:nth-child(4n)):not(:last-child)::after {
    content: "→"; left: auto; bottom: auto; right: -19px; top: 50%; transform: translateY(-50%);
  }
}
.fig-cycle-note { text-align: center; margin-top: 10px; font-weight: 600; color: #1c5cab; }

/* Listening ------------------------------------------------------------------ */
#exam-screen.listening-mode .cd-pane-left,
#exam-screen.listening-mode .cd-resizer,
#exam-screen.listening-mode .pane-switch { display: none !important; }
#exam-screen.listening-mode .cd-workspace .cd-pane-right { display: block; flex: 1 1 100%; }
.listening-questions { max-width: 920px; margin: 0 auto; }
.listening-part-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.listening-part-questions { color: var(--cd-text-muted); font-weight: 650; font-size: 0.92em; }

.cd-audio-bar {
  background: var(--cd-nav-bg); color: var(--cd-text-color); border-bottom: 1px solid var(--cd-nav-border);
  padding: 8px 16px; flex-shrink: 0; font-size: 14px; font-family: var(--cd-font-family);
}
.cd-audio-bar[hidden] { display: none; }
.audio-bar-inner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 1180px; margin: 0 auto; }
.audio-btn {
  min-width: 38px; height: 34px; padding: 0 10px; border: 1px solid var(--cd-nav-border); background: var(--cd-input-bg);
  color: var(--cd-text-color); border-radius: 6px; font-weight: 700; font-size: 0.9em; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
}
.audio-btn:hover { border-color: var(--cd-accent); }
.audio-play { background: var(--cd-accent); color: var(--cd-accent-text); border-color: var(--cd-accent); min-width: 44px; }
.audio-play:hover { background: var(--cd-accent-hover); }
.audio-select {
  height: 34px; padding: 0 6px; border: 1px solid var(--cd-nav-border); border-radius: 6px; background: var(--cd-input-bg);
  color: var(--cd-text-color); font-family: inherit; font-size: 0.92em; cursor: pointer;
}
.audio-status { font-weight: 650; white-space: nowrap; }
.audio-status.is-plain { display: none; }
.audio-live-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #dc2626; flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.22); animation: audio-pulse 1.6s ease-in-out infinite;
}
@keyframes audio-pulse { 50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.08); } }
@media (prefers-reduced-motion: reduce) { .audio-live-dot { animation: none; } }
.audio-track {
  flex: 1 1 160px; min-width: 120px; height: 8px; background: var(--cd-soft-bg); border: 1px solid var(--cd-nav-border);
  border-radius: 999px; overflow: hidden;
}
.audio-track-fill { height: 100%; width: 0; background: var(--cd-accent); transition: width 0.3s linear; }
.audio-seek { flex: 1 1 180px; min-width: 120px; accent-color: var(--cd-accent); cursor: pointer; }
.audio-time { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; color: var(--cd-text-muted); white-space: nowrap; }
.audio-volume { display: inline-flex; align-items: center; gap: 6px; color: var(--cd-text-muted); cursor: pointer; }
.audio-volume input { width: 96px; accent-color: var(--cd-accent); cursor: pointer; }
.audio-start-btn {
  background: var(--cd-accent); color: var(--cd-accent-text); border: none; padding: 8px 14px; border-radius: 6px;
  font-weight: 700; font-size: 0.95em; cursor: pointer; font-family: inherit;
}
.audio-start-btn:hover { background: var(--cd-accent-hover); }
.audio-start-btn[hidden] { display: none; }
.cd-audio-bar.is-checking .audio-track, .cd-audio-bar.is-checking .audio-time,
.cd-audio-bar.is-checking .audio-live-dot { display: none; }
.part-tab-btn.is-playing::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #dc2626;
  margin-right: 6px; vertical-align: 2px;
}

/* Map labelling: map (always on a light "paper" surface) and a letter grid */
.map-layout { display: grid; gap: 14px; }
@media (min-width: 1200px) {
  .map-layout { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
  .map-layout .task-figure { margin: 0; }
}
.map-scroll { overflow-x: auto; }
.map-svg { min-width: 440px; }
.map-label { font-size: 15px; font-weight: 650; fill: #0b0b0b; font-family: var(--cd-font-family); }
.map-letter { font-size: 17px; font-weight: 800; fill: #0b0b0b; font-family: var(--cd-font-family); }
.map-grid { border-collapse: collapse; width: 100%; background: var(--cd-panel-bg); }
.map-grid th, .map-grid td { border: 1px solid var(--cd-border-color); padding: 6px 4px; text-align: center; }
.map-grid thead th { background: var(--cd-soft-bg); font-weight: 800; min-width: 30px; }
.map-grid tbody th { text-align: left; font-weight: 500; padding: 7px 10px; min-width: 150px; }
.map-grid tbody th .q-line { align-items: center; }
.map-grid input { width: 18px; height: 18px; accent-color: var(--cd-accent); cursor: pointer; margin: 0; vertical-align: middle; }
.map-grid-row.active-question th, .map-grid-row.active-question td { background: var(--cd-accent-soft); }
.map-grid-row.has-value .question-number-badge { background: var(--cd-accent); color: var(--cd-accent-text); }

/* Footer navigation -------------------------------------------------------- */
.cd-footer {
  min-height: 60px; background: var(--cd-nav-bg); color: var(--cd-text-color); border-top: 1px solid var(--cd-nav-border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 14px; flex-shrink: 0;
  font-size: 15px;
}
.cd-footer-left { display: flex; align-items: center; }
.part-nav-tabs { display: flex; gap: 4px; background: var(--cd-soft-bg); padding: 4px; border-radius: 6px; border: 1px solid var(--cd-nav-border); }
.part-tab-btn {
  padding: 5px 12px; border: none; background: transparent; color: var(--cd-text-color); font-weight: 650;
  font-size: 0.85em; border-radius: 4px; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.part-tab-btn.active { background: var(--cd-accent); color: var(--cd-accent-text); }
.part-count { font-weight: 500; opacity: 0.85; margin-left: 4px; font-size: 0.92em; }

.cd-footer-center { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; padding: 4px 2px; }
.q-nav-btn {
  min-width: 28px; height: 28px; padding: 0 5px; border: 1px solid var(--cd-nav-border); background: var(--cd-input-bg);
  color: var(--cd-text-color); font-size: 0.82em; font-weight: 600; border-radius: 4px; cursor: pointer; position: relative;
  flex-shrink: 0; font-family: inherit; opacity: 0.55;
}
.q-nav-btn.in-part { opacity: 1; }
.q-nav-btn:hover { border-color: var(--cd-accent); opacity: 1; }
.q-nav-btn.answered { border-bottom: 3px solid var(--cd-accent); font-weight: 800; }
.q-nav-btn.current { background: var(--cd-accent); color: var(--cd-accent-text); border-color: var(--cd-accent); opacity: 1; }
.q-nav-btn.flagged::before {
  content: ""; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; background: #ea580c; border-radius: 50%;
}

.cd-footer-right { display: flex; align-items: center; gap: 8px; }
.cd-review-checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 0.88em; font-weight: 600; cursor: pointer; }
.cd-review-checkbox-label input { accent-color: #ea580c; width: 16px; height: 16px; }
.cd-arrow-btn {
  width: 34px; height: 34px; border: 1px solid var(--cd-nav-border); background: var(--cd-input-bg); color: var(--cd-text-color);
  border-radius: 4px; font-size: 1.05em; cursor: pointer; font-family: inherit;
}
.cd-arrow-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cd-submit-btn {
  background: var(--cd-accent); color: var(--cd-accent-text); border: none; padding: 8px 16px; border-radius: 4px;
  font-weight: 700; font-size: 0.9em; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.cd-submit-btn:hover { background: var(--cd-accent-hover); }

/* Highlighting and notes --------------------------------------------------- */
.cd-highlight { background: var(--cd-highlight-bg); color: var(--cd-highlight-text); border-radius: 2px; cursor: context-menu; }
.cd-highlight.has-note { border-bottom: 2px dotted #b45309; }
.cd-highlight:focus-visible { outline: 2px solid var(--cd-accent); outline-offset: 1px; }
.cd-note-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.cd-note-delete {
  background: none; border: none; color: #92400e; font-size: 12px; font-weight: 600;
  text-decoration: underline; cursor: pointer; padding: 2px 0;
}
.cd-highlight-toolbar {
  position: fixed; display: flex; gap: 2px; background: #1e293b; padding: 4px; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); z-index: 1500;
}
.cd-highlight-toolbar button {
  background: transparent; border: none; color: #fff; padding: 5px 10px; border-radius: 4px; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: var(--cd-font-family);
}
.cd-highlight-toolbar button:hover { background: rgba(255, 255, 255, 0.18); }
.cd-note-card {
  position: fixed; width: 250px; background: #fef08a; color: #422006; border: 1px solid #facc15; border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); padding: 8px; z-index: 1400; font-size: 13px;
}
.cd-note-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 11px; text-transform: uppercase; margin-bottom: 4px; }
.cd-note-close { background: none; border: none; font-size: 18px; line-height: 1; cursor: pointer; color: #422006; }
.cd-note-card textarea {
  width: 100%; height: 70px; border: 1px solid #facc15; background: #fefce8; color: #1e293b; resize: vertical;
  font-family: inherit; font-size: 12.5px; padding: 6px; border-radius: 4px;
}

/* Modals ------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: flex; align-items: center; justify-content: center;
  z-index: 2000; padding: 16px;
}
.modal-box {
  background: #fff; color: #1e293b; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); font-family: var(--cd-font-family); font-size: 15px;
}
.modal-header {
  background: #1f2732; color: #fff; padding: 12px 18px; font-size: 1.05em; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.modal-close { background: none; border: none; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.modal-body { padding: 18px 20px; line-height: 1.6; }
.modal-body p + p { margin-top: 8px; }
.modal-footer { padding: 12px 18px; background: #f8fafc; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* Narrow screens: one pane at a time --------------------------------------- */
@media (max-width: 860px) {
  .cd-header { flex-wrap: wrap; padding: 6px 10px; }
  .cd-test-badge { display: none; }
  .cd-icon-btn { padding: 4px 8px; font-size: 0.78em; }
  .pane-switch { display: flex; background: var(--cd-nav-bg); border-bottom: 1px solid var(--cd-nav-border); }
  .pane-switch-btn {
    flex: 1; padding: 9px; border: none; background: transparent; color: var(--cd-text-color); font-weight: 700;
    font-family: inherit; font-size: 0.92em; border-bottom: 3px solid transparent; cursor: pointer;
  }
  .pane-switch-btn.active { border-bottom-color: var(--cd-accent); color: var(--cd-accent); }
  .cd-resizer { display: none; }
  .cd-pane-left, .cd-pane-right { flex: 1 1 100% !important; padding: 16px 16px 32px; border-right: none; }
  .cd-workspace .cd-pane-right { display: none; }
  .cd-workspace.show-right .cd-pane-left { display: none; }
  .cd-workspace.show-right .cd-pane-right { display: block; }
  .cd-footer { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  .cd-footer-center { order: 3; flex-basis: 100%; }
  .cd-footer-left { flex: 1; min-width: 0; overflow-x: auto; }
  .gap-input { width: 130px; }
  .cd-audio-bar { padding: 6px 10px; }
  .audio-bar-inner { gap: 8px; }
  /* Two rows: controls and status, then the position bar with the time */
  .audio-seek, .audio-track { order: 10; flex: 1 1 55%; }
  .audio-time { order: 11; }
  .audio-volume input { width: 72px; }
  /* Phones have volume keys; keep the practice player on two rows. */
  .is-practice .audio-volume { display: none; }
  .audio-btn { min-width: 34px; padding: 0 8px; }
  .map-grid tbody th { min-width: 108px; padding: 6px; }
  .map-grid th, .map-grid td { padding: 5px 2px; }
  .map-grid thead th { min-width: 24px; }
  .map-grid input { width: 16px; height: 16px; }
}

/* Speaking ------------------------------------------------------------------- */
#exam-screen.speaking-mode .cd-pane-left,
#exam-screen.speaking-mode .cd-resizer,
#exam-screen.speaking-mode .pane-switch { display: none !important; }
#exam-screen.speaking-mode .cd-workspace .cd-pane-right { display: block; flex: 1 1 100%; background: var(--cd-bg-main); }
.speak-part-tab { cursor: default; }
.speak-part-tab.is-done { opacity: 0.7; }
.speak-stage {
  max-width: 760px; margin: 18px auto 40px; background: var(--cd-panel-bg); color: var(--cd-text-color);
  border: 1px solid var(--cd-border-color); border-radius: 14px; padding: 22px 26px; display: flex; flex-direction: column; gap: 18px;
  font-family: var(--cd-font-family);
}
.speak-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.speak-part { font-weight: 800; font-size: 1.15em; }
.speak-part-title { color: var(--cd-text-muted); font-weight: 600; }
.speak-count { color: var(--cd-text-muted); font-size: 0.92em; font-weight: 650; }
.speak-examiner { display: flex; align-items: center; gap: 14px; }
.speak-avatar {
  position: relative; width: 58px; height: 58px; border-radius: 50%; background: var(--cd-accent); color: var(--cd-accent-text);
  display: flex; align-items: center; justify-content: center; font-size: 1.5em; font-weight: 800; flex-shrink: 0;
}
.speak-examiner.is-speaking .speak-avatar::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid var(--cd-accent);
  opacity: 0.5; animation: speak-ring 1.4s ease-out infinite;
}
@keyframes speak-ring { from { transform: scale(0.92); opacity: 0.6; } to { transform: scale(1.18); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .speak-examiner.is-speaking .speak-avatar::after { animation: none; opacity: 0.6; } }
.speak-examiner-name { display: flex; flex-direction: column; }
.speak-examiner-name span { color: var(--cd-text-muted); font-size: 0.9em; }
.speak-question:empty { display: none; }
.speak-q-text { font-size: 1.2em; font-weight: 650; line-height: 1.45; }
.speak-show-q { font-size: 0.95em; }
.cue-card {
  border: 2px solid var(--cd-text-color); border-radius: 8px; padding: 16px 20px; background: var(--cd-input-bg);
  font-size: 1.02em; line-height: 1.55;
}
.cue-card .cue-topic { font-weight: 800; font-size: 1.08em; margin-bottom: 8px; }
.cue-card ul { margin: 4px 0 8px 22px; }
.speak-notes-view { margin-top: 12px; padding: 10px 14px; border-left: 4px solid var(--cd-accent); background: var(--cd-soft-bg); border-radius: 4px; }
.speak-notes-view p { margin-top: 4px; white-space: pre-wrap; }
.speak-panel { min-height: 80px; }
.speak-status { font-weight: 650; display: flex; align-items: center; gap: 10px; color: var(--cd-text-muted); }
.speak-ear {
  width: 12px; height: 12px; border-radius: 50%; background: var(--cd-accent); animation: audio-pulse 1.6s ease-in-out infinite;
}
.speak-rec, .speak-prep, .speak-review, .speak-error { display: flex; flex-direction: column; gap: 12px; }
.speak-rec-head, .speak-timer-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.speak-countdown { margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.25em; font-weight: 800; }
.speak-bar, .speak-level {
  height: 10px; border-radius: 999px; background: var(--cd-soft-bg); border: 1px solid var(--cd-nav-border); overflow: hidden;
}
.speak-bar span, .speak-level span { display: block; height: 100%; width: 0; background: var(--cd-accent); transition: width 0.25s linear; }
.speak-bar-time span { background: #dc2626; }
.speak-level { height: 8px; }
.speak-level span { background: #16a34a; transition: width 0.08s linear; }
.speak-hint { color: var(--cd-text-muted); font-size: 0.95em; }
.speak-warn { color: #b45309; font-weight: 700; }
.speak-rec .btn-primary, .speak-prep .btn-secondary { align-self: flex-start; }
.speak-notes-label { font-weight: 650; font-size: 0.92em; }
.speak-notes {
  width: 100%; font: inherit; padding: 10px 12px; border: 1.5px solid var(--cd-nav-border); border-radius: 8px;
  background: var(--cd-input-bg); color: var(--cd-text-color); resize: vertical;
}
.speak-audio { width: 100%; max-width: 460px; }
.speak-review-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.speak-error { border: 1px solid #f6d3a8; background: #fff4e5; color: #6b3a06; padding: 14px 16px; border-radius: 10px; }
.speak-error .btn-primary, .speak-error .btn-secondary { align-self: flex-start; }
.speak-saving { font-size: 0.88em; color: var(--cd-text-muted); min-height: 1.2em; }
.speak-save-ok { color: #15803d; font-weight: 650; }
.speak-save-bad { color: #b45309; font-weight: 650; }
.inline-spinner { width: 18px; height: 18px; border-width: 3px; margin: 0; display: inline-block; }
@media (max-width: 640px) {
  .speak-stage { margin: 10px; padding: 16px; }
  .speak-q-text { font-size: 1.08em; }
}
