/* ============================================
   单词大师 - 护眼清新共享样式 (Eye-care Fresh Theme)
   设计原则: 低饱和、柔对比、暖白/薄荷底色，长时间阅读不刺眼
   小学: 柔绿  初中: 柔蓝绿  高中: 柔靛蓝 (各页面浅色调)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

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

:root {
  /* 护眼底色: 极浅薄荷 + 浅湖蓝渐变，明度高、饱和度低 */
  --bg: linear-gradient(160deg, #EAF4EC 0%, #DCEFF0 45%, #E7F2F4 100%);
  --card-bg: #FFFFFF;
  --text: #2E3B34;            /* 墨绿灰，柔和不刺眼 */
  --text-light: #6E8178;
  --primary: #2F9E8F;         /* 主色: 静谧青绿 */
  --primary-light: #7FC8B9;
  --secondary: #4FAE8B;       /* 成功/已掌握 */
  --accent: #E6B36A;          /* 暖沙金，用于卡片背面 */
  --danger: #E08A8A;          /* 柔和红 */
  --chip: rgba(255,255,255,0.72);
  --chip-border: rgba(46,59,52,0.08);
  --shadow: 0 8px 28px rgba(47,94,84,0.10);
  --shadow-strong: 0 14px 40px rgba(47,94,84,0.16);
  /* 护眼绿（与闪卡正面一致）：浅绿渐变 + 淡绿边框 */
  --flash-green: linear-gradient(145deg, #E9F6EC 0%, #D8EFDD 100%);
  --flash-green-border: #B7E0C4;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

/* ========== 首页入口 ========== */
.home-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  text-align: center;
}
.home-logo {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.home-subtitle {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 40px;
}
.grade-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 680px;
}
.grade-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px 24px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--chip-border);
}
.grade-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-strong);
}
.grade-card .icon { font-size: 3rem; }
.grade-card .title { font-size: 1.3rem; font-weight: 700; }
.grade-card .desc { font-size: 0.85rem; color: var(--text-light); }
.grade-card .count { font-size: 0.9rem; font-weight: 600; color: var(--primary); }

/* ========== Header ========== */
.header { text-align: center; margin-bottom: 24px; color: var(--text); position: relative; }
.logo { font-size: 2.2rem; font-weight: 700; letter-spacing: 1px; }
.subtitle { font-size: 0.95rem; color: var(--text-light); margin-top: 4px; }
.stats-bar { display: flex; justify-content: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.stat-badge {
  background: var(--chip); border: 1px solid var(--chip-border);
  padding: 7px 16px; border-radius: 20px; font-size: 0.9rem;
  display: flex; align-items: center; gap: 6px; color: var(--text);
  box-shadow: var(--shadow);
}
.stat-badge.reset { cursor: pointer; transition: all 0.2s; }
.stat-badge.reset:hover { background: #fff; color: var(--danger); border-color: var(--danger); }

/* ========== 导航标签 ========== */
.grade-tabs { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.grade-btn {
  border: 1px solid var(--chip-border); border-radius: 12px; padding: 10px 16px; font-size: 0.92rem;
  font-family: inherit; cursor: pointer; font-weight: 500; transition: all 0.2s;
  background: var(--chip); color: var(--text-light);
}
.grade-btn:hover { background: #fff; transform: translateY(-1px); }
.grade-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 14px rgba(47,158,143,0.25); }

.unit-tabs { display: flex; gap: 6px; padding: 0 8px 8px; flex-wrap: wrap; justify-content: center; }
.unit-btn {
  padding: 5px 11px; border-radius: 16px; border: 1px solid var(--chip-border);
  background: var(--chip); color: var(--text-light); cursor: pointer;
  font-size: 0.78rem; transition: all 0.2s; font-family: inherit;
}
.unit-btn:hover { background: #fff; }
.unit-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ========== 模式标签 ========== */
.mode-tabs {
  display: flex; background: var(--chip); border: 1px solid var(--chip-border); border-radius: 16px;
  padding: 6px; margin-bottom: 24px;
}
.mode-tab {
  flex: 1; border: none; background: transparent; border-radius: 12px;
  padding: 12px 8px; font-family: inherit; font-size: 0.9rem; cursor: pointer;
  transition: all 0.2s; display: flex; flex-direction: column; align-items: center;
  gap: 4px; color: var(--text-light); font-weight: 500;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--primary); box-shadow: 0 4px 14px rgba(47,158,143,0.25); color: #fff; }
.mode-tab .mode-icon { font-size: 1.4rem; }

/* ========== 进度条 ========== */
.progress-section {
  background: var(--card-bg); border-radius: 16px; padding: 16px 20px;
  margin-bottom: 20px; box-shadow: var(--shadow); border: 1px solid var(--chip-border);
}
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.progress-title { font-size: 0.9rem; color: var(--text-light); font-weight: 500; }
.progress-value { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.progress-bar { height: 10px; border-radius: 8px; background: #E6EDE9; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--primary), var(--primary-light)); transition: width 0.5s ease; }

/* ========== 卡片 ========== */
.card {
  background: var(--card-bg); border-radius: 20px; padding: 24px;
  box-shadow: var(--shadow); margin-bottom: 20px; border: 1px solid var(--chip-border);
}

/* ========== 发音按钮 ========== */
.speak-btn {
  background: #F2F8F5; border: 2px solid var(--primary-light); border-radius: 50%;
  width: 40px; height: 40px; cursor: pointer; font-size: 1.2rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.2s; margin-left: 8px; vertical-align: middle; color: var(--primary);
}
.speak-btn:hover { background: var(--primary); color: white; transform: scale(1.1); }
.speak-btn:active { transform: scale(0.95); }
.speak-btn.speaking { background: var(--primary); color: white; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47,158,143,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(47,158,143,0); }
}

/* ========== 闪卡 ========== */
.flashcard-container { perspective: 1200px; margin-bottom: 20px; }
.flashcard {
  width: 100%; aspect-ratio: 16/10; position: relative;
  transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0; border-radius: 20px; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px; box-shadow: var(--shadow);
}
.flashcard-front { background: var(--flash-green); border: 2px solid var(--flash-green-border); }
.flashcard-back { background: linear-gradient(145deg, #FFF6E8 0%, #FCEBCF 100%); border: 2px solid var(--accent); transform: rotateY(180deg); }

.word-main { font-size: clamp(1.8rem, 6vw, 2.8rem); font-weight: 700; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.word-phonetic { font-size: 1.1rem; color: var(--text-light); font-family: 'Times New Roman', serif; margin-bottom: 16px; }
.word-hint { font-size: 0.85rem; color: #9DB1A8; display: flex; align-items: center; gap: 6px; }
.word-meaning { font-size: clamp(1.8rem, 6.5vw, 2.8rem); font-weight: 700; color: #9A6B2E; margin-bottom: 12px; text-align: center; line-height: 1.35; }
.word-tags { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.tag { padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 500; }
.tag-n, .tag-noun { background: #DCEFEA; color: #1E6E62; }
.tag-v, .tag-verb { background: #DCF1E6; color: #2B7A56; }
.tag-adj, .tag-adjective { background: #FBEFD8; color: #9A6B2E; }
.tag-adv, .tag-adverb { background: #ECE6F7; color: #6B4FA0; }
.tag-phr { background: #FBE2E4; color: #B1444F; }
.tag-prep { background: #E2E9F7; color: #3A4FA0; }
.tag-conj { background: #D7F2EC; color: #1E6E62; }
.tag-pron { background: #FBE3EF; color: #A23B6E; }
.tag-modal { background: #FBEFD8; color: #8A5A1E; }
.tag-art { background: #EDEFEE; color: #51615A; }
.tag-num { background: #DCEFEA; color: #1E6E62; }
.tag-interj { background: #FCEBCF; color: #9A6B2E; }
.tag-part { background: #EDEFEE; color: #51615A; }

/* ========== 选择题 ========== */
.quiz-word { text-align: center; margin-bottom: 24px; }
.quiz-word-text { font-size: clamp(1.6rem, 5vw, 2.2rem); font-weight: 700; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.quiz-word-phonetic { font-size: 1rem; color: var(--text-light); font-family: 'Times New Roman', serif; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quiz-option {
  border: 2px solid var(--flash-green-border); border-radius: 14px; padding: 16px; font-family: inherit;
  font-size: 1rem; cursor: pointer; background: var(--flash-green); transition: all 0.2s;
  font-weight: 500; text-align: center; color: var(--text);
}
.quiz-option:hover:not(.correct):not(.wrong) { border-color: var(--primary); background: #F2F8F5; transform: translateY(-2px); }
.quiz-option.correct { border-color: var(--secondary); background: #DCF1E6; color: #2B7A56; animation: popIn 0.4s; }
.quiz-option.wrong { border-color: var(--danger); background: #FBE6E6; color: #B1444F; animation: shake 0.4s; }

@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }
@keyframes popIn { 0%{transform:scale(0.9)} 50%{transform:scale(1.05)} 100%{transform:scale(1)} }

/* ========== 拼写 ========== */
.spelling-prompt { text-align: center; margin-bottom: 20px; }
.spelling-meaning { font-size: clamp(1.4rem, 5vw, 1.8rem); font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.spelling-hint { font-size: 0.9rem; color: var(--text-light); }
.spelling-input {
  width: 100%; border: 2px solid var(--flash-green-border); border-radius: 14px; padding: 16px 20px;
  font-size: 1.3rem; font-family: inherit; text-align: center; letter-spacing: 2px;
  transition: all 0.2s; outline: none; margin-bottom: 12px; background: var(--flash-green); color: var(--text);
}
.spelling-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,158,143,0.12); }
.spelling-input.correct { border-color: var(--secondary); background: #DCF1E6; }
.spelling-input.wrong { border-color: var(--danger); background: #FBE6E6; }
.spelling-answer { text-align: center; padding: 12px; background: #F2F5F3; border-radius: 10px; font-size: 1.1rem; color: var(--text-light); display: none; }
.spelling-answer.show { display: block; }

/* ========== 词表 ========== */
.word-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.word-list-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.word-list-count { font-size: 0.85rem; color: var(--text-light); background: #EEF3F0; padding: 4px 12px; border-radius: 20px; }
.word-list-filter { display: flex; gap: 6px; margin-bottom: 14px; }
.word-list-filter .fbtn {
  padding: 6px 14px; border-radius: 16px; border: 1px solid var(--chip-border);
  background: var(--chip); color: var(--text-light); cursor: pointer; font-size: 0.8rem;
  font-family: inherit; transition: all 0.2s;
}
.word-list-filter .fbtn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.word-list-scroll { max-height: 420px; overflow-y: auto; padding-right: 8px; }
.word-list-scroll::-webkit-scrollbar { width: 6px; }
.word-list-scroll::-webkit-scrollbar-thumb { background: #C9D8D2; border-radius: 3px; }
.word-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 12px; margin-bottom: 8px; background: var(--flash-green); border: 1px solid var(--flash-green-border); transition: background 0.2s; }
.word-item:hover { background: #EEF4F1; }
.word-item-info { flex: 1; }
.word-item-word { font-weight: 600; color: var(--text); font-size: 1rem; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.word-item-meaning { font-size: 0.85rem; color: var(--text-light); }
.word-item-status { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; flex-shrink: 0; margin-left: 8px; }
.word-item-status.known { background: var(--secondary); color: white; }
.word-item-status.unknown { background: #E3EAE6; color: #9DB1A8; }
.mini-speak { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 2px; opacity: 0.55; transition: opacity 0.2s; }
.mini-speak:hover { opacity: 1; }

/* ========== 按钮 ========== */
.actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.btn {
  border: none; border-radius: 14px; padding: 14px 24px; font-family: inherit; font-size: 1rem;
  cursor: pointer; font-weight: 600; transition: all 0.2s; display: flex; align-items: center;
  gap: 8px; box-shadow: var(--shadow);
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-strong); }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--secondary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--accent); color: #5a3d12; }
.btn-secondary { background: #7C8C84; color: white; }

/* ========== 结果面板 ========== */
.result-panel { text-align: center; padding: 32px 20px; }
.result-emoji { font-size: 4rem; margin-bottom: 12px; }
.result-title { font-size: 1.6rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.result-detail { font-size: 1rem; color: var(--text-light); margin-bottom: 16px; }
.result-stars { font-size: 2rem; margin-bottom: 20px; }

/* ========== 模式面板 ========== */
.mode-panel { display: none; }
.mode-panel.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ========== 响应式 ========== */
@media (max-width: 480px) {
  .quiz-options { grid-template-columns: 1fr; }
  .grade-btn { padding: 8px 12px; font-size: 0.85rem; }
  .mode-tab { padding: 10px 4px; font-size: 0.8rem; }
  .mode-tab .mode-icon { font-size: 1.2rem; }
  .grade-cards { grid-template-columns: 1fr; }
}

/* ========== Toast ========== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px);
  background: rgba(46,59,52,0.92); color: white; padding: 12px 28px; border-radius: 30px;
  font-family: inherit; font-size: 0.95rem; z-index: 300; transition: transform 0.3s ease;
  white-space: nowrap; backdrop-filter: blur(10px); box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ========== Confetti ========== */
#confetti-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 200; }

/* ========== 搜索框 ========== */
.search-box {
  width: 100%; border: 2px solid #E3EAE6; border-radius: 12px; padding: 10px 16px;
  font-family: inherit; font-size: 0.95rem; outline: none; margin-bottom: 16px; transition: border-color 0.2s;
  background: #fff; color: var(--text);
}
.search-box:focus { border-color: var(--primary); }

/* ========== 自动发音开关 ========== */
.toggle-row {
  display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 16px; color: var(--text-light); font-size: 0.9rem;
}
.toggle-switch {
  position: relative; width: 44px; height: 24px; background: rgba(46,59,52,0.18);
  border-radius: 12px; cursor: pointer; transition: background 0.2s;
}
.toggle-switch.on { background: var(--secondary); }
.toggle-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  background: white; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on::after { transform: translateX(20px); }

/* ========== 当前册/单元显示 ========== */
.current-selection {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 18px; padding: 12px 18px; background: var(--card-bg);
  border: 1px solid var(--chip-border); border-radius: 14px; box-shadow: var(--shadow);
  animation: fadeIn 0.3s;
}
.current-selection .cs-grade { font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.current-selection .cs-sep { color: var(--text-light); font-weight: 400; }
.current-selection .cs-unit { font-size: 1.05rem; font-weight: 600; color: var(--text); }

/* ========== 返回按钮 ========== */
.back-btn {
  position: absolute; top: 20px; left: 20px; background: var(--chip);
  border: 1px solid var(--chip-border); border-radius: 50%; width: 40px; height: 40px; cursor: pointer;
  font-size: 1.2rem; color: var(--text); display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.back-btn:hover { background: #fff; transform: scale(1.1); }
