:root {
  --bg0: #e8eef5;
  --bg1: #f6f8fb;
  --ink: #1a2433;
  --muted: #5b6b7c;
  --line: #cfd8e3;
  --card: #ffffff;
  --accent: #1f6b5c;
  --accent-2: #c45c26;
  --danger: #b42318;
  --ok: #0f7a4a;
  --shadow: 0 8px 22px rgba(26, 36, 51, 0.08);
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --shell-pad: clamp(8px, 1.2vw, 16px);
  --content-max: 1480px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d7e8e3 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #f3e2d4 0%, transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

.app-shell {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 12px var(--shell-pad) 28px;
}

.topbar {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}
.brand {
  font-size: clamp(1.2rem, 2.2vw, 1.45rem);
  font-weight: 750;
  letter-spacing: 0.02em;
  color: inherit;
  text-decoration: none;
}
.site-nav {
  display: flex;
  gap: 8px;
  flex: none;
}
.site-nav a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.92rem;
}
.site-nav a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.login-panel { max-width: 460px; margin: 24px auto; }
.login-form .field { margin-bottom: 12px; }

.score-query {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.score-query .field { flex: 1 1 240px; margin-bottom: 0; }
.score-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 0 8px;
  align-items: baseline;
}
.score-head span { color: var(--muted); font-size: 0.9rem; }
.score-project {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.score-project-head h2 { margin: 0; font-size: 1.08rem; }
.score-project-head p { margin: 4px 0 0; color: var(--muted); }
.score-table-wrap { overflow-x: auto; margin-top: 8px; }
.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.score-table th,
.score-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.score-table th { color: var(--muted); font-weight: 700; background: #f7faf8; }
.topbar-sub {
  color: var(--muted);
  margin-top: 2px;
  font-size: 0.9rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(12px, 1.5vw, 18px);
}

h1 { margin: 0 0 6px; font-size: clamp(1.15rem, 2vw, 1.35rem); }
h2.section-title {
  margin: 16px 0 10px;
  font-size: 1.02rem;
}
.lead { color: var(--muted); line-height: 1.55; margin: 0 0 14px; }
.meta-line { color: var(--muted); margin: 0; line-height: 1.45; font-size: 0.92rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.field span { font-weight: 600; }
.field input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 1rem;
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 107, 92, 0.15);
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.exam-card {
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #f7faf9);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.exam-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(31, 107, 92, 0.12);
}
.exam-card-name {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.exam-card-desc, .exam-card-meta {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}
.exam-card-meta { margin-top: 6px; color: var(--accent); min-height: 1.2em; }

.progress-box {
  background: #f2f7f5;
  border: 1px dashed #b7d2c9;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* ===== 考试顶部计时 ===== */
.exam-top-sticky {
  position: sticky;
  top: 0;
  z-index: 60;
  margin: 0 calc(var(--shell-pad) * -0.2) 10px;
}
.timer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  justify-content: space-between;
  background: rgba(26, 36, 51, 0.96);
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 6px 18px rgba(26, 36, 51, 0.22);
}
.timer-left, .timer-mid, .timer-right {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  font-size: 0.88rem;
}
.timer-exam { font-weight: 700; }
.timer-name { opacity: 0.85; }
.timer-sep { opacity: 0.4; }
.timer-mid strong, .timer-right strong {
  font-variant-numeric: tabular-nums;
}
#remainText.urgent { color: #ffb4a8; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.timer-progress {
  height: 3px;
  background: #d7dee8;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.timer-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s linear;
}
.timer-progress-fill.urgent { background: var(--danger); }

/* ===== 考试主体：导航 + 题目 ===== */
.exam-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.exam-nav {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 12px !important;
}
.nav-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.nav-hint {
  font-size: 0.75rem;
  color: var(--muted);
}
.nav-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: -1px;
  border: 1px solid var(--line);
}
.dot-todo { background: #fff; }
.dot-done { background: var(--accent); border-color: var(--accent); }
.dot-curr { background: var(--accent-2); border-color: var(--accent-2); }

.nav-section { margin-bottom: 10px; }
.nav-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}
.nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.nav-btn {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
}
.nav-btn:hover { border-color: var(--accent); }
.nav-btn.answered {
  background: #e7f3ef;
  border-color: #9ecbbd;
  color: var(--accent);
}
.nav-btn.current {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}
.btn-block {
  width: 100%;
  margin-top: 8px;
}

.exam-main { min-width: 0; }
.exam-head { margin-bottom: 10px; }

.section-divider {
  margin: 6px 0 4px;
  padding: 8px 10px;
  background: linear-gradient(90deg, #e8f3ef, #f7faf9);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  font-weight: 750;
  font-size: 0.95rem;
  color: var(--accent);
  scroll-margin-top: 90px;
}
.section-divider:first-child { margin-top: 0; }

.question-list { display: flex; flex-direction: column; gap: 10px; }
.question {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fcfdff;
  scroll-margin-top: 96px;
}
.question:target, .question.flash {
  box-shadow: 0 0 0 2px rgba(196, 92, 38, 0.35);
}
.q-title {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.q-index {
  background: #e8eef5;
  color: var(--ink);
  border-radius: 7px;
  min-width: 28px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.84rem;
}
.q-type {
  border-radius: 7px;
  padding: 3px 7px;
  font-size: 0.74rem;
  font-weight: 700;
}
.q-multi { background: #fff1e8; color: var(--accent-2); }
.q-judge { background: #eef3ff; color: #3557a0; }
.q-choice { background: #e7f3ef; color: var(--accent); }
.q-diff {
  border-radius: 7px;
  padding: 3px 7px;
  font-size: 0.74rem;
  font-weight: 700;
}
.q-easy { background: #eef6ea; color: #3d6b32; }
.q-hard { background: #fde8e6; color: #9b2c2c; }
.q-stem {
  flex: 1 1 240px;
  line-height: 1.5;
  font-weight: 600;
  font-size: 0.98rem;
}
.multi-hint {
  font-style: normal;
  color: var(--accent-2);
  font-weight: 700;
  margin-left: 4px;
  font-size: 0.88em;
}
.q-image-wrap {
  margin: 10px 0 12px;
  padding: 8px;
  background: #f0f4f7;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 640px;
}
.q-image-wrap-sm { max-width: 420px; }
.q-image-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  position: relative;
  text-align: left;
}
.q-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}
.q-image-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(26, 36, 51, 0.72);
  color: #fff;
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 999px;
  pointer-events: none;
}
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 16, 24, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: zoom-out;
}
.img-lightbox.open { display: flex; }
.img-lightbox img {
  max-width: min(96vw, 1400px);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  background: #fff;
}
.img-lightbox-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.options-inline {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  max-width: 480px;
}
.options-stack {
  grid-template-columns: 1fr;
  max-width: 920px;
}
.option {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.98rem;
  line-height: 1.45;
  background: #f7faf8;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}
.option:hover {
  background: #c5ddd6;
  border-color: #8fb8ab;
}
.option:has(input:checked) {
  background: #d7ebe4;
  border-color: var(--accent);
}
.option:has(input:checked):hover {
  background: #c0ddd3;
}
.option input[type="radio"],
.option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin: 0;
  flex: none;
  border: 2.5px solid #6a7f93;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.option input[type="radio"]::after,
.option input[type="checkbox"]::after {
  content: "";
  width: 14px;
  height: 8px;
  border: solid transparent;
  border-width: 0 0 3px 3px;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
}
.option input[type="radio"]:checked,
.option input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.option input[type="radio"]:checked::after,
.option input[type="checkbox"]:checked::after {
  border-color: #fff;
  opacity: 1;
}
.option-text {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
/* 用途类长选项：整行更易读 */
.option:has(.option-text) {
  align-items: flex-start;
}
.option:has(.option-text) input[type="radio"],
.option:has(.option-text) input[type="checkbox"] {
  margin-top: 2px;
}

.exam-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.sticky-actions {
  position: sticky;
  bottom: 8px;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  justify-content: flex-end;
  backdrop-filter: blur(6px);
  z-index: 20;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover { background: #f5f7fa; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.error-text {
  color: var(--danger);
  min-height: 1.2em;
  margin: 0;
  font-size: 0.88rem;
}

.ready-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 14px;
  background: #f7faf9;
  margin: 12px 0;
}
.ready-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px dashed #d5e0da;
  font-size: 0.95rem;
}
.ready-row:last-child { border-bottom: none; }
.ready-row span { color: var(--muted); }
.ready-row .accent { color: var(--accent-2); font-size: 1.1rem; }
.ready-tips {
  color: var(--muted);
  line-height: 1.65;
  padding-left: 18px;
  font-size: 0.92rem;
}

.timeout-tag,
.review-tag {
  color: #fff;
  background: var(--danger);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}
.review-tag { background: #3557a0; }

.mastery-board {
  margin: 14px 0 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf8;
}
.mastery-bar {
  height: 12px;
  border-radius: 999px;
  background: #d7e3dc;
  overflow: hidden;
  margin: 8px 0 10px;
}
.mastery-fill {
  height: 100%;
  background: linear-gradient(90deg, #1f6b5c, #3aa68a);
  border-radius: inherit;
  min-width: 0;
  transition: width 0.35s ease;
}
.mastery-text {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}
.mastery-tip { margin: 8px 0 0; }
.mastery-done {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #e8f6ef;
  border: 1px solid #b7dfc8;
  color: var(--ok);
}
.mastery-done p { margin: 0; line-height: 1.5; }
.mastery-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}
.btn-accent {
  background: #3557a0;
  color: #fff;
  border-color: #3557a0;
}
.btn-accent:hover { filter: brightness(1.06); }

.score-board {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 6px 12px;
  align-items: end;
  background: linear-gradient(135deg, #1f6b5c, #2a8f7a);
  color: #fff;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0 8px;
}
.score-big {
  font-size: clamp(2.4rem, 6vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
}
.score-unit {
  font-size: 1rem;
  opacity: 0.9;
  padding-bottom: 6px;
}
.score-detail {
  grid-column: 1 / -1;
  opacity: 0.95;
  line-height: 1.5;
  font-size: 0.92rem;
}

.wrong-list { display: flex; flex-direction: column; gap: 10px; }
.wrong-item {
  border: 1px solid #f0c9c4;
  background: #fff8f7;
  border-radius: 10px;
  padding: 12px;
}
.answer-lines {
  margin: 6px 0 0;
  padding-left: 18px;
  line-height: 1.55;
  color: var(--muted);
  font-size: 0.92rem;
}
.bad { color: var(--danger); font-weight: 700; }
.good { color: var(--ok); font-weight: 700; }
.explain { color: #4d5d6d; }
.all-correct {
  margin: 12px 0;
  padding: 12px;
  background: #eef8f2;
  border: 1px solid #b7dfc8;
  border-radius: 10px;
  color: var(--ok);
  font-weight: 650;
}
.result-actions { margin-top: 16px; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 14px;
}

/* 移动端抽屉导航 */
.nav-fab {
  display: none;
  position: fixed;
  right: 14px;
  bottom: 72px;
  z-index: 70;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  box-shadow: 0 8px 20px rgba(31, 107, 92, 0.35);
  cursor: pointer;
}
.nav-drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 36, 51, 0.45);
  z-index: 65;
}
.nav-drawer-mask.open { display: block; }

@media (max-width: 960px) {
  .exam-layout {
    grid-template-columns: 1fr;
  }
  .exam-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: min(320px, 88vw);
    height: 100vh;
    max-height: none;
    z-index: 80;
    border-radius: 0;
    transform: translateX(105%);
    transition: transform .2s ease;
    margin: 0;
  }
  .exam-nav.open { transform: translateX(0); }
  .nav-fab { display: inline-flex; align-items: center; justify-content: center; }
  .nav-grid { grid-template-columns: repeat(6, 1fr); }
  .options { grid-template-columns: 1fr; }
  #btnSubmitSide { display: none; }
}

@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .exam-grid { grid-template-columns: 1fr; }
  .exam-actions, .action-right {
    flex-direction: column;
    align-items: stretch;
  }
  .score-board { grid-template-columns: 1fr; }
  .timer-bar { font-size: 0.82rem; }
  .timer-left { width: 100%; }
  .question { padding: 10px; }
  .q-stem { font-size: 0.95rem; }
  .sticky-actions { bottom: 6px; }
  .app-shell { padding: 8px 8px 24px; }
}

@media (min-width: 1200px) {
  .exam-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 14px; }
  .nav-grid { grid-template-columns: repeat(5, 1fr); }
  .options { grid-template-columns: 1fr 1fr; }
}
