:root {
  --blue: #3378f6;
  --blue-dark: #1266df;
  --line: #dce2eb;
  --text: #172033;
  --muted: #68758a;
  --surface: #f5f7fb;
  --done: #48c98c;
  --mark: #f04f63;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #fff;
  overflow: hidden;
}
button, textarea { font: inherit; }
button { cursor: pointer; }

.exam-shell { height: 100vh; display: grid; grid-template-rows: 56px 1fr 60px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 16px; color: #fff; background: var(--blue); box-shadow: 0 1px 5px rgba(16,40,90,.2);
}
.exam-title { font-size: 23px; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 20px; white-space: nowrap; }
.admin-link, .font-btn, .pause-btn {
  color: #fff; background: transparent; text-decoration: none; border: 1px solid rgba(255,255,255,.8); border-radius: 18px; padding: 5px 14px;
}
.font-btn { border: 0; padding: 3px; font-weight: 700; font-size: 20px; }
.font-btn span { font-size: 14px; }
.timer { color: var(--blue); background: #fff; border-radius: 18px; padding: 5px 18px; }
.seat { display: inline-grid; place-items: center; width: 34px; height: 34px; color: var(--blue); background: #fff; border-radius: 5px; font-size: 22px; font-weight: 700; }

.layout { min-height: 0; display: grid; grid-template-columns: 290px 24px 1fr; }
.layout.collapsed { grid-template-columns: 0 24px 1fr; }
.sidebar { min-width: 0; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto auto; background: #fafbfc; border-right: 1px solid var(--line); }
.layout.collapsed .sidebar { visibility: hidden; }
.candidate-card { margin: 12px; padding: 12px; border: 1px dashed #9ba6b5; border-radius: 6px; background: #fff; }
.avatar { position: relative; width: 108px; height: 96px; margin: 0 auto 8px; background: #f8fafc; }
.avatar-face { position: absolute; left: 31px; top: 5px; width: 48px; height: 48px; border-radius: 50%; background: #dfe6f0; }
.avatar-body { position: absolute; left: 18px; bottom: 4px; width: 74px; height: 34px; border-radius: 22px 22px 10px 10px; background: #dfe6f0; }
dl { display: grid; grid-template-columns: 88px 1fr; gap: 5px 0; margin: 0; font-size: 15px; line-height: 1.35; }
dt { font-weight: 700; color: #435064; }
dd { margin: 0; overflow-wrap: anywhere; }
.paper-nav-wrap { min-height: 0; padding: 8px 12px; overflow: auto; }
.paper-nav-wrap h2 { margin: 0 0 10px; color: #59677c; font-size: 18px; }
.paper-nav { display: grid; gap: 8px; }
.paper-item { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; text-align: left; background: #fff; color: var(--text); }
.paper-item strong { display: block; font-size: 15px; line-height: 1.45; }
.paper-item span { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; }
.paper-item.active { border-color: var(--blue); background: #edf4ff; box-shadow: inset 4px 0 var(--blue); }
.paper-item.active strong { color: var(--blue-dark); }
.loading { margin: 8px 0; color: var(--muted); font-size: 14px; }
.loading.error { color: #c93d32; }
.legend { display: flex; flex-wrap: wrap; gap: 7px 12px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 14px; height: 14px; border: 1px solid #9aa5b4; border-radius: 3px; background: #fff; }
.legend .legend-current { background: var(--blue); border-color: var(--blue); }
.legend .legend-done { background: var(--done); border-color: var(--done); }
.legend .legend-mark { background: linear-gradient(135deg, #fff 48%, var(--mark) 49%); border-color: var(--mark); }
.submit-btn { height: 40px; margin: 10px 16px; border: 0; border-radius: 5px; color: #fff; background: #0784ff; font-size: 18px; }
.collapse-btn { align-self: center; width: 24px; height: 92px; padding: 0; border: 0; border-radius: 0 38px 38px 0; color: #fff; background: var(--blue); font-size: 40px; z-index: 2; }
.layout.collapsed .collapse-btn { transform: rotate(180deg); }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto 1fr; overflow: hidden; background: #fff; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.section-head h1 { margin: 2px 0 0; font-size: 20px; }
.eyebrow { margin: 0; color: var(--blue); font-size: 13px; font-weight: 700; }
.open-pdf { flex: none; color: var(--blue); border: 1px solid var(--blue); border-radius: 5px; padding: 8px 12px; text-decoration: none; font-size: 14px; }
.exam-content { min-height: 0; display: grid; grid-template-rows: minmax(260px, 58%) minmax(220px, 42%); }
.document-panel, .answer-panel { min-height: 0; display: grid; overflow: hidden; }
.document-panel { grid-template-rows: 38px 1fr; border-bottom: 4px solid #e8edf5; }
.panel-bar { display: flex; align-items: center; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.panel-bar strong { font-size: 18px; }
.panel-bar span { color: var(--muted); font-size: 13px; }
#paperViewer { width: 100%; height: 100%; border: 0; background: #e8ebf0; }
.paper-empty { display: grid; place-items: center; padding: 30px; color: var(--muted); background: var(--surface); text-align: center; }
.answer-panel { grid-template-rows: auto 1fr; }
.answer-toolbar { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-bottom: 1px solid var(--line); background: #fff; }
.answer-toolbar > strong { flex: none; font-size: 17px; }
.requirement-tabs { min-width: 0; display: flex; gap: 5px; overflow-x: auto; padding: 2px; }
.requirement-tab { position: relative; flex: none; min-width: 74px; height: 34px; border: 1px solid #ccd4df; border-radius: 4px; color: #29364a; background: #fff; }
.requirement-tab.active { color: #fff; background: var(--blue); border-color: var(--blue); }
.requirement-tab.done:not(.active) { color: #14734a; background: #e7f8f0; border-color: #75d3a7; }
.requirement-tab.marked:after { content: ""; position: absolute; right: 2px; bottom: 2px; border-left: 8px solid var(--mark); border-top: 8px solid transparent; }
.requirement-count { flex: none; display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.requirement-count button { width: 28px; height: 28px; padding: 0; border: 1px solid #ccd4df; border-radius: 4px; background: #fff; color: var(--blue); font-size: 20px; line-height: 1; }
.answer-body { min-height: 0; display: grid; grid-template-rows: auto auto 1fr; gap: 5px; padding: 10px 16px 14px; }
.answer-body label { font-size: 18px; font-weight: 700; }
.answer-body p { margin: 0; color: var(--muted); font-size: 13px; }
#answerInput { width: 100%; min-height: 100px; resize: none; padding: 12px; border: 1px solid #aeb8c6; border-radius: 5px; outline: none; line-height: 1.7; font-size: 16px; }
#answerInput:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(51,120,246,.12); }

.bottombar { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px; padding: 8px 18px; border-top: 1px solid var(--line); background: #fff; }
.mark-btn { justify-self: start; border: 0; color: #718098; background: transparent; font-size: 17px; }
.mark-btn span { color: #94a0b2; }
.mark-btn.active, .mark-btn.active span { color: var(--mark); }
.save-state { color: #8390a3; font-size: 13px; }
.footer-actions { display: flex; gap: 9px; }
.outline-btn, .nav-btn { min-width: 118px; height: 40px; border-radius: 5px; font-size: 16px; }
.outline-btn { color: var(--blue); border: 1px solid var(--blue); background: #fff; }
.nav-btn { color: #fff; border: 0; background: #087eff; }
.nav-btn:disabled { cursor: not-allowed; opacity: .42; }

dialog { border: 0; border-radius: 8px; padding: 0; box-shadow: 0 18px 60px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(15,24,38,.28); }
.calc { width: 290px; padding: 14px; background: #f5f7fa; }
.calc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.calc-head button { width: 30px; height: 30px; border: 0; background: #e1e5ea; }
#calcDisplay { width: 100%; height: 46px; margin-bottom: 10px; padding: 0 10px; border: 1px solid #aeb7c3; text-align: right; font-size: 23px; background: #fff; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-grid button { height: 39px; border: 1px solid #bbc4cf; border-radius: 4px; background: #fff; }
.result-card { width: 390px; padding: 22px; }
.result-card h2 { margin: 0 0 12px; }
.result-card p { color: var(--muted); line-height: 1.7; }
.result-card button { width: 100%; height: 40px; border: 0; border-radius: 5px; color: #fff; background: var(--blue); }
.large-font #answerInput { font-size: 20px; }

@media (max-width: 1000px) {
  .top-actions { gap: 8px; font-size: 13px; }
  .admin-link { display: none; }
  .layout { grid-template-columns: 0 20px 1fr; }
  .sidebar { visibility: hidden; }
  .exam-title { font-size: 18px; }
}
@media (max-width: 700px) {
  .exam-shell { grid-template-rows: auto 1fr auto; }
  .topbar { padding: 8px 10px; flex-wrap: wrap; }
  .top-actions { flex-wrap: wrap; }
  .pause-btn, .seat, .top-actions > span:last-of-type { display: none; }
  .exam-content { grid-template-rows: 52% 48%; }
  .section-head { align-items: flex-start; }
  .section-head h1 { font-size: 16px; }
  .bottombar { grid-template-columns: 1fr auto; }
  .save-state { display: none; }
  .outline-btn { display: none; }
  .nav-btn { min-width: 96px; }
}
/* Official comprehensive-exam layout */
.exam-shell { grid-template-rows: 62px 1fr 58px; }
.topbar { font-size: 17px; }
.layout { grid-template-columns: 306px 24px 1fr; }
.section-head { min-height: 104px; padding: 12px 22px; }
.paper-heading { min-width: 0; }
.section-head h1 { margin: 0 0 8px; color: #111; font-size: 23px; }
#paperInstruction { margin: 0; max-width: 1220px; color: #111; font-size: 17px; font-weight: 700; line-height: 1.45; }
.input-method { flex: none; align-self: center; height: 40px; padding: 0 18px; border: 1px solid var(--blue); border-radius: 21px; color: var(--blue); background: #fff; }
.exam-content { grid-template-rows: minmax(260px, 56%) minmax(220px, 44%); transition: grid-template-rows .18s ease; }
.exam-content.material-expanded { grid-template-rows: 1fr 0; }
.exam-content.answer-expanded { grid-template-rows: 0 1fr; }
.exam-content.material-expanded .answer-panel,
.exam-content.answer-expanded .document-panel { visibility: hidden; }
.document-panel { grid-template-rows: 40px 42px 1fr; }
.panel-bar, .answer-titlebar { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); background: #fff; }
.panel-bar strong, .answer-titlebar strong { font-size: 19px; font-weight: 500; }
.panel-actions { display: flex; align-items: center; gap: 8px; }
.plain-action { height: 32px; padding: 5px 10px; border: 1px solid #cbd3de; border-radius: 5px; color: #596579; background: #fff; text-decoration: none; font-size: 14px; }
.material-tabs { display: flex; align-items: end; gap: 0; padding: 6px 16px 0; overflow-x: auto; border-bottom: 1px solid var(--line); background: #fff; }
.material-tab { min-width: 72px; height: 35px; margin-bottom: -1px; border: 1px solid #cdd4de; border-radius: 4px 4px 0 0; color: #202a39; background: #fff; font-size: 16px; }
.material-tab + .material-tab { margin-left: -1px; }
.material-tab.active { position: relative; z-index: 1; color: #fff; border-color: var(--blue); background: var(--blue); }
#paperViewer { background: #fff; }
.answer-panel { grid-template-rows: 40px 44px 1fr; }
.answer-titlebar { border-top: 1px solid var(--line); }
.answer-toolbar { min-height: 44px; padding: 4px 16px 0; align-items: end; border-bottom: 1px solid var(--line); }
.requirement-tabs { align-items: end; gap: 0; padding: 0; }
.requirement-tab { min-width: 76px; height: 36px; margin-bottom: -1px; border-radius: 4px 4px 0 0; font-size: 16px; }
.requirement-tab + .requirement-tab { margin-left: -1px; }
.requirement-count { margin-left: auto; padding-bottom: 4px; }
.answer-body { grid-template-rows: auto auto 38px 1fr; gap: 7px; padding: 10px 16px 14px; overflow: auto; }
.answer-body label { display: none; }
#requirementPrompt { color: #151a22; font-size: 17px; line-height: 1.55; }
.editor-toolbar { display: flex; align-items: center; gap: 2px; min-height: 38px; padding: 2px 8px; border: 1px solid #cbd2dc; border-bottom: 0; background: #f4f5f7; }
.editor-toolbar button { min-width: 34px; height: 30px; border: 0; color: #111; background: transparent; font-size: 18px; }
.editor-toolbar button:hover { background: #e3e7ed; }
.editor-toolbar span { margin-left: auto; color: #7b8798; font-size: 12px; }
#answerInput { border-radius: 0; border-color: #9ba5b3; font-size: 17px; }
#answerInput:focus { box-shadow: inset 0 0 0 1px var(--blue); }
.bottombar { padding: 7px 18px; }
.submit-btn { height: 46px; font-size: 20px; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 0 20px 1fr; }
  .section-head { min-height: 88px; }
  #paperInstruction { font-size: 14px; }
}
/* Structured material text */
.document-panel { grid-template-rows: 40px auto 42px 1fr; }
.case-overview {
  max-height: 126px;
  overflow: auto;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  color: #171b22;
  background: #fff;
  white-space: pre-wrap;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.65;
}
.case-overview:empty { display: none; }
.material-content {
  min-height: 0;
  overflow: auto;
  padding: 12px 24px 28px;
  color: #171b22;
  background: #fff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.85;
}
.large-font .case-overview,
.large-font .material-content,
.large-font #requirementPrompt { font-size: 21px; }
/* Material reading area sizing */
.exam-content { grid-template-rows: minmax(360px, 68%) minmax(190px, 32%); }
.case-overview {
  max-height: 105px;
  font-size: 14px;
  line-height: 1.55;
}
.material-content {
  padding: 10px 22px 34px;
  font-size: 14px;
  line-height: 1.7;
}
.material-tab { font-size: 14px; }
@media (max-height: 760px) {
  .exam-content { grid-template-rows: minmax(300px, 65%) minmax(180px, 35%); }
  .case-overview { max-height: 84px; }
}
/* Highlight the material reading frame on hover/focus */
.document-panel { grid-template-rows: 40px auto 1fr; }
.material-workarea {
  min-height: 0;
  display: grid;
  grid-template-rows: 42px 1fr;
  overflow: hidden;
  border: 2px solid transparent;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.material-workarea:hover,
.material-workarea:focus,
.material-workarea:focus-within {
  border-color: #3378f6;
  box-shadow: inset 0 0 0 1px rgba(51, 120, 246, .12);
}
/* Remove the paper heading block and reclaim its space */
.section-head { display: none; }
.workspace { grid-template-rows: 1fr; }