/* 初中英语词汇掌握 — Design System */

:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: #eef2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Layout */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: #fff;
  position: relative;
  overflow-x: hidden;
}

.app-header {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.app-header .header-sub {
  font-size: .75rem;
  opacity: .8;
  margin-top: 2px;
}

.app-content {
  padding: 16px;
  padding-bottom: 100px;
}

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Dashboard */
.dashboard-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--gray-200);
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.box-distribution {
  display: flex;
  gap: 4px;
  margin: 12px 0;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.box-distribution .box-bar {
  height: 100%;
  transition: width .3s;
}

.btn-start {
  display: block;
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .02em;
  box-shadow: var(--shadow-md);
  transition: transform .15s, box-shadow .15s;
}

.btn-start:active {
  transform: scale(.98);
  box-shadow: var(--shadow);
}

.btn-start:disabled {
  opacity: .5;
  transform: none;
}

/* Progress bar */
.progress-bar-wrap {
  background: var(--gray-200);
  border-radius: 6px;
  height: 6px;
  margin: 12px 0;
  overflow: hidden;
}

.progress-bar-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 6px;
  transition: width .3s ease;
}

.progress-text {
  text-align: center;
  font-size: .8rem;
  color: var(--gray-500);
}

/* Flashcard */
.flashcard-container {
  position: relative;
  margin: 8px 0 16px;
}

.flashcard-box-badge {
  position: absolute;
  top: -8px;
  right: 12px;
  color: #fff;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
  z-index: 2;
}

.flashcard {
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 40px 24px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: transform .3s, border-color .3s, box-shadow .3s;
  box-shadow: var(--shadow);
  position: relative;
}

.flashcard:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.flashcard.flipped {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.flashcard-front, .flashcard-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.flashcard .flashcard-back { display: none; }
.flashcard.flipped .flashcard-front { display: none; }
.flashcard.flipped .flashcard-back { display: flex; }

.flashcard-word {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.flashcard-pos {
  font-size: .8rem;
  color: var(--gray-400);
  font-style: italic;
}

.flashcard-hint {
  font-size: .75rem;
  color: var(--gray-400);
  margin-top: 8px;
}

.flashcard-translation {
  font-size: 1.5rem;
  color: var(--primary);
  font-weight: 600;
  line-height: 1.4;
}

.flashcard-phrases {
  margin-top: 12px;
  text-align: left;
  width: 100%;
  border-top: 1px solid var(--gray-100);
  padding-top: 12px;
}

.phrase-item {
  font-size: .8rem;
  padding: 4px 0;
  color: var(--gray-600);
}

.phrase-en { font-weight: 500; color: var(--gray-700); }
.phrase-sep { margin: 0 6px; color: var(--gray-300); }
.phrase-cn { color: var(--gray-500); }

.flashcard-mistakes {
  margin-top: 8px;
  font-size: .75rem;
  color: var(--danger);
  background: #fef2f2;
  padding: 2px 10px;
  border-radius: 8px;
}

/* Flashcard actions */
.flashcard-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.btn-speak, .btn-mode-switch {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background .15s;
}

.btn-speak:hover, .btn-mode-switch:hover { background: var(--gray-200); }

/* Self-assessment */
.flashcard-self-assessment {
  margin-top: 16px;
  text-align: center;
}

.assessment-label {
  font-size: .85rem;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.assessment-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-assess {
  flex: 1;
  padding: 12px 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}

.btn-assess:active { transform: scale(.96); }

.btn-forgot {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-fuzzy {
  background: #fffbeb;
  color: var(--warning);
  border: 1px solid #fde68a;
}

.btn-knew {
  background: #ecfdf5;
  color: var(--success);
  border: 1px solid #a7f3d0;
}

/* Context exercise */
.context-exercise {
  margin: 8px 0;
}

.exercise-type-badge {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.exercise-sentence {
  font-size: 1.2rem;
  color: var(--gray-800);
  line-height: 1.8;
  padding: 20px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  margin-bottom: 12px;
}

.blank {
  display: inline-block;
  min-width: 80px;
  border-bottom: 2px dashed var(--primary);
  color: var(--primary);
  font-weight: 600;
  padding: 0 8px;
  margin: 0 4px;
}

.exercise-hint {
  font-size: .8rem;
  color: var(--gray-400);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

.exercise-word-info {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  font-size: .85rem;
}

.word-hint {
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}

.word-pos {
  color: var(--gray-400);
  font-style: italic;
}

.word-meaning {
  color: var(--gray-500);
}

.exercise-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-option {
  padding: 14px 12px;
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
  color: var(--gray-700);
}

.btn-option:hover:not(:disabled) {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.btn-option:disabled { cursor: default; }
.btn-option.option-correct { border-color: var(--success); background: #ecfdf5; color: var(--success); }
.btn-option.option-wrong { border-color: var(--danger); background: #fef2f2; color: var(--danger); }

.exercise-feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-weight: 600;
}

.feedback-correct { color: var(--success); }
.feedback-wrong { color: var(--danger); }

/* Session complete */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

.empty-state .session-score {
  font-size: 1.2rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 12px;
}

.btn-next-step {
  display: none;
  width: 100%;
  padding: 14px;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
}

/* Flash animations */
.correct-flash .flashcard { border-color: var(--success); background: #ecfdf5; }
.wrong-flash .flashcard { border-color: var(--danger); background: #fef2f2; }

/* Error notebook */
.error-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
}

.error-word {
  font-weight: 600;
  font-size: 1.1rem;
}

.error-info {
  font-size: .8rem;
  color: var(--gray-500);
}

.error-count {
  background: #fef2f2;
  color: var(--danger);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: .75rem;
  font-weight: 600;
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top: 1px solid var(--gray-200);
  display: flex;
  z-index: 10;
  box-shadow: 0 -1px 3px rgba(0,0,0,.04);
}

.bottom-nav .nav-item {
  flex: 1;
  padding: 10px 4px;
  text-align: center;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--gray-400);
  font-size: .7rem;
  transition: color .15s;
}

.bottom-nav .nav-item.active { color: var(--primary); }

.bottom-nav .nav-item svg {
  display: block;
  margin: 0 auto 2px;
}

/* Loading / Setup */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--gray-500);
  font-size: .9rem;
}

/* Responsive */
@media (max-width: 480px) {
  .app-shell { max-width: 100%; }
  .flashcard-word { font-size: 1.6rem; }
  .flashcard { padding: 32px 20px; min-height: 180px; }
}

/* Listening module */
.listen-area {
  text-align: center;
  padding: 32px 20px;
  margin: 16px 0;
  background: var(--primary-bg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
  border: 2px dashed var(--primary-light);
}
.listen-area:hover { background: #e0e7ff; }
.listen-btn {
  color: var(--primary);
  display: inline-block;
  margin-bottom: 8px;
}
.listen-hint {
  font-size: .85rem;
  color: var(--gray-500);
}

/* Dialogue module */
.dialogue-card {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 20px;
  margin: 12px 0;
  border: 1px solid var(--gray-200);
}

.dialogue-line {
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  line-height: 1.6;
}

.dialogue-line.speaker-a {
  background: #eef2ff;
  margin-right: 20px;
}

.dialogue-line.speaker-b {
  background: #f0fdf4;
  margin-left: 20px;
}

.dialogue-speaker {
  font-weight: 700;
  font-size: .75rem;
  color: var(--gray-400);
  margin-right: 8px;
}

.dialogue-text {
  font-size: .95rem;
  color: var(--gray-800);
}

.dialogue-prompt {
  text-align: center;
  font-size: .85rem;
  color: var(--primary);
  font-weight: 600;
  margin: 12px 0 8px;
}

/* Writing module */
.writing-hint {
  text-align: center;
  font-size: .8rem;
  color: var(--gray-400);
  margin-bottom: 8px;
}

.writing-meaning {
  text-align: center;
  font-size: 1.1rem;
  color: var(--gray-700);
  margin: 12px 0;
  padding: 12px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
}

.writing-answer-area {
  min-height: 48px;
  padding: 12px;
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin: 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.writing-placeholder {
  color: var(--gray-300);
  font-size: .9rem;
}

.word-chip-selected {
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: .9rem;
  font-weight: 500;
}

.writing-word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}

.btn-word-chip {
  padding: 8px 16px;
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: 20px;
  font-size: .9rem;
  cursor: pointer;
  transition: all .15s;
  color: var(--gray-700);
}

.btn-word-chip:hover:not(:disabled) {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.word-chip-used {
  opacity: .3;
  cursor: default;
}

.writing-actions {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.translate-prompt {
  text-align: center;
  font-size: 1.3rem;
  color: var(--gray-800);
  font-weight: 600;
  padding: 24px 16px;
  background: var(--primary-bg);
  border-radius: var(--radius);
  margin: 16px 0;
}

.translate-input-area {
  margin: 12px 0;
}

.translate-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  text-align: center;
  outline: none;
  transition: border-color .15s;
  color: var(--gray-800);
}

.translate-input:focus {
  border-color: var(--primary-light);
}

/* AI review button */
.btn-ai-review {
  background: none;
  border: 1px solid var(--primary-light);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: .75rem;
  cursor: pointer;
  margin-top: 8px;
}
