:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-subtle: #f7f9f7;
  --text: #1b211d;
  --muted: #69716c;
  --border: #dce1dd;
  --accent: #32684e;
  --accent-strong: #25543d;
  --accent-soft: #e8f0eb;
  --danger: #a94d45;
  --danger-soft: #f8ecea;
  --shadow: 0 16px 48px rgba(22, 33, 26, .07);
  --backdrop: rgba(17, 22, 19, .56);
  --font: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111513;
  --surface: #191e1b;
  --surface-subtle: #202622;
  --text: #edf1ee;
  --muted: #9ca6a0;
  --border: #323a35;
  --accent: #77b592;
  --accent-strong: #91c8a7;
  --accent-soft: #263c30;
  --danger: #e28a80;
  --danger-soft: #432b29;
  --shadow: 0 18px 54px rgba(0, 0, 0, .24);
  --backdrop: rgba(0, 0, 0, .72);
}

* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background: var(--bg); font-family: var(--font); transition: color .18s ease, background .18s ease; }
button, input, select { color: inherit; font: inherit; }
button { cursor: pointer; }
button, input, select { -webkit-tap-highlight-color: transparent; }
svg { width: 1.25em; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1060px, calc(100% - 40px));
  height: 76px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand strong { font-size: 16px; font-weight: 700; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; color: #fff; background: var(--accent); border-radius: 50%; }
.brand-mark svg { width: 25px; fill: currentColor; stroke: none; }
.header-actions { display: flex; align-items: center; overflow: visible; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.top-action { position: relative; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; color: var(--muted); background: transparent; border: 0; border-left: 1px solid var(--border); }
.top-action.first-visible { border-left: 0; border-radius: 5px 0 0 5px; }
.top-action.last-visible { border-radius: 0 5px 5px 0; }
.top-action:hover { z-index: 2; color: var(--accent); background: var(--accent-soft); }
.top-action:focus-visible { z-index: 3; outline: 2px solid var(--accent); outline-offset: -2px; }
.top-action svg { width: 18px; height: 18px; }
.top-action::after { position: absolute; right: 50%; bottom: -34px; z-index: 20; padding: 5px 7px; color: var(--surface); content: attr(data-tooltip); background: var(--text); border-radius: 3px; font-size: 10px; line-height: 1; white-space: nowrap; opacity: 0; pointer-events: none; transform: translateX(50%) translateY(-3px); transition: opacity .14s ease, transform .14s ease; }
.top-action:hover::after, .top-action:focus-visible::after { opacity: 1; transform: translateX(50%) translateY(0); }
.sun-icon { display: none; }
html[data-theme="dark"] .moon-icon { display: none; }
html[data-theme="dark"] .sun-icon { display: block; }

.page-shell { width: min(1060px, calc(100% - 40px)); margin: 0 auto; padding: 40px 0 64px; }
.mode-screen { display: grid; align-content: center; min-height: calc(100vh - 76px); padding-top: 24px; }
.mode-heading { margin-bottom: 32px; }
.question-bank-note { max-width: 760px; margin: -14px 0 28px; color: var(--muted); font-size: 11px; line-height: 1.8; }
.mode-kicker { color: var(--accent); font-size: 12px; font-weight: 700; }
.mode-heading h1 { margin: 8px 0 7px; font-size: 36px; font-weight: 700; }
.mode-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mode-card { position: relative; display: grid; grid-template-columns: 1fr auto; min-height: 210px; padding: 28px; overflow: hidden; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; text-align: left; transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.mode-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.mode-index { align-self: start; color: var(--muted); font-size: 12px; }
.mode-card > strong { grid-column: 1 / -1; align-self: end; margin-top: 42px; font-size: 27px; }
.mode-card > small { align-self: end; margin-top: 7px; color: var(--muted); font-size: 12px; }
.mode-card > b { align-self: end; color: var(--accent); font-size: 12px; }

.practice-screen, .exam-screen { max-width: 1000px; }
.question-stage { min-width: 0; }
.question-card, .loading-card, .empty-card { min-height: 590px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.loading-card, .empty-card { display: grid; place-content: center; justify-items: center; text-align: center; }
.loading-card p { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.empty-card > span { color: var(--accent); font-size: 42px; font-weight: 700; }
.empty-card h2 { margin: 12px 0 20px; font-size: 20px; }
.loader { width: 32px; height: 32px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.question-card { padding: 48px 56px 28px; }
.question-meta { display: flex; align-items: center; justify-content: space-between; min-height: 34px; }
.meta-left { display: flex; align-items: center; gap: 8px; }
.mode-badge { padding: 5px 9px; color: var(--accent); background: var(--accent-soft); border-radius: 3px; font-size: 11px; font-weight: 700; }
.bookmark-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; color: var(--muted); background: transparent; border: 0; }
.bookmark-button svg { width: 21px; }
.bookmark-button:hover, .bookmark-button.active { color: var(--accent); }
.bookmark-button.active svg { fill: currentColor; }
.question-card h2 { min-height: 60px; margin: 20px 0 8px; font-size: 25px; font-weight: 650; line-height: 1.65; }
.inline-type { display: inline-flex; align-items: center; margin: 0 10px 4px 0; padding: 5px 9px; color: #fff; background: var(--accent); border-radius: 3px; font-family: var(--font); font-size: 11px; font-weight: 700; line-height: 1.2; vertical-align: middle; }
.exam-screen .question-meta .inline-type { margin: 0; }
.answer-hint { margin: 0 0 22px; color: var(--muted); font-size: 11px; }
.options-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; min-width: 0; }
.option-button { display: grid; grid-template-columns: 32px 1fr 18px; align-items: center; gap: 11px; min-height: 62px; padding: 11px 15px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 4px; text-align: left; transition: background .15s ease, border-color .15s ease; }
.option-button:hover:not(:disabled) { border-color: var(--accent); }
.option-key { display: grid; place-items: center; width: 30px; height: 30px; color: var(--accent); border: 1px solid var(--border); border-radius: 50%; font-size: 11px; font-weight: 700; }
.option-text { min-width: 0; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.option-state { display: grid; place-items: center; width: 17px; height: 17px; color: transparent; border: 1px solid var(--border); border-radius: 50%; font-size: 11px; }
.option-button.selected { background: var(--accent-soft); border-color: var(--accent); }
.option-button.selected .option-key, .option-button.selected .option-state { color: #fff; background: var(--accent); border-color: var(--accent); }
.option-button.correct { background: var(--accent-soft); border-color: var(--accent); }
.option-button.correct .option-state { color: #fff; background: var(--accent); border-color: var(--accent); }
.option-button.wrong { background: var(--danger-soft); border-color: var(--danger); }
.option-button.wrong .option-key, .option-button.wrong .option-state { color: #fff; background: var(--danger); border-color: var(--danger); }
.option-button:disabled { cursor: default; }
.result-panel { grid-template-columns: 38px 1fr; align-items: center; gap: 12px; margin-top: 16px; padding: 13px 15px; background: var(--accent-soft); border-left: 3px solid var(--accent); }
.result-panel.visible { display: grid !important; }
.result-panel.is-wrong { background: var(--danger-soft); border-color: var(--danger); }
.result-icon { display: grid; place-items: center; width: 30px; height: 30px; color: #fff; background: var(--accent); border-radius: 50%; font-size: 14px; font-weight: 700; }
.result-panel.is-wrong .result-icon { background: var(--danger); }
.result-panel strong { font-size: 13px; }
.result-panel p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.question-footer { display: grid; grid-template-columns: 122px minmax(150px, 1fr) 152px; align-items: center; gap: 22px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 0 18px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.primary-button { color: #fff; background: var(--accent); border: 1px solid var(--accent); }
.primary-button:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; }
.secondary-button { color: var(--muted); background: transparent; border: 1px solid var(--border); }
.secondary-button:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.secondary-button:disabled { cursor: not-allowed; opacity: .36; }
.primary-button svg, .secondary-button svg { width: 15px; }
.progress-wrap { min-width: 0; text-align: center; }
.progress-count { display: flex; align-items: baseline; justify-content: center; gap: 7px; color: var(--muted); }
.progress-count b { color: var(--accent); font-size: 21px; line-height: 1; }
.progress-count span { font-size: 11px; }
.progress-count strong { color: var(--text); font-size: 14px; }
.progress-wrap > i { display: block; height: 4px; margin-top: 9px; overflow: hidden; background: var(--border); border-radius: 4px; }
.progress-wrap > i b { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s ease; }

.exam-heading { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 2px 20px; }
.exam-heading div { display: flex; align-items: baseline; gap: 10px; }
.exam-heading span { font-size: 24px; font-weight: 700; }
.exam-heading strong { color: var(--accent); font-size: 13px; }
.exam-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.exam-heading p b { color: var(--text); }
.exam-result { display: grid; place-items: center; min-height: 520px; padding: 40px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); text-align: center; }
.exam-result > span { color: var(--muted); font-size: 14px; }
.exam-result > strong { margin: 18px 0 8px; color: var(--accent); font-size: 24px; }
.exam-result > strong b { font-size: 72px; }
.exam-result.fail > strong { color: var(--danger); }
.exam-result > p { margin: 0 0 28px; color: var(--muted); }
.exam-result > div { display: flex; gap: 10px; }

dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 15px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 20px; }
.dialog-close { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 24px; }
.dialog-body { padding: 20px 24px 24px; }
.settings-dialog { width: min(420px, calc(100% - 28px)); padding: 0; }
.select-field, .search-field { display: block; }
.select-field > span, .search-field > span, .dialog-body label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.select-field select, .search-field input, .dialog-body input { width: 100%; height: 44px; padding: 0 12px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 4px; outline: none; }
.search-field { margin-top: 14px; }
.select-field select:focus, .search-field input:focus, .dialog-body input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.mode-return { width: 100%; min-height: 42px; margin-top: 14px; color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 4px; font-size: 11px; font-weight: 700; }
.navigator-dialog { width: min(760px, calc(100% - 28px)); max-height: min(82vh, 760px); padding: 0; }
.legend { display: flex; gap: 18px; padding: 14px 24px 0; color: var(--muted); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; }
.legend .done { background: var(--accent); }
.legend .wrong { background: var(--danger); }
.legend .current { background: var(--text); }
.navigator-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 7px; padding: 17px 24px 24px; }
.nav-item { aspect-ratio: 1; padding: 0; color: var(--muted); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 3px; font-size: 10px; }
.nav-item:hover { border-color: var(--accent); }
.nav-item.done { color: #fff; background: var(--accent); border-color: var(--accent); }
.nav-item.wrong { color: #fff; background: var(--danger); border-color: var(--danger); }
.nav-item.current { outline: 2px solid var(--text); outline-offset: 1px; }
.choice-dialog { width: min(420px, calc(100% - 28px)); padding: 0; }
.choice-list { display: grid; gap: 10px; padding: 20px; }
.choice-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 16px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 4px; text-align: left; }
.choice-card:hover { border-color: var(--accent); }
.choice-card strong, .choice-card small { display: block; }
.choice-card strong { font-size: 13px; }
.choice-card small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.choice-card > b { color: var(--accent); font-size: 11px; }

.account-dialog { width: min(460px, calc(100% - 28px)); max-height: 88vh; padding: 0; }
.account-dialog form { margin: 0; }
.account-dialog .dialog-body { max-height: calc(88vh - 70px); overflow-y: auto; }
.account-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.account-summary small, .account-summary strong { display: block; }
.account-summary small { margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.account-summary strong { font-size: 14px; }
.account-section { padding: 20px 0; border-bottom: 1px solid var(--border); }
.account-section h3 { margin: 0 0 13px; font-size: 12px; }
.account-section label { display: block; margin-top: 12px; }
.account-section .primary-button { width: 100%; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.stats-grid > div, .stats-grid > button { display: flex; flex-direction: column; align-items: flex-start; min-height: 72px; padding: 13px; color: var(--text); background: transparent; border: 0; }
.stats-grid > :nth-child(odd) { border-right: 1px solid var(--border); }
.stats-grid > :nth-child(-n+2) { border-bottom: 1px solid var(--border); }
.stats-grid > button:hover { background: var(--accent-soft); }
.stats-grid strong { color: var(--accent); font-size: 20px; }
.stats-grid span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.account-link { display: block; margin-top: 16px; padding: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; font-size: 11px; text-align: center; text-decoration: none; }
.danger-button, .plain-button { width: 100%; min-height: 42px; margin-top: 10px; background: transparent; border-radius: 4px; font-size: 11px; }
.danger-button { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); }
.danger-button:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.plain-button { color: var(--muted); border: 1px solid var(--border); }
.plain-button:hover { color: var(--text); background: var(--surface-subtle); }
.feedback-button { margin-top: 18px; padding: 7px 10px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 4px; font-size: 10px; }
.feedback-button:hover { color: var(--accent); border-color: var(--accent); }
.feedback-dialog { width: min(420px, calc(100% - 28px)); padding: 0; }
.feedback-dialog textarea, .feedback-dialog select { width: 100%; padding: 10px 12px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 4px; font: inherit; resize: vertical; }
.feedback-dialog label { display: block; margin-bottom: 14px; }
.exam-stats { grid-template-columns: 1fr 1fr; }
.exam-stats > :nth-child(-n+2) { border-bottom: 0; }
.exam-history-list { display: grid; gap: 7px; margin-top: 12px; }
.exam-history-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; width: 100%; padding: 10px 11px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 4px; text-align: left; }
.exam-history-item:hover { border-color: var(--accent); }
.exam-history-item span, .exam-history-item small { color: var(--muted); font-size: 10px; }
.exam-history-item strong { color: var(--accent); font-size: 12px; }

.auth-screen { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.auth-theme-button { position: absolute; top: 20px; right: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.auth-theme-button::after { right: 0; transform: translateX(0) translateY(-3px); }
.auth-theme-button:hover::after, .auth-theme-button:focus-visible::after { transform: translateX(0) translateY(0); }
.auth-card { width: min(360px, 100%); padding: 34px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.auth-card .brand-mark { margin-bottom: 22px; }
.auth-card h1 { margin: 0; font-size: 23px; }
.auth-card > p { margin: 7px 0 23px; color: var(--muted); font-size: 11px; }
.auth-card label { display: block; margin-bottom: 13px; }
.auth-card label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.auth-card input, .auth-card select { width: 100%; height: 44px; padding: 0 12px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 4px; outline: none; }
.auth-card input:focus, .auth-card select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.auth-card .primary-button { width: 100%; }
.auth-error { min-height: 17px; margin: 0 0 8px !important; color: var(--danger) !important; font-size: 10px; }
.auth-switch { display: block; width: 100%; margin-top: 12px; padding: 7px; color: var(--muted); background: transparent; border: 0; font-size: 10px; }
.auth-switch:hover { color: var(--accent); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 40; max-width: min(340px, calc(100% - 44px)); padding: 12px 16px; color: var(--surface); background: var(--text); border-radius: 4px; box-shadow: var(--shadow); font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 720px) {
  .topbar { width: calc(100% - 24px); height: 68px; }
  .brand strong { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .top-action { width: 38px; height: 38px; }
  .top-action::after { display: none; }
  .page-shell { width: calc(100% - 20px); padding: 24px 0 42px; }
  .mode-screen { min-height: calc(100vh - 68px); }
  .mode-heading { margin-bottom: 22px; }
  .mode-heading h1 { font-size: 28px; }
  .mode-grid { grid-template-columns: 1fr; gap: 10px; }
  .mode-card { min-height: 155px; padding: 22px; }
  .mode-card > strong { margin-top: 25px; font-size: 23px; }
  .question-card { min-height: 0; padding: 22px 16px 18px; }
  .question-card h2 { min-height: 0; margin: 15px 0 8px; font-size: 18px; line-height: 1.65; }
  .answer-hint { margin-bottom: 15px; }
  .options-list { grid-template-columns: 1fr; gap: 9px; }
  .option-button { min-height: 56px; }
  .question-footer { grid-template-columns: 44px 1fr 126px; gap: 9px; margin-top: 20px; padding-top: 17px; }
  .question-footer .secondary-button { width: 44px; padding: 0; }
  .question-footer .secondary-button span { display: none; }
  .exam-heading { align-items: flex-start; }
  .exam-heading span { font-size: 20px; }
  .exam-heading p { max-width: 150px; text-align: right; line-height: 1.5; }
  .exam-result { min-height: 460px; padding: 28px 16px; }
  .exam-result > strong b { font-size: 60px; }
  .navigator-grid { grid-template-columns: repeat(6, 1fr); padding: 15px 18px 22px; }
  .dialog-head { padding: 18px 18px 13px; }
  .dialog-body { padding: 18px; }
  .legend { padding-left: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
