/* ==================================================================
   reading.css — IELTS Reading exam / practice screen
   Every class starts with "rd-". The only rule outside the module's
   own elements is body.rd-active (stops the page behind from scrolling).
   ================================================================== */

body.rd-active { overflow: hidden; overscroll-behavior: none; }

/* ---------- theme variables (contrast settings) ---------- */
.rd-root {
  --rd-bg: #ffffff;
  --rd-fg: #222222;
  --rd-muted: #5a5a5a;
  --rd-line: #c9c9c9;
  --rd-line-strong: #8a8a8a;
  --rd-soft: #f2f2f2;
  --rd-bar: #f7f7f7;
  --rd-accent: #1a5fc8;
  --rd-accent-soft: #e6effc;
  --rd-accent-fg: #ffffff;
  --rd-hl: #ffe94d;
  --rd-hl-fg: #000000;
  --rd-ok: #12733a;
  --rd-ok-soft: #e5f4ea;
  --rd-bad: #c0261c;
  --rd-bad-soft: #fbe9e7;
  --rd-input: #ffffff;
  --rd-ph: #e7e7e7;
  --rd-flag: #e07b00;
  --rd-split: 50%;
  --rd-fs: 16px;
}
.rd-root.rd-contrast-wb {
  --rd-bg: #000000; --rd-fg: #ffffff; --rd-muted: #dddddd; --rd-line: #777777; --rd-line-strong: #bbbbbb;
  --rd-soft: #1b1b1b; --rd-bar: #111111; --rd-accent: #7db8ff; --rd-accent-soft: #10284a; --rd-accent-fg: #000000;
  --rd-ok: #74e08f; --rd-ok-soft: #0f2d18; --rd-bad: #ff8f85; --rd-bad-soft: #3a1210; --rd-input: #000000; --rd-ph: #2b2b2b;
  --rd-flag: #ffb34d;
}
.rd-root.rd-contrast-yb {
  --rd-bg: #000000; --rd-fg: #ffeb3b; --rd-muted: #fff176; --rd-line: #a89a1c; --rd-line-strong: #ffeb3b;
  --rd-soft: #1a1800; --rd-bar: #0d0c00; --rd-accent: #ffffff; --rd-accent-soft: #333000; --rd-accent-fg: #000000;
  --rd-ok: #9cff9c; --rd-ok-soft: #0f2d0f; --rd-bad: #ff9c8f; --rd-bad-soft: #3a1210; --rd-input: #000000; --rd-ph: #262300;
  --rd-flag: #ffffff;
}
.rd-root.rd-size-std { --rd-fs: 16px; }
.rd-root.rd-size-l   { --rd-fs: 18px; }
.rd-root.rd-size-xl  { --rd-fs: 21px; }

/* ---------- root layout ---------- */
.rd-root, .rd-root * { box-sizing: border-box; }
.rd-root {
  display: flex; flex-direction: column;
  height: 100%; width: 100%; min-height: 0;
  background: var(--rd-bg); color: var(--rd-fg);
  font-family: Arial, "Helvetica Neue", Helvetica, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  position: relative;
}
.rd-root.rd-fixed { position: fixed; inset: 0; top: 0; left: 0; right: 0; bottom: 0; height: auto; z-index: 9000; }
.rd-root [hidden] { display: none !important; }
:where(.rd-root) :where(button, input, select, textarea) { font: inherit; color: inherit; }
.rd-root :focus-visible { outline: 2px solid var(--rd-accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.rd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 5px 12px;
  background: var(--rd-bg); color: var(--rd-fg);
  border: 1px solid var(--rd-line-strong); border-radius: 3px;
  cursor: pointer; white-space: nowrap; font-size: 14px;
}
.rd-btn:hover { background: var(--rd-soft); }
.rd-btn:disabled { opacity: .5; cursor: default; }
.rd-btn-primary { background: var(--rd-accent); border-color: var(--rd-accent); color: var(--rd-accent-fg); font-weight: bold; }
.rd-btn-primary:hover { background: var(--rd-accent); filter: brightness(1.08); }
.rd-btn-danger { color: var(--rd-bad); border-color: var(--rd-bad); }
.rd-btn-small { min-height: 28px; padding: 3px 9px; font-size: 13px; }
.rd-btn-icon .rd-ico { font-size: 16px; line-height: 1; }

/* ---------- top bar ---------- */
.rd-top {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  min-height: 50px; padding: 6px 12px;
  border-bottom: 1px solid var(--rd-line); background: var(--rd-bg);
}
.rd-top-left { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.rd-cand { font-weight: bold; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-testname { font-size: 12px; color: var(--rd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-top-center { flex: 0 1 auto; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.rd-top-right { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.rd-timer { font-weight: bold; font-size: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rd-timer.rd-timer-warn { color: var(--rd-bad); }
.rd-timer.rd-timer-critical { color: var(--rd-bad); animation: rd-blink 1s steps(2, start) infinite; }
@keyframes rd-blink { to { visibility: hidden; } }
.rd-review-score { font-weight: bold; white-space: nowrap; }
.rd-practice-tools { display: flex; gap: 4px; }

/* ---------- instruction strip & tabs ---------- */
.rd-instr {
  flex: 0 0 auto; padding: 7px 16px; background: var(--rd-soft);
  border-bottom: 1px solid var(--rd-line); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rd-tabs { display: none; flex: 0 0 auto; border-bottom: 1px solid var(--rd-line); background: var(--rd-bg); }
.rd-tab {
  flex: 1 1 0; min-height: 42px; border: 0; background: transparent; cursor: pointer;
  font-weight: bold; color: var(--rd-muted); border-bottom: 3px solid transparent;
}
.rd-tab.rd-active { color: var(--rd-fg); border-bottom-color: var(--rd-accent); }

/* ---------- main split ---------- */
.rd-main { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
.rd-pane {
  min-width: 0; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 18px 24px 40px; font-size: var(--rd-fs);
}
.rd-pane-p { flex: 0 0 var(--rd-split); }
.rd-pane-q { flex: 1 1 0; }
.rd-divider {
  flex: 0 0 10px; cursor: col-resize; background: var(--rd-soft);
  border-left: 1px solid var(--rd-line); border-right: 1px solid var(--rd-line);
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.rd-divider-grip { width: 4px; height: 36px; border-left: 1px solid var(--rd-line-strong); border-right: 1px solid var(--rd-line-strong); }
.rd-divider:hover, .rd-resizing .rd-divider { background: var(--rd-accent-soft); }
.rd-resizing, .rd-resizing * { cursor: col-resize !important; user-select: none !important; }

/* ---------- passage ---------- */
.rd-ptitle { font-size: 1.3em; margin: 0 0 4px; line-height: 1.25; }
.rd-psub { margin: 0 0 16px; font-style: italic; color: var(--rd-muted); }
.rd-para { margin: 0 0 1em; display: flex; gap: 12px; }
.rd-plabel { flex: 0 0 auto; font-weight: bold; min-width: 1em; }
.rd-ptext { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.rd-hl { background: var(--rd-hl); color: var(--rd-hl-fg); cursor: pointer; }
.rd-note { text-decoration: underline; text-decoration-color: var(--rd-accent); text-decoration-thickness: 2px; text-underline-offset: 3px; cursor: pointer; }
.rd-ph {
  display: block; margin: 10px 0 14px; padding: 14px 16px;
  background: var(--rd-ph); border: 1px dashed var(--rd-line-strong); border-radius: 3px;
  color: var(--rd-fg); font-size: .92em;
}
.rd-ph-kind { display: block; margin-bottom: 4px; text-transform: uppercase; font-size: .8em; letter-spacing: .04em; color: var(--rd-muted); }

/* heading drop boxes above paragraphs */
.rd-drop {
  display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; padding: 6px 10px;
  min-height: 38px; border: 1px dashed var(--rd-line-strong); border-radius: 3px;
  font-size: .9em; color: var(--rd-muted); cursor: pointer; background: var(--rd-bg);
}
.rd-drop.rd-filled { border-style: solid; color: var(--rd-fg); background: var(--rd-accent-soft); }
.rd-drop.rd-dragover, .rd-q.rd-dragover { outline: 2px solid var(--rd-accent); background: var(--rd-accent-soft); }
.rd-dragging .rd-drop { border-color: var(--rd-accent); }

/* ---------- questions ---------- */
.rd-group { margin: 0 0 28px; }
.rd-group-title { font-size: 1.05em; margin: 0 0 8px; text-align: center; font-weight: 700; }
.rd-group-subtitle {
  display: block;
  text-align: center;
  font-weight: 700;
  font-size: 1.05em;
  margin: 0 0 12px;
}
.rd-group-instr { margin: 0 0 12px; }
.rd-group-instr p { margin: 0 0 4px; }
.rd-instr-main { margin: 0 0 8px; }
.rd-instr-limit { font-weight: 700; }
.rd-instr-key { display: flex; gap: 10px; margin: 2px 0; }
.rd-instr-key strong { min-width: 6.5em; }
.rd-hint { font-size: .85em; color: var(--rd-muted); margin: 6px 0 0; }

.rd-optbox { border: 1px solid var(--rd-line); border-radius: 3px; padding: 10px 12px; margin: 0 0 14px; }
.rd-optbox-title { font-weight: bold; margin: 0 0 6px; }
.rd-optlist { list-style: none; margin: 0; padding: 0; }
.rd-opt { display: flex; gap: 10px; padding: 3px 4px; border-radius: 3px; }
.rd-optkey { flex: 0 0 auto; min-width: 2em; font-weight: bold; }
.rd-wordbox .rd-optlist { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.rd-draggable { cursor: grab; }
.rd-draggable:hover { background: var(--rd-accent-soft); }

.rd-content { margin: 0 0 10px; }
.rd-c-p { margin: 0 0 10px; }
.rd-c-h { font-weight: bold; margin: 8px 0 6px; }
.rd-c-ul { margin: 0 0 10px; padding-left: 1.3em; }
.rd-c-li { margin: 0 0 6px; }
.rd-has-gap { line-height: 2.1; }
.rd-table-wrap { overflow-x: auto; margin: 0 0 12px; }
.rd-c-table { border-collapse: collapse; width: 100%; min-width: 280px; }
.rd-c-table th, .rd-c-table td { border: 1px solid var(--rd-line-strong); padding: 6px 8px; text-align: left; vertical-align: top; line-height: 2; }
.rd-c-table th { background: var(--rd-soft); }

.rd-q { margin: 0 0 16px; padding: 4px 6px; border-radius: 3px; }
.rd-q-stem { display: flex; gap: 8px; align-items: baseline; margin: 0 0 6px; }
.rd-qnum {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  min-width: 1.9em; height: 1.6em; padding: 0 4px; font-weight: bold;
  border: 1px solid var(--rd-line-strong); border-radius: 3px; font-size: .9em; line-height: 1;
}
.rd-qnum-wide { min-width: 3.2em; }
.rd-q-text { flex: 1 1 auto; min-width: 0; }
.rd-q-gapline { display: block; line-height: 2.1; }
.rd-q-gapline > .rd-q-text { display: inline; }
.rd-q-select { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.rd-q-select .rd-q-text { flex: 1 1 14em; }

.rd-choices { display: flex; flex-direction: column; gap: 4px; margin-left: 2.4em; }
.rd-choices-inline { flex-direction: row; flex-wrap: wrap; gap: 6px; }
.rd-choice {
  display: flex; align-items: flex-start; gap: 8px; padding: 6px 10px;
  border: 1px solid transparent; border-radius: 3px; cursor: pointer; min-height: 38px;
}
.rd-choices-inline .rd-choice { border-color: var(--rd-line); align-items: center; }
.rd-choice:hover { background: var(--rd-soft); }
.rd-choice:has(input:checked) { background: var(--rd-accent-soft); border-color: var(--rd-accent); }
.rd-choice input { margin: 3px 0 0; width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--rd-accent); }
.rd-choices-inline .rd-choice input { margin: 0; }
.rd-choice-key { font-weight: bold; flex: 0 0 auto; }
.rd-choice-text { flex: 1 1 auto; }
.rd-limit { color: var(--rd-bad); font-size: .9em; margin: 4px 0 0 2.4em; min-height: 0; }
.rd-limit:empty { display: none; }

/* text gaps and dropdowns */
.rd-gapwrap { display: inline; white-space: nowrap; }
.rd-gap {
  display: inline-block;
  width: 9.5em; max-width: 100%; height: 1.9em; padding: 2px 6px;
  border: 1px solid var(--rd-line-strong); border-radius: 3px;
  background: var(--rd-input); color: var(--rd-fg); font-size: 1em; vertical-align: baseline;
  text-align: center;
}
.rd-gap::placeholder { color: var(--rd-muted); font-weight: 700; text-align: center; opacity: .9; }
.rd-gap:focus, .rd-sel:focus { outline: 2px solid var(--rd-accent); outline-offset: 0; border-color: var(--rd-accent); }
.rd-sel {
  max-width: 100%; min-width: 5em; height: 2em; padding: 2px 4px;
  border: 1px solid var(--rd-line-strong); border-radius: 3px;
  background: var(--rd-input); color: var(--rd-fg); font-size: .95em;
}
.rd-gapwrap .rd-sel { max-width: 14em; }
.rd-q-select .rd-sel { flex: 0 1 auto; max-width: 100%; }
.rd-ctl:disabled { opacity: 1; color: var(--rd-fg); -webkit-text-fill-color: var(--rd-fg); }
.rd-q.rd-pulse { animation: rd-pulse 1s ease-out 1; }
@keyframes rd-pulse { from { background: var(--rd-accent-soft); } to { background: transparent; } }

.rd-part-foot { margin: 8px 0 24px; display: flex; justify-content: flex-end; }

/* ---------- review colouring ---------- */
.rd-review .rd-q.rd-right, .rd-review .rd-gapwrap.rd-right .rd-gap, .rd-review .rd-gapwrap.rd-right .rd-sel { border-color: var(--rd-ok); }
.rd-review .rd-q.rd-right { background: var(--rd-ok-soft); }
.rd-review .rd-q.rd-wrong { background: var(--rd-bad-soft); }
.rd-review .rd-gapwrap.rd-right .rd-gap, .rd-review .rd-gapwrap.rd-right .rd-sel { background: var(--rd-ok-soft); border-width: 2px; }
.rd-review .rd-gapwrap.rd-wrong .rd-gap, .rd-review .rd-gapwrap.rd-wrong .rd-sel { background: var(--rd-bad-soft); border-color: var(--rd-bad); border-width: 2px; }
.rd-review .rd-gapwrap { white-space: normal; }
.rd-verdict { font-weight: bold; margin-left: 6px; white-space: normal; }
.rd-q > .rd-verdict { display: block; margin: 4px 0 0 2.4em; }
.rd-ok { color: var(--rd-ok); }
.rd-bad { color: var(--rd-bad); }
.rd-correct { color: var(--rd-ok); }
.rd-choice.rd-key { border-color: var(--rd-ok); box-shadow: inset 3px 0 0 var(--rd-ok); }
.rd-choice.rd-picked-wrong { border-color: var(--rd-bad); background: var(--rd-bad-soft); }
.rd-drop.rd-right { border-color: var(--rd-ok); }
.rd-drop.rd-wrong { border-color: var(--rd-bad); }

/* ---------- bottom navigation ---------- */
.rd-nav {
  flex: 0 0 auto; display: flex; align-items: stretch; gap: 0;
  border-top: 1px solid var(--rd-line); background: var(--rd-bar);
  min-height: 52px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.rd-nav-part { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-right: 1px solid var(--rd-line); min-width: 0; }
.rd-nav-part.rd-active { flex: 1 1 auto; }
.rd-nav-pbtn {
  display: inline-flex; align-items: baseline; gap: 8px; border: 0; background: transparent;
  cursor: pointer; padding: 6px 4px; white-space: nowrap; font-size: 14px;
}
.rd-nav-plabel { font-weight: bold; }
.rd-nav-count { color: var(--rd-muted); font-size: 13px; }
.rd-nav-part.rd-active .rd-nav-count { display: none; }
.rd-nav-nums { display: none; gap: 4px; flex-wrap: wrap; min-width: 0; padding: 2px; }
.rd-nav-part.rd-active .rd-nav-nums { display: flex; }
.rd-nav-num {
  position: relative; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--rd-line-strong); border-radius: 3px;
  background: var(--rd-bg); color: var(--rd-fg); font-size: 13px; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.rd-nav-num.rd-answered { background: var(--rd-fg); color: var(--rd-bg); border-color: var(--rd-fg); font-weight: bold; }
.rd-nav-num.rd-current { outline: 2px solid var(--rd-accent); outline-offset: 1px; }
.rd-nav-num.rd-flagged { border-radius: 50%; }
.rd-nav-num.rd-flagged::after {
  content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--rd-flag); border: 1px solid var(--rd-bg);
}
.rd-review .rd-nav-num.rd-right { background: var(--rd-ok); border-color: var(--rd-ok); color: #fff; }
.rd-review .rd-nav-num.rd-wrong { background: var(--rd-bad); border-color: var(--rd-bad); color: #fff; }
.rd-contrast-wb.rd-review .rd-nav-num.rd-right, .rd-contrast-yb.rd-review .rd-nav-num.rd-right,
.rd-contrast-wb.rd-review .rd-nav-num.rd-wrong, .rd-contrast-yb.rd-review .rd-nav-num.rd-wrong { color: #000; }
.rd-nav-arrows { display: flex; align-items: center; gap: 6px; padding: 6px 10px; margin-left: auto; }
.rd-nav-arrow { width: 44px; min-height: 38px; padding: 0; font-size: 15px; }

/* ---------- popup (highlight / notes) ---------- */
.rd-pop {
  position: fixed; z-index: 30; display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  max-width: min(320px, calc(100vw - 16px)); padding: 5px;
  background: var(--rd-bg); color: var(--rd-fg); border: 1px solid var(--rd-line-strong); border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25); font-size: 14px;
}
.rd-pop-btn { min-height: 36px; padding: 4px 12px; border: 1px solid var(--rd-line); border-radius: 3px; background: var(--rd-bg); cursor: pointer; }
.rd-pop-btn:hover { background: var(--rd-soft); }
.rd-pop-danger { color: var(--rd-bad); }
.rd-pop-note { flex: 1 1 100%; padding: 6px 8px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40vh; overflow-y: auto; }
.rd-pop-row { display: flex; flex-wrap: wrap; gap: 4px; }

/* Practice: liquid-glass Highlight/Notes menu, same family as the hard-word popover.
   Strict Exam keeps the official plain menu (.rd-pop-official) so it feels like the real test. */
.rd-mode-practice .rd-pop-glass {
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: #f4f1eb;
  box-shadow:
    0 10px 28px rgba(28, 25, 23, 0.18),
    0 0 0 1px rgba(28, 25, 23, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(255, 255, 255, 0.25);
  gap: 6px;
  opacity: 0;
  transform: scale(0.85) translateY(-8px);
  transform-origin: 50% 0%;
  transition:
    opacity 200ms cubic-bezier(0.22, 1.18, 0.36, 1),
    transform 200ms cubic-bezier(0.22, 1.18, 0.36, 1);
  will-change: opacity, transform;
}
.rd-mode-practice .rd-pop-glass:not(.rd-pop--below) {
  transform: scale(0.85) translateY(8px);
  transform-origin: 50% 100%;
}
.rd-mode-practice .rd-pop-glass.rd-pop--open {
  opacity: 1;
  transform: scale(1) translateY(0);
}
.rd-mode-practice .rd-pop-glass.rd-pop--close {
  opacity: 0;
  transform: scale(0.85) translateY(-8px);
  transition-duration: 120ms;
  transition-timing-function: ease-in;
}
.rd-mode-practice .rd-pop-glass:not(.rd-pop--below).rd-pop--close {
  transform: scale(0.85) translateY(8px);
}
.rd-mode-practice .rd-pop-glass .rd-pop-btn {
  min-height: 38px;
  padding: 4px 14px;
  border-radius: 10px;
  border: 1px solid rgba(28, 25, 23, 0.12);
  background: rgba(255, 255, 255, 0.55);
  font-weight: 600;
}
.rd-mode-practice .rd-pop-glass .rd-pop-btn:hover,
.rd-mode-practice .rd-pop-glass .rd-pop-btn:focus-visible {
  background: rgba(255, 255, 255, 0.85);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .rd-mode-practice .rd-pop-glass {
    background: rgba(255, 252, 247, 0.8);
    -webkit-backdrop-filter: blur(18px) saturate(1.65);
    backdrop-filter: blur(18px) saturate(1.65);
  }
}
[data-theme=dark] .rd-mode-practice .rd-pop-glass {
  border-color: rgba(255, 255, 255, 0.2);
  background: #1c1e24;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
[data-theme=dark] .rd-mode-practice .rd-pop-glass .rd-pop-btn {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f3efe8;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  [data-theme=dark] .rd-mode-practice .rd-pop-glass {
    background: rgba(22, 24, 30, 0.55);
  }
}
html[data-motion=off] .rd-mode-practice .rd-pop-glass,
html[data-motion=off] .rd-mode-practice .rd-pop-glass.rd-pop--close,
html[data-motion=off] .rd-mode-practice .rd-pop-glass:not(.rd-pop--below) {
  transform: none;
  transition: opacity 120ms ease;
}
@media (prefers-reduced-motion: reduce) {
  .rd-mode-practice .rd-pop-glass,
  .rd-mode-practice .rd-pop-glass.rd-pop--close,
  .rd-mode-practice .rd-pop-glass:not(.rd-pop--below) {
    transform: none;
    transition: opacity 120ms ease;
  }
}

/* ---------- modal ---------- */
.rd-modal-layer { display: none; }
.rd-modal-layer.rd-open {
  display: flex; position: absolute; inset: 0; z-index: 40; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .45); padding: 16px;
}
.rd-modal {
  width: 100%; max-width: 460px; max-height: 100%; overflow-y: auto;
  background: var(--rd-bg); color: var(--rd-fg); border: 1px solid var(--rd-line-strong); border-radius: 4px;
  padding: 18px 20px; box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}
.rd-modal + .rd-modal { display: none; }
.rd-modal-title { font-size: 18px; margin: 0 0 10px; }
.rd-modal-body { font-size: 15px; }
.rd-modal-body p { margin: 0 0 10px; }
.rd-modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.rd-modal-actions .rd-btn { min-height: 40px; }
.rd-note-quote { color: var(--rd-muted); font-style: italic; }
.rd-note-input {
  width: 100%; padding: 8px; border: 1px solid var(--rd-line-strong); border-radius: 3px;
  background: var(--rd-input); color: var(--rd-fg); resize: vertical; min-height: 90px;
}
.rd-set-group { border: 1px solid var(--rd-line); border-radius: 3px; margin: 0 0 12px; padding: 8px 12px; }
.rd-set-group legend { font-weight: bold; padding: 0 4px; }
.rd-set-opt { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.rd-set-opt input { width: 18px; height: 18px; accent-color: var(--rd-accent); }
.rd-help { margin: 0; }
.rd-help dt { font-weight: bold; margin-top: 8px; }
.rd-help dd { margin: 2px 0 0; }

.rd-toast {
  position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%); z-index: 35;
  background: var(--rd-fg); color: var(--rd-bg); padding: 8px 14px; border-radius: 4px; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center; pointer-events: none;
}
.rd-error { padding: 32px 24px; max-width: 560px; margin: 0 auto; }

/* ---------- results ---------- */
.rd-results { flex: 1 1 auto; overflow-y: auto; padding: 20px 24px 48px; -webkit-overflow-scrolling: touch; }
.rd-res-summary { max-width: 760px; margin: 0 auto 26px; border: 1px solid var(--rd-line); border-radius: 4px; padding: 20px; text-align: center; }
.rd-res-score { font-size: 26px; }
.rd-res-score strong { font-size: 34px; }
.rd-res-band { margin: 8px 0 2px; display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.rd-res-band-label { font-size: 18px; color: var(--rd-muted); }
.rd-res-band-num { font-size: 48px; line-height: 1.1; }
.rd-res-note { font-size: 13px; color: var(--rd-muted); margin: 0 0 10px; }
.rd-res-time { font-size: 16px; margin-bottom: 14px; }
.rd-res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.rd-res-actions .rd-btn { min-height: 42px; min-width: 110px; }
.rd-res-section { max-width: 760px; margin: 0 auto 26px; }
.rd-res-section h2 { font-size: 18px; margin: 0 0 10px; }
.rd-res-table { border-collapse: collapse; width: 100%; }
.rd-res-table th, .rd-res-table td { border: 1px solid var(--rd-line); padding: 7px 10px; text-align: left; }
.rd-res-table td:not(:first-child), .rd-res-table th:not(:first-child) { text-align: center; width: 18%; }
.rd-res-table th { background: var(--rd-soft); }
.rd-sheet { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 24px; }
.rd-sheet-row {
  break-inside: avoid; display: grid; grid-template-columns: 2.4em minmax(0, 1fr) 1.6em; grid-template-areas: "n user mark" ". key key";
  align-items: baseline; gap: 2px 8px; padding: 7px 4px; border-bottom: 1px solid var(--rd-line);
}
.rd-sheet-n { grid-area: n; font-weight: bold; }
.rd-sheet-user { grid-area: user; overflow-wrap: anywhere; }
.rd-sheet-user.rd-blank { color: var(--rd-muted); }
.rd-sheet-mark { grid-area: mark; font-weight: bold; font-size: 18px; text-align: center; }
.rd-sheet-key { grid-area: key; color: var(--rd-ok); font-size: 14px; overflow-wrap: anywhere; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .rd-timer.rd-timer-critical { animation: none; text-decoration: underline; }
  .rd-q.rd-pulse { animation: none; }
}

/* ==================================================================
   Phones and narrow windows (under 800px): Passage / Questions tabs
   ================================================================== */
@media (max-width: 799px) {
  .rd-root { font-size: 15px; }
  .rd-top { min-height: 48px; padding: 4px 8px; gap: 6px; }
  .rd-top-left { display: none; }
  .rd-on-results .rd-top-left, .rd-review .rd-top-left { display: flex; }
  .rd-testname { display: none; }
  .rd-cand { font-size: 13px; }
  .rd-top-center { flex: 1 1 auto; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
  .rd-review .rd-top-center { align-items: center; }
  .rd-timer { font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .rd-btn-timer { min-height: 22px; padding: 0 6px; font-size: 11px; border-color: var(--rd-line); }
  .rd-top-right { flex: 0 0 auto; gap: 4px; }
  .rd-btn-icon:not(.rd-btn-labelled) .rd-lbl { display: none; }
  .rd-btn-icon { min-width: 38px; min-height: 38px; padding: 4px 8px; }
  .rd-btn-submit { min-height: 38px; padding: 4px 10px; font-size: 13px; }
  .rd-practice-tools { display: none; }

  .rd-instr { padding: 5px 10px; font-size: 13px; }
  .rd-tabs { display: flex; }
  .rd-divider { display: none; }
  .rd-pane { padding: 14px 14px 32px; }
  .rd-pane-p, .rd-pane-q { flex: 1 1 auto; }
  .rd-root.rd-tab-passage .rd-pane-q { display: none; }
  .rd-root.rd-tab-questions .rd-pane-p { display: none; }

  .rd-choices { margin-left: 0; }
  .rd-limit, .rd-q > .rd-verdict { margin-left: 0; }
  .rd-q-select .rd-sel { flex: 1 1 100%; }
  .rd-gap { width: 8em; }
  .rd-choice { min-height: 44px; align-items: center; }
  .rd-choice input { margin: 0; }

  /* bottom navigation: row 1 = parts + arrows, row 2 = numbers of the open part */
  .rd-nav { display: grid; grid-template-columns: 1fr 1fr 1fr auto; grid-template-rows: auto auto; }
  .rd-nav-part { display: contents; }
  .rd-nav-pbtn {
    grid-row: 1; justify-content: center; min-height: 44px; padding: 4px 2px;
    border-right: 1px solid var(--rd-line); border-bottom: 3px solid transparent; flex-direction: column; align-items: center; gap: 0;
  }
  .rd-nav-part[data-part="1"] .rd-nav-pbtn { grid-column: 1; }
  .rd-nav-part[data-part="2"] .rd-nav-pbtn { grid-column: 2; }
  .rd-nav-part[data-part="3"] .rd-nav-pbtn { grid-column: 3; }
  .rd-nav-part.rd-active .rd-nav-pbtn { border-bottom-color: var(--rd-accent); background: var(--rd-bg); }
  .rd-nav-count { font-size: 11px; }
  .rd-nav-part.rd-active .rd-nav-count { display: inline; }
  .rd-nav-arrows { grid-column: 4; grid-row: 1; padding: 3px 6px; gap: 4px; }
  .rd-nav-arrow { width: 44px; min-height: 40px; }
  .rd-nav-part.rd-active .rd-nav-nums {
    grid-column: 1 / -1; grid-row: 2; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    padding: 6px 8px 8px; gap: 6px; border-top: 1px solid var(--rd-line); scrollbar-width: thin;
  }
  .rd-nav-num { flex: 0 0 auto; width: 38px; height: 38px; font-size: 14px; }

  /* while typing on a phone, give the keyboard room */
  .rd-root.rd-typing .rd-nav, .rd-root.rd-typing .rd-instr { display: none; }

  .rd-results { padding: 14px 12px 40px; }
  .rd-res-summary { padding: 16px 12px; }
  .rd-res-score { font-size: 22px; }
  .rd-res-score strong { font-size: 30px; }
  .rd-sheet { columns: 1; }
  .rd-toast { bottom: 110px; }
  .rd-modal { padding: 16px; }
}

@media (max-width: 380px) {
  .rd-btn-submit { padding: 4px 8px; }
  .rd-timer { font-size: 13px; }
  .rd-review-score { font-size: 13px; }
}

/* Results only: pace display shares the Reading palette, with no exam-overlay CSS. */
.rd-timing {
  border: 1px solid var(--rd-line);
  border-radius: 14px;
  padding: 15px 17px;
  background: var(--rd-bar);
}
.rd-timing-explain, .rd-timing-note {
  margin: 0;
  color: var(--rd-muted);
  font-size: 14px;
}
.rd-timing-note { margin-top: 6px; }
.rd-timing-list { list-style: none; padding: 0; margin: 12px 0 0; }
.rd-timing-row + .rd-timing-row { border-top: 1px solid var(--rd-line); }
.rd-timing-row { padding: 9px 0; }
.rd-timing-row:last-child { padding-bottom: 2px; }
.rd-timing-row-main {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  align-items: baseline;
  gap: 10px;
}
.rd-timing-passage, .rd-timing-time, .rd-timing-score {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.rd-timing-time { font-weight: 700; color: var(--rd-accent); }
.rd-timing-score { min-width: 7.6em; text-align: right; color: var(--rd-fg); }
.rd-timing-rail { display: block; margin-top: 6px; height: 4px; border-radius: 999px; background: var(--rd-soft); }
.rd-timing-fill { display: block; height: 100%; border-radius: inherit; background: var(--rd-accent); }
@media (max-width: 420px) {
  .rd-timing { padding: 12px 10px; }
  .rd-timing-row-main { gap: 7px; }
  .rd-timing-score { min-width: 0; }
}
