/* Lingua 离线版样式 —— 复用原版紫色主题并按 SPA 需要增补 */
:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --secondary: #10b981;
  --accent: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.05);
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }

/* ============ SPA 布局 ============ */
.view {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.2rem 1rem calc(84px + env(safe-area-inset-bottom));
}
.view.narrow { max-width: 720px; }

/* ============ 底部导航（移动端优先） ============ */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  background: var(--surface);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: .55rem 0 .5rem;
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: .75rem; font-weight: 600;
  font-family: inherit;
}
.tab-item .tab-icon { font-size: 1.35rem; line-height: 1; filter: grayscale(.6); }
.tab-item.active { color: var(--primary); }
.tab-item.active .tab-icon { filter: none; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.2rem; border: none; border-radius: 10px;
  font-size: .95rem; font-weight: 600; cursor: pointer;
  transition: all .2s; text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; transform: translateY(-1px); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #059669; color: white; }
.btn-success { background: var(--secondary); color: white; }
.btn-success:hover { background: #059669; color: white; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-lg { padding: .85rem 1.8rem; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ============ 卡片 ============ */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem;
  transition: transform .2s, box-shadow .2s;
}

/* ============ 表单 ============ */
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; margin-bottom: .4rem; font-weight: 600; font-size: .9rem; }
.form-control {
  width: 100%; padding: .7rem .9rem; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: .95rem; transition: border-color .2s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,.15); }

/* ============ 首次建档页 ============ */
.onboarding {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.onboarding-card {
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg);
  padding: 2.2rem; width: 100%; max-width: 420px;
}
.onboarding-logo { text-align: center; font-size: 3rem; margin-bottom: .5rem; }
.onboarding-title { text-align: center; font-size: 1.6rem; font-weight: 800; margin-bottom: .3rem; }
.onboarding-sub { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.lang-choices { display: flex; flex-direction: column; gap: .6rem; }
.lang-choice {
  display: flex; align-items: center; gap: .8rem;
  padding: .85rem 1rem; border: 2px solid var(--border); border-radius: 12px;
  cursor: pointer; font-size: 1rem; font-weight: 600; transition: all .15s;
  background: white; width: 100%; font-family: inherit; text-align: left;
}
.lang-choice .flag { font-size: 1.5rem; }
.lang-choice small { color: var(--text-muted); font-weight: 400; margin-left: auto; }
.lang-choice.selected { border-color: var(--primary); background: #f3f1fd; }
.lang-choice:hover { border-color: var(--primary); }

/* ============ 顶部问候区 ============ */
.dash-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.avatar-badge {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: white; flex-shrink: 0;
}

/* ============ 统计卡片 ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 1.2rem 1.5rem;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 1rem;
}
.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; }
.stat-label { font-size: .85rem; color: var(--text-muted); }

/* ============ 继续学习横幅 ============ */
.continue-card {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white; margin-bottom: 2rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
}
.continue-card .btn { background: white; color: var(--primary-dark); }

/* ============ 课程卡片 ============ */
.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.course-card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
  display: flex; flex-direction: column;
}
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.course-banner { padding: 2rem; text-align: center; font-size: 3rem; color: white; }
.course-body { padding: 1.2rem; flex: 1; display: flex; flex-direction: column; }
.course-level {
  display: inline-block; padding: .2rem .7rem; border-radius: 20px;
  font-size: .75rem; font-weight: 700; color: white; margin-bottom: .5rem;
  width: fit-content;
}
.course-title { font-size: 1.15rem; font-weight: 700; margin-bottom: .4rem; }
.course-desc { color: var(--text-muted); font-size: .88rem; flex: 1; margin-bottom: 1rem; }
.course-meta { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--text-muted); }

/* ============ 语言筛选 ============ */
.lang-tabs { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.lang-tab {
  padding: .5rem 1.2rem; border-radius: 20px; background: var(--surface);
  border: 2px solid var(--border); cursor: pointer; font-weight: 500; font-size: .9rem;
  font-family: inherit;
}
.lang-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ============ 课时列表 ============ */
.lesson-list { list-style: none; }
.lesson-item {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.2rem;
  border: 1.5px solid var(--border); border-radius: 12px; margin-bottom: .75rem;
  transition: all .2s; background: var(--surface);
}
.lesson-item:hover { border-color: var(--primary); background: #fafafe; }
.lesson-item.done { border-color: var(--secondary); background: #f0fdf4; }
.lesson-type-badge {
  padding: .3rem .7rem; border-radius: 8px; font-size: .75rem; font-weight: 600;
  background: #ece9fc; color: var(--primary-dark); white-space: nowrap;
}
.lesson-info { flex: 1; min-width: 0; }
.lesson-title { font-weight: 600; }
.lesson-desc { font-size: .82rem; color: var(--text-muted); }
.lesson-check { font-size: 1.3rem; }

/* ============ 学习模块 ============ */
.lesson-player { max-width: 860px; margin: 0 auto; }
.module-header { text-align: center; margin-bottom: 2rem; }
.module-type-tag {
  display: inline-block; padding: .3rem 1rem; border-radius: 20px;
  background: var(--primary); color: white; font-size: .8rem; font-weight: 600; margin-bottom: .8rem;
}
.module-title { font-size: 1.8rem; font-weight: 800; }
.module-desc { color: var(--text-muted); margin-top: .4rem; }

/* 单词卡片 */
.flashcard-container { perspective: 1000px; max-width: 500px; margin: 0 auto; }
.flashcard {
  height: 280px; position: relative; cursor: pointer;
  transform-style: preserve-3d; transition: transform .5s;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0; border-radius: 20px; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem; backface-visibility: hidden; box-shadow: var(--shadow-lg);
}
.flashcard-front { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }
.flashcard-back { background: white; transform: rotateY(180deg); border: 2px solid var(--border); }
.word-main { font-size: 2.6rem; font-weight: 800; margin-bottom: .3rem; text-align: center; }
.word-pron { font-size: 1.1rem; opacity: .9; font-style: italic; }
.word-hint { margin-top: 1rem; font-size: .9rem; opacity: .8; }
.word-translation { font-size: 1.8rem; font-weight: 700; color: var(--primary-dark); margin-bottom: .5rem; }
.word-example { color: var(--text-muted); font-size: .95rem; text-align: center; font-style: italic; }
.card-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; gap: 1rem; }
.card-counter { font-weight: 600; color: var(--text-muted); }

/* 语法/听力 选择题 */
.quiz-question {
  background: var(--surface); border-radius: var(--radius); padding: 2rem;
  box-shadow: var(--shadow); margin-bottom: 1.5rem;
}
.quiz-q-text { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.2rem; }
.quiz-options { display: flex; flex-direction: column; gap: .75rem; }
.quiz-option {
  padding: 1rem 1.2rem; border: 2px solid var(--border); border-radius: 12px;
  cursor: pointer; transition: all .2s; font-size: 1rem; background: white;
  display: flex; align-items: center; gap: .75rem; text-align: left;
  font-family: inherit; width: 100%;
}
.quiz-option:hover:not(.disabled) { border-color: var(--primary); background: #fafafe; }
.quiz-option.correct { border-color: var(--secondary); background: #d1fae5; }
.quiz-option.wrong { border-color: var(--danger); background: #fee2e2; }
.quiz-option.disabled { cursor: default; }
.option-letter {
  width: 28px; height: 28px; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  flex-shrink: 0;
}
.quiz-option.correct .option-letter { background: var(--secondary); color: white; }
.quiz-option.wrong .option-letter { background: var(--danger); color: white; }
.explain-box {
  margin-top: 1rem; padding: .8rem 1rem; background: #fef3c7; border-radius: 10px;
  color: #92400e; font-size: .9rem; display: none;
}
.explain-box.show { display: block; }

/* 口语跟读 */
.speaking-box {
  background: var(--surface); border-radius: var(--radius); padding: 2.5rem;
  box-shadow: var(--shadow); text-align: center;
}
.dialogue-text {
  font-size: 1.4rem; line-height: 2; margin-bottom: 2rem; padding: 1.5rem;
  background: linear-gradient(135deg, #ece9fc, #f5f3ff); border-radius: 16px;
}
.speak-controls { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.self-assess { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }

/* 听力 */
.listen-box {
  background: var(--surface); border-radius: var(--radius); padding: 2rem;
  box-shadow: var(--shadow); text-align: center; margin-bottom: 1.5rem;
}
.play-btn {
  width: 70px; height: 70px; border-radius: 50%; border: none;
  background: var(--primary); color: white; font-size: 1.8rem; cursor: pointer;
  transition: transform .2s; margin-bottom: 1rem;
}
.play-btn:hover { transform: scale(1.1); }
.play-btn:disabled { opacity: .6; transform: none; }

/* 进度条 */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width .3s; }
.quiz-progress { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; font-size: .85rem; color: var(--text-muted); font-weight: 600; }

/* ============ 结算弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none;
  align-items: center; justify-content: center; z-index: 200; padding: 1rem;
}
.modal-mask.show { display: flex; }
.complete-content {
  background: white; border-radius: 24px; padding: 2.5rem; max-width: 420px;
  width: 100%; text-align: center; animation: pop .4s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.complete-icon { font-size: 4rem; margin-bottom: 1rem; }
.complete-title { font-size: 1.6rem; font-weight: 800; margin-bottom: .5rem; }
.xp-gain { color: var(--accent); font-weight: 700; font-size: 1.1rem; margin: .5rem 0; }
.new-ach-box { margin-top: 1rem; padding: 1rem; background: #fef3c7; border-radius: 12px; text-align: left; }

/* ============ 成就 ============ */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.2rem; }
.ach-card {
  background: var(--surface); border-radius: var(--radius); padding: 1.5rem;
  text-align: center; box-shadow: var(--shadow); border: 2px solid transparent;
}
.ach-card.earned { border-color: var(--accent); background: linear-gradient(135deg, #fffbeb, #fef3c7); }
.ach-card.locked { opacity: .5; filter: grayscale(.7); }
.ach-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.ach-name { font-weight: 700; margin-bottom: .3rem; }
.ach-desc { font-size: .82rem; color: var(--text-muted); }

/* ============ 我的 ============ */
.profile-row { display: flex; justify-content: space-between; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--border); gap: 1rem; flex-wrap: wrap; }
.profile-row:last-child { border-bottom: none; }
.profile-label { color: var(--text-muted); font-size: .9rem; }
.profile-value { font-weight: 700; }
.profile-switch-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.profile-switch-item {
  display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem;
  border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer;
  background: white; font-family: inherit; font-size: .9rem; text-align: left;
}
.profile-switch-item:hover { border-color: var(--primary); }
.profile-switch-item.current { border-color: var(--primary); background: #f3f1fd; }

.section-title { margin: 2rem 0 1rem; font-size: 1.25rem; font-weight: 800; }
.page-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.2rem; }
.muted { color: var(--text-muted); }

/* 响应式 */
@media (max-width: 640px) {
  .word-main { font-size: 2rem; }
  .module-title { font-size: 1.5rem; }
  .dialogue-text { font-size: 1.15rem; }
  .speaking-box { padding: 1.5rem; }
  .quiz-question { padding: 1.4rem; }
  .lesson-item { gap: .6rem; padding: .9rem; }
  .lesson-type-badge { display: none; }
}
@media (min-width: 640px) {
  .tabbar { justify-content: center; }
  .tab-item { flex: 0 0 140px; }
}

/* ============ 中职模拟卷 ============ */
.btn-block { display: block; width: 100%; }
.exam-card { margin-bottom: 1rem; }
.exam-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; margin-bottom: .7rem; }
.exam-card-title { font-size: 1.05rem; font-weight: 800; }
.exam-card-sub { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; line-height: 1.5; }
.exam-badge { flex: none; background: rgba(108,92,231,.12); color: var(--primary); font-size: .78rem; font-weight: 700; padding: .25rem .6rem; border-radius: 20px; }
.exam-meta { display: flex; flex-wrap: wrap; gap: .5rem .9rem; font-size: .85rem; color: var(--text-muted); margin-bottom: .9rem; }
.exam-best { color: var(--accent); font-weight: 700; }
.exam-tip { font-size: .82rem; color: var(--text-muted); background: var(--bg); padding: .6rem .8rem; border-radius: 10px; line-height: 1.6; }
.exam-bar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .7rem 1rem; margin: -1rem -1rem .8rem; background: rgba(255,255,255,.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); font-weight: 700; font-size: .9rem; }
.exam-bar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-clock { flex: none; font-variant-numeric: tabular-nums; color: var(--primary); font-size: 1.05rem; }
.exam-clock.urgent { color: var(--danger); animation: examBlink 1s infinite; }
@keyframes examBlink { 50% { opacity: .45; } }
.exam-section { margin-bottom: 1.6rem; }
.exam-section-name { font-size: 1rem; font-weight: 800; margin-bottom: .3rem; color: var(--text); }
.exam-passage { background: var(--bg); border-left: 3px solid var(--primary); padding: .8rem 1rem; border-radius: 10px; font-size: .9rem; line-height: 1.8; margin-bottom: 1rem; }
.exam-q { margin-bottom: 1.1rem; }
.exam-q-text { font-size: .95rem; line-height: 1.6; margin-bottom: .5rem; }
.q-no { font-weight: 800; color: var(--primary); margin-right: .35rem; }
.exam-opts { display: flex; flex-direction: column; gap: .45rem; }
.exam-opt { text-align: left; padding: .6rem .8rem; border: 1.5px solid var(--border); background: var(--surface); border-radius: 10px; font-size: .9rem; color: var(--text); cursor: pointer; transition: all .15s; font-family: inherit; }
.exam-opt:hover { border-color: var(--primary); background: rgba(108,92,231,.05); }
.exam-opt.selected { border-color: var(--primary); background: rgba(108,92,231,.12); color: var(--primary); font-weight: 600; }
.exam-fill { margin-top: .2rem; }
.exam-result { text-align: center; padding: 1.5rem 1rem; background: linear-gradient(135deg, #f5f3ff, #ede9fe); border-radius: 16px; margin-bottom: .5rem; }
.exam-score { font-size: 3.2rem; font-weight: 900; color: var(--primary); line-height: 1; }
.exam-score small { font-size: 1.1rem; font-weight: 700; margin-left: .2rem; }
.exam-result-sub { color: var(--text-muted); font-size: .9rem; margin-top: .7rem; }
.exam-result-xp { display: inline-block; margin-top: .7rem; background: var(--accent); color: #fff; font-weight: 800; font-size: .85rem; padding: .25rem .9rem; border-radius: 20px; }
.exam-result-ach { margin-top: .8rem; font-size: .9rem; font-weight: 700; color: #b45309; }
.review-item { border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; margin-bottom: .7rem; background: var(--surface); }
.review-item.ok { border-left: 4px solid var(--secondary); }
.review-item.bad { border-left: 4px solid var(--danger); }
.review-q { font-size: .92rem; line-height: 1.6; margin-bottom: .45rem; display: flex; gap: .4rem; }
.review-no { flex: none; width: 1.4rem; height: 1.4rem; display: inline-flex; align-items: center; justify-content: center; background: var(--bg); border-radius: 50%; font-size: .72rem; font-weight: 700; }
.review-line { font-size: .88rem; line-height: 1.7; }
.review-blank { color: var(--danger); font-weight: 600; }
.review-explain { margin-top: .5rem; font-size: .85rem; line-height: 1.6; color: var(--text-muted); background: var(--bg); padding: .5rem .7rem; border-radius: 8px; }
.exam-opt-static { font-size: .85rem; color: var(--text-muted); line-height: 1.7; margin-bottom: .35rem; }
.review-ans { color: var(--secondary); font-size: .95rem; }
