/* A speaking topic page (practice/speaking_topic.html): itongzhuo's topic
   layout (drawer tab, PART badge, accordion, answer tabs, recorder, bottom
   question player) in dearKiwi's card style and colours. */
.sp { max-width: 900px; margin: 0 auto; position: relative; }
.sp-crumbs { font-size: .86rem; color: var(--muted); margin-bottom: 10px; }
.sp-crumbs a { color: var(--muted); }
.sp-card { padding: 22px 26px 0; overflow: hidden; }

.sp-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sp-head h1 { margin: 0; font-size: clamp(1.3rem, 2.4vw, 1.7rem); letter-spacing: -0.02em; }
.sp-part { font-size: .7rem; font-weight: 800; letter-spacing: .08em; color: var(--second); background: #f1efeb; border-radius: 6px; padding: 4px 9px; }
.sp-head-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.sp-switch { display: inline-flex; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; }
.sp-switch button { background: #fff; color: var(--muted); box-shadow: none; border-radius: 0; padding: 7px 14px; font-size: .85rem; }
.sp-switch button.on { background: var(--second); color: #fff; }
.sp-switch button:hover { transform: none; opacity: 1; }
.sp-switch button:disabled { opacity: .4; cursor: default; }
.sp-print { padding: 7px 14px; font-size: .85rem; }

/* Questions accordion */
.sp-q { border-top: 1px solid rgba(15,23,42,0.08); }
.sp-q:first-child { border-top: none; }
.sp-q-head { display: flex; width: 100%; align-items: center; gap: 12px; justify-content: space-between; text-align: left;
    background: none; color: var(--second); box-shadow: none; padding: 14px 4px; font-weight: 700; font-size: 1rem; border-radius: 0; }
.sp-q-head:hover { transform: none; opacity: 1; color: var(--primary); }
.sp-chev { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 7px solid var(--muted); flex: 0 0 auto; transition: transform .15s; }
.sp-q.open .sp-chev { transform: rotate(180deg); }
.sp-q.playing > .sp-q-head, .sp-q.playing .sp-cue { color: var(--primary); }
.sp-q-body { padding: 0 0 18px; }
.sp-p3-note { margin: 0 0 6px; font-size: .9rem; }

.sp-cue { background: #faf8f4; border: 1.5px solid var(--border); border-radius: 12px; padding: 16px 20px; margin: 4px 0 14px; line-height: 1.6; }
.sp-cue p { margin: 0 0 4px; }
.sp-cue ul { margin: 0 0 4px; padding-left: 22px; }
.sp-cue-prompt { font-weight: 800; font-size: 1.05rem; color: var(--second); }

/* Answer tabs */
.sp-ans { background: #faf8f4; border-radius: 12px; padding: 4px 16px 14px; }
.sp-tabs { display: flex; gap: 18px; border-bottom: 1px solid rgba(15,23,42,0.08); margin-bottom: 12px; }
.sp-tabs button { background: none; box-shadow: none; color: var(--muted); padding: 10px 0 8px; border-radius: 0; font-size: .86rem; border-bottom: 2.5px solid transparent; }
.sp-tabs button:hover { transform: none; opacity: 1; color: var(--second); }
.sp-tabs button.on { color: var(--second); border-bottom-color: var(--primary); }
.sp-kw { margin: 0 0 8px; font-size: .9rem; color: var(--second); }
.sp-text { margin: 0 0 10px; line-height: 1.7; color: var(--text); }
.sp-empty { margin: 4px 0; font-size: .9rem; }
.sp-listen { background: #fff; color: var(--primary-darker); border: 1.5px solid rgba(24,165,88,0.35); box-shadow: none; padding: 5px 12px; font-size: .8rem; }
.sp-listen:hover { color: var(--primary-darker); transform: none; }
.sp-notes { min-height: 90px; font-size: .92rem; }
.sp-notes-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: .8rem; }
.sp-notes-clear { background: none; color: var(--muted); box-shadow: none; padding: 2px 4px; font-size: .8rem; }
.sp-notes-clear:hover { color: var(--danger); transform: none; }

/* Recorder */
.sp-rec { margin-top: 12px; background: #faf8f4; border-radius: 12px; padding: 14px 16px; text-align: center; }
.sp-rec-main { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sp-mic { width: 46px; height: 46px; border-radius: 50%; padding: 0; display: grid; place-items: center;
    background: linear-gradient(135deg, #f0624f, var(--accent)); box-shadow: 0 6px 16px rgba(233,49,32,0.28); }
.sp-mic svg { width: 22px; height: 22px; fill: #fff; color: #fff; }
.sp-rec.recording .sp-mic { animation: sp-pulse 1.2s infinite; }
.sp-rec.recording .sp-mic svg rect { rx: 1; }
@keyframes sp-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(233,49,32,0.45); } 50% { box-shadow: 0 0 0 10px rgba(233,49,32,0); } }
.sp-rec-label { font-size: .84rem; color: var(--second); font-variant-numeric: tabular-nums; }
.sp-prep { padding: 6px 12px; font-size: .8rem; margin-top: 2px; }
.sp-takes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.sp-take { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; }
.sp-take span { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.sp-take audio { flex: 1; height: 34px; min-width: 0; }
.sp-take button { background: none; box-shadow: none; color: var(--muted); padding: 2px 6px; font-size: .8rem; }
.sp-take button:hover { color: var(--danger); transform: none; }
.sp-rec-msg { font-size: .84rem; color: var(--danger); margin: 6px 0 0; }

/* Bottom question player (itongzhuo plays the examiner audio; we read aloud) */
.sp-player { margin: 18px -26px 0; border-top: 1px solid rgba(15,23,42,0.08); background: #fbfaf8; position: sticky; bottom: 0; z-index: 5; }
.sp-progress { height: 3px; background: #e7e4df; }
.sp-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.sp-player-row { display: flex; align-items: center; gap: 14px; padding: 10px 18px; flex-wrap: wrap; }
.sp-ctrls { display: flex; align-items: center; gap: 6px; }
.sp-ctrls button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: #ece9e4; color: var(--second); box-shadow: none; }
.sp-ctrls button:hover { transform: none; opacity: 1; background: #e2ded7; color: var(--second); }
.sp-ctrls svg { width: 16px; height: 16px; fill: currentColor; }
.sp-ctrls .sp-play { width: 38px; height: 38px; background: var(--second); color: #fff; }
.sp-ctrls .sp-play:hover { background: #000; color: #fff; }
.sp-play .i-stop, .sp-play.playing .i-play { display: none; }
.sp-play.playing .i-stop { display: block; }
.sp-now { flex: 1; min-width: 160px; font-size: .86rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-opt { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: .8rem; font-weight: 600; color: var(--muted); }
.sp-opt select { width: auto; padding: 3px 6px; border-radius: 6px; font-size: .8rem; }
.sp-vol input { width: 80px; }
.sp-no-tts { padding: 0 18px 10px; margin: 0; font-size: .8rem; }

/* Topic drawer */
.sp-drawer-tab { position: fixed; left: 0; top: 40%; z-index: 40; writing-mode: vertical-rl; padding: 12px 7px; border-radius: 0 10px 10px 0;
    background: #fff; color: var(--second); border: 1.5px solid var(--border); border-left: none; box-shadow: 0 6px 18px rgba(0,0,0,0.08); font-size: .84rem; }
.sp-drawer-tab:hover { color: var(--primary); transform: none; opacity: 1; }
.sp-drawer { position: fixed; left: 0; top: 0; bottom: 0; width: min(380px, 92vw); z-index: 600; background: #fff;
    box-shadow: 8px 0 40px rgba(0,0,0,0.16); padding: 18px 18px 24px; overflow-y: auto; }
.sp-drawer[hidden] { display: none; }
.sp-drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sp-drawer-tabs { display: flex; gap: 6px; }
.sp-drawer-tabs button { background: #f1efeb; color: var(--second); box-shadow: none; padding: 6px 12px; font-size: .82rem; border-radius: 999px; }
.sp-drawer-tabs button.on { background: var(--second); color: #fff; }
.sp-drawer-tabs button:hover { transform: none; opacity: 1; }
.sp-drawer-close { background: none; box-shadow: none; color: var(--muted); font-size: 1.6rem; padding: 0 4px; line-height: 1; }
.sp-drawer-close:hover { color: var(--text); transform: none; }
.sp-drawer-search { margin: 0 0 12px; width: 100%; }
.sp-drawer-list { display: flex; flex-direction: column; }
.sp-drawer-list[hidden] { display: none; }
.sp-drawer-list a { padding: 9px 10px; border-radius: 8px; color: var(--second); font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.sp-drawer-list a:hover { background: rgba(24,165,88,0.07); text-decoration: none; }
.sp-drawer-list a.on { background: rgba(24,165,88,0.12); color: var(--primary-darker); font-weight: 700; }
.sp-drawer-list a.is-hidden { display: none; }

@media (max-width: 640px) {
    .sp-card { padding: 16px 14px 0; }
    .sp-player { margin: 14px -14px 0; }
    .sp-head-right { margin-left: 0; width: 100%; }
    .sp-drawer-tab { top: auto; bottom: 120px; }
    .sp-vol { display: none; }
}

/* Export PDF = print: every question and both sample answers, no controls. */
@media print {
    .topnav, .site-footer, .messages, .sp-drawer-tab, .sp-drawer, .sp-player, .sp-rec, .sp-tabs,
    .sp-head-right, .sp-crumbs, .sp-listen, .sp-pane[data-pane="notes"] { display: none !important; }
    body { background: #fff !important; }
    .card.sp-card { box-shadow: none; border: none; backdrop-filter: none; }
    .sp-view, .sp-q-body, .sp-pane { display: block !important; }
    .sp-pane[data-pane="advanced"]::before { content: "Advanced answer"; display: block; font-weight: 700; margin: 6px 0 4px; }
    .sp-pane[data-pane="basic"]::before { content: "Sample answer"; display: block; font-weight: 700; margin: 6px 0 4px; }
    .sp-chev { display: none; }
    .sp-q { break-inside: avoid; }
}

/* Scoring: the chosen take per question, and the submit card. */
.sp-take.chosen { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(24,165,88,.15); }
.sp-take .sp-use { color: var(--primary); font-weight: 600; }
.sp-take.chosen .sp-use { color: var(--primary); cursor: default; }
.sp-submit { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 22px 0 0; padding: 16px 18px;
  border-radius: 14px; background: rgba(24,165,88,.07); border: 1px solid rgba(24,165,88,.22); }
.sp-submit-txt { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.sp-submit-txt span { font-size: .86rem; color: var(--muted); }
.sp-submit .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.sp-submit-msg { flex-basis: 100%; margin: 0; font-size: .86rem; color: var(--danger); }
