:root {
  --font-ui: Arial, Helvetica, sans-serif;
  --font-explanation: "Segoe UI", "Noto Sans", Arial, Helvetica, sans-serif;
  --text: #111111;
  --muted: #666666;
  --line: #c9c9c9;
  --line-soft: #dddddd;
  --surface: #f1f2ec;
  --surface-hover: #efefef;
  --blue: #418ec8;
  --blue-soft: #d7eaf7;
  --green: #2f9d63;
  --green-soft: #dff2e6;
  --red: #c63d4d;
  --red-soft: #fde4e4;
  --bookmark: #c12f49;
  --gray-answer: #a7a7a7;
  --footer-h: 58px;
  --topbar-h: 58px;
  --radius: 4px;
  --shadow-modal: 0 24px 70px rgba(0,0,0,.22);
}
* { box-sizing: border-box; }
html, body { width:100%; height:100%; margin:0; }
body { font-family:var(--font-ui); color:var(--text); background:#fff; overflow:hidden; }
button, input, select { font:inherit; }
button { color:inherit; }
::-webkit-scrollbar { width:17px; height:17px; }
::-webkit-scrollbar-thumb { background:#8a8a8a; border-radius:0; }
::-webkit-scrollbar-track { background:transparent; }
#app { width:100%; height:100%; }

.boot-screen,.fatal-screen,.start-screen { width:100%; height:100%; display:grid; place-items:center; padding:24px; background:#f7f7f7; }
.boot-card,.fatal-card,.start-card { width:min(780px,100%); background:#fff; border:1px solid #d6d6d6; border-radius:8px; padding:28px; }
.boot-card { display:grid; grid-template-columns:28px 1fr; gap:8px 14px; align-items:center; }
.boot-card span { grid-column:2; color:var(--muted); font-size:14px; }
.boot-spinner { width:24px; height:24px; border:3px solid #ddd; border-top-color:#222; border-radius:50%; animation:spin .8s linear infinite; grid-row:1/3; }
@keyframes spin { to { transform:rotate(360deg); } }
.fatal-card h1 { margin:6px 0 10px; font-size:24px; }
.fatal-card pre { overflow:auto; max-height:55vh; white-space:pre-wrap; background:#161616; color:#f1f1f1; padding:16px; border-radius:4px; font:13px/1.5 Consolas,monospace; }
.fatal-hint { color:#555; font-size:14px; }
.error-kicker { font-size:12px; font-weight:800; color:#b00020; letter-spacing:.08em; }

.start-card { display:grid; gap:18px; }
.start-brand { display:flex; align-items:center; gap:16px; border-bottom:1px solid #e4e4e4; padding-bottom:18px; }
.start-brand img { height:44px; width:auto; max-width:280px; object-fit:contain; }
.start-brand div { display:flex; flex-direction:column; gap:2px; }
.start-brand strong { font-size:13px; }
.start-brand span { font-size:11px; color:var(--muted); letter-spacing:.08em; }
.start-card h1 { margin:0; font-size:28px; }
.entry-heading { display:grid; gap:8px; }
.entry-heading p { margin:0; color:#444; line-height:1.55; }
.start-meta { display:grid; grid-template-columns:1fr auto; align-items:center; gap:12px; background:var(--surface); padding:14px; border:1px solid #d7d7d7; border-radius:4px; }
.start-meta small { color:var(--muted); display:block; margin-top:2px; }
.mode-picker { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.mode-card { border:1px solid #cfcfcf; border-radius:5px; padding:12px 14px; display:flex; align-items:flex-start; gap:10px; cursor:pointer; background:#fff; }
.mode-card:hover { border-color:#999; background:#fafafa; }
.mode-card.is-selected { border-color:var(--blue); box-shadow:0 0 0 2px rgba(65,142,200,.12); background:#f7fbfe; }
.mode-card input { margin-top:3px; accent-color:var(--blue); }
.mode-card span { display:flex; flex-direction:column; gap:2px; }
.mode-card small { color:var(--muted); line-height:1.35; }
.saved-mode { display:flex; align-items:center; gap:8px; border:1px solid #d7d7d7; background:#fafafa; padding:9px 12px; border-radius:4px; width:max-content; }
.saved-mode span { color:#777; font-size:12px; text-transform:uppercase; letter-spacing:.05em; }
.entry-rule { margin-top:5px !important; }
.start-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.autosave-note { color:#666; font-size:13px; }
.entry-buttons { margin-left:auto; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.entry-btn { min-width:150px; border:1px solid #aaa; background:#fff; color:#111; padding:11px 16px; border-radius:4px; cursor:pointer; font-weight:800; }
.entry-btn:hover { background:#f2f2f2; }
.entry-btn.primary { min-width:180px; background:#111; color:#fff; border-color:#111; }
.entry-btn.primary:hover { background:#000; }
.entry-btn.danger { background:#a72c38; color:#fff; border-color:#a72c38; }
.entry-btn.danger:hover { background:#922530; }
.entry-btn[disabled] { opacity:.6; cursor:wait; }
.entry-alert { border:1px solid #d69a9a; border-left:4px solid var(--red); background:#fff6f6; padding:12px 14px; border-radius:4px; display:grid; gap:5px; }
.entry-alert strong { color:#9d2531; }
.entry-alert p { margin:0; white-space:pre-wrap; line-height:1.45; font-size:13px; }
.entry-alert small { color:#666; line-height:1.45; }
.restart-confirm { border:1px solid #d7b757; background:#fff9e7; border-radius:4px; padding:13px 14px; display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.restart-confirm > div:first-child { display:grid; gap:3px; }
.restart-confirm span { color:#665f4a; font-size:13px; }
.restart-confirm-actions { display:flex; gap:8px; flex-wrap:wrap; margin-left:auto; }
.test-picker-label { min-height:38px; display:flex; align-items:center; gap:5px; border:1px solid #c8c8c8; border-radius:4px; padding:4px 7px; background:#fff; }
.test-picker-label > span { font-size:10px; color:#777; font-weight:800; text-transform:uppercase; letter-spacing:.05em; }
.test-picker-label select { border:none; outline:none; max-width:245px; background:transparent; font-size:13px; font-weight:600; }
.qa-warning { font-size:12px; line-height:1.5; border:1px solid #d7b757; background:#fff4ce; padding:10px 12px; border-radius:4px; }

.exam-shell { height:100%; display:grid; grid-template-rows:auto auto minmax(0,1fr) auto; background:#fff; font-weight:500; line-height:1.5; }
.topbar { min-height:var(--topbar-h); border-bottom:1px solid #c1c1c1; display:flex; align-items:center; gap:12px; padding:6px 14px; }
.brand-block { display:flex; align-items:center; flex:0 0 auto; min-width:0; }
.brand-logo { display:block; height:38px; width:auto; max-width:255px; object-fit:contain; }
.test-meta { display:flex; flex-direction:column; gap:0; min-width:180px; flex:0 1 auto; }
.test-meta strong { font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:30vw; }
.test-meta span { font-size:12px; color:#555; }
.header-player { flex:1 1 480px; min-width:260px; display:flex; align-items:center; gap:8px; }
.header-player.review-player { justify-content:center; color:#666; font-size:13px; }
.practice-audio-controls { display:flex; align-items:center; gap:4px; flex:0 0 auto; }
.compact-audio-btn { min-width:34px; height:32px; border:1px solid #c8c8c8; background:#fff; border-radius:4px; padding:0 7px; cursor:pointer; font-size:12px; font-weight:700; }
.compact-audio-btn:hover { background:#f1f1f1; border-color:#999; }
.compact-audio-btn.play-toggle { min-width:38px; font-size:15px; }
.header-track-wrap { min-width:160px; flex:1 1 auto; display:grid; grid-template-columns:minmax(100px,1fr) auto; align-items:center; gap:8px; }
.audio-track { height:6px; border-radius:999px; background:#e3e3e3; overflow:hidden; position:relative; }
.audio-progress { position:absolute; inset:0 auto 0 0; width:var(--progress,0%); background:#333; }
.audio-seek { width:100%; min-width:100px; accent-color:#333; cursor:pointer; }
.audio-time { font-variant-numeric:tabular-nums; font-size:11px; color:#555; white-space:nowrap; }
.volume-wrap { display:flex; align-items:center; gap:4px; font-size:12px; flex:0 0 auto; }
.volume-wrap input { width:72px; accent-color:#333; }
.review-countdown { font-variant-numeric:tabular-nums; font-weight:800; font-size:11px; white-space:nowrap; }
.top-actions { margin-left:auto; display:flex; align-items:center; gap:6px; min-width:0; flex:0 0 auto; }
.score-pill { min-height:34px; display:flex; align-items:center; gap:7px; border:1px solid #a9d6b8; background:#eff9f2; padding:4px 10px; border-radius:999px; white-space:nowrap; font-size:12px; }
.score-pill strong,.score-pill b { color:#166c39; font-size:14px; }
.score-pill span { color:#355c43; }
.part-banner { min-height:42px; border-bottom:1px solid #d5d5d5; background:var(--surface); padding:8px 18px; display:flex; align-items:center; gap:10px; }
.part-banner strong { font-size:16px; font-weight:900; white-space:nowrap; }
.part-banner span { font-size:14px; color:#222; }

.workspace { min-height:0; overflow:hidden; position:relative; padding:0 18px 12px; }
.question-scroll { position:absolute; inset:0; overflow-y:auto; overflow-x:hidden; scrollbar-gutter:stable; padding:0 22px 95px; }
.question-document { width:min(1260px,100%); margin:0 auto; }
.question-group { margin:0 0 34px; }
.group-header { margin:0 0 12px; }
.group-header h3 { font-size:16px; margin:0 0 6px; font-weight:800; }
.group-instruction { font-size:16px; line-height:1.45; }
.group-instruction strong { font-weight:900; }
.question-card { border-radius:4px; margin:0 0 14px; scroll-margin:90px 0; }
.question-head { display:grid; grid-template-columns:auto 1fr auto; gap:8px; align-items:start; margin:0 0 8px; }
.question-prompt { font-size:16px; padding-top:3px; }
.question-number { position:relative; min-width:34px; height:32px; padding:0 5px; background:#fff; border:1px solid transparent; border-radius:4px; font-weight:800; cursor:pointer; }
.question-number::before,.nav-q::before { content:''; position:absolute; left:2px; right:2px; top:-4px; height:3px; background:linear-gradient(to right,var(--green) var(--answer-progress,0%),#d2d2d2 var(--answer-progress,0%)); }
.question-number.is-current,.nav-q.is-current { border-color:var(--blue); box-shadow:0 0 0 1px var(--blue) inset; }
.bookmark-btn { border:0; background:transparent; width:30px; height:30px; cursor:pointer; color:#222; font-size:19px; line-height:1; border-radius:4px; }
.bookmark-btn.is-marked { color:var(--bookmark); }
.bookmark-btn:hover { background:#f3f3f3; }

.choice-list { display:grid; gap:1px; }
.choice-row { display:flex; align-items:center; gap:10px; min-height:42px; padding:8px 10px; cursor:pointer; border-radius:2px; transition:background .12s; }
.choice-row:hover { background:#e4e4e4; }
.choice-row.is-selected { background:var(--blue-soft); }
.choice-row input { margin:0; width:15px; height:15px; accent-color:var(--blue); }
.choice-row.is-correct { background:var(--green-soft); box-shadow:inset 4px 0 var(--green); }
.choice-row.is-wrong { background:var(--red-soft); box-shadow:inset 4px 0 var(--red); }
.is-review .choice-row { cursor:default; }

.completion-template { border:1px solid #777; padding:16px; line-height:2.05; font-size:16px; }
.completion-template h3 { margin:0 0 8px; }
.completion-template ul,.completion-template ol { margin:6px 0; padding-left:22px; }
.completion-template li { margin:6px 0; }
.table-wrap { overflow-x:auto; }
.completion-template table { width:100%; border-collapse:collapse; line-height:1.5; }
.completion-template th,.completion-template td { border:1px solid #777; padding:9px; vertical-align:middle; }
.flow-chart { display:grid; justify-items:center; gap:6px; }
.flow-box { border:1px solid #777; padding:10px 14px; min-width:260px; text-align:center; }
.slot-wrap { display:inline-flex; align-items:center; gap:3px; vertical-align:middle; scroll-margin:90px 0; }
.text-slot { width:var(--slot-width,150px); min-width:90px; max-width:230px; height:32px; border:1px solid #777; border-radius:4px; padding:3px 8px; text-align:center; background:#fff; outline:none; }
.text-slot:focus { border-color:var(--blue); box-shadow:0 0 0 2px rgba(65,142,200,.13); }
.text-slot::placeholder { color:#111; font-weight:800; opacity:1; }
.text-slot.review-correct,.bank-slot.review-correct { border-color:var(--green); background:var(--green-soft); color:#166d38; font-weight:700; }
.text-slot.review-wrong,.bank-slot.review-wrong { border-color:var(--red); background:var(--red-soft); color:#9e2222; font-weight:700; }
.text-slot.review-skipped,.bank-slot.review-skipped { border-color:#999; background:#f3f3f3; }
.short-answer-list { display:grid; gap:12px; }
.short-answer-row { display:grid; grid-template-columns:auto minmax(0,1fr) auto auto; align-items:center; gap:8px; scroll-margin:90px 0; }

.matching-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(280px,.7fr); gap:22px; align-items:start; }
.matching-rows { display:grid; gap:8px; }
.matching-row { display:grid; grid-template-columns:auto minmax(0,1fr) minmax(170px,.7fr) auto; gap:8px; align-items:center; padding:7px 0; scroll-margin:90px 0; }
.bank-slot { min-height:34px; min-width:120px; padding:5px 9px; border:1px dashed #b9c8d6; background:#fff; border-radius:4px; cursor:pointer; font-weight:700; text-align:left; }
.bank-slot.has-answer { border-style:solid; border-color:#99aec0; background:#f7fbfe; }
.bank-slot.is-current { box-shadow:0 0 0 2px rgba(65,142,200,.18); border-color:var(--blue); }
.slot-clear { width:25px; height:25px; border:0; border-radius:50%; background:#eee; cursor:pointer; }
.slot-bookmark { width:25px; height:25px; border:0; background:transparent; border-radius:4px; cursor:pointer; color:#222; }
.slot-bookmark.is-marked { color:var(--bookmark); }
.slot-bookmark:hover { background:#f1f1f1; }
.option-pool { border:1px solid #d6d6d6; padding:12px; background:#fafafa; position:sticky; top:0; }
.pool-title { font-weight:800; margin-bottom:5px; }
.pool-help { font-size:12px; color:#777; margin-bottom:8px; }
.pool-items { display:flex; flex-wrap:wrap; gap:7px; }
.pool-chip { border:1px solid #c9c9c9; background:#fff; border-radius:5px; padding:6px 9px; cursor:grab; }
.pool-chip:hover { border-color:var(--blue); }
.pool-chip.is-selected { border-color:var(--blue); box-shadow:0 0 0 2px rgba(65,142,200,.15); background:#f2f8fc; }
.pool-chip.is-used { opacity:.32; cursor:not-allowed; }

.spatial-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(250px,.45fr); gap:20px; align-items:start; }
.diagram-figure { margin:0; overflow-x:auto; }
.diagram-stage { position:relative; width:100%; min-width:620px; }
.diagram-image { width:100%; height:auto; display:block; border:1px solid #aaa; }
.diagram-slot { position:absolute; transform:translate(-50%,-50%); }
.diagram-slot .text-slot,.diagram-slot .bank-slot { width:100%; min-width:0; max-width:none; background:rgba(255,255,255,.97); }

.inline-review-stack { display:grid; gap:6px; margin-top:10px; }
.review-inline { display:flex; align-items:center; gap:14px; padding:8px 10px; border-radius:4px; font-size:13px; }
.review-inline > div { display:flex; flex-direction:column; }
.review-inline.is-correct { background:var(--green-soft); color:#1b6638; }
.review-inline.is-wrong { background:var(--red-soft); }
.review-inline.is-skipped { background:#f2f2f2; }
.review-label { color:#666; font-size:11px; text-transform:uppercase; letter-spacing:.04em; }
.correct-text { color:#16723a; }
.wrong-text { color:#a32121; }
.explain-btn { margin-left:auto; border:1px solid #b63737; background:#fff; color:#9b2424; border-radius:4px; padding:5px 9px; cursor:pointer; }
.explain-btn:hover { background:#fff6f6; }

.floating-nav { position:absolute; right:22px; bottom:15px; display:flex; gap:8px; z-index:4; }
.floating-nav button { width:54px; height:50px; border:0; border-radius:3px; background:#555; color:#fff; font-size:27px; cursor:pointer; }
.floating-nav .next { background:#000; }
.bottom-nav { min-height:var(--footer-h); border-top:1px solid #ddd; background:#f6f8fa; display:flex; align-items:stretch; }
.part-tabs { min-width:0; flex:1; display:flex; align-items:stretch; overflow-x:auto; }
.part-tab { border:0; background:transparent; min-width:170px; padding:0 18px; display:flex; align-items:center; gap:8px; cursor:pointer; border-right:1px solid #e4e4e4; }
.part-tab:hover { background:var(--surface-hover); }
.part-tab span { color:#555; }
.active-part { display:flex; align-items:center; gap:2px; padding:0 14px; white-space:nowrap; }
.active-part > strong { margin-right:14px; }
.nav-q { position:relative; min-width:30px; height:34px; border:1px solid transparent; border-radius:4px; background:transparent; cursor:pointer; padding:0 5px; }
.nav-q.is-bookmarked::after { content:'◆'; position:absolute; top:-15px; left:50%; transform:translateX(-50%); color:var(--bookmark); font-size:8px; }
.is-review .nav-q.review-correct::before { background:var(--green); }
.is-review .nav-q.review-wrong::before { background:var(--red); }
.is-review .nav-q.review-skipped::before { background:#aaa; }
.submit-btn { width:64px; border:0; border-left:1px solid #ddd; background:#f7f7f7; font-size:26px; cursor:pointer; }
.submit-btn:hover { background:#efefef; }

.modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.36); display:grid; place-items:center; z-index:30; padding:20px; }
.explanation-modal { position:relative; width:min(860px,100%); max-height:88vh; overflow:auto; background:#fff; border-radius:8px; box-shadow:var(--shadow-modal); padding:24px; font-family:var(--font-explanation); }
.explanation-modal * { font-family:var(--font-explanation); }
.modal-close { position:absolute; right:14px; top:12px; width:34px; height:34px; border:0; background:transparent; font-size:28px; cursor:pointer; }
.modal-kicker { color:#777; font-size:12px; text-transform:uppercase; letter-spacing:.08em; font-weight:800; }
.explanation-modal h2 { margin:5px 0 18px; }
.explain-answer-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:16px; }
.explain-answer-grid > div { border:1px solid #ddd; padding:10px; border-radius:4px; display:flex; flex-direction:column; }
.explain-answer-grid span { color:#777; font-size:12px; margin-bottom:3px; }
.explain-section { margin-top:18px; border-top:1px solid #ddd; padding-top:15px; }
.explain-section h3 { margin:0 0 10px; font-size:16px; }
.explain-steps { margin:0; padding-left:22px; }
.explain-steps li { margin:8px 0; line-height:1.55; }
.paraphrase-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.paraphrase-grid > div { border:1px solid #ddd; padding:9px; border-radius:4px; }
.distractor-card { padding:9px 11px; border-left:3px solid #aaa; background:#f8f8f8; margin:7px 0; }
.evidence-card { border:1px solid #dbe5ed; background:#f6fafc; padding:12px; border-radius:5px; margin:8px 0; }
.evidence-actions { display:flex; justify-content:space-between; gap:10px; align-items:center; flex-wrap:wrap; }
.evidence-quote { margin:9px 0 0; line-height:1.55; }
.transcript-snippet { margin-top:10px; padding-top:10px; border-top:1px dashed #b9c7d1; display:grid; gap:6px; }
.transcript-line strong { margin-right:7px; font-size:12px; }
.modal-done { margin-top:18px; border:0; background:#111; color:#fff; border-radius:4px; padding:9px 18px; cursor:pointer; }

.dev-warning { position:fixed; right:12px; bottom:calc(var(--footer-h) + 10px); max-width:520px; padding:10px 12px; background:#fff4ce; border:1px solid #d7b757; border-radius:4px; z-index:20; font:12px/1.45 var(--font-ui); box-shadow:0 6px 20px rgba(0,0,0,.12); }
.renderer-error,.broken-slot { background:#fff0f0; color:#9e2222; border:1px solid #d99999; padding:10px; }
.renderer-error pre { white-space:pre-wrap; font-size:12px; }

@media (max-width:1200px) {
  .brand-logo { height:32px; max-width:210px; }
  .test-meta { min-width:150px; }
  .test-meta strong { max-width:22vw; }
  .volume-wrap input { width:56px; }
  .test-picker-label > span { display:none; }
  .matching-layout,.spatial-layout { grid-template-columns:1fr; }
  .option-pool { position:static; }
}
@media (max-width:820px) {
  body { overflow:auto; }
  ::-webkit-scrollbar { width:8px; height:8px; }
  .exam-shell { min-height:100vh; height:auto; display:block; }
  .topbar { align-items:center; flex-wrap:wrap; }
  .test-meta { flex:1 1 45%; min-width:0; }
  .test-meta strong { max-width:100%; }
  .header-player { order:3; flex:1 1 100%; min-width:0; }
  .top-actions { margin-left:auto; flex-wrap:wrap; }
  .mode-picker { grid-template-columns:1fr; }
  .test-picker-label { flex:1; }
  .test-picker-label select { width:100%; max-width:none; }
  .workspace { min-height:65vh; overflow:visible; padding:0 12px; }
  .question-scroll { position:relative; inset:auto; max-height:65vh; padding:0 8px 95px; }
  .bottom-nav { position:sticky; bottom:0; z-index:15; }
  .part-tab { min-width:145px; padding:0 10px; }
  .active-part { padding:0 8px; }
  .active-part > strong { margin-right:5px; }
  .short-answer-row,.matching-row { grid-template-columns:1fr; }
  .diagram-stage { min-width:650px; }
}
