/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --success: #52c41a;
  --danger: #ff4d4f;
  --warning: #faad14;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #888;
  --border: #e8e8e8;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #e8edf2;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

/* ===== App Container ===== */
#app {
  max-width: 576px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.12);
}

/* ===== Pages ===== */
.page {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}
.page.active {
  display: flex;
}

/* ============================================================
   封面页
   ============================================================ */
#page-cover {
  background: linear-gradient(160deg, #1677ff 0%, #0958d9 55%, #003eb3 100%);
  align-items: center;
  justify-content: center;
  padding: 48px 24px 40px;
  position: relative;
  overflow: hidden;
}

#page-cover::before {
  content: '';
  position: absolute;
  top: -100px; right: -100px;
  width: 320px; height: 320px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
#page-cover::after {
  content: '';
  position: absolute;
  bottom: -80px; left: -80px;
  width: 260px; height: 260px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.cover-logo {
  font-size: 72px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
  position: relative; z-index: 1;
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

.cover-title {
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: 1px;
  position: relative; z-index: 1;
}
.cover-subtitle {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  text-align: center;
  margin-bottom: 44px;
  position: relative; z-index: 1;
}

.cover-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative; z-index: 1;
}

.cover-btn {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.13);
  border: 1.5px solid rgba(255,255,255,0.22);
  border-radius: 16px;
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}
.cover-btn:active {
  transform: scale(0.97);
  background: rgba(255,255,255,0.22);
}
.cover-btn.disabled {
  opacity: 0.38;
  pointer-events: none;
}

.cover-btn-icon { font-size: 34px; margin-right: 14px; flex-shrink: 0; }
.cover-btn-info { flex: 1; text-align: left; }
.cover-btn-title { color: #fff; font-size: 16px; font-weight: 600; margin-bottom: 3px; }
.cover-btn-desc  { color: rgba(255,255,255,0.6); font-size: 12px; }
.cover-btn-arrow { color: rgba(255,255,255,0.45); font-size: 22px; font-weight: 300; }

.cover-footer {
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  margin-top: 36px;
  text-align: center;
  position: relative; z-index: 1;
}

/* ============================================================
   通用页头
   ============================================================ */
.page-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.btn-back {
  background: none; border: none;
  color: #fff; font-size: 26px;
  cursor: pointer; padding: 2px 6px 2px 0;
  line-height: 1;
}
.page-header-title {
  font-size: 16px; font-weight: 600; flex: 1;
}
.page-header-action {
  background: none; border: none;
  color: rgba(255,255,255,0.85);
  font-size: 13px; cursor: pointer;
  padding: 4px 8px;
}

/* ============================================================
   模式选择页
   ============================================================ */
.mode-content { padding: 16px; }

.mode-stats {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.mode-stats-title { font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; }
.stats-row { display: flex; gap: 10px; }
.stat-item {
  flex: 1; text-align: center;
  background: var(--bg); border-radius: 8px; padding: 10px 6px;
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-num.red   { color: var(--danger); }
.stat-num.green { color: var(--success); }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.mode-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 2px solid transparent;
}
.mode-card:active { transform: scale(0.98); border-color: var(--primary); }
.mode-card.disabled { opacity: 0.4; pointer-events: none; }
.mode-card-icon  { font-size: 36px; flex-shrink: 0; }
.mode-card-info  { flex: 1; }
.mode-card-title { font-size: 17px; font-weight: 700; margin-bottom: 3px; }
.mode-card-desc  { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.mode-card-arrow { color: #ccc; font-size: 22px; }

/* ============================================================
   答题页
   ============================================================ */
#page-quiz { background: var(--bg); }

.quiz-header {
  background: var(--card);
  padding: 10px 14px 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
}
.quiz-header-top {
  display: flex; align-items: center; margin-bottom: 8px;
}
.quiz-mode-badge {
  font-size: 11px; padding: 3px 9px;
  border-radius: 20px; font-weight: 600; margin-right: 8px;
}
.badge-practice { background: #e6f4ff; color: var(--primary); }
.badge-exam     { background: #fff2e8; color: #d4380d; }

.quiz-progress-text { font-size: 13px; color: var(--text-secondary); flex: 1; }
.quiz-score-text    { font-size: 13px; font-weight: 700; color: var(--primary); }

.quiz-timer {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-left: auto;
  margin-right: 8px;
  transition: color 0.3s;
}
.quiz-timer.warning { color: var(--warning); }
.quiz-timer.danger  { color: var(--danger); animation: timerPulse 0.5s ease infinite; }
@keyframes timerPulse {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.4; }
}

.progress-bar-wrap {
  height: 5px; background: #eee; border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #40a9ff);
  border-radius: 3px;
  transition: width 0.35s ease;
}

/* 题目主体 */
.quiz-body {
  flex: 1;
  padding: 14px 14px 0;
  overflow-y: auto;
}

/* 题目卡片 */
.question-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

/* 题目文字 */
.question-text {
  padding: 16px 16px 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
  border-bottom: 1px solid var(--border);
}
.question-num {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 8px;
  vertical-align: middle;
}

/* 题目图片区 */
.question-imgs {
  display: flex;
  gap: 0;
  background: #f7f7f7;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.question-imgs.single .q-img-wrap { flex: 1; }
.question-imgs.multi  .q-img-wrap { flex: 1 1 0; min-width: 0; }

.q-img-wrap {
  position: relative;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
}
.q-img-wrap:last-child { border-right: none; }

.q-img-label {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}

.q-img {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 260px;
}
.q-img-loading {
  position: absolute;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== 选项 ===== */
.options-wrap {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: flex;
  align-items: center;
  background: #fafafa;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  text-align: left;
  gap: 12px;
}
.option-btn:active { transform: scale(0.985); }
.option-btn:disabled { cursor: default; }

.option-letter {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #d0d0d0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800;
  flex-shrink: 0;
  transition: all 0.15s;
  color: #555;
}
.option-text {
  flex: 1;
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}

/* 选项图片（如果选项本身有图） */
.option-img {
  width: 60px; height: 60px;
  object-fit: contain;
  border-radius: 6px;
  background: #f0f0f0;
  flex-shrink: 0;
}

/* 选项状态 */
.option-btn.selected {
  border-color: var(--primary);
  background: #e6f4ff;
}
.option-btn.selected .option-letter {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.option-btn.correct {
  border-color: var(--success);
  background: #f6ffed;
}
.option-btn.correct .option-letter {
  background: var(--success); border-color: var(--success); color: #fff;
}
.option-btn.wrong {
  border-color: var(--danger);
  background: #fff2f0;
}
.option-btn.wrong .option-letter {
  background: var(--danger); border-color: var(--danger); color: #fff;
}

/* ===== 答题反馈 ===== */
.answer-feedback {
  margin: 0 14px 14px;
  padding: 13px 14px;
  border-radius: 10px;
  display: none;
  align-items: flex-start;
  gap: 10px;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.answer-feedback.show { display: flex; }
.feedback-correct { background: #f6ffed; border: 1px solid #b7eb8f; }
.feedback-wrong   { background: #fff2f0; border: 1px solid #ffccc7; }
.feedback-icon    { font-size: 22px; flex-shrink: 0; margin-top: 1px; }
.feedback-title   { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.feedback-correct .feedback-title { color: var(--success); }
.feedback-wrong   .feedback-title { color: var(--danger); }
.feedback-desc    { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* 多选题标签 */
.multi-tag {
  display: inline-block;
  background: #fff2e8;
  color: #d4380d;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

/* 多选题选项：方形角标 */
.option-btn.multi .option-letter {
  border-radius: 6px; /* 方形表示多选 */
}

/* ===== 底部按钮 ===== */
.quiz-footer {
  padding: 12px 14px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-next {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  display: none;
}
.btn-next.show { display: block; }
.btn-next:active { background: var(--primary-dark); transform: scale(0.98); }

.btn-confirm {
  width: 100%;
  background: #ff7a00;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  margin-bottom: 10px;
}
.btn-confirm:active { background: #d46b00; transform: scale(0.98); }

/* ============================================================
   结果页
   ============================================================ */
#page-result { background: var(--bg); }

.result-header {
  width: 100%;
  padding: 44px 24px 28px;
  text-align: center;
}
.result-header.pass { background: linear-gradient(160deg, #52c41a, #389e0d); }
.result-header.fail { background: linear-gradient(160deg, #ff7875, #cf1322); }

.result-emoji {
  font-size: 60px; margin-bottom: 10px; display: block;
  animation: bounceIn 0.5s ease;
}
@keyframes bounceIn {
  0%  { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.1); }
  100%{ transform: scale(1);   opacity: 1; }
}
.result-score-big   { font-size: 68px; font-weight: 800; color: #fff; line-height: 1; margin-bottom: 4px; }
.result-score-label { font-size: 13px; color: rgba(255,255,255,0.7); margin-bottom: 8px; }
.result-verdict     { font-size: 20px; font-weight: 700; color: #fff; }

.result-body { width: 100%; padding: 18px 14px; }

.result-stats-card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.result-stats-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 10px;
}
.result-stat {
  text-align: center; padding: 12px 6px;
  background: var(--bg); border-radius: 8px;
}
.result-stat-num   { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.result-stat-label { font-size: 11px; color: var(--text-secondary); }

.result-actions { display: flex; flex-direction: column; gap: 10px; }

.btn-primary {
  width: 100%; background: var(--primary); color: #fff;
  border: none; border-radius: 10px; padding: 15px;
  font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.18s;
}
.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }

.btn-secondary {
  width: 100%; background: var(--card); color: var(--primary);
  border: 2px solid var(--primary); border-radius: 10px; padding: 13px;
  font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.18s;
}
.btn-secondary:active { background: #e6f4ff; transform: scale(0.98); }

/* ============================================================
   错题本页
   ============================================================ */
#page-wronglist { background: var(--bg); }

.wrong-list { padding: 14px; }

.wrong-item {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.wrong-item-question {
  padding: 14px 14px 10px;
  font-size: 15px; font-weight: 600; color: var(--text);
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.wrong-item-imgs {
  display: flex; background: #f7f7f7;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.wrong-item-img {
  flex: 0 0 auto;
  max-height: 140px;
  object-fit: contain;
  display: block;
}
.wrong-item-footer {
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.wrong-answer-tags { display: flex; gap: 8px; }
.wrong-answer-tag {
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.tag-wrong    { background: #fff2f0; color: var(--danger); }
.tag-correct  { background: #f6ffed; color: var(--success); }
.wrong-item-num { font-size: 12px; color: var(--text-secondary); }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-secondary);
}
.empty-state-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state-text { font-size: 15px; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(0.9);
  background: rgba(0,0,0,0.72);
  color: #fff; padding: 11px 22px;
  border-radius: 8px; font-size: 14px;
  z-index: 9999; opacity: 0;
  transition: all 0.2s; pointer-events: none;
  white-space: nowrap; max-width: 280px; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

/* ============================================================
   记忆曲线复习页
   ============================================================ */
#page-ebbinghaus { background: var(--bg); }

.ebbinghaus-content { padding: 16px; }

.ebbinghaus-intro {
  background: linear-gradient(135deg, #e6f4ff 0%, #f0f5ff 100%);
  border: 1px solid #91caff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.ebbinghaus-intro-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}
.ebbinghaus-intro-desc {
  font-size: 13px;
  color: #555;
  line-height: 1.7;
}
.ebbinghaus-intro-desc strong {
  color: var(--primary);
}

.ebbinghaus-stats {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.ebbinghaus-start-btn {
  margin-bottom: 18px;
}
.ebbinghaus-start-btn:disabled {
  background: #ccc;
  cursor: default;
}

.ebbinghaus-schedule-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.ebbinghaus-list { display: flex; flex-direction: column; gap: 10px; }

.ebb-item {
  background: var(--card);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}
.ebb-item-stage {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  color: #fff;
}
.ebb-item-stage.due      { background: var(--danger); }
.ebb-item-stage.waiting  { background: #d9d9d9; }
.ebb-item-stage.done     { background: var(--success); }

.ebb-item-info { flex: 1; min-width: 0; }
.ebb-item-question {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.ebb-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ebb-item-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.ebb-badge-due     { background: #fff2f0; color: var(--danger); }
.ebb-badge-waiting { background: #f5f5f5; color: #999; }
.ebb-badge-done    { background: #f6ffed; color: var(--success); }

/* ============================================================
   题库预览页
   ============================================================ */
#page-bank { background: var(--bg); }

.bank-list { padding: 14px; }

.bank-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.bank-item-header {
  padding: 14px 14px 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}
.bank-item-imgs {
  display: flex;
  background: #f7f7f7;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.bank-item-imgs .q-img-wrap { flex: 1 1 0; min-width: 0; }
.bank-item-imgs .q-img {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 160px;
}
.bank-item-options {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bank-option {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  padding: 2px 0;
}
.bank-option.is-answer {
  color: var(--success);
  font-weight: 700;
}
.bank-item-answer {
  padding: 8px 14px 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.bank-answer-label {
  display: inline-block;
  background: #f6ffed;
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 6px;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* ============================================================
   吸底导航栏
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 576px;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  z-index: 200;
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav.show {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item:active {
  transform: scale(0.92);
}

.bottom-nav-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 2px;
  transition: transform 0.2s;
}
.bottom-nav-item.active .bottom-nav-icon {
  transform: scale(1.15);
}

.bottom-nav-label {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.2s;
  white-space: nowrap;
}
.bottom-nav-item.active .bottom-nav-label {
  color: var(--primary);
  font-weight: 700;
}

/* 激活指示条 */
.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

/* 有底部导航的页面需要留出底部空间 */
.page.has-bottom-nav {
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}
