/* C1 Advanced practice — Inspera-like styling */
:root {
  --header-bg: #1f3a5f;
  --header-fg: #ffffff;
  --accent: #2d6da3;
  --accent-dark: #1f4e79;
  --bg: #eef1f4;
  --panel: #ffffff;
  --border: #c9d2da;
  --text: #1d2733;
  --muted: #5b6a7a;
  --flag: #e07b00;
  --ok: #2e7d32;
  --bad: #c62828;
  --attempted: #2d6da3;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- Header ---------- */
.exam-header {
  background: var(--header-bg);
  color: var(--header-fg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 52px; flex: 0 0 auto;
  position: sticky; top: 0; z-index: 30;
}
.exam-header .brand { font-weight: 600; letter-spacing: .3px; }
.exam-header .brand small { font-weight: 400; opacity: .8; margin-left: 8px; }
.header-right { display: flex; align-items: center; gap: 18px; }
.timer { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600;
  background: rgba(255,255,255,.12); padding: 4px 12px; border-radius: 4px; }
.timer.warning { background: #b53d00; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.header-btn {
  background: transparent; color: var(--header-fg); border: 1px solid rgba(255,255,255,.4);
  padding: 5px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;
}
.header-btn:hover { background: rgba(255,255,255,.15); }

/* ---------- Home ---------- */
.home { max-width: 860px; margin: 40px auto; padding: 0 20px; width: 100%; }
.home h1 { font-size: 26px; margin-bottom: 4px; }
.home .sub { color: var(--muted); margin-bottom: 28px; }
.test-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 18px 22px; margin-bottom: 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
}
.test-card h3 { margin: 0 0 4px; font-size: 18px; }
.test-card .meta { color: var(--muted); font-size: 14px; }
.test-card .best { color: var(--ok); font-size: 14px; font-weight: 600; }
.test-card .actions { display: flex; gap: 10px; flex: 0 0 auto; }
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 4px;
  padding: 9px 18px; font-size: 15px; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #fff; color: var(--accent-dark); border: 1px solid var(--accent-dark); }
.btn.secondary:hover { background: #f0f5fa; }
.btn.danger { background: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.notice { background: #fff8e6; border: 1px solid #e8d9a0; border-radius: 6px;
  padding: 12px 16px; font-size: 14px; color: #6b5900; margin-bottom: 24px; }

/* ---------- Part header ---------- */
.part-banner {
  background: #dfe7ee; border-bottom: 1px solid var(--border);
  padding: 12px 28px; flex: 0 0 auto;
}
.part-banner h3 { margin: 0 0 2px; font-size: 17px; }
.part-banner p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Player main ---------- */
.player-main { flex: 1 1 auto; overflow-y: auto; padding: 28px; }
.content-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  max-width: 980px; margin: 0 auto; padding: 30px 40px; line-height: 1.75;
}
.content-panel h2 { margin-top: 0; font-size: 21px; }
.content-panel .intro { color: var(--muted); font-style: italic; margin-bottom: 18px; }
.reading-text p { margin: 0 0 14px; }

/* Inline gap widgets */
.gap-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; border-radius: 4px; background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 600; margin-right: 4px; padding: 0 5px;
}
.gap-select, .gap-input {
  font-size: 15px; padding: 4px 8px; border: 1.5px solid var(--accent);
  border-radius: 4px; background: #f4f8fc; color: var(--text); margin: 0 2px;
}
.gap-select.answered, .gap-input.answered { background: #e2efe2; border-color: var(--ok); }
.gap-input { width: 150px; }
.gap-wrap { white-space: nowrap; }
.base-word { font-weight: 700; letter-spacing: .5px; color: var(--accent-dark); margin-left: 6px; font-size: 14px; }

/* two-column layouts */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.col-scroll { max-height: calc(100vh - 320px); overflow-y: auto; padding-right: 10px; }

/* Part 4 KWT */
.kwt-item { border-bottom: 1px solid var(--border); padding: 18px 0; }
.kwt-item:last-child { border-bottom: none; }
.kwt-first { margin: 0 0 10px; }
.kwt-key { font-weight: 700; letter-spacing: 1px; margin: 0 0 10px; color: var(--accent-dark); }
.kwt-second { margin: 0; }
.kwt-second input { width: 320px; max-width: 100%; }
.kwt-note { font-size: 13px; color: var(--muted); margin: 4px 0 14px; }

/* MCQ */
.mcq-item { margin-bottom: 22px; }
.mcq-item .q { font-weight: 600; margin-bottom: 8px; }
.mcq-opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px;
  border: 1px solid transparent; border-radius: 4px; cursor: pointer;
}
.mcq-opt:hover { background: #f0f5fa; }
.mcq-opt.selected { background: #e2ecf5; border-color: var(--accent); }
.mcq-opt input { margin-top: 4px; }
.opt-letter { font-weight: 700; flex: 0 0 18px; }

/* Part 6 / 8 texts */
.lettered-text { margin-bottom: 20px; }
.lettered-text h4 { margin: 0 0 6px; font-size: 16px; }
.lettered-text .label-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; background: var(--accent-dark); color: #fff;
  border-radius: 4px; font-weight: 700; margin-right: 8px;
}

/* Part 7 */
.gap-slot {
  border: 2px dashed var(--accent); border-radius: 6px; background: #f4f8fc;
  padding: 10px 14px; margin: 14px 0; display: flex; align-items: center; gap: 12px;
}
.gap-slot.answered { border-style: solid; border-color: var(--ok); background: #eef7ee; }
.para-card {
  border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px;
  margin-bottom: 12px; background: #fbfcfd;
}
.para-card.used { opacity: .45; }
.para-card .label-badge { float: left; margin: 2px 10px 4px 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; background: var(--accent-dark); color: #fff;
  border-radius: 4px; font-weight: 700; }

/* match rows (part 8) */
.match-q { display: flex; gap: 12px; align-items: baseline; margin-bottom: 14px; }
.match-q .gap-num { flex: 0 0 auto; }

/* ---------- Footer nav ---------- */
.exam-footer {
  background: #ffffff; border-top: 2px solid var(--border);
  padding: 8px 16px; flex: 0 0 auto; position: sticky; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.nav-arrows { display: flex; gap: 6px; }
.nav-arrow {
  width: 38px; height: 38px; border: 1px solid var(--border); background: #fff;
  border-radius: 4px; font-size: 17px; cursor: pointer; color: var(--accent-dark);
}
.nav-arrow:disabled { opacity: .35; cursor: default; }
.part-tabs { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.part-tab {
  border: 1px solid var(--border); background: #f2f5f8; border-radius: 4px;
  padding: 4px 10px; cursor: pointer; font-size: 13px; color: var(--text);
  display: flex; flex-direction: column; align-items: center; min-width: 54px;
}
.part-tab .pt-label { font-size: 11px; color: var(--muted); }
.part-tab .pt-count { font-size: 11px; color: var(--muted); }
.part-tab.active { background: var(--accent); border-color: var(--accent); }
.part-tab.active .pt-label, .part-tab.active .pt-count, .part-tab.active .pt-num { color: #fff; }
.q-dots { display: flex; gap: 4px; align-items: center; }
.q-dot {
  width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; cursor: pointer; position: relative; color: var(--text);
}
.q-dot.attempted { background: var(--attempted); color: #fff; border-color: var(--attempted); }
.q-dot.active { outline: 2px solid var(--accent-dark); outline-offset: 1px; }
.q-dot.flagged::after {
  content: ""; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px;
  background: var(--flag); border-radius: 50%;
}

/* flag button */
.flag-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  cursor: pointer; font-size: 13px; padding: 3px 8px; color: var(--muted); margin-left: 8px;
}
.flag-btn.on { color: var(--flag); border-color: var(--flag); font-weight: 600; }

/* ---------- Review & results ---------- */
.review-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.review-table th, .review-table td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 14px; }
.review-table th { background: #eef2f6; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.tag.ok { background: #e2efe2; color: var(--ok); }
.tag.bad { background: #fbe4e4; color: var(--bad); }
.tag.warn { background: #fdeeda; color: var(--flag); }

.results-score { font-size: 42px; font-weight: 700; margin: 6px 0; }
.results-grade { font-size: 20px; font-weight: 600; }
.results-grade.pass { color: var(--ok); }
.results-grade.fail { color: var(--bad); }
.part-bars { margin: 24px 0; }
.part-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.part-bar-row .pb-label { flex: 0 0 220px; font-size: 14px; }
.part-bar-row .pb-track { flex: 1; height: 16px; background: #e3e8ee; border-radius: 8px; overflow: hidden; }
.part-bar-row .pb-fill { height: 100%; background: var(--accent); border-radius: 8px; }
.part-bar-row .pb-val { flex: 0 0 70px; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }

.answer-detail { margin-top: 10px; }
.answer-row { padding: 8px 10px; border-bottom: 1px solid #e8edf2; font-size: 14px; display: flex; gap: 12px; align-items: baseline; }
.answer-row .an { flex: 0 0 34px; font-weight: 700; }
.answer-row .a-given { flex: 1; }
.answer-row .a-correct { flex: 1; color: var(--muted); }
details.part-detail { margin-bottom: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 10px 16px; }
details.part-detail summary { cursor: pointer; font-weight: 600; }

.center-actions { display: flex; gap: 12px; justify-content: center; margin: 26px 0; flex-wrap: wrap; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(20,30,45,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 8px; padding: 28px 32px; max-width: 460px; width: 92%; }
.modal h3 { margin-top: 0; }
.modal .modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* ---------- listening & review additions ---------- */
.paper-head { font-size: 19px; margin: 30px 0 12px; border-bottom: 2px solid var(--border); padding-bottom: 6px; }
.paper-head small { font-weight: 400; color: var(--muted); font-size: 13px; }
.audio-block { background: #f0f5fa; border: 1px solid var(--accent); border-radius: 6px;
  padding: 14px 18px; margin-bottom: 22px; }
.audio-block .btn { margin-right: 14px; }
.audio-status { color: var(--muted); font-size: 14px; }
.sc-item { line-height: 2.2; }
.explanation { padding: 2px 10px 10px 46px; font-size: 13px; color: var(--muted);
  border-bottom: 1px solid #e8edf2; font-style: italic; }
