:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d9dee8;
  --paper: #ffffff;
  --canvas: #f4f6f9;
  --navy: #162d4a;
  --blue: #1769d2;
  --blue-soft: #eaf2ff;
  --orange: #b54708;
  --orange-soft: #fff3e8;
  --red: #b42318;
  --green: #067647;
  --shadow: 0 10px 30px rgba(21, 42, 70, 0.08);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; line-height: 1.65; }
button, select, input { font: inherit; }
button, .file-button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(23, 105, 210, .24); outline-offset: 2px; }

.site-header { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px clamp(18px, 5vw, 72px); color: white; background: var(--navy); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.35); border-radius: 9px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.text-button { appearance: none; border: 0; padding: 6px 4px; color: rgba(255,255,255,.88); background: transparent; text-decoration: none; }
.text-button:hover { color: white; text-decoration: underline; }
.file-button input { display: none; }

#app { width: min(1180px, calc(100% - 32px)); margin: 34px auto 72px; }
.hero { padding: clamp(26px, 5vw, 54px); border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: .9rem; font-weight: 700; letter-spacing: .08em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.25; }
.lead { max-width: 720px; margin-bottom: 0; color: var(--muted); font-size: 1.04rem; }
.section { margin-top: 26px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 1.15rem; }
.section-heading span { color: var(--muted); font-size: .9rem; }
.mode-grid, .year-grid, .stats-grid { display: grid; gap: 14px; }
.mode-grid { grid-template-columns: repeat(3, 1fr); }
.year-grid { grid-template-columns: repeat(7, 1fr); }
.mode-card, .year-card { text-align: left; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--paper); transition: border-color .15s, box-shadow .15s, transform .15s; }
.mode-card { min-height: 142px; padding: 20px; }
.mode-card:hover, .year-card:hover { transform: translateY(-1px); border-color: #9bbbea; box-shadow: 0 8px 20px rgba(22,45,74,.08); }
.mode-card.selected, .year-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,210,.12); }
.mode-card strong, .mode-card span { display: block; }
.mode-card strong { margin-bottom: 7px; font-size: 1.08rem; }
.mode-card span { color: var(--muted); font-size: .92rem; }
.year-card { padding: 14px 12px; text-align: center; }
.year-card strong, .year-card small { display: block; }
.year-card small { color: var(--muted); }
.year-card.incomplete small { color: var(--orange); }
.setup-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.duration-field { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.duration-field input { width: 82px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }
.primary, .secondary, .danger { border: 0; border-radius: 9px; padding: 10px 18px; font-weight: 650; }
.primary { color: white; background: var(--blue); }
.primary:hover { background: #0d5dbd; }
.primary:disabled { cursor: not-allowed; opacity: .45; }
.secondary { color: var(--ink); border: 1px solid var(--line); background: white; }
.danger { color: white; background: var(--red); }
.notice { margin-top: 16px; padding: 12px 14px; border-left: 4px solid #e87517; color: #7a2e0e; background: var(--orange-soft); }
.resume-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding: 14px 18px; border: 1px solid #a8c7f0; border-radius: 12px; background: var(--blue-soft); }
.resume-bar p { margin: 0; }
.resume-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.history-list { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.history-row { display: grid; grid-template-columns: minmax(170px, 1fr) 130px 100px; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-row time, .history-row span { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; background: rgba(255,255,255,.55); }
.data-actions { display: flex; justify-content: flex-end; margin-top: 22px; }
.link-danger { color: var(--red); border: 0; background: transparent; }

.exam-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.exam-sidebar, .question-card, .result-sidebar, .result-summary, .review-card { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); }
.exam-sidebar { position: sticky; top: 18px; padding: 18px; }
.exam-meta { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.exam-meta strong, .timer { display: block; }
.exam-meta span { color: var(--muted); font-size: .9rem; }
.timer { margin-top: 8px; color: var(--navy); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.timer.expired { color: var(--red); }
.navigator { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 16px 0; }
.nav-number { aspect-ratio: 1; padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: white; }
.nav-number.answered { color: var(--blue); border-color: #83afe8; background: var(--blue-soft); }
.nav-number.flagged { box-shadow: inset 0 -3px 0 #f79009; }
.nav-number.current { color: white; border-color: var(--navy); background: var(--navy); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: .78rem; }
.legend i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 2px; background: var(--line); }
.legend .answered-key i { background: #83afe8; }
.legend .flagged-key i { background: #f79009; }
.submit-wide { width: 100%; margin-top: 18px; }
.question-card { min-height: 590px; padding: clamp(22px, 4vw, 42px); }
.question-kicker { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .9rem; }
.flag-button { border: 0; color: var(--muted); background: transparent; }
.flag-button.active { color: var(--orange); font-weight: 650; }
.passage { margin: 18px 0; padding: 18px; white-space: pre-line; border-left: 4px solid #93b7e8; background: #f7f9fc; font-family: Georgia, "Times New Roman", serif; }
.stem { margin: 18px 0 22px; white-space: pre-line; font-size: 1.12rem; font-weight: 650; }
.question-image { display: block; max-width: 100%; max-height: 420px; margin: 14px auto 22px; object-fit: contain; }
.options { display: grid; gap: 12px; }
.option { display: grid; grid-template-columns: 34px 1fr; align-items: start; gap: 12px; width: 100%; padding: 14px; text-align: left; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }
.option:hover { border-color: #8ab2e8; background: #fbfdff; }
.option.selected { border-color: var(--blue); background: var(--blue-soft); }
.option-letter { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: var(--navy); background: #edf0f5; font-weight: 700; }
.option.selected .option-letter { color: white; background: var(--blue); }
.exam-controls { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; }

.result-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.result-sidebar { position: sticky; top: 18px; padding: 18px; }
.result-nav-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.result-nav-heading span { color: var(--red); font-size: .82rem; }
.result-navigator { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 16px 0; }
.result-nav-number { aspect-ratio: 1; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: white; font-size: .84rem; font-variant-numeric: tabular-nums; }
.result-nav-number.correct { color: var(--green); border-color: #86c9ad; background: #ecfdf3; }
.result-nav-number.wrong { color: white; border-color: var(--red); background: var(--red); font-weight: 700; }
.result-nav-number:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(21,42,70,.14); }
.result-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: .78rem; }
.result-legend i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 2px; }
.result-legend i.correct { background: #86c9ad; }
.result-legend i.wrong { background: var(--red); }
.jump-first-wrong { width: 100%; margin-top: 16px; padding-inline: 8px; font-size: .88rem; }
.result-content { min-width: 0; }
.result-summary { padding: 28px; }
.score-line { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.score { color: var(--navy); font-size: 3rem; font-weight: 800; line-height: 1; }
.score small { color: var(--muted); font-size: 1rem; font-weight: 500; }
.result-actions { display: flex; gap: 10px; margin-top: 20px; }
.review-list { display: grid; gap: 16px; margin-top: 22px; }
.review-card { padding: 22px; scroll-margin-top: 18px; }
.review-card.correct { border-left: 5px solid var(--green); }
.review-card.wrong { border-left: 5px solid var(--red); }
.review-status { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.review-status strong.correct-text { color: var(--green); }
.review-status strong.wrong-text { color: var(--red); }
.answer-line { margin: 10px 0; padding: 10px 12px; background: #f7f8fa; }
.explanation { margin-top: 12px; white-space: pre-line; color: #344054; }

dialog { width: min(440px, calc(100% - 32px)); border: 0; border-radius: 14px; box-shadow: 0 22px 60px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(8, 18, 32, .55); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@media (max-width: 900px) {
  .mode-grid { grid-template-columns: 1fr; }
  .year-grid { grid-template-columns: repeat(4, 1fr); }
  .exam-shell, .result-shell { grid-template-columns: 1fr; }
  .exam-sidebar, .result-sidebar { position: static; }
  .navigator { grid-template-columns: repeat(10, 1fr); }
  .result-navigator { grid-template-columns: repeat(10, 1fr); }
}

@media (max-width: 620px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: flex-end; }
  #app { width: min(100% - 20px, 1180px); margin-top: 18px; }
  .hero { padding: 22px; }
  .year-grid { grid-template-columns: repeat(2, 1fr); }
  .setup-footer, .resume-bar, .score-line { align-items: stretch; flex-direction: column; }
  .resume-actions, .result-actions { flex-wrap: wrap; }
  .navigator { grid-template-columns: repeat(8, 1fr); }
  .result-navigator { grid-template-columns: repeat(8, 1fr); }
  .history-row { grid-template-columns: 1fr auto; }
  .history-row time { grid-column: 1 / -1; }
}
