/* ===== 设计令牌 ===== */
:root {
  --bg: #f5f5f7;
  --bg-elev: #ffffff;
  --bg-elev-2: #fbfbfd;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --line: rgba(60, 60, 67, 0.12);
  --line-strong: rgba(60, 60, 67, 0.2);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-press: #006edb;
  --success: #34c759;
  --danger: #ff3b30;
  --warn: #ff9f0a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.05);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --blur-bg: rgba(245, 245, 247, 0.72);
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: #1c1c1e;
  --bg-elev-2: #2c2c2e;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #0a84ff;
  --accent-hover: #1f8fff;
  --accent-press: #006edb;
  --success: #30d158;
  --danger: #ff453a;
  --warn: #ff9f0a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.6);
  --blur-bg: rgba(28, 28, 30, 0.72);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "PingFang SC", "Helvetica Neue", "Hiragino Sans GB",
               "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }

[hidden] { display: none !important; }

/* ===== 布局 ===== */
#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 80px;
  min-height: 100vh;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  margin-bottom: 16px;
  background: var(--blur-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease);
}
.top-bar.scrolled { border-color: var(--line); }

.title-block { flex: 1; min-width: 0; }
.title-block h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-block .subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin: 2px 0 0;
}

.subtitle { color: var(--text-2); font-size: 14px; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elev);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}
.icon-btn:hover { background: var(--bg-elev-2); }
.icon-btn:active { transform: scale(0.94); }

main { animation: pageIn 0.36s var(--ease-out); }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page { display: flex; flex-direction: column; gap: 24px; }

.section-head { margin-top: 8px; }
.section-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.section-head .subtitle { margin-top: 4px; }

/* ===== 首页 ===== */
.hero { padding: 8px 0 4px; }
.hero-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}
.hero-sub { color: var(--text-2); margin: 6px 0 0; font-size: 17px; }

.subject-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) {
  .subject-grid { grid-template-columns: 1fr; }
}

.subject-card {
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}
.subject-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.subject-card:active { transform: translateY(0) scale(0.99); }
.subject-icon { font-size: 28px; }
.subject-name { font-size: 13px; color: var(--text-2); font-weight: 500; }
.subject-full { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.subject-meta { font-size: 12px; color: var(--text-3); margin-top: 8px; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 520px) {
  .quick-actions { grid-template-columns: 1fr; }
}
.quick-action {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}
.quick-action:hover { background: var(--bg-elev-2); }
.quick-action:active { transform: scale(0.98); }
.qa-title { font-size: 15px; font-weight: 600; }
.qa-sub { font-size: 12px; color: var(--text-2); }

.disclaimer {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
  margin: 8px 0 0;
}

/* ===== 套卷列表 ===== */
.paper-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.paper-card {
  width: 100%;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.paper-card:hover { background: var(--bg-elev-2); border-color: var(--line-strong); }
.paper-card:active { transform: scale(0.995); }
.paper-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.paper-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.paper-count { font-size: 13px; color: var(--text-2); }
.paper-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.paper-best {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.12);
  color: var(--accent);
}

.paper-card.paper-exam {
  background: linear-gradient(135deg, rgba(0, 113, 227, 0.06), rgba(0, 113, 227, 0.02));
  border-color: rgba(0, 113, 227, 0.24);
}
[data-theme="dark"] .paper-card.paper-exam {
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.10), rgba(10, 132, 255, 0.04));
  border-color: rgba(10, 132, 255, 0.30);
}
.paper-card.paper-exam .paper-name { color: var(--accent); }

/* ===== 模式选择 ===== */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .mode-grid { grid-template-columns: 1fr; } }
.mode-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: left;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}
.mode-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.mode-card:active { transform: translateY(0) scale(0.99); }
.mode-icon { font-size: 28px; }
.mode-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.mode-sub { font-size: 13px; color: var(--text-2); }

/* ===== 答题页 ===== */
.quiz-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quiz-meta {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  gap: 8px;
  align-items: center;
}
.quiz-meta .dot { color: var(--text-3); }

.progress { display: flex; align-items: center; gap: 12px; }
.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-elev);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s var(--ease-out);
}
.progress-text { font-size: 13px; color: var(--text-2); min-width: 60px; text-align: right; }

.qcard {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-md);
  animation: qIn 0.34s var(--ease-out);
}

@keyframes qIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.qhead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 12px;
}
.qtype {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.10);
}
[data-theme="dark"] .qtype { background: rgba(10, 132, 255, 0.16); }
.qchapter { color: var(--text-3); font-size: 12px; }

.qstem {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 4px 0 18px;
}

.qoptions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qopt {
  background: var(--bg-elev-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  user-select: none;
}
.qopt:hover { border-color: var(--line-strong); background: var(--bg-elev); }
.qopt.selected { border-color: var(--accent); background: rgba(0, 113, 227, 0.06); }
[data-theme="dark"] .qopt.selected { background: rgba(10, 132, 255, 0.10); }
.qopt.correct { border-color: var(--success); background: rgba(52, 199, 89, 0.10); }
.qopt.wrong { border-color: var(--danger); background: rgba(255, 59, 48, 0.10); }
.qopt.disabled { cursor: default; }
.qopt-letter {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1.5px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-2);
  transition: all 0.18s var(--ease);
}
.qopt.selected .qopt-letter { background: var(--accent); color: white; border-color: var(--accent); }
.qopt.correct .qopt-letter { background: var(--success); color: white; border-color: var(--success); }
.qopt.wrong .qopt-letter { background: var(--danger); color: white; border-color: var(--danger); }
.qopt-text { font-size: 15px; line-height: 1.5; flex: 1; }

.qfeedback {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  animation: feedIn 0.3s var(--ease-out);
}
@keyframes feedIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.qresult { font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.qresult.right { color: var(--success); }
.qresult.wrong { color: var(--danger); }
.qexplain {
  background: var(--bg-elev-2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--line);
}
.qexplain-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.qexplain-body { font-size: 14px; line-height: 1.65; color: var(--text); }

.quiz-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}
.quiz-actions.secondary-row { justify-content: flex-end; }

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  transition: all 0.16s var(--ease);
  letter-spacing: -0.005em;
}
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); transform: scale(0.98); }

.btn-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover { background: var(--bg-elev-2); }
.btn-secondary:active { transform: scale(0.98); }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: rgba(0, 113, 227, 0.08); }
[data-theme="dark"] .btn-ghost:hover { background: rgba(10, 132, 255, 0.12); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--line-strong);
}
.btn-danger:hover { background: rgba(255, 59, 48, 0.08); }

button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:hover { background: var(--bg-elev); transform: none; }

/* ===== 模考报告 ===== */
.report-summary {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  align-items: center;
  box-shadow: var(--shadow-md);
}
@media (max-width: 520px) {
  .report-summary { grid-template-columns: 1fr; text-align: center; }
}
.score-ring {
  width: 140px; height: 140px;
  border-radius: 50%;
  background:
    conic-gradient(var(--accent) var(--p, 0deg), var(--bg-elev-2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 auto;
}
.score-ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--bg-elev);
}
.score-num {
  position: relative;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.03em;
  z-index: 1;
}
.score-total {
  position: absolute;
  bottom: 32px;
  font-size: 12px;
  color: var(--text-3);
  z-index: 1;
}

.score-text { display: flex; flex-direction: column; gap: 8px; }
.score-line {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  font-size: 14px;
}
.score-line:last-child { border-bottom: none; }
.score-line .label { color: var(--text-2); }

.chapter-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.chap-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.chap-name { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.chap-score {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.chap-bar { margin-top: 8px; height: 4px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden; }
.chap-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-item {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.review-item:hover { background: var(--bg-elev-2); }
.review-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.review-num { font-size: 12px; color: var(--text-3); font-weight: 600; }
.review-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.review-tag.right { background: rgba(52, 199, 89, 0.14); color: var(--success); }
.review-tag.wrong { background: rgba(255, 59, 48, 0.14); color: var(--danger); }
.review-tag.skip { background: rgba(142, 142, 147, 0.18); color: var(--text-2); }
.review-stem {
  font-size: 14px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.review-body { display: none; padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line); }
.review-item.expanded .review-body { display: block; }
.review-item.expanded .review-stem { -webkit-line-clamp: unset; }

/* ===== 错题本 ===== */
.wrong-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: fit-content;
}
.wrong-tab {
  border: none;
  background: transparent;
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.wrong-tab.active { background: var(--bg-elev-2); color: var(--text); box-shadow: var(--shadow-sm); }

.wrong-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.empty-state {
  background: var(--bg-elev);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
}

/* ===== 数据管理 ===== */
.data-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}
.data-actions button { width: 100%; padding: 14px; font-size: 15px; }

/* ===== 历史 ===== */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.history-row .name { font-weight: 500; }
.history-row .score { color: var(--accent); font-weight: 600; }
.history-row .time { color: var(--text-3); font-size: 12px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s var(--ease-out);
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Scroll & focus ===== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
::selection { background: rgba(0, 113, 227, 0.18); }
