/*
 * English Kertas 1 — Reading (papers-reading-app, js/paper-reading.js; 2026-11-18). On top of the paper app's look
 * (paper-app.css) and the 输入题 page's bar / sheet (paper-written-app.css, body.pw-app). Flat, white, light
 * grey; orange for what you picked; green / pink only after marking. Dark twins come from tools/dark-css.
 */

/* ---------- page ---------- */
body.rd-app .rd { display: flex; flex-direction: column; gap: 0; padding-bottom: 120px; }
body.rd-app.pa-result .rd { padding-bottom: 24px; }
/* A Part with its text beside the questions takes the width on wide screens. */
@media (min-width: 1000px) {
    body.rd-app .rd:has(.rd-part.is-split:not([hidden])) { max-width: 1180px; }
}
body.rd-app .rd-test-note { display: flex; gap: 8px; align-items: center; margin: 12px 0 0; color: #8a5a00; font-size: 13px; }
body.rd-app .rd-test-note .material-symbols-outlined { --icon-size: 18px; font-size: 18px; }

body.rd-app .rd-part { display: flex; flex-direction: column; gap: 14px; padding: 6px 4px 8px; }
body.rd-app .rd-part.rd-in-next { animation: rd-in-next 0.28s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
body.rd-app .rd-part.rd-in-prev { animation: rd-in-prev 0.28s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
@keyframes rd-in-next { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes rd-in-prev { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
body.rd-app .rd-part-head { display: flex; align-items: baseline; margin: 6px 0 0; }
body.rd-app .rd-part-head .wp-section-title { color: #23232b; font-size: 18px; font-weight: 800; }
body.rd-app .rd-part-score { margin-left: auto; padding: 2px 10px; border-radius: 999px; background: #fbe9ec; color: #b0485f; font-size: 13px; font-weight: 700; }
body.rd-app .rd-part-score.is-full { background: #e6f4ec; color: #2f7a52; }

body.rd-app .rd-instruction { color: #6b6b75; font-size: 14px; line-height: 1.6; }
body.rd-app .rd-instruction p { margin: 0; }
body.rd-app .rd-instruction p + p { margin-top: 6px; }
body.rd-app .rd-sub-instruction { margin-top: 10px; padding-top: 14px; border-top: 1px solid #efefef; }
body.rd-app .rd-col > .rd-sub-instruction:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

body.rd-app .rd-cols { display: flex; flex-direction: column; gap: 14px; }
body.rd-app .rd-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 1000px) {
    body.rd-app .rd-part.is-split .rd-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; gap: 28px; }
    body.rd-app .rd-part.is-split .rd-col-b { position: sticky; top: 8px; max-height: calc(100vh - 170px); overflow-y: auto; padding-right: 4px; overscroll-behavior: contain; }
}

/* ---------- texts ---------- */
body.rd-app .rd-text,
body.rd-app .rd-items { padding: 18px 18px 16px; border-radius: 18px; background: #f6f6f7; }
body.rd-app .rd-text-title { margin: 0 0 10px; color: #23232b; font-size: 16px; font-weight: 800; line-height: 1.35; }
body.rd-app .rd-body { color: #2b2b33; font-size: 16px; line-height: 1.75; overflow-wrap: anywhere; }
body.rd-app .rd-body p { margin: 0; }
body.rd-app .rd-body p + p { margin-top: 12px; }
body.rd-app .rd-body ul,
body.rd-app .rd-body ol { margin: 6px 0; padding-left: 22px; }
body.rd-app .rd-body table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: 14.5px; }
body.rd-app .rd-body th,
body.rd-app .rd-body td { padding: 6px 8px; border: 1px solid #e4e4e7; text-align: left; vertical-align: top; }
body.rd-app .rd-source { margin: 12px 0 0; color: #9a9aa3; font-size: 12.5px; font-style: italic; overflow-wrap: anywhere; }

body.rd-app .rd-items { display: flex; flex-direction: column; gap: 0; }
body.rd-app .rd-item { padding: 12px 0; }
body.rd-app .rd-item + .rd-item { border-top: 1px solid #e8e8ea; }
body.rd-app .rd-item header { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; color: #23232b; font-size: 15px; }
body.rd-app .rd-item .rd-body { font-size: 15.5px; line-height: 1.7; }
body.rd-app .rd-letter-badge {
    display: inline-grid; flex: none; place-items: center; width: 26px; height: 26px; border-radius: 8px;
    background: #fff; color: #4a4a57; font-size: 13px; font-weight: 800; box-shadow: inset 0 0 0 1.5px #e4e4e7;
}

/* The sentence bank (Part 4): beside the text on wide screens. */
body.rd-app .rd-bank { display: flex; flex-direction: column; gap: 8px; }
body.rd-app .rd-bank-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; box-shadow: inset 0 0 0 1.5px #ececee; color: #33333d; font-size: 14.5px; line-height: 1.55; }
body.rd-app .rd-bank-item.is-used { opacity: 0.5; }

/* ---------- gaps in a text ---------- */
body.rd-app .rd-gap { display: inline-flex; gap: 6px; align-items: center; vertical-align: baseline; margin: 0 2px; }
body.rd-app .rd-gap-n {
    display: inline-grid; flex: none; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 7px;
    background: #e9e9ee; color: #55555e; font-size: 12px; font-weight: 800; line-height: 1;
}
body.rd-app .rd-gap-pick {
    min-height: 32px; padding: 3px 10px 3px 4px; border: 0; border-radius: 10px; background: #fff;
    box-shadow: inset 0 0 0 1.5px #dcdce2; color: #23232b; font: inherit; font-weight: 700; line-height: 1.3; cursor: pointer;
    transition: transform 0.12s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
body.rd-app .rd-gap-pick:active { transform: scale(0.96); }
body.rd-app .rd-gap-pick:focus-visible { outline: 2px solid #f2a07b; outline-offset: 2px; }
body.rd-app .rd-gap-pick .rd-gap-v:empty::after { content: ""; display: inline-block; width: 3.2em; height: 2px; margin-bottom: -2px; border-radius: 2px; background: #c9c9d1; }
body.rd-app .rd-gap-pick.is-filled { background: #fff0e6; box-shadow: none; color: #8a4116; }
body.rd-app .rd-gap-pick.is-filled .rd-gap-n { background: #ffd7c2; color: #8a4116; }
body.rd-app .rd-gap-s { color: #8a4116; font-style: italic; }
body.rd-app .rd-gap-s:empty { display: none; }
body.rd-app .rd-gap-s:not(:empty)::after { content: " "; }

body.rd-app .rd-gap-type { padding: 0 2px; }
body.rd-app .rd-gap-input {
    width: 8.5em; max-width: 52vw; height: 32px; padding: 0 10px; border: 0; border-radius: 10px; background: #fff;
    box-shadow: inset 0 0 0 1.5px #dcdce2; color: #23232b; font: inherit; font-weight: 700; outline: none;
    transition: box-shadow 0.18s ease, background-color 0.18s ease;
}
body.rd-app .rd-gap-input:focus { box-shadow: inset 0 0 0 2px #f2a07b; }
body.rd-app .rd-gap-type.is-filled .rd-gap-input:not(:focus) { background: #fff0e6; box-shadow: none; color: #8a4116; }
body.rd-app .rd-gap-mark:empty { display: none; }
body.rd-app .rd-gap.is-missing { color: #b0485f; }

/* After marking: right green, wrong pink with the answer after it. */
body.rd-app.rd-review .rd-gap.is-right .rd-gap-n,
body.rd-app.rd-review .rd-gap.is-wrong .rd-gap-n { color: #fff; }
body.rd-app.rd-review .rd-gap-pick.is-right,
body.rd-app.rd-review .rd-gap-type.is-right .rd-gap-input { background: #e6f4ec; box-shadow: none; color: #2f7a52; }
body.rd-app.rd-review .rd-gap.is-right .rd-gap-n { background: #3f9a68; }
body.rd-app.rd-review .rd-gap-pick.is-wrong,
body.rd-app.rd-review .rd-gap-type.is-wrong .rd-gap-input { background: #fbe9ec; box-shadow: none; color: #b0485f; }
body.rd-app.rd-review .rd-gap-pick.is-wrong .rd-gap-v,
body.rd-app.rd-review .rd-gap-type.is-wrong .rd-gap-input { text-decoration: line-through; text-decoration-thickness: 1.5px; }
body.rd-app.rd-review .rd-gap.is-wrong .rd-gap-n { background: #d0607a; }
body.rd-app.rd-review .rd-gap-type .rd-gap-input { cursor: pointer; }
body.rd-app.rd-review .rd-gap-mark:not(:empty) { display: inline; color: #2f7a52; font-weight: 800; }
body.rd-app.rd-review .rd-gap-mark:not(:empty)::before { content: "→ "; color: #9a9aa3; font-weight: 600; }
body.rd-app.rd-review .rd-gap-type.is-wrong .rd-gap-input:placeholder-shown { text-decoration: none; }

/* The answer's place in the text, after marking. */
body.rd-app mark.rd-ev { padding: 1px 0; border-radius: 3px; background: #fff3c4; color: inherit; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
body.rd-app mark.rd-ev.is-first::before {
    content: attr(data-n); display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-right: 4px; padding: 0 4px;
    border-radius: 6px; background: #f0d36b; color: #5b4300; font-size: 11px; font-weight: 800; vertical-align: 2px;
}
body.rd-app mark.rd-ev.is-flash { animation: rd-flash 1.4s ease; }
@keyframes rd-flash { 0%, 40% { background: #ffd96a; } 100% { background: #fff3c4; } }

/* ---------- questions ---------- */
body.rd-app .rd-qs { display: flex; flex-direction: column; }
body.rd-app .rd-q { display: flex; flex-direction: column; gap: 12px; padding: 18px 2px; scroll-margin-top: 12px; }
body.rd-app .rd-q + .rd-q { border-top: 1px solid #efefef; }
body.rd-app .rd-qs:first-child .rd-q:first-child { padding-top: 4px; }
body.rd-app .rd-q.rd-flash { animation: rd-q-flash 1.2s ease; }
@keyframes rd-q-flash { 0%, 30% { background: #fff6ef; } 100% { background: transparent; } }
body.rd-app .rd-q-head { display: flex; gap: 12px; align-items: flex-start; }
body.rd-app .rd-qnum {
    display: inline-grid; flex: none; place-items: center; min-width: 34px; height: 28px; padding: 0 8px; border-radius: 999px;
    background: #f2f2f2; color: #55555e; font-size: 13.5px; font-weight: 800;
}
body.rd-app .rd-q.is-answered .rd-qnum { background: #ffe0cc; color: #8a4116; }
body.rd-app.rd-review .rd-q.is-right .rd-qnum { background: #e6f4ec; color: #2f7a52; }
body.rd-app.rd-review .rd-q.is-wrong .rd-qnum { background: #fbe9ec; color: #b0485f; }
body.rd-app .rd-q-text { flex: 1; min-width: 0; padding-top: 3px; color: #23232b; font-size: 16px; line-height: 1.6; }
body.rd-app .rd-q-text p { margin: 0; }
body.rd-app .rd-q-text:empty { display: none; }
body.rd-app .rd-q-mark:empty { display: none; }

body.rd-app .rd-stim { margin: 0; }
body.rd-app .rd-stim-img { display: block; max-width: 100%; max-height: 520px; margin: 0 auto; border-radius: 14px; box-shadow: 0 0 0 1px #ececee; cursor: zoom-in; }
body.rd-app .rd-options { margin: 0; }

/* Letters to match (A–F): one row of keys. */
body.rd-app .rd-letters { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 46px; }
body.rd-app .rd-letter {
    width: 44px; height: 44px; border: 0; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1.5px #e4e4e7;
    color: #33333d; font: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
    transition: transform 0.12s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
body.rd-app .rd-letter:active { transform: scale(0.94); }
body.rd-app .rd-letter.is-on { background: #fff0e6; box-shadow: inset 0 0 0 2px #f2a07b; color: #8a4116; }
body.rd-app.rd-review .rd-letter { cursor: default; }
body.rd-app.rd-review .rd-letter.is-correct { background: #e6f4ec; box-shadow: inset 0 0 0 2px #7cc59c; color: #2f7a52; }
body.rd-app.rd-review .rd-letter.is-wrong { background: #fbe9ec; box-shadow: inset 0 0 0 2px #e79aab; color: #b0485f; }
@media (max-width: 520px) { body.rd-app .rd-letters { padding-left: 0; } }

/* ---------- after marking: why ---------- */
body.rd-app .rd-review { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 16px; background: #f6f6f7; font-size: 14.5px; line-height: 1.6; }
body.rd-app .rd-review[hidden] { display: none; }
body.rd-app .rd-rv-verdict { display: flex; gap: 6px; align-items: center; margin: 0; font-weight: 800; }
body.rd-app .rd-rv-verdict .material-symbols-outlined { --icon-size: 20px; font-size: 20px; }
body.rd-app .rd-rv-verdict.is-right { color: #2f7a52; }
body.rd-app .rd-rv-verdict.is-wrong { color: #b0485f; }
body.rd-app .rd-rv-verdict.is-blank { color: #8a8a93; }
body.rd-app .rd-rv-line { display: flex; gap: 10px; margin: 0; color: #33333d; }
body.rd-app .rd-rv-line b { flex: none; min-width: 64px; color: #8a8a93; font-weight: 600; }
body.rd-app .rd-rv-line:not(.is-mine) span { color: #2f7a52; font-weight: 700; }
body.rd-app .rd-rv-line.is-mine span { color: #b0485f; }
body.rd-app .rd-rv-ev { margin: 2px 0 0; padding: 10px 12px; border-left: 3px solid #f0d36b; border-radius: 4px 12px 12px 4px; background: #fffbea; color: #4a4a57; font-style: italic; }
body.rd-app .rd-rv-ev-label { display: block; margin-bottom: 2px; color: #8a6d00; font-size: 12px; font-style: normal; font-weight: 700; }
body.rd-app .rd-rv-see {
    display: inline-flex; gap: 4px; align-items: center; margin: 8px 0 0; padding: 5px 10px; border: 0; border-radius: 999px;
    background: #fff; box-shadow: inset 0 0 0 1px #eadfae; color: #6b5300; font: inherit; font-size: 12.5px; font-style: normal; font-weight: 700; cursor: pointer;
}
body.rd-app .rd-rv-see .material-symbols-outlined { --icon-size: 16px; font-size: 16px; }
body.rd-app .rd-rv-ex { margin: 0; color: #33333d; }

/* ---------- a gap's picker: a sheet from the bottom on phones, a box in the middle on wide screens ---------- */
body.rd-app .rd-pick { position: fixed; inset: 0; z-index: 1200; }
body.rd-app .rd-pick[hidden] { display: none; }
body.rd-app .rd-pick-backdrop { position: absolute; inset: 0; background: rgba(20, 20, 26, 0.32); opacity: 0; transition: opacity 0.22s ease; }
body.rd-app .rd-pick.is-open .rd-pick-backdrop { opacity: 1; }
body.rd-app .rd-pick-panel {
    position: absolute; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; gap: 10px;
    max-height: 82vh; padding: 8px 16px max(16px, env(safe-area-inset-bottom)); overflow-y: auto;
    border-radius: 24px 24px 0 0; background: #fff; transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
body.rd-app .rd-pick.is-open .rd-pick-panel { transform: none; }
body.rd-app .rd-pick .pa-sheet-handle { align-self: center; }
body.rd-app .rd-pick-head { display: flex; align-items: center; justify-content: space-between; }
body.rd-app .rd-pick-head h2 { margin: 0; color: #23232b; font-size: 17px; font-weight: 800; }
body.rd-app .rd-pick-list { display: flex; flex-direction: column; gap: 8px; }
body.rd-app .rd-pick-list[hidden] { display: none; }
body.rd-app .rd-pick-opt {
    display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 12px 14px; border: 0; border-radius: 14px;
    background: #fff; box-shadow: inset 0 0 0 1.5px #e8e8e8; color: #33333d; font: inherit; font-size: 15px; line-height: 1.55; text-align: left; cursor: pointer;
    transition: transform 0.12s ease, background-color 0.18s ease;
}
body.rd-app .rd-pick-opt:active:not(:disabled) { transform: scale(0.98); }
body.rd-app .rd-pick-opt .rd-letter-badge { margin-top: -1px; }
body.rd-app .rd-pick-opt.is-on { background: #fff0e6; box-shadow: none; color: #8a4116; }
body.rd-app .rd-pick-opt.is-on .rd-letter-badge { background: #f2a07b; color: #fff; box-shadow: none; }
body.rd-app .rd-pick-opt:disabled { cursor: default; }
body.rd-app .rd-pick-opt.is-correct { background: #e6f4ec; box-shadow: none; color: #2f7a52; }
body.rd-app .rd-pick-opt.is-correct .rd-letter-badge { background: #3f9a68; color: #fff; box-shadow: none; }
body.rd-app .rd-pick-opt.is-wrong { background: #fbe9ec; box-shadow: none; color: #b0485f; }
body.rd-app .rd-pick-opt.is-wrong .rd-letter-badge { background: #d0607a; color: #fff; box-shadow: none; }
body.rd-app .rd-pick-text { flex: 1; min-width: 0; }
body.rd-app .rd-pick-clear { align-self: center; padding: 8px 14px; border: 0; border-radius: 999px; background: none; color: #8a8a93; font: inherit; font-size: 14px; cursor: pointer; }
body.rd-app .rd-pick-clear[hidden] { display: none; }
@media (min-width: 721px) {
    body.rd-app .rd-pick-panel {
        top: 50%; right: auto; bottom: auto; left: 50%; width: min(520px, calc(100vw - 48px)); max-height: 80vh; padding: 14px 20px 20px;
        border-radius: 24px; opacity: 0; transform: translate(-50%, -48%) scale(0.98); transition: opacity 0.2s ease, transform 0.22s ease;
    }
    body.rd-app .rd-pick.is-open .rd-pick-panel { opacity: 1; transform: translate(-50%, -50%); }
    body.rd-app .rd-pick .pa-sheet-handle { display: none; }
}

/* ---------- the question sheet: one row of numbers per Part ---------- */
body.rd-app .rd-nav-parts { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
body.rd-app .rd-nav-part p { margin: 0 0 8px; color: #8a8a93; font-size: 13px; font-weight: 700; }
body.rd-app .rd-nav-part.is-locked p::after { content: " 🔒"; }
body.rd-app .rd-nav-part .paper-nav-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
body.rd-app .paper-nav-cell.is-cur { box-shadow: inset 0 0 0 2px #23232b; }

/* ---------- phones: 看文章 ↔ 去答题 ---------- */
body.rd-app .rd-jump {
    position: fixed; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 30; display: inline-flex; gap: 6px; align-items: center;
    height: 38px; padding: 0 14px 0 12px; border: 0; border-radius: 999px; background: #23232b; color: #fff;
    font: inherit; font-size: 13.5px; font-weight: 700; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16); cursor: pointer;
}
body.rd-app .rd-jump[hidden] { display: none; }
body.rd-app .rd-jump .material-symbols-outlined { --icon-size: 18px; font-size: 18px; }
body.rd-app.pa-result .rd-jump { display: none; }

/* The result's rows say the Part, not a number. */
body.rd-app .rd-row-part { min-width: 58px; width: auto; padding: 0 8px; white-space: nowrap; }
body.rd-app .rd-locked { margin-top: 8px; }

@media (max-width: 720px) {
    body.rd-app .rd-text,
    body.rd-app .rd-items { margin: 0 -6px; padding: 16px 14px; border-radius: 16px; }
    body.rd-app .rd-body { font-size: 15.5px; }
}

@media (prefers-reduced-motion: reduce) {
    body.rd-app .rd-part.rd-in-next,
    body.rd-app .rd-part.rd-in-prev,
    body.rd-app mark.rd-ev.is-flash,
    body.rd-app .rd-q.rd-flash { animation: none !important; }
    body.rd-app .rd-pick-panel,
    body.rd-app .rd-pick-backdrop { transition: none !important; }
}

/* The question's pieces in order (paper-ui-a.css gives .paper-options order 3). */
body.rd-app .rd-q > .rd-stim { order: 1; }
body.rd-app .rd-q > .rd-q-head { order: 2; }
body.rd-app .rd-q > .rd-options,
body.rd-app .rd-q > .rd-letters { order: 3; }
body.rd-app .rd-q > .rd-review { order: 4; }
body.rd-app .wp-row-num.rd-row-part::before { content: none; }
