/* ===== 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:root {
  --primary: #4f6ef7;
  --primary-dark: #3b55d9;
  --primary-light: #eef1fe;
  --success: #22c55e;
  --success-bg: #e9faf0;
  --danger: #ef4444;
  --danger-bg: #feeeee;
  --warning: #f59e0b;
  --text-1: #1a1d29;
  --text-2: #5b6172;
  --text-3: #9aa0b0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #ebedf3;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(31, 45, 92, .08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: #dfe4f2;
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
em { font-style: normal; }

/* ===== 应用容器：桌面端居中手机框 ===== */
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 520px) {
  body { padding: 20px 0; }
  #app { min-height: calc(100vh - 40px); min-height: calc(100dvh - 40px); border-radius: 24px; box-shadow: 0 18px 60px rgba(20, 30, 70, .25); }
}

/* ===== 视图切换 ===== */
.view { display: none; min-height: 100vh; min-height: 100dvh; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== 首页 Hero ===== */
.hero { position: relative; padding: 56px 20px 66px; overflow: hidden; }
.hero-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #5b7cfa 0%, #4f6ef7 45%, #6d5df0 100%);
}
.hero-bg::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.hero-bg::before {
  content: ""; position: absolute; left: -40px; bottom: -80px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.hero-inner { position: relative; color: #fff; text-align: center; }
.hero-inner h1 { font-size: 24px; letter-spacing: 1px; }
.hero-inner p { font-size: 13px; opacity: .85; margin-top: 4px; }
.hero-stat {
  display: flex; justify-content: space-around;
  margin-top: 20px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius);
  padding: 14px 8px;
  backdrop-filter: blur(6px);
}
.hero-stat-item { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.hero-stat-item strong { font-size: 20px; }
.hero-stat-item span { font-size: 11.5px; opacity: .85; }
.hero-stat-item + .hero-stat-item { border-left: 1px solid rgba(255,255,255,.25); }

.home-body { padding: 0 16px 40px; position: relative; }
.section-title { font-size: 16px; margin: 22px 4px 12px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--primary); }

/* 题型卡片 */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* 仅首组卡片轻微叠加到hero背景上，标题保持在背景下方 */
.home-body > .type-grid:first-of-type { margin-top: -34px; }
/* 首页首个"题型练习"标题：与上方hero区拉开距离 */
#viewHome > .home-body > h2.section-title:nth-child(1) {
  box-sizing: content-box;
  margin: 20px 0 50px;
}
.type-card {
  background: var(--card); border-radius: var(--radius); padding: 16px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
  transition: transform .12s;
}
.type-card:active { transform: scale(.96); }
.type-icon {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 700;
}
.type-icon-single { background: linear-gradient(135deg, #4f6ef7, #6d8bff); }
.type-icon-multi  { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.type-icon-judge  { background: linear-gradient(135deg, #10b981, #34d399); }
.type-icon-all    { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.type-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.type-name { font-size: 15px; font-weight: 600; }
.type-sub { font-size: 12px; color: var(--text-3); }
.type-sub em { color: var(--primary); font-weight: 600; }

/* 模式列表 */
.mode-list { display: flex; flex-direction: column; gap: 10px; }
.mode-card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow);
  transition: transform .12s;
}
.mode-card:active { transform: scale(.98); }
.mode-ico {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.mode-info { flex: 1; display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-width: 0; }
.mode-info strong { font-size: 15px; }
.mode-info span { font-size: 12px; color: var(--text-3); }
.mode-arrow { color: var(--text-3); font-size: 22px; line-height: 1; }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--danger); color: #fff; font-size: 12px; font-style: normal;
  display: inline-flex; align-items: center; justify-content: center;
}

.btn-text-danger {
  display: block; margin: 28px auto 10px;
  color: var(--text-3); font-size: 13px; padding: 8px 16px;
}
.btn-text-danger:active { color: var(--danger); }
.copyright { text-align: center; color: var(--text-3); font-size: 11px; }

/* ===== 答题页 ===== */
.view-quiz { display: none; padding-bottom: calc(72px + var(--safe-bottom)); }
.view-quiz.active { display: block; }
.view-quiz.has-multi-bar { padding-bottom: calc(142px + var(--safe-bottom)); }
.quiz-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text-1);
}
.icon-btn:active { background: var(--bg); }
.quiz-topbar-mid { text-align: center; font-weight: 600; font-size: 16px; display: flex; flex-direction: column; }
.quiz-timer { font-size: 12.5px; color: var(--danger); font-weight: 600; }

.quiz-progress { height: 3px; background: #e4e8f2; }
.quiz-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #8b5cf6); transition: width .25s; }
.quiz-progress-text {
  display: flex; justify-content: space-between;
  padding: 8px 18px; font-size: 12.5px; color: var(--text-3);
}
#quizRightMini { color: var(--success); font-weight: 600; }

.quiz-body { padding: 8px 14px 20px; }
.question-card {
  background: var(--card); border-radius: 18px;
  padding: 20px 18px 22px;
  box-shadow: var(--shadow);
  animation: cardIn .22s ease;
}
@keyframes cardIn { from { opacity: .35; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.q-tags { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.q-tag {
  font-size: 11.5px; font-weight: 600; color: var(--primary);
  background: var(--primary-light); padding: 3px 10px; border-radius: 20px;
}
.q-no { font-size: 12.5px; color: var(--text-3); }
.q-stem { font-size: 17px; line-height: 1.65; font-weight: 600; margin-bottom: 18px; word-break: break-word; }

.q-options { display: flex; flex-direction: column; gap: 12px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px;
  border: 1.5px solid var(--border); border-radius: 12px;
  padding: 13px 14px; font-size: 15px; line-height: 1.5;
  background: #fff; text-align: left; width: 100%;
  transition: border-color .15s, background .15s, transform .1s;
  word-break: break-word;
}
.opt:active { transform: scale(.99); }
.opt-letter {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid #cfd5e4; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 600;
  transition: all .15s;
}
.opt-text { flex: 1; padding-top: 2px; }
.opt.selected { border-color: var(--primary); background: var(--primary-light); }
.opt.selected .opt-letter { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt.show-right { border-color: var(--success); background: var(--success-bg); }
.opt.show-right .opt-letter { background: var(--success); border-color: var(--success); color: #fff; }
.opt.show-wrong { border-color: var(--danger); background: var(--danger-bg); }
.opt.show-wrong .opt-letter { background: var(--danger); border-color: var(--danger); color: #fff; }
.opt.disabled { pointer-events: none; }
.opt-mark { margin-left: auto; font-size: 17px; flex-shrink: 0; line-height: 1.4; }

/* 作答结果 */
.q-result {
  margin-top: 18px; border-radius: 12px; padding: 14px 15px;
  border: 1px dashed var(--border);
  animation: fadeIn .25s;
}
.q-result-head { font-size: 15.5px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.q-result-head.is-right { color: var(--success); }
.q-result-head.is-wrong { color: var(--danger); }
.q-answer-row { font-size: 14px; color: var(--text-2); display: flex; gap: 6px; }
.q-answer-row b { font-weight: 700; letter-spacing: 1px; }
.text-right { color: var(--success); }
.text-wrong { color: var(--danger); }
.q-tip { margin-top: 9px; font-size: 12.5px; color: var(--text-3); line-height: 1.55;
  background: var(--bg); border-radius: 8px; padding: 9px 11px; }

/* 底部操作栏 */
.quiz-bottombar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 30;
  display: flex; gap: 10px;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.bb-btn {
  flex: 1; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 15px; font-weight: 600;
  background: var(--bg); color: var(--text-2);
  transition: transform .1s;
}
.bb-btn:active { transform: scale(.97); }
#btnFav { flex: 0 0 66px; flex-direction: column; gap: 1px; font-size: 11.5px; height: 46px; }
#btnFav .bb-ico { font-size: 18px; line-height: 1; }
#btnFav.faved { color: var(--warning); }
.bb-btn-primary { background: var(--primary); color: #fff; }
.bb-btn-primary:active { background: var(--primary-dark); }
.bb-btn:disabled { opacity: .4; pointer-events: none; }
.bb-ico { font-size: 16px; }

/* 多选确认条：悬浮于底部操作栏上方 */
.multi-confirm {
  position: fixed; bottom: calc(66px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 35;
  padding: 10px 14px;
  background: rgba(255,255,255,.98);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 18px rgba(31, 45, 92, .06);
  animation: slideUp .2s;
}
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.btn-primary-block {
  width: 100%; height: 46px; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600;
}
.btn-primary-block:active { background: var(--primary-dark); }
.btn-primary-block:disabled { opacity: .45; }

/* 答题卡 */
.answer-sheet-mask { position: fixed; inset: 0; background: rgba(20,24,40,.45); z-index: 40; }
.answer-sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: 84%; max-width: 380px;
  background: #fff;
  display: flex; flex-direction: column;
  animation: sheetIn .22s ease;
}
@keyframes sheetIn { from { transform: translateX(100%); } to { transform: none; } }
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.sheet-head strong { font-size: 17px; }
.sheet-head .icon-btn { font-size: 24px; }
.sheet-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 12px 18px; font-size: 12px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.sheet-legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 13px; height: 13px; border-radius: 4px; display: inline-block; }
.dot-right { background: var(--success); }
.dot-wrong { background: var(--danger); }
.dot-current { background: var(--primary); }
.dot-none { background: #e3e7f1; }
.sheet-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;
  padding: 16px;
  align-content: start;
}
.sheet-cell {
  aspect-ratio: 1; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 600;
  background: #f0f2f8; color: var(--text-2);
}
.sheet-cell.st-right { background: var(--success); color: #fff; }
.sheet-cell.st-wrong { background: var(--danger); color: #fff; }
.sheet-cell.st-current { box-shadow: 0 0 0 2px var(--primary); }
.answer-sheet .btn-primary-block { margin: 12px 16px calc(16px + var(--safe-bottom)); }

/* ===== 成绩页 ===== */
.view-result { background: linear-gradient(180deg, #4f6ef7 0%, #6d5df0 38%, var(--bg) 38%); }
.result-wrap { padding: 54px 24px 40px; text-align: center; }
.score-ring {
  width: 168px; height: 168px; margin: 0 auto 18px;
  border-radius: 50%;
  background: conic-gradient(#fff var(--score-deg, 0deg), rgba(255,255,255,.25) 0deg);
  display: flex; align-items: center; justify-content: center;
}
.score-inner {
  width: 138px; height: 138px; border-radius: 50%;
  background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-inner strong { font-size: 44px; color: var(--text-1); line-height: 1; }
.score-inner span { font-size: 14px; color: var(--text-3); margin-top: 4px; }
#resultTitle { color: #fff; font-size: 21px; margin-bottom: 26px; }
.result-stat {
  background: #fff; border-radius: var(--radius);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 18px 6px; box-shadow: var(--shadow);
}
.result-stat-item { display: flex; flex-direction: column; gap: 3px; }
.result-stat-item + .result-stat-item { border-left: 1px solid var(--border); }
.result-stat-item strong { font-size: 17px; color: var(--text-1); }
.result-stat-item span { font-size: 11.5px; color: var(--text-3); }
.result-actions { display: flex; gap: 12px; margin-top: 26px; }
.btn-primary, .btn-outline {
  flex: 1; height: 48px; border-radius: 12px; font-size: 16px; font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:active { background: var(--primary-light); }
.btn-danger { background: var(--danger); }
.btn-danger:active { background: #d93b3b; }

/* ===== 弹层 ===== */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20,24,40,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 480px;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(20px + var(--safe-bottom));
  animation: modalUp .25s ease;
}
@keyframes modalUp { from { transform: translateY(100%); } to { transform: none; } }
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal-sm { border-radius: 18px; margin: auto 18px; }
.modal-mask:has(.modal-sm) { align-items: center; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 9px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  padding: 8px 16px; border-radius: 20px;
  background: var(--bg); color: var(--text-2);
  font-size: 13.5px; border: 1.5px solid transparent;
}
.chip.chip-active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); font-weight: 600; }
.form-tip { font-size: 12px; color: var(--text-3); background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 12px; }
.confirm-text { font-size: 14.5px; color: var(--text-2); margin-bottom: 20px; line-height: 1.6; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  z-index: 99; max-width: 80%;
  background: rgba(26,29,41,.92); color: #fff;
  padding: 11px 20px; border-radius: 22px;
  font-size: 14px; text-align: center;
  animation: toastIn .25s;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 空状态提示 */
.empty-tip {
  text-align: center; padding: 80px 30px; color: var(--text-3);
}
.empty-tip .empty-ico { font-size: 48px; display: block; margin-bottom: 14px; }
.empty-tip p { font-size: 14.5px; }
.empty-tip .btn-primary { margin-top: 22px; max-width: 200px; }
