:root {
  color-scheme: light;
  --bg: #f4f1e9;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #183128;
  --muted: #6d7a72;
  --line: #dce2dc;
  --primary: #166534;
  --primary-strong: #0f4d29;
  --accent: #d6a84b;
  --soft: #e8f2e9;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --success: #137044;
  --shadow: 0 18px 50px rgba(32, 54, 43, 0.09);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101713;
  --surface: #17221c;
  --surface-strong: #1c2a22;
  --text: #edf6ef;
  --muted: #a5b4aa;
  --line: #32453a;
  --primary: #65b77d;
  --primary-strong: #7ac890;
  --accent: #e5bb63;
  --soft: #243b2d;
  --danger: #ff928a;
  --danger-soft: #402421;
  --success: #7bdca1;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-height: 100%; color: var(--text); background: radial-gradient(circle at 10% 0, rgba(214,168,75,.13), transparent 28rem), var(--bg); font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }

.app-shell { width: min(100%, 980px); margin: 0 auto; padding: 0 24px 72px; }
.site-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; gap: 11px; align-items: center; border: 0; background: transparent; padding: 6px 0; cursor: pointer; text-align: left; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: var(--primary-strong); color: #fff; font-size: 20px; font-weight: 800; box-shadow: 0 8px 20px rgba(15,77,41,.2); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 11px; letter-spacing: .08em; }
.icon-button { border: 1px solid var(--line); background: var(--surface); width: 42px; height: 42px; border-radius: 13px; cursor: pointer; font-size: 21px; }
.icon-button.active { color: var(--accent); }

.hero { padding: clamp(36px, 8vw, 76px) clamp(24px, 6vw, 62px); border-radius: 28px; background: linear-gradient(135deg, #103e2d 0%, #1b6a3b 62%, #b28b38 150%); color: white; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; width: 260px; height: 260px; right: -80px; top: -105px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; box-shadow: 0 0 0 36px rgba(255,255,255,.035), 0 0 0 80px rgba(255,255,255,.025); }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero h1 { position: relative; z-index: 1; margin: 0; max-width: 630px; font-size: clamp(30px, 6vw, 52px); line-height: 1.16; letter-spacing: -.03em; }
.hero-copy { position: relative; z-index: 1; max-width: 600px; margin: 20px 0 30px; color: rgba(255,255,255,.78); line-height: 1.7; }
.bank-stats { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px; }
.bank-stats span { padding: 9px 13px; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; background: rgba(255,255,255,.08); font-size: 13px; }
.bank-stats strong { margin-right: 4px; font-size: 17px; }

.panel, .question-card, .result-hero, .loading-card, .error-card { margin-top: 22px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.panel { padding: clamp(22px, 5vw, 40px); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.section-heading h2 { margin: 0; font-size: 24px; }
fieldset { border: 0; padding: 0; margin: 0 0 28px; }
legend { margin-bottom: 13px; font-size: 14px; font-weight: 800; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmented input, .count-grid input, .check-chip input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; border: 1px solid var(--line); border-radius: 15px; padding: 15px 17px; cursor: pointer; background: var(--surface-strong); font-weight: 700; }
.segmented small { display: block; margin-top: 5px; color: var(--muted); font-weight: 400; }
.segmented input:checked + span, .count-grid input:checked + span, .check-chip input:checked + span { border-color: var(--primary); background: var(--soft); box-shadow: inset 0 0 0 1px var(--primary); }
.check-row { display: flex; gap: 10px; flex-wrap: wrap; }
.check-chip span, .count-grid span { display: grid; place-items: center; min-height: 46px; padding: 0 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-strong); cursor: pointer; font-weight: 700; }
.count-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.primary-button, .secondary-button { min-height: 50px; border-radius: 14px; padding: 0 22px; border: 0; cursor: pointer; font-weight: 800; }
.primary-button { width: 100%; color: #fff; background: var(--primary-strong); box-shadow: 0 10px 24px rgba(15,77,41,.18); }
.primary-button.compact { width: auto; min-width: 130px; }
.secondary-button { border: 1px solid var(--line); background: var(--surface); }
button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

.resume-card { width: 100%; margin-top: 18px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; border: 1px solid color-mix(in srgb, var(--accent) 65%, var(--line)); border-radius: 17px; color: var(--text); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); cursor: pointer; text-align: left; }
.resume-card small, .resume-card strong { display: block; }
.resume-card small { color: var(--muted); margin-bottom: 3px; }
.resume-card b { color: var(--primary); }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 22px; }
.mini-card { min-height: 132px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); text-align: left; }
.mini-card small, .mini-card strong, .mini-card span { display: block; }
.mini-card small, .mini-card span { color: var(--muted); }
.mini-card strong { margin: 6px 0; font-size: 29px; }
.mini-card span { font-size: 12px; }
.mini-card.actionable { cursor: pointer; }

.quiz-topbar { position: sticky; z-index: 5; top: 10px; display: grid; grid-template-columns: 1fr auto; gap: 10px 20px; margin-top: 8px; padding: 16px 18px 12px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(15px); box-shadow: 0 8px 28px rgba(24,49,40,.08); }
.quiz-topbar .eyebrow { margin-bottom: 3px; }
.quiz-actions { display: flex; gap: 8px; align-items: center; }
.text-button { border: 0; background: transparent; padding: 10px; color: var(--muted); cursor: pointer; }
.progress-track { grid-column: 1 / -1; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--accent); transition: width .25s ease; }
.question-card { padding: clamp(24px, 6vw, 50px); }
.question-meta { display: flex; flex-wrap: wrap; gap: 9px 16px; align-items: center; color: var(--muted); font-size: 12px; }
.type-badge { padding: 6px 9px; border-radius: 8px; background: var(--soft); color: var(--primary); font-weight: 800; }
.question-card h1 { margin: 24px 0 30px; font-size: clamp(21px, 4vw, 30px); line-height: 1.55; }
.choice-list { display: grid; gap: 12px; }
.choice { width: 100%; display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-strong); cursor: pointer; text-align: left; line-height: 1.55; transition: transform .12s ease, border-color .12s ease, background .12s ease; }
.choice:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--primary); }
.choice b { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--soft); color: var(--primary); }
.choice.selected { border-color: var(--primary); background: var(--soft); }
.choice.correct { border-color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--surface)); }
.choice.correct b { background: var(--success); color: #fff; }
.choice.wrong { border-color: var(--danger); background: var(--danger-soft); }
.choice.wrong b { background: var(--danger); color: #fff; }
.choice:disabled { opacity: 1; }
.feedback { margin-top: 22px; padding: 18px; border-radius: 15px; border-left: 4px solid; }
.feedback.success { background: color-mix(in srgb, var(--success) 9%, var(--surface)); border-color: var(--success); }
.feedback.error { background: var(--danger-soft); border-color: var(--danger); }
.feedback strong { color: var(--success); }
.feedback.error strong, .answer-line { color: var(--danger); }
.feedback p { margin: 8px 0 0; }
.feedback small { display: block; margin-top: 10px; color: var(--muted); }
.quiz-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }

.result-hero { padding: 42px 24px; text-align: center; }
.score-ring { --score: 0deg; display: grid; place-items: center; width: 154px; height: 154px; margin: 6px auto 22px; border-radius: 50%; background: conic-gradient(var(--primary) var(--score), var(--line) 0); position: relative; }
.score-ring::after { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.score-ring span { position: relative; z-index: 1; }
.score-ring strong { font-size: 43px; }
.score-ring small { margin-left: 3px; color: var(--muted); }
.result-hero h1 { margin-bottom: 8px; }
.result-hero > p:not(.eyebrow) { color: var(--muted); }
.result-stats { display: flex; justify-content: center; gap: 24px; margin: 24px 0; }
.result-stats span { color: var(--muted); }
.result-stats strong { display: block; margin-bottom: 3px; color: var(--text); font-size: 22px; }
.result-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.review-list { display: grid; gap: 10px; }
.review-list details { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-strong); }
.review-list summary { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 16px; cursor: pointer; line-height: 1.5; }
.review-list summary b { color: var(--danger); }
.review-list details > div { padding: 0 16px 16px 56px; color: var(--muted); }
.loading-card, .error-card { padding: 70px 20px; text-align: center; }
.spinner { width: 34px; height: 34px; margin: 0 auto; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 12px; background: #14251c; color: white; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .app-shell { padding: 0 14px calc(38px + env(safe-area-inset-bottom)); }
  .site-header { min-height: 66px; }
  .hero { border-radius: 22px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .count-grid { grid-template-columns: repeat(3, 1fr); }
  .question-card { margin-top: 14px; border-radius: 19px; }
}

@media (max-width: 480px) {
  .segmented { grid-template-columns: 1fr; }
  .hero-copy { margin-bottom: 22px; }
  .bank-stats { gap: 7px; }
  .bank-stats span { font-size: 11px; }
  .question-card h1 { margin: 20px 0 24px; }
  .choice { grid-template-columns: 36px 1fr; padding: 12px; gap: 11px; }
  .choice b { width: 34px; height: 34px; }
  .quiz-nav { position: sticky; bottom: 0; padding: 12px 0 calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 24%); }
  .quiz-nav > * { flex: 1; }
}

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