/* ============================================
   考试模拟工具 - 样式表
   Mobile-first Responsive Design
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --correct: #10b981;
  --correct-light: #d1fae5;
  --error: #ef4444;
  --error-light: #fee2e2;
  --parse-correct: #dbeafe;
  --parse-error: #fef3c7;
  --star: #f59e0b;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --nav-height: 56px;
  --bottom-bar-height: 64px;
  --transition: all 0.2s ease;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
  display: block;
}

/* ---------- Page Container ---------- */
.page {
  width: 100%;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ============================================
   通用组件 (Common Components)
   ============================================ */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.35);
}

.btn-outline {
  background: var(--card-bg);
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: rgba(37, 99, 235, 0.05);
}

.btn-success {
  background: var(--correct);
  color: #fff;
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.125rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Cards --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-elevated {
  box-shadow: var(--shadow-lg);
}

/* --- Modal / Popup --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.modal-body {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  text-align: center;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn {
  flex: 1;
}

/* --- Progress Bar --- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.35s ease;
}

/* --- Badge / Tag --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--correct);
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

/* ============================================
   1. 首页 (Home Page)
   ============================================ */
.home-page {
  padding: 24px 16px;
  max-width: 600px;
  margin: 0 auto;
}

.home-header {
  text-align: center;
  padding: 32px 0 24px;
}

.home-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.home-header p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* 功能卡片网格 */
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.home-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
  cursor: pointer;
  text-align: center;
  border: 2px solid transparent;
}

.home-card:active {
  transform: scale(0.96);
  border-color: var(--primary);
}

.home-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
}

.home-card-icon.green {
  background: rgba(16, 185, 129, 0.08);
  color: var(--correct);
}

.home-card-icon.orange {
  background: rgba(245, 158, 11, 0.08);
  color: var(--star);
}

.home-card-icon.red {
  background: rgba(239, 68, 68, 0.08);
  color: var(--error);
}

.home-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.home-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ============================================
   2. 题型选择页 (Type Select)
   ============================================ */
.type-select {
  padding: 24px 16px;
  max-width: 600px;
  margin: 0 auto;
}

.type-select-header {
  text-align: center;
  padding: 32px 0 16px;
}

.type-select-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.type-select-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.type-select-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.type-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 2px solid transparent;
  text-align: left;
}

.type-btn:active {
  transform: scale(0.98);
  border-color: var(--primary);
}

.type-btn-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.type-btn-info h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.type-btn-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================
   3. 答题页 (Practice / Exam Page)
   ============================================ */

/* --- Top Navigation Bar --- */
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.nav-bar-left,
.nav-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 60px;
}

.nav-bar-right {
  justify-content: flex-end;
}

.nav-back-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.25rem;
  transition: var(--transition);
}

.nav-back-btn:active {
  background: rgba(0, 0, 0, 0.06);
}

.nav-bar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.nav-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.nav-progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-timer {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--error);
  font-variant-numeric: tabular-nums;
  background: rgba(239, 68, 68, 0.08);
  padding: 4px 10px;
  border-radius: 20px;
}

/* --- Question Content Area --- */
.question-area {
  padding: calc(var(--nav-height) + 16px) 16px calc(var(--bottom-bar-height) + 16px);
  max-width: 700px;
  margin: 0 auto;
}

.question-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.question-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.question-type-badge {
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
  font-weight: 600;
}

.question-stem {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* --- Options List --- */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.option-item:active {
  transform: scale(0.99);
}

.option-label {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: var(--transition);
}

.option-text {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  padding-top: 3px;
}

/* Option: Selected */
.option-item.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.04);
}

.option-item.selected .option-label {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Option: Correct */
.option-item.correct {
  border-color: var(--correct);
  background: var(--correct-light);
}

.option-item.correct .option-label {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

/* Option: Wrong */
.option-item.wrong {
  border-color: var(--error);
  background: var(--error-light);
}

.option-item.wrong .option-label {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

/* Option: Disabled (after submit) */
.option-item.disabled {
  cursor: default;
  pointer-events: none;
  opacity: 0.85;
}

/* --- 解析区域 (Explanation) --- */
.explanation {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius-sm);
  animation: fadeInUp 0.3s ease;
}

.explanation.correct {
  background: var(--parse-correct);
  border-left: 4px solid var(--primary);
}

.explanation.wrong {
  background: var(--parse-error);
  border-left: 4px solid var(--star);
}

.explanation-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.explanation.correct .explanation-title {
  color: var(--primary);
}

.explanation.wrong .explanation-title {
  color: #b45309;
}

.explanation-text {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

/* --- Bottom Action Bar --- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-bar-height);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.bottom-bar .btn {
  min-width: 90px;
}

.btn-prev,
.btn-next {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-prev {
  background: var(--bg);
  color: var(--text-secondary);
}

.btn-next {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn-submit-exam {
  background: var(--correct);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-favorite {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.btn-favorite:active {
  transform: scale(1.15);
}

.btn-favorite.active {
  color: var(--star);
}

/* ============================================
   4. 考试专用 (Exam Specific)
   ============================================ */

/* --- Answer Card Panel --- */
.answer-card-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.answer-card-overlay.active {
  opacity: 1;
  visibility: visible;
}

.answer-card {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
  max-height: 70vh;
  overflow-y: auto;
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.answer-card-overlay.active .answer-card {
  transform: translateY(0);
}

.answer-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.answer-card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.answer-card-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.answer-card-close:active {
  background: rgba(0, 0, 0, 0.06);
}

.answer-card-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.legend-dot.answered {
  background: var(--primary);
}

.legend-dot.unanswered {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
}

.legend-dot.flagged {
  background: var(--star);
}

.answer-card-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
}

.answer-card-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
  cursor: pointer;
}

.answer-card-cell:active {
  transform: scale(0.9);
}

.answer-card-cell.answered {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.answer-card-cell.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

.answer-card-cell.flagged {
  background: var(--star);
  border-color: var(--star);
  color: #fff;
}

/* Timer */
.exam-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--error);
  font-variant-numeric: tabular-nums;
}

.exam-timer-icon {
  font-size: 1.1rem;
}

.exam-timer.urgent {
  animation: pulse 1s ease infinite;
}

/* Exam Submit Button */
.exam-submit-area {
  margin-top: 20px;
  display: flex;
  gap: 12px;
}

/* ============================================
   5. 考试结果页 (Result Page)
   ============================================ */
.result-page {
  padding: 24px 16px;
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.result-hero {
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius-lg);
  color: #fff;
  margin-bottom: 24px;
}

.result-score {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
}

.result-score-unit {
  font-size: 1.5rem;
  font-weight: 600;
  opacity: 0.85;
}

.result-total {
  font-size: 1rem;
  opacity: 0.8;
  margin-top: 4px;
}

.result-status {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
}

.result-status.pass {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.result-status.fail {
  background: rgba(239, 68, 68, 0.6);
  color: #fff;
}

/* Stats Row */
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-card.correct .stat-value {
  color: var(--correct);
}

.stat-card.wrong .stat-value {
  color: var(--error);
}

/* Wrong Questions List */
.result-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wrong-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wrong-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--error);
}

.wrong-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.wrong-item-number {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--error);
}

.wrong-item-type {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.08);
  color: var(--error);
  font-weight: 600;
}

.wrong-item-stem {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 10px;
}

.wrong-item-answer {
  font-size: 0.85rem;
  color: var(--correct);
  font-weight: 600;
}

.wrong-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ============================================
   6. 错题本 (Wrong Book Page)
   ============================================ */
.wrongbook-page {
  padding: 16px;
  max-width: 700px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.wrongbook-header {
  padding: 16px 0 20px;
}

.wrongbook-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.wrongbook-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.wrongbook-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.wrongbook-filter::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  transition: var(--transition);
}

.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.wrongbook-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wrongbook-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.wrongbook-item:active {
  box-shadow: var(--shadow-md);
}

.wrongbook-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.wrongbook-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wrongbook-item-num {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.wrongbook-item-stem {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wrongbook-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.wrongbook-item-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.wrongbook-item-actions {
  display: flex;
  gap: 8px;
}

.btn-star {
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.btn-star.active {
  color: var(--star);
}

.btn-retry {
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
  transition: var(--transition);
}

.btn-retry:active {
  background: rgba(37, 99, 235, 0.15);
}

/* ============================================
   7. Animations
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.animate-fade-in {
  animation: fadeInUp 0.3s ease;
}

.animate-scale-in {
  animation: scaleIn 0.25s ease;
}

/* ============================================
   Responsive - Tablet (≥640px)
   ============================================ */
@media (min-width: 640px) {
  .home-page,
  .type-select,
  .result-page {
    padding: 32px 24px;
  }

  .home-header h1 {
    font-size: 2rem;
  }

  .home-grid {
    gap: 20px;
  }

  .home-card {
    padding: 32px 20px;
  }

  .home-card-icon {
    width: 64px;
    height: 64px;
    font-size: 2rem;
  }

  .answer-card-grid {
    grid-template-columns: repeat(15, 1fr);
    gap: 10px;
  }

  .question-stem {
    font-size: 1.1rem;
    padding: 20px;
  }

  .option-item {
    padding: 16px 20px;
  }

  .result-score {
    font-size: 5rem;
  }

  .result-hero {
    padding: 48px 24px;
  }
}

/* ============================================
   Responsive - Desktop (≥1024px)
   ============================================ */
@media (min-width: 1024px) {
  body {
    background: #eef2f7;
  }

  .page {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg);
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.06);
  }

  .nav-bar {
    max-width: 800px;
    left: 50%;
    transform: translateX(-50%);
  }

  .bottom-bar {
    max-width: 800px;
    left: 50%;
    transform: translateX(-50%);
  }

  .answer-card {
    max-width: 800px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
  }

  .answer-card-overlay.active .answer-card {
    transform: translateX(-50%) translateY(0);
  }

  .home-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .result-stats {
    gap: 16px;
  }

  .answer-card-grid {
    grid-template-columns: repeat(20, 1fr);
  }
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-success { color: var(--correct); }
.text-error { color: var(--error); }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Safe area padding for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-bar {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ============================================
   文本学习页 (Text Study)
   ============================================ */
.textstudy-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.textstudy-toolbar {
  position: sticky;
  top: var(--nav-height);
  z-index: 10;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.textstudy-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.textstudy-tab {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.textstudy-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.textstudy-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 40px;
}

.textstudy-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.textstudy-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.textstudy-item-num {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  min-width: 36px;
}

.textstudy-item-type {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.textstudy-item-type.single { background: #dbeafe; color: #1d4ed8; }
.textstudy-item-type.multi { background: #d1fae5; color: #065f46; }
.textstudy-item-type.judge { background: #fef3c7; color: #92400e; }

.textstudy-item-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.textstudy-question-col {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  line-height: 1.7;
  font-size: 14px;
  color: var(--text-primary);
}

.textstudy-question-col .answer-mark {
  color: var(--error);
  font-weight: 700;
}

.textstudy-explain-col {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  background: #fafbfc;
}

.textstudy-explain-col strong {
  color: var(--text-primary);
}

/* 移动端单栏 */
@media (max-width: 768px) {
  .textstudy-item-body {
    grid-template-columns: 1fr;
  }
  .textstudy-question-col {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* 文本学习 - 正确答案绿色底色 */
.textstudy-opt {
  padding: 4px 8px;
  border-radius: 4px;
  margin: 2px 0;
}

.textstudy-opt.textstudy-correct {
  background: #d1fae5;
  color: #065f46;
  font-weight: 600;
}

.textstudy-opt.textstudy-correct::after {
  content: '';
}
