:root {
  color-scheme: light;
  --ink: #162229;
  --muted: #65727a;
  --line: #d9e0e2;
  --surface: #ffffff;
  --canvas: #f3f6f5;
  --brand: #12645a;
  --brand-dark: #0b4b44;
  --brand-soft: #e4f2ef;
  --amber: #9a6400;
  --amber-soft: #fff1cf;
  --danger: #b43b32;
  --danger-soft: #fff0ee;
  --blue: #245f9f;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
}
.topbar-inner {
  width: min(1120px, calc(100% - 32px));
  min-height: 70px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: grid; gap: 3px; }
.brand strong { font-size: 18px; }
.brand span { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.plan-badge {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #b7d3ce;
  border-radius: 5px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-weight: 700;
}
.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.shell { width: min(1120px, calc(100% - 32px)); margin: 28px auto 56px; }
.gate { min-height: 62vh; display: grid; align-content: center; gap: 28px; }
.gate-copy { max-width: 720px; }
.eyebrow { margin: 0 0 8px; color: var(--brand); font-size: 13px; font-weight: 800; }
.gate h1, .mock-head h1 { margin: 0; font-size: 32px; line-height: 1.25; }
.gate-copy > p:last-child, .mock-head p:last-child { color: var(--muted); line-height: 1.7; }
.gate-actions { display: flex; gap: 12px; }

.primary, .secondary, .danger {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-weight: 750;
}
.primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.primary:hover { background: var(--brand-dark); }
.secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.primary:disabled, .secondary:disabled { cursor: not-allowed; opacity: .5; }
.danger { color: var(--danger); background: var(--danger-soft); border-color: #efc4bf; }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.stats-strip > div { min-height: 76px; padding: 14px 18px; display: grid; gap: 4px; border-right: 1px solid var(--line); }
.stats-strip > div:last-child { border-right: 0; }
.stats-strip span { color: var(--muted); font-size: 12px; }
.stats-strip strong { font-size: 22px; }

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 8px;
  margin: 16px 0;
}
.mode-tabs button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #34434b;
  font-weight: 700;
}
.mode-tabs button.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.mode-tabs button.locked::after { content: "升级"; margin-left: 5px; color: var(--amber); font-size: 11px; }

.question-panel {
  min-height: 520px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.question-toolbar { min-height: 45px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.question-toolbar > div { display: grid; gap: 3px; }
.type-label { color: var(--brand); font-size: 12px; font-weight: 800; }
#progressLabel { color: var(--muted); font-size: 13px; }
.switch { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 36px; height: 20px; padding: 2px; border-radius: 10px; background: #c6cfd2; }
.switch span::before { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .16s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(16px); }
.question-text { margin: 26px 0 20px; font-size: 21px; line-height: 1.75; }
.question-media {
  margin: -4px 0 20px;
  display: grid;
  gap: 10px;
}
.question-media img {
  width: min(100%, 620px);
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf9;
}
.options { display: grid; gap: 10px; }
.option {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  line-height: 1.55;
}
.option-key { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #bdc8cc; border-radius: 4px; font-weight: 800; }
.option.selected { border-color: var(--blue); background: #eef5fb; }
.option.selected .option-key { color: #fff; border-color: var(--blue); background: var(--blue); }
.option.correct { border-color: var(--brand); background: var(--brand-soft); }
.option.correct .option-key { color: #fff; border-color: var(--brand); background: var(--brand); }
.option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.option.wrong .option-key { color: #fff; border-color: var(--danger); background: var(--danger); }
.feedback { margin-top: 16px; padding: 14px 16px; border-left: 4px solid var(--brand); background: var(--brand-soft); line-height: 1.65; }
.feedback.error { border-left-color: var(--danger); background: var(--danger-soft); }
.answer-explanation {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid #cfe0dc;
  border-radius: 6px;
  background: #fbfdfc;
}
.explanation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.explanation-head span {
  color: var(--brand-dark);
  font-weight: 850;
}
.explanation-head strong {
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 12px;
}
.explanation-summary {
  margin: 0 0 12px;
  color: #27363c;
  line-height: 1.7;
}
.explanation-sections {
  display: grid;
  gap: 10px;
}
.explanation-sections > div {
  padding: 12px;
  border-left: 3px solid #a9cac4;
  background: #fff;
}
.explanation-sections h3 {
  margin: 0 0 5px;
  font-size: 14px;
  color: var(--brand-dark);
}
.explanation-sections p,
.memory-cue,
.related-cue {
  margin: 0;
  color: #405058;
  line-height: 1.65;
}
.memory-cue,
.related-cue {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 5px;
  background: #fff8e7;
}
.related-cue { background: #eef5fb; }
.explanation-visual {
  position: relative;
  width: min(100%, 660px);
  margin: 0 0 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf9;
}
.explanation-visual img {
  display: block;
  width: 100%;
}
.visual-marker {
  position: absolute;
  max-width: min(210px, 45%);
  transform: translate(-50%, -50%);
  padding: 6px 8px;
  border: 2px solid #fff;
  border-radius: 4px;
  color: #fff;
  background: var(--brand);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}
.visual-marker.warn { background: var(--danger); }
.visual-marker.info { background: var(--blue); }
.question-actions { min-height: 68px; margin-top: 20px; padding-top: 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
.empty { min-height: 390px; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); }
.empty strong { color: var(--ink); font-size: 20px; }

.mock-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.mock-controls { display: flex; align-items: center; gap: 8px; }
.timer { min-width: 92px; font-size: 24px; color: var(--danger); font-variant-numeric: tabular-nums; }
.mock-layout { display: grid; grid-template-columns: minmax(0,1fr) 250px; gap: 16px; align-items: start; }
.paper { display: grid; gap: 12px; }
.exam-question { padding: 20px; border: 1px solid var(--line); border-radius: 6px; background: #fff; scroll-margin-top: 90px; }
.exam-question.current { border-color: var(--blue); box-shadow: 0 0 0 2px #dbeafa; }
.exam-question h2 { margin: 0 0 14px; font-size: 17px; line-height: 1.65; }
.exam-question .question-media { margin: 0 0 14px; }
.exam-question .question-media img { width: min(100%, 520px); max-height: 420px; }
.exam-options { display: grid; gap: 7px; }
.exam-option { min-height: 42px; padding: 8px 10px; display: flex; gap: 9px; align-items: center; border: 1px solid #e1e6e8; border-radius: 4px; }
.exam-option input { width: 18px; height: 18px; accent-color: var(--brand); }
.exam-option.correct { border-color: var(--brand); background: var(--brand-soft); }
.exam-option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.answer-sheet { position: sticky; top: 88px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.answer-sheet-title { display: flex; justify-content: space-between; margin-bottom: 12px; }
.answer-sheet-title span { color: var(--muted); font-size: 13px; }
.answer-sheet-title button { display: none; min-height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.answer-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.answer-grid button { aspect-ratio: 1; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 3px; background: #fff; font-size: 12px; }
.answer-grid button.answered { color: #fff; border-color: var(--brand); background: var(--brand); }
.answer-grid button.missing { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.answer-grid button.current { outline: 2px solid var(--blue); outline-offset: 1px; }
.exam-question.review-wrong { border-color: var(--danger); }
.exam-question.review-correct { border-color: var(--brand); }

dialog { width: min(480px, calc(100% - 28px)); max-height: calc(100dvh - 24px); padding: 0; overflow: auto; border: 0; border-radius: 7px; background: transparent; }
#plansDialog { width: min(620px, calc(100% - 28px)); }
#mockCenterDialog, #resultDialog { width: min(620px, calc(100% - 28px)); }
dialog::backdrop { background: rgba(12,24,28,.54); }
.dialog-card { padding: 22px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; font-size: 21px; }
.dialog-head button { width: 34px; height: 34px; border: 0; background: transparent; font-size: 24px; }
.dialog-card label { display: grid; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.dialog-card input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); }
.dialog-card > .primary { width: 100%; }
.fine-print { margin: 12px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.form-error { padding: 10px 12px; color: var(--danger); background: var(--danger-soft); }
.menu-card { display: grid; gap: 1px; }
.menu-row { min-height: 48px; padding: 0 4px; display: flex !important; align-items: center; margin: 0 !important; border: 0; border-bottom: 1px solid var(--line); background: #fff; color: var(--ink) !important; font-size: 15px !important; text-align: left; }
.menu-row:last-child { border-bottom: 0; }
.special-card { width: 100%; }
.special-list { display: grid; gap: 10px; }
.special-row {
  min-height: 92px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfc;
}
.special-copy { min-width: 0; }
.special-copy h3 { margin: 0; font-size: 17px; }
.special-copy p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.plans-card { width: 100%; }
.plan-message { margin: -4px 0 12px; padding: 10px 12px; color: var(--amber); background: var(--amber-soft); line-height: 1.55; }
.plan-list { border-top: 1px solid var(--line); }
.plan-row { padding: 16px 0; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.plan-row.current { box-shadow: inset 3px 0 var(--brand); padding-left: 12px; }
.plan-copy { min-width: 0; }
.plan-name { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.plan-name h3 { margin: 0; font-size: 16px; }
.plan-name span { color: var(--brand-dark); font-size: 13px; font-weight: 800; white-space: nowrap; }
.plan-copy p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.plan-action { min-width: 94px; min-height: 38px; padding: 0 10px; font-size: 13px; }
.plan-action:disabled { cursor: default; color: var(--muted); background: #f5f7f7; }
.about-copy { color: #435159; line-height: 1.75; }
.mock-center-card, .result-card { width: 100%; }
.mock-summary { display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mock-summary div { padding: 12px 8px; text-align: center; }
.mock-summary span { display: block; color: var(--muted); font-size: 12px; }
.mock-summary strong { display: block; margin-top: 5px; font-size: 20px; }
.resume-panel { margin: 16px 0 0; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--amber-soft); }
.resume-panel > div { display: grid; gap: 4px; }
.resume-panel span { color: #6d5730; font-size: 13px; }
.mock-center-actions { margin-top: 16px; display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.history-head { margin-top: 22px; padding-bottom: 9px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.history-head span { color: var(--muted); font-size: 12px; }
.history-list { display: grid; }
.history-row { min-height: 54px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.history-row span { color: var(--muted); font-size: 12px; }
.history-row strong { font-size: 18px; }
.history-empty { padding: 24px 0; color: var(--muted); text-align: center; }
.score { display: block; margin: 0; color: var(--brand); font-size: 60px; text-align: center; }
.result-status { margin: -4px 0 20px; color: var(--muted); font-weight: 700; text-align: center; }
.result-status.pass { color: var(--brand); }
.result-status.fail { color: var(--danger); }
.result-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.result-grid div { padding: 12px; border: 1px solid var(--line); border-radius: 5px; text-align: center; }
.result-grid span { display: block; color: var(--muted); font-size: 12px; }
.result-grid strong { display: block; margin-top: 4px; }
.result-meta { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: center; }
.dialog-actions { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin-top: 18px; }
.dialog-actions button { flex: 1; }

@media (max-width: 760px) {
  .topbar-inner, .shell { width: min(100% - 20px, 1120px); }
  .shell { margin-top: 16px; }
  .brand span { display: none; }
  .gate { min-height: 70vh; }
  .gate h1, .mock-head h1 { font-size: 26px; }
  .stats-strip { grid-template-columns: repeat(2,1fr); }
  .stats-strip > div:nth-child(2) { border-right: 0; }
  .stats-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .mode-tabs { grid-template-columns: repeat(2,1fr); }
  .question-panel { padding: 18px 14px 96px; scroll-margin-top: 86px; }
  .question-text { font-size: 18px; }
  .question-media img { max-height: 390px; }
  .question-actions {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: 0;
    margin: 0;
    padding: 10px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,.98);
    box-shadow: 0 -5px 18px rgba(22,34,41,.1);
  }
  .question-actions button { min-width: 0; min-height: 48px; flex: 1; }
  .feedback { scroll-margin-bottom: 88px; }
  .mock-summary { grid-template-columns: repeat(2,1fr); }
  .mock-summary div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .resume-panel { align-items: stretch; flex-direction: column; }
  .mock-center-actions { grid-template-columns: 1fr; }
  .history-row { gap: 8px; }
  .mock-head { align-items: flex-start; flex-direction: column; }
  .mock-controls { width: 100%; position: sticky; top: 71px; z-index: 20; padding: 8px; border: 1px solid var(--line); background: #fff; }
  .timer { margin-right: auto; }
  .mock-layout { display: flex; flex-direction: column; }
  .answer-sheet { order: -1; position: sticky; top: 128px; z-index: 18; width: 100%; padding: 10px; }
  .answer-sheet-title { align-items: center; margin: 0; }
  .answer-sheet-title button { display: inline-block; }
  .answer-sheet:not(.collapsed) .answer-sheet-title { margin-bottom: 9px; }
  .answer-sheet.collapsed .answer-grid { display: none; }
  .answer-grid { grid-template-columns: repeat(10,1fr); gap: 4px; }
  .answer-grid button { font-size: 10px; }
  .paper { width: 100%; }
  .exam-question { padding: 15px 12px; scroll-margin-top: 250px; }
}

@media (max-width: 430px) {
  .gate-actions { flex-direction: column; }
  .gate-actions button, .question-actions button { width: 100%; }
  .plan-badge { max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .plan-row { grid-template-columns: 1fr; gap: 10px; }
  .plan-action { width: 100%; }
  .special-row { grid-template-columns: 1fr; gap: 12px; }
  .special-row button { width: 100%; }
  .mock-controls .secondary, .mock-controls .primary { padding: 0 10px; }
  .answer-grid { grid-template-columns: repeat(9,1fr); }
}
