:root {
  color-scheme: light;
  --shell-blue: #1d4ed8;
  --shell-ink: #172033;
  --shell-muted: #667085;
  --shell-border: #dbe3ef;
}

body {
  min-height: 100vh;
  position: relative;
}

[hidden] {
  display: none !important;
}

.session-actions {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 6px 7px 6px 14px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(30, 64, 175, 0.1);
  backdrop-filter: blur(10px);
}

.candidate-identity {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}

.candidate-label {
  flex: none;
  color: var(--shell-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.candidate-username {
  min-width: 0;
  overflow: hidden;
  color: var(--shell-ink);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  min-height: 32px;
  flex: none;
  padding: 0 12px;
  border: 1px solid #d7dfeb;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #475467;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.logout-button:hover {
  border-color: #fca5a5;
  color: #b42318;
  background: #fff7f7;
}

.logout-button:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.16);
  outline-offset: 2px;
}

.login-view,
.state-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
}

.exam-state-card {
  justify-content: center;
  text-align: center;
}

.exam-state-card h1 {
  max-width: min(620px, 100%);
  margin: 4px auto 12px;
  color: var(--shell-ink);
  font-size: clamp(24px, 4vw, 38px);
}

.exam-state-card > p:not(.state-note) {
  margin: 0;
  color: var(--shell-muted);
  font-size: 17px;
}

.large-countdown {
  display: block;
  margin: 16px 0 10px;
  color: var(--shell-blue);
  font-size: clamp(50px, 11vw, 96px);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.045em;
  line-height: 1;
}

.state-note {
  margin: 0;
  color: var(--shell-muted);
  font-size: 14px;
}

.login-card {
  width: min(390px, 100%);
  padding: 34px;
  border: 1px solid var(--shell-border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 55px rgba(30, 64, 175, 0.11);
}

.login-card h1 {
  margin: 0;
  color: var(--shell-ink);
  font-size: 26px;
}

.login-description {
  margin: 8px 0 24px;
  color: var(--shell-muted);
  font-size: 14px;
}

.login-card label {
  display: block;
  margin-bottom: 16px;
}

.login-card label span {
  display: block;
  margin-bottom: 6px;
  color: #475467;
  font-size: 13px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--shell-border);
  border-radius: 9px;
  color: var(--shell-ink);
  background: #fff;
  font: inherit;
  outline: none;
}

.login-card input:focus {
  border-color: var(--shell-blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.primary-button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: var(--shell-blue);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-error {
  margin: 0 0 14px;
  color: #b42318;
  font-size: 13px;
}

.state-view {
  align-content: center;
  color: var(--shell-muted);
  font-size: 14px;
}

.loading-ring {
  width: 24px;
  height: 24px;
  border: 2px solid #dbe3ef;
  border-top-color: var(--shell-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.save-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 0;
  color: #667085;
  font-size: 13px;
  font-weight: 700;
}

.save-status[data-state="loading"] { color: #1d4ed8; }
.save-status[data-state="success"] { color: #16835f; }
.save-status[data-state="failed"] { color: #b42318; }

.save-status[data-state="loading"]::before {
  width: 13px;
  height: 13px;
  flex: none;
  border: 2px solid #bfdbfe;
  border-top-color: currentColor;
  border-radius: 50%;
  content: "";
  animation: spin 0.65s linear infinite;
}

.save-status[data-state="success"]::before {
  content: "✓";
}

.save-status[data-state="failed"]::before {
  content: "!";
}

article.problem[data-save-state="loading"] {
  border-color: #93c5fd;
  animation: answer-loading 0.8s ease-in-out infinite alternate;
}

article.problem[data-save-state="success"] {
  border-color: #4ade80;
  background-color: #dcfce7;
  animation: answer-success 0.55s ease-out;
}

article.problem[data-save-state="failed"] {
  border-color: #f87171;
  background-color: #fee2e2;
  animation: answer-failed 0.55s ease-out;
}

article.problem[data-save-state="loading"] label.option {
  cursor: wait;
}

#exam-content article.problem[data-save-state="success"],
#exam-content article.problem[data-save-state="success"]:hover {
  border-color: #4ade80;
}

#exam-content article.problem[data-save-state="success"] .problem-title {
  color: #15803d;
  background: #bbf7d0;
}

#exam-content article.problem[data-save-state="success"] .option-letter {
  color: #15803d;
}

#exam-content article.problem[data-save-state="success"] ul.options li,
#exam-content article.problem[data-save-state="success"] ul.options li:hover {
  border-color: #86efac;
}

#exam-content article.problem[data-save-state="success"] ul.options li:hover {
  background: #f0fdf4;
}

#exam-content article.problem[data-save-state="success"] input[type="radio"],
#exam-content article.problem[data-save-state="success"] input[type="radio"]:hover {
  border-color: #22c55e;
}

#exam-content article.problem[data-save-state="success"] input[type="radio"]:checked {
  border-color: #16a34a;
  background: #16a34a;
}

#exam-content article.problem[data-save-state="failed"],
#exam-content article.problem[data-save-state="failed"]:hover {
  border-color: #f87171;
}

#exam-content article.problem[data-save-state="failed"] .problem-title {
  color: #b91c1c;
  background: #fecaca;
}

#exam-content article.problem[data-save-state="failed"] .option-letter {
  color: #b91c1c;
}

#exam-content article.problem[data-save-state="failed"] ul.options li,
#exam-content article.problem[data-save-state="failed"] ul.options li:hover {
  border-color: #fca5a5;
}

#exam-content article.problem[data-save-state="failed"] ul.options li:hover {
  background: #fef2f2;
}

#exam-content article.problem[data-save-state="failed"] input[type="radio"],
#exam-content article.problem[data-save-state="failed"] input[type="radio"]:hover {
  border-color: #ef4444;
}

#exam-content article.problem[data-save-state="failed"] input[type="radio"]:checked {
  border-color: #dc2626;
  background: #dc2626;
}

.dialog-backdrop {
  position: fixed;
  z-index: 500;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(15 23 42 / 20%);
}

.dialog-panel {
  box-sizing: border-box;
  width: min(370px, 100%);
  padding: 22px;
  border: 1px solid #e5e9f0;
  border-radius: 10px;
  color: #243247;
  background: #fff;
  box-shadow: 0 18px 50px rgb(15 23 42 / 18%);
}

.dialog-panel h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-panel p {
  margin: 10px 0 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.55;
}

.dialog-backdrop[data-tone="danger"] .dialog-panel {
  border-color: #fca5a5;
  background: #fff7f7;
  box-shadow: 0 18px 50px rgb(185 28 28 / 20%);
}

.dialog-backdrop[data-tone="danger"] .dialog-panel h2 {
  color: #b91c1c;
}

.dialog-backdrop[data-tone="danger"] .dialog-panel p {
  color: #991b1b;
}

.dialog-backdrop[data-tone="danger"] .dialog-primary {
  border-color: #dc2626;
  background: #dc2626;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.dialog-button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 7px;
  font: inherit;
  cursor: pointer;
}

.dialog-secondary {
  border: 1px solid #d9e0ea;
  color: #475569;
  background: #fff;
}

.dialog-primary {
  border: 1px solid #1f6feb;
  color: #fff;
  background: #1f6feb;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes answer-loading {
  from { background-color: #fbfcff; }
  to { background-color: #eff6ff; }
}

@keyframes answer-success {
  0% { background-color: #fbfcff; }
  55% { background-color: #86efac; border-color: #22c55e; }
  100% { background-color: #dcfce7; border-color: #4ade80; }
}

@keyframes answer-failed {
  0% { background-color: #fbfcff; }
  55% { background-color: #fca5a5; border-color: #ef4444; }
  100% { background-color: #fee2e2; border-color: #f87171; }
}

@media (prefers-reduced-motion: reduce) {
  .save-status[data-state="loading"]::before,
  article.problem[data-save-state] {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}

@media (max-width: 680px) {
  .session-actions { top: 8px; right: 8px; gap: 7px; padding-left: 10px; }
  .candidate-label { display: none; }
  .candidate-username { max-width: 120px; }
  .logout-button { padding: 0 10px; }
  .login-card { padding: 26px 22px; }
}

/* ============================================================
   exam.css — 结构化试卷 blocks 的前端渲染样式
   清新现代 · 干净清爽 · 适合学生考试
   ============================================================ */

@font-face {
  font-family: "LMCC JetBrains Mono";
  src: url("./fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "LMCC JetBrains Mono";
  src: url("./fonts/JetBrainsMono-SemiBold.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --teal: #0d9488;
  --bg: #eef3fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e3eaf5;
  --code-bg: #f6f8fb;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(29, 78, 216, 0.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;              /* 统一基准：题面 / 选项 / 列表同一字号 */
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  counter-reset: problem;   /* 题目自动编号 */
}
::selection { background: #dbeafe; }

/* ---------- 页面卡片 ---------- */
.page {
  max-width: 880px;
  margin: 24px auto 120px;   /* 下留进度栏空间 */
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.content { padding: 10px 48px 40px; }

/* ---------- 章节标题（##） ---------- */
.content > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 42px 0 12px;
  font-size: 21px;
  letter-spacing: 0.3px;
  color: var(--primary-dark);
}
.content > h2::before {
  content: "";
  width: 7px;
  height: 20px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--primary), var(--teal));
}
.content > h2:first-child { margin-top: 26px; }

/* ---------- 材料题标题（### 材料题 N：…） ---------- */
.content > h3 {
  margin: 30px 0 10px;
  padding: 10px 16px;
  font-size: 17px;
  color: #0f766e;
  background: #f0fdfa;
  border-left: 5px solid var(--teal);
  border-radius: 10px;
}

/* ---------- 正文元素 ---------- */
.content > p { font-size: inherit; }
.content > ol, .content > ul { font-size: inherit; }
/* 内联代码（仅限行内上下文，避免泄漏到代码块；比行内文本略小，避免等宽字体显大） */
p code, li code, .option-text code {
  font-family: "LMCC JetBrains Mono", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans SC", monospace;
  font-size: 0.9em;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  background: #eef2f8;
  padding: 0 5px;
  border-radius: 6px;
}
/* 代码块内 reset；结构化代码内容由前端按 language 字段高亮。 */
pre code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
}
.hljs { color: #24292e; }
.hljs-doctag,
.hljs-keyword,
.hljs-meta .hljs-keyword,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-variable.language_ { color: #cf222e; }
.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
.hljs-title.function_ { color: #8250df; }
.hljs-attr,
.hljs-attribute,
.hljs-literal,
.hljs-meta,
.hljs-number,
.hljs-operator,
.hljs-variable,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-id { color: #0550ae; }
.hljs-regexp,
.hljs-string,
.hljs-meta .hljs-string { color: #0a3069; }
.hljs-built_in,
.hljs-symbol { color: #953800; }
.hljs-comment,
.hljs-code,
.hljs-formula { color: #6e7781; font-style: italic; }
.hljs-name,
.hljs-quote,
.hljs-selector-tag,
.hljs-selector-pseudo { color: #116329; }
.hljs-section { color: #0550ae; font-weight: 700; }
.hljs-bullet { color: #953800; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
.hljs-addition { color: #116329; background: #dafbe1; }
.hljs-deletion { color: #82071e; background: #ffebe9; }
math { font-size: 1.05em; }
.math-inline { white-space: nowrap; }
.math-display {
  display: block;
  margin: 12px 0;
  overflow-x: auto;
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}
th, td { border: 1px solid var(--border); padding: 10px 14px; text-align: left; }
thead th { background: #eaf1fd; color: var(--primary-dark); font-weight: 600; }
tbody tr:nth-child(even) { background: #f7fafd; }

pre {
  margin: 16px 0;
  padding: 18px 20px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  font-family: "LMCC JetBrains Mono", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans SC", monospace;
  font-size: 13px;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  line-height: 1.65;
  color: #1e293b;
}

/* ---------- 题目卡片（Problem 块） ---------- */
article.problem {
  counter-increment: problem;
  background: #fbfcff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 18px;
  margin: 16px 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
article.problem:hover {
  border-color: #bcd3f7;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.08);
}
article.problem .problem-title {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 12px;
  border-radius: 999px;
  background: #e8f0fe;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
article.problem .problem-title::after { content: " " counter(problem); }
article.problem > p { margin: 0 0 12px; font-size: inherit; }

/* ---------- 单选选项（radio） ----------
   注意：padding 放在 <label> 上（不放 <li>），
   这样整个可见的选项盒子都是可点击区域。 */
ul.options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
ul.options li {
  padding: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease;
}
ul.options li:hover { background: #eef5ff; border-color: #bcd3f7; }
ul.options li:active { background: #dbeafe; }   /* 按下即时反馈 */

label.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;          /* 内边距属于 label → 整个盒子都可点 */
  cursor: pointer;
  user-select: none;
}
.option-text { flex: 1; }

label.option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border: 2px solid #c7d2e0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
label.option input[type="radio"]:hover { border-color: var(--primary); }
label.option input[type="radio"]:checked {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 3px #fff;   /* 选中：实心圆 + 白色内环 */
}

.option-letter {
  flex: none;
  min-width: 18px;
  color: #475467;
  font-weight: 800;
  line-height: 24px;
  text-align: center;
}

/* ---------- 底部浮动答题进度 ---------- */
.submit-bar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  padding: 9px 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(29, 78, 216, 0.18);
}
.submit-progress { font-size: 14px; color: var(--muted); white-space: nowrap; }
.submit-progress b { color: var(--primary-dark); font-size: 16px; }

/* ---------- 窄屏适配 ---------- */
@media (max-width: 1160px) and (min-width: 681px) {
  .page { margin-top: 68px; }
}

@media (max-width: 680px) {
  .page { margin: 60px 10px 110px; border-radius: 14px; }
  .content { padding: 4px 18px 28px; }
  article.problem { padding: 16px; }
  .submit-bar { bottom: 14px; }
}

/* ---------- 打印 ---------- */
@media print {
  body { background: #fff; }
  .page { box-shadow: none; border-radius: 0; margin: 0; max-width: none; }
  .content { padding: 0; }
  article.problem { break-inside: avoid; page-break-inside: avoid; box-shadow: none; }
  pre { white-space: pre-wrap; word-break: break-all; }
  a { text-decoration: none; color: inherit; }
  .submit-bar { display: none; }
}
