/* Practice workspace (focus mode): runs practice, review and lab sessions.
   The .pr-page / .pr-top / .pr-strip / .pr-foot / .pr-split / .pr-q shell is shared with the result page. */
.pr-missing { padding: 40px 20px; }
body.focus-mode { min-height: 0; }

.pr-page {
  --pr-fs: 15px;
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar));
  background: #fff;
}

/* ---------- Top bar ---------- */
.pr-top {
  display: flex; align-items: center; gap: 14px; flex: none; min-height: 52px;
  padding: 6px 20px; background: #fff; border-bottom: 1px solid var(--line); z-index: 5;
}
.pr-back {
  flex: none; border: 0; background: none; padding: 4px 14px 4px 0; cursor: pointer;
  color: var(--muted); font-size: 13px; border-right: 1px solid var(--line); white-space: nowrap;
}
a.pr-back { display: inline-flex; align-items: center; }
.pr-back:hover { color: var(--brand-600); }
.pr-titles { min-width: 0; max-width: 340px; line-height: 1.3; }
.pr-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-top .spacer { min-width: 4px; }

.pr-status {
  flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pr-status > i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.pr-status b { font-weight: 500; color: var(--muted); }
.pr-status.paused > i { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-50); }
.pr-status.is-lab { padding: 4px 10px; border-radius: 999px; background: var(--brand-50); color: var(--brand-600); }
.pr-status.is-lab b { font-size: 15px; font-weight: 700; color: var(--brand-600); }
.pr-status.urgent { background: var(--danger-50); color: var(--danger); }
.pr-status.urgent > i { background: var(--danger); box-shadow: 0 0 0 3px #f9d6d2; }
.pr-status.urgent b { color: var(--danger); animation: pr-blink 1s steps(2) infinite; }
@keyframes pr-blink { 50% { opacity: 0.55; } }

/* Font size control */
.pr-font { flex: none; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; height: 28px; }
.pr-font-btn { border: 0; background: none; width: 26px; height: 100%; cursor: pointer; color: var(--muted); font-size: 14px; }
.pr-font-btn:hover { color: var(--brand-600); background: var(--brand-50); }
.pr-font-btn:first-child { border-radius: 7px 0 0 7px; }
.pr-font-btn:last-child { border-radius: 0 7px 7px 0; }
.pr-font-aa { padding: 0 4px; font-size: 13px; color: var(--text); }

/* Audio controls in the bar */
.pr-audio-slot { min-width: 0; display: flex; }
.pr-audio-slot:empty { display: none; }
.pr-audio { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pr-ab {
  flex: none; height: 28px; min-width: 28px; padding: 0 6px; border-radius: 50%; border: 1px solid transparent; background: none;
  cursor: pointer; color: var(--text); font-size: 15px; line-height: 1;
}
.pr-ab:hover { background: var(--bg); }
.pr-ab-play { border-color: var(--line); font-size: 11px; }
.pr-ab-play.on { border-color: var(--brand); color: var(--brand-600); background: var(--brand-50); }
.pr-aspeed { border-radius: 6px; background: var(--bg); font-size: 11.5px; font-weight: 600; min-width: 40px; color: var(--muted); }
.pr-aprog { position: relative; width: clamp(80px, 16vw, 220px); height: 4px; border-radius: 999px; background: var(--line); cursor: pointer; }
.pr-aprog::before { content: ""; position: absolute; inset: -8px 0; }
.pr-aprog > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width 0.3s; }
.pr-atime { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pr-aplay-once { height: 28px; }

/* ---------- Instruction strip ---------- */
.pr-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: none;
  padding: 8px 20px; background: #fbf9ef; border-bottom: 1px solid #efe9d2; font-size: 13px;
}
.pr-strip-l { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.pr-strip-l b { font-weight: 600; }
.pr-strip-l span { color: #5d5a48; }
.pr-strip-r { display: flex; align-items: center; gap: 12px; flex: none; }
.pr-lookup {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12.5px;
}
.pr-lookup.on { border-color: var(--brand); color: var(--brand-600); }
.pr-lookup:disabled { opacity: 0.5; cursor: not-allowed; }
.pr-lookup-manual[hidden] { display: none; }

/* ---------- Work area ---------- */
.pr-work { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pr-work.is-paused .pr-body { visibility: hidden; }
.pr-body { flex: 1; min-height: 0; overflow: auto; background: #fff; }
.pr-body.is-split { overflow: hidden; }
.pr-col { max-width: 860px; margin: 0 auto; padding: 22px 24px 48px; }

/* ---------- Split panes ---------- */
.pr-split { --pr-left: 52%; display: grid; grid-template-columns: var(--pr-left) 9px minmax(0, 1fr); height: 100%; }
.pr-pane { overflow: auto; min-width: 0; padding: 20px 28px 48px; }
.pr-pane-l { background: #fff; }
.pr-pane-r { background: #fff; }
.pr-pane-l .pr-passage { max-width: 760px; margin: 0 auto; }
.pr-divider {
  position: relative; cursor: col-resize; touch-action: none;
  background: #fafcfb; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
.pr-divider::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 3px; height: 36px; transform: translate(-50%, -50%);
  border-left: 1px solid #b9c7c2; border-right: 1px solid #b9c7c2;
}
.pr-divider:hover, .pr-divider.dragging { background: var(--brand-50); }

/* ---------- Passages and highlights ---------- */
.pr-page .passage p, .pr-page .pr-q-text, .pr-page .pr-ctx, .pr-page .pr-opt-t, .pr-page .pr-textarea, .pr-page .pr-bank-w { font-size: var(--pr-fs); }
.pr-passage-title { font-size: calc(var(--pr-fs) + 3px); margin-bottom: 14px; text-align: center; font-family: Georgia, "Times New Roman", serif; }
.pr-hl-tools { display: flex; align-items: center; gap: 4px; max-width: 760px; margin: 0 auto 10px; }
.pr-tool { border: 0; background: none; padding: 3px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 12px; }
.pr-tool:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.pr-tool:disabled { opacity: 0.45; cursor: default; }
.pr-passage[data-hl] { cursor: text; }
mark.pr-hl { background: #fff0a8; color: inherit; border-radius: 2px; padding: 0 1px; cursor: pointer; transition: filter 0.12s; }
mark.pr-hl:hover { filter: brightness(0.95); }
mark.pr-hl-ul { background: transparent; border-bottom: 2px solid var(--brand); border-radius: 0; padding-bottom: 1px; }
mark.pr-hl-note { background: #eaf6f1; border-bottom: 2px dashed var(--brand-600); }
mark.pr-hl-note::after { content: "✎"; font-size: 11px; color: var(--brand-600); margin-left: 2px; vertical-align: super; font-family: -apple-system, sans-serif; }
.pr-sel-pop {
  position: absolute; z-index: 40; display: flex; flex-direction: column; gap: 6px;
  padding: 6px 8px; border-radius: 10px; background: #1d2a26; color: #fff;
  box-shadow: 0 8px 24px rgba(16, 40, 32, 0.24); max-width: 320px;
}
.pr-sel-pop[hidden] { display: none; }
.pr-sel-pop:not(:has(.pr-sel-row)) { flex-direction: row; align-items: center; gap: 4px; }
.pr-sel-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pr-sel-note { font-size: 12px; line-height: 1.5; color: #dff2ea; padding: 2px 4px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.14); word-break: break-word; }
.pr-sel-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px;
  border: 0; border-radius: 6px; background: transparent; color: #fff; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.pr-sel-btn:hover, .pr-sel-btn.active { background: rgba(255, 255, 255, 0.16); }
.pr-sel-btn.danger { color: #ffb3ab; }
.pr-sel-btn.danger:hover { background: rgba(212, 72, 59, 0.32); color: #fff; }
.pr-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.pr-dot-hl { background: #ffe46b; }
.pr-dot-ul { border-bottom: 2.5px solid #52d1a8; height: 8px; border-radius: 0; }
.pr-note-quote { margin: 0; padding: 8px 12px; border: 1px solid var(--line); background: #fafcfb; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.pr-amute.on { color: var(--danger); background: var(--danger-50); }
.pr-para-label {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-right: 8px;
  border-radius: 6px; background: var(--brand-50); color: var(--brand-600); font-family: -apple-system, sans-serif; font-size: 13px;
}
.pr-bank-passage p { line-height: 2.3; }
.pr-gap { display: inline-block; padding: 0 4px; color: var(--muted); font-family: -apple-system, sans-serif; font-size: 13px; }
.pr-gap.hit { background: var(--warn-50); color: #9a5f05; border-radius: 4px; font-weight: 600; }

/* ---------- Word bank ---------- */
.pr-bank {
  position: sticky; top: 8px; z-index: 3; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px 8px;
  padding: 12px 14px; margin-bottom: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.pr-bank-static { position: static; box-shadow: none; }
.pr-bank-w { display: flex; align-items: baseline; gap: 6px; padding: 3px 6px; border-radius: 6px; font-family: Georgia, "Times New Roman", serif; font-size: 14px; transition: 0.15s; }
.pr-bank-w b { flex: none; width: 14px; font-family: -apple-system, sans-serif; font-size: 12px; color: var(--brand-600); }
.pr-bank-w.used { color: var(--muted); background: var(--bg); text-decoration: line-through; text-decoration-color: #b9c7c2; }
.pr-bank-w.used b { color: var(--muted); }
.pr-blank {
  height: 30px; max-width: 170px; padding: 0 6px; margin: 0 2px; vertical-align: baseline;
  font-family: Georgia, "Times New Roman", serif; font-size: 14px; background: var(--brand-50); border-color: var(--brand-100); color: var(--muted);
}
.pr-blank.filled { background: #fff; border-color: var(--brand); color: var(--brand-600); }

/* ---------- Questions ---------- */
.pr-qs { display: flex; flex-direction: column; }
.pr-q { padding: 14px 0; border-bottom: 1px dashed var(--line); scroll-margin: 90px; border-radius: 8px; }
.pr-q:last-child { border-bottom: 0; }
.pr-q-stem { display: flex; gap: 10px; align-items: flex-start; }
.pr-no {
  flex: none; min-width: 26px; height: 26px; padding: 0 6px; margin-top: 1px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; transition: 0.15s;
}
.pr-q.answered .pr-no { background: var(--brand); color: #fff; }
.pr-q-text { font-size: 15px; line-height: 1.65; padding-top: 1px; }
.pr-ctx { font-size: 15px; line-height: 2.2; }
.pr-opts { display: grid; gap: 6px; padding-left: 36px; margin-top: 10px; }
.pr-opt {
  position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.pr-opt:hover { border-color: var(--brand-100); background: #fbfdfc; }
.pr-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pr-opt-l {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--muted); transition: 0.15s;
}
.pr-opt-t { font-size: 14.5px; line-height: 1.55; }
.pr-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.pr-opt:has(input:checked) .pr-opt-l { background: var(--brand); border-color: var(--brand); color: #fff; }
.pr-opt input:focus-visible + .pr-opt-l { outline: 2px solid var(--brand); outline-offset: 2px; }
.pr-match-pick { display: flex; align-items: center; gap: 8px; padding-left: 36px; margin-top: 10px; }
.pr-sel { height: 32px; min-width: 120px; }
.pr-sel.filled { border-color: var(--brand); color: var(--brand-600); background: var(--brand-50); font-weight: 600; }
.pr-flash { animation: pr-flash 1.4s ease-out; }
@keyframes pr-flash { 0%, 30% { background: var(--warn-50); box-shadow: 0 0 0 6px var(--warn-50); } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }

/* ---------- Listening ---------- */
.pr-item { padding: 14px 18px 6px; border: 1px solid var(--line); border-radius: var(--radius); transition: border-color 0.2s, box-shadow 0.2s; }
.pr-item + .pr-item { margin-top: 14px; }
.pr-item.playing { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.pr-item-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pr-item-head h3 { font-size: 16px; }
.pr-player {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; margin: 12px 0 4px; border-radius: 10px; background: var(--brand-50); border: 1px solid var(--brand-100);
}
.pr-player audio { width: 100%; height: 40px; }
.pr-play { min-width: 96px; }
.pr-prog { flex: 1; min-width: 140px; display: flex; align-items: center; gap: 10px; }
.pr-prog .bar { flex: 1; background: #fff; }

/* ---------- Writing / translation ---------- */
.pr-src { max-width: 640px; }
.pr-src-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-size: 14px; }
.pr-zh { font-size: 15.5px; line-height: 2; letter-spacing: 0.02em; }
.pr-prompt p { margin: 0; }
.pr-editor { display: flex; flex-direction: column; height: 100%; min-height: 360px; }
.pr-textarea { flex: 1; min-height: 300px; font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.8; border-color: var(--line); background: #fcfdfd; resize: none; }
.pr-editor-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.pr-wc { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.pr-wc.ok { color: var(--ok); }
.pr-wc.low { color: var(--warn); }
.pr-wc.over { color: var(--danger); }
.pr-count:not(:empty) { margin-left: 4px; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand-50); color: var(--brand-600); font-size: 11px; line-height: 18px; }
.pr-drafts { border: 1px solid var(--line); border-radius: 10px; }
.pr-draft-meta { display: flex; flex-direction: column; flex: none; width: 150px; font-size: 13px; }
.pr-draft-text { flex: 1; min-width: 0; font-family: Georgia, "Times New Roman", serif; color: var(--muted); font-size: 13px; }

/* ---------- Review ---------- */
.pr-group + .pr-group { margin-top: 28px; }
.pr-group-title { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.pr-rcard { padding: 16px 20px 8px; }
.card.pr-rcard + .card.pr-rcard { margin-top: 12px; }
.pr-rcard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pr-rcard .pr-q { border-bottom: 0; }
.pr-src-modal .passage p { font-size: 15px; }
.pr-src-title { font-size: 16px; margin: 4px 0 12px; }
.pr-src-player { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.pr-src-player audio { width: 100%; }
.pr-script p { padding: 4px 8px; margin: 0 0 4px; border-radius: 6px; transition: background 0.2s; }
.pr-script p.on { background: var(--brand-50); }
.pr-spk { font-family: -apple-system, sans-serif; font-weight: 600; font-size: 12px; color: var(--brand-600); margin-right: 8px; }

/* ---------- Bottom bar ---------- */
.pr-foot { display: flex; align-items: center; gap: 16px; padding: 8px 20px; background: #fff; border-top: 1px solid var(--line); flex: none; z-index: 5; }
.pr-nav { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; max-height: 76px; overflow: auto; }
.pr-nav-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px; }
.pr-nav-label {
  border: 0; background: none; padding: 0 6px 0 0; cursor: pointer; font-size: 12px; color: var(--text); white-space: nowrap;
}
button.pr-nav-label:hover { color: var(--brand-600); }
.pr-nav-label small { color: var(--muted); font-size: 11px; margin-left: 2px; font-variant-numeric: tabular-nums; }
.pr-nav-label.here { font-weight: 600; color: var(--brand-600); }
.pr-nav-btn {
  min-width: 26px; height: 26px; padding: 0 4px; border-radius: 6px; border: 1px solid transparent; background: none; cursor: pointer;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; transition: 0.15s;
}
.pr-nav-btn:hover { border-color: var(--line); color: var(--text); }
.pr-nav-btn.done { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
.pr-nav-btn.ok { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
.pr-nav-btn.bad { background: var(--danger-50); color: var(--danger); font-weight: 600; }
.pr-nav-btn.cur { border-color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); color: var(--brand-600); }
.pr-nav-btn.bad.cur { border-color: var(--danger); box-shadow: inset 0 -2px 0 var(--danger); color: var(--danger); }
.pr-foot-r { display: flex; align-items: center; gap: 8px; flex: none; }
.pr-foot-stats { display: inline-flex; align-items: center; gap: 12px; margin-right: 6px; }
.pr-foot-stats:empty { display: none; }
.pr-stat { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.pr-stat.warn b { color: var(--warn); font-size: 14px; }
.pr-stat.ok { color: var(--ok); }

/* ---------- Pause overlay ---------- */
.pr-pause {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(244, 247, 246, 0.86); backdrop-filter: blur(6px);
}
.pr-pause[hidden] { display: none; }
.pr-pause-card { text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 32px 44px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pr-pause-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-50); color: var(--brand-600); display: flex; align-items: center; justify-content: center; font-size: 16px; letter-spacing: -2px; }
.pr-pause-card h3 { font-size: 18px; }
.pr-pause-card .btn { margin-top: 8px; }

/* ---------- Medium screens: let the bar wrap ---------- */
@media (max-width: 1180px) {
  .pr-top { flex-wrap: wrap; row-gap: 6px; }
  .pr-audio-slot { order: 10; flex-basis: 100%; }
  .pr-aprog { flex: 1; width: auto; }
  .pr-audio { flex: 1; }
}

/* ---------- Narrow screens: single column, page scrolls ---------- */
@media (max-width: 860px) {
  .pr-page { height: auto; min-height: calc(100vh - var(--topbar)); }
  .pr-top { position: sticky; top: var(--topbar); padding: 8px 14px; gap: 10px; }
  .pr-titles { flex: 1; max-width: none; }
  .pr-sub { display: none; }
  .pr-top .spacer { display: none; }
  .pr-strip { flex-wrap: wrap; padding: 8px 14px; gap: 6px; }
  .pr-work { flex: none; }
  .pr-body, .pr-body.is-split { overflow: visible; }
  .pr-split { display: block; height: auto; }
  .pr-divider { display: none; }
  .pr-pane { overflow: visible; padding: 18px 14px; }
  .pr-pane-l { border-bottom: 1px solid var(--line); }
  .pr-col { padding: 16px 14px 24px; }
  .pr-bank { position: static; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pr-opts, .pr-match-pick { padding-left: 0; }
  .pr-q { scroll-margin: 150px; }
  .pr-foot { position: sticky; bottom: 0; flex-wrap: wrap; gap: 8px; padding: 8px 14px; }
  .pr-nav { flex-basis: 100%; max-height: 72px; }
  .pr-foot-r { width: 100%; }
  .pr-foot-r .btn { flex: 1; }
  .pr-pause { align-items: flex-start; padding-top: 60px; }
  .pr-pause-card { position: sticky; top: 180px; padding: 24px; }
  .pr-draft { flex-wrap: wrap; }
  .pr-draft-meta { width: auto; }
  .pr-editor { height: auto; }
}
