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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 640px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Page ===== */
.page {
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

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

/* ===== Header ===== */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}

.header-count {
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--border);
  padding: 2px 10px;
  border-radius: 20px;
}

.back-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  min-height: 44px;
  display: flex;
  align-items: center;
}

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

/* ===== Home Page ===== */
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-top: 8px;
}

.home-title-area h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  padding: 8px 14px;
  border-radius: 20px;
  font-weight: 600;
}

.streak-icon { font-size: 18px; }
.streak-num { font-size: 20px; color: #92400e; }
.streak-label { font-size: 12px; color: #92400e; }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.stat-body {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-card-today .stat-value { color: var(--primary); }
.stat-card-accuracy .stat-value { color: var(--success); }
.stat-card-total .stat-value { color: #7c3aed; }
.stat-card-wrong .stat-value { color: var(--danger); }

/* ===== Action Grid ===== */
.action-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  width: 100%;
  min-height: 72px;
}

.action-btn:active {
  transform: scale(0.98);
  box-shadow: var(--shadow);
}

.action-icon {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.action-title {
  font-size: 16px;
  font-weight: 600;
  display: block;
}

.action-desc {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.action-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--danger);
  color: white;
  font-size: 12px;
  font-weight: 600;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Sections ===== */
.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

/* ===== Overview ===== */
.overview-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.overview-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
}

.overview-item:active { transform: scale(0.96); }

.overview-icon { font-size: 24px; display: block; margin-bottom: 6px; }
.overview-info { display: flex; flex-direction: column; }
.overview-num { font-size: 20px; font-weight: 700; }
.overview-label { font-size: 12px; color: var(--text-secondary); }

/* ===== Recent Exams ===== */
.recent-exams {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-card-mini {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.exam-card-mini-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.exam-card-mini-name {
  font-size: 14px;
  font-weight: 600;
}

.exam-card-mini-time {
  font-size: 12px;
  color: var(--text-light);
}

.exam-card-mini-right {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-weight: 700;
  font-size: 20px;
}

.exam-card-mini-right.passed { color: var(--success); }
.exam-card-mini-right.failed { color: var(--danger); }

.exam-card-mini-label {
  font-size: 12px;
  font-weight: 400;
}

/* ===== Practice Page ===== */
.practice-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.practice-type-tabs {
  display: flex;
  gap: 4px;
  background: var(--border);
  padding: 3px;
  border-radius: 20px;
  flex: 1;
}

.practice-tab {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.practice-tab.active {
  background: var(--bg-card);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* ===== Question Grid ===== */
.question-grid-header {
  margin-bottom: 12px;
  cursor: pointer;
  user-select: none;
}

.grid-header-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

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

.grid-header-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.grid-header-badges {
  display: flex;
  gap: 8px;
}

.grid-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg);
}

.fav-badge {
  color: #f59e0b;
}

.grid-toggle-btn {
  font-size: 12px;
  color: var(--text-light);
  min-width: 20px;
  text-align: right;
}

.question-grid {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 260px;
  overflow-y: auto;
}

.question-grid.expanded {
  display: flex;
}

.grid-dot {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.1s;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.grid-dot:active {
  transform: scale(0.9);
}

.grid-dot.current {
  background: var(--primary);
  color: white;
  font-weight: 700;
  border-color: var(--primary);
}

.grid-dot.correct {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}

.grid-dot.wrong {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.grid-dot.fav {
  position: relative;
}

.grid-dot.fav::after {
  content: '★';
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 10px;
  color: #f59e0b;
}

.grid-dot.key {
  background: #fff1f2;
  color: #e11d48;
  border-color: #fda4af;
  font-weight: 700;
}

/* ===== Progress Bar (deprecated for practice, keep for exam) ===== */
.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 48px;
  text-align: right;
}

/* ===== Question Card ===== */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

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

.fav-btn {
  margin-left: auto;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  user-select: none;
}

.fav-btn:active {
  transform: scale(0.85);
}

.fav-btn.faved {
  color: #f59e0b;
}

.key-icon {
  font-size: 12px;
  font-weight: 600;
  color: #e11d48;
  background: #ffe4e6;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: auto;
  white-space: nowrap;
  user-select: none;
  line-height: 1.4;
}

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

.question-type-badge.small {
  font-size: 11px;
  padding: 1px 8px;
}

.question-number {
  font-size: 13px;
  color: var(--text-secondary);
}

.question-pool-id {
  font-size: 12px;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.question-content {
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 16px;
  font-weight: 500;
}

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

.option-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 48px;
  position: relative;
}

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

.option-item.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.option-item.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.option-item.wrong {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.option-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.15s;
}

.option-item.selected .option-marker {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.option-item.correct .option-marker {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.option-item.wrong .option-marker {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.option-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.5;
}

.option-check {
  color: var(--success);
  font-weight: 700;
  font-size: 18px;
}

.option-cross {
  color: var(--danger);
  font-weight: 700;
  font-size: 18px;
}

/* Multi-select hint */
.multi-select .option-item.selected::after {
  content: '☑';
  position: absolute;
  right: 12px;
  font-size: 18px;
  color: var(--primary);
}

/* ===== Explanation ===== */
.explanation-panel {
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  margin-top: 12px;
  border: 1px solid;
}

.explanation-panel.correct {
  background: var(--success-bg);
  border-color: var(--success);
}

.explanation-panel.wrong {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.explanation-header {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
}

.explanation-answer {
  font-weight: 400;
  font-size: 13px;
  margin-left: 8px;
  opacity: 0.8;
}

.explanation-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.explanation-body strong {
  color: var(--primary);
}

/* ===== Practice Nav ===== */
.practice-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.nav-btn {
  flex: 1;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 48px;
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.confirm-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  min-height: 48px;
}

.confirm-btn:active {
  background: var(--primary-dark);
}

/* ===== Exam List ===== */
.exam-list-intro {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.exam-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.exam-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.exam-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.exam-card-number {
  font-size: 18px;
  font-weight: 700;
}

.exam-card-score {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
}

.exam-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.exam-card-pass {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.exam-card-last {
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
  display: inline-block;
}

.exam-card-last.passed {
  background: var(--success-bg);
  color: var(--success);
}

.exam-card-last.failed {
  background: var(--danger-bg);
}

.exam-card-draft {
  font-size: 13px;
  color: var(--warning);
  background: #fef3c7;
  padding: 6px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-weight: 500;
}

.exam-records {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

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

.exam-record-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 3px solid var(--border);
}

.exam-record-item.passed { border-left-color: var(--success); }
.exam-record-item.failed { border-left-color: var(--danger); }

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.record-date {
  font-size: 12px;
  color: var(--text-light);
}

.record-result {
  font-size: 12px;
  font-weight: 600;
}

.record-result.passed { color: var(--success); }
.record-result.failed { color: var(--danger); }

.record-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.record-score {
  font-size: 14px;
}

.record-score strong {
  font-size: 18px;
  color: var(--text);
}

.record-passline {
  font-size: 12px;
  color: var(--text-light);
}

.record-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.record-stat {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 4px;
}

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

.record-review-btn {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}

.record-review-btn:active {
  opacity: 0.9;
}

.record-no-wrong {
  font-size: 13px;
  color: var(--success);
  text-align: center;
  padding: 8px;
}

.wrong-review-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.wrong-review-nav .nav-btn {
  flex: 1;
  font-size: 14px;
}

.start-exam-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
}

.start-exam-btn:active {
  background: var(--primary-dark);
}

/* ===== Exam Room ===== */
.exam-room-page {
  padding: 0;
}

.exam-room-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.exam-room-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.exam-room-timer {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  min-width: 60px;
  text-align: right;
}

.timer-warning {
  color: var(--danger) !important;
  animation: pulse 1s infinite;
}

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

.exam-room-page .question-card {
  border-radius: 0;
  border-left: none;
  border-right: none;
  box-shadow: none;
  margin-bottom: 0;
}

.exam-room-page .progress-bar-container {
  padding: 12px 16px;
  margin-bottom: 0;
}

/* ===== Question Dots ===== */
.question-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}

.question-nav .nav-btn {
  flex: 0 0 auto;
  padding: 10px 16px;
  font-size: 13px;
}

.question-dots {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.q-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

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

.q-dot.current {
  transform: scale(1.4);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

.q-dot-more {
  font-size: 12px;
  color: var(--text-light);
}

/* ===== Exam Room Footer ===== */
.exam-room-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  bottom: 0;
}

.answered-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.submit-exam-btn {
  padding: 12px 28px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.submit-exam-btn:active {
  opacity: 0.9;
}

.exam-room-actions {
  display: flex;
  gap: 10px;
}

.save-exam-btn {
  padding: 12px 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
}

.save-exam-btn:active {
  background: var(--bg);
}

.draft-banner {
  padding: 10px 16px;
  background: #fef3c7;
  color: #92400e;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  border-bottom: 1px solid #fde68a;
}

/* ===== Result Page ===== */
.result-hero {
  text-align: center;
  margin-bottom: 24px;
  padding: 24px 0;
}

.result-ring {
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
  position: relative;
}

.ring-svg {
  width: 100%;
  height: 100%;
}

.result-ring.passed { color: var(--success); }
.result-ring.failed { color: var(--danger); }

.result-score {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.result-score-num {
  font-size: 36px;
  font-weight: 800;
  display: block;
  line-height: 1;
}

.result-score-total {
  font-size: 16px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.result-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.result-stat-item {
  text-align: center;
}

.result-stat-num {
  font-size: 20px;
  font-weight: 700;
  display: block;
}

.result-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.result-stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

.result-detail {
  display: flex;
  justify-content: space-around;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}

.result-detail-item {
  text-align: center;
}

.detail-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}

.detail-value {
  font-size: 18px;
  font-weight: 700;
  display: block;
  margin-top: 4px;
}

.text-green { color: var(--success); }
.text-red { color: var(--danger); }

/* ===== Result Questions ===== */
.result-questions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-q-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.result-q-item:active {
  transform: scale(0.98);
}

.result-q-item.correct { border-left: 3px solid var(--success); }
.result-q-item.wrong { border-left: 3px solid var(--danger); }

.result-q-num {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-secondary);
  min-width: 24px;
}

.result-q-type {
  font-size: 11px;
  color: var(--text-light);
  min-width: 40px;
}

.result-q-preview {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-q-status {
  font-size: 16px;
}

.result-answer-info {
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  font-weight: 500;
}

.result-answer-info.correct { background: var(--success-bg); }
.result-answer-info.wrong { background: var(--danger-bg); }

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

/* ===== Wrong Book ===== */
.wrong-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.wrong-stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
}

.wrong-stat-num {
  font-weight: 700;
  color: var(--danger);
}

.wrong-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.wrong-action-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  background: var(--primary);
  color: white;
}

.wrong-action-btn:active {
  opacity: 0.9;
}

.wrong-action-btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.wrong-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s;
}

.wrong-item:active { transform: scale(0.98); }

.wrong-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.wrong-count {
  font-size: 12px;
  color: var(--danger);
  font-weight: 600;
}

.wrong-time {
  font-size: 12px;
  color: var(--text-light);
  margin-left: auto;
}

.wrong-item-content {
  font-size: 14px;
  margin-bottom: 6px;
  line-height: 1.5;
}

.wrong-item-answer {
  font-size: 13px;
  color: var(--text-secondary);
}

.correct-answer {
  color: var(--success);
  font-weight: 600;
}

.wrong-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.wrong-modal-actions {
  margin-top: 12px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeInModal 0.2s ease;
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: white;
  border-radius: 16px 16px 0 0;
  max-width: var(--max-width);
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 20px 12px;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover {
  background: var(--bg);
}

.modal-body {
  padding: 0 20px 20px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

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

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

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

/* ===== Safe Area ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  .page {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
}

/* ===== Search Page ===== */
.search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.search-title {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}

.search-input-wrap {
  position: relative;
  margin-bottom: 12px;
}

.search-input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: var(--border);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear-btn:active {
  background: var(--text-light);
}

.search-info {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 0 4px;
}

.search-info strong {
  color: var(--primary);
  font-weight: 600;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.search-result-item:active {
  background: var(--bg);
  border-color: var(--primary);
}

.search-result-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  width: 70px;
}

.search-result-type {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
}

.search-result-id {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
}

.search-result-content {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-arrow {
  font-size: 20px;
  color: var(--text-light);
  flex-shrink: 0;
}

.search-mask {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.search-detail-modal {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  bottom: 0;
  width: 100%;
  max-width: var(--max-width);
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  z-index: 101;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.search-detail-modal.show {
  transform: translateX(-50%) translateY(0);
}

.detail-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  z-index: 1;
}

.detail-modal-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
}

.detail-modal-id {
  flex: 1;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.detail-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-close-btn:active {
  background: var(--border);
}

.detail-modal-body {
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.detail-question {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--text);
}

.action-btn-search .action-icon {
  background: #fef3c7;
}

@media (min-width: 480px) {
  .action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}