/* ===== 基础 ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 关键修复：强制所有 hidden 元素隐藏，覆盖任何 display 样式 */
[hidden] { display: none !important; }

:root {
  --bg: #f5f7fb;
  --card: #fff;
  --text: #1f2330;
  --muted: #8a90a2;
  --primary: #667eea;
  --primary-2: #764ba2;
  --shadow: 0 8px 24px rgba(102,126,234,.12);
  --radius: 18px;
}
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
.muted { color: var(--muted); font-size: 12px; }
button { font-family: inherit; cursor: pointer; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: linear-gradient(180deg, #eef1ff 0%, #f5f7fb 220px);
  padding-bottom: 96px;
  position: relative; overflow: hidden;
}

/* ===== 顶部 ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 6px 16px rgba(102,126,234,.35);
}
.brand-title { font-size: 17px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: none;
  background: #fff; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.streak-pill {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 999px;
  background: linear-gradient(135deg,#ff9a9e,#fad0c4);
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 12px rgba(255,154,158,.4);
}
.wrong-pill {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 999px;
  background: linear-gradient(135deg,#f87171,#fbbf24);
  color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(248,113,113,.4);
  animation: bob 2.4s ease-in-out infinite;
}
.wrong-pill[hidden] { display: none; }

/* ===== 屏幕切换 ===== */
.screen {
  display: none;
  padding: 8px 16px 24px;
  animation: fadeUp .35s ease;
}
.screen.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Hero ===== */
.hero-card {
  margin: 12px 4px 18px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 14px 30px rgba(118,75,162,.35);
  position: relative; overflow: hidden;
}
.hero-card::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 80% -20%, rgba(255,255,255,.4), transparent 50%);
}
.hero-left { display: flex; align-items: center; gap: 14px; }
.hero-emoji {
  font-size: 42px; width: 64px; height: 64px;
  background: rgba(255,255,255,.2); border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  transition: transform .3s;
}
.hero-title { font-size: 18px; font-weight: 700; }
.hero-sub { font-size: 12px; opacity: .85; margin-top: 4px; }

.ring-wrap { position: relative; width: 70px; height: 70px; }
.ring { transform: rotate(-90deg); width: 70px; height: 70px; }
.ring-bg { fill: none; stroke: rgba(255,255,255,.25); stroke-width: 6; }
.ring-fg {
  fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round;
  transition: stroke-dashoffset .8s ease;
  stroke-dasharray: 213.6; stroke-dashoffset: 213.6;
}
.ring-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}

/* ===== 区块 ===== */
.block { margin: 16px 4px; }
.block-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.block-head h3 { margin: 0; font-size: 15px; font-weight: 700; }

/* ===== 任务列表 ===== */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 16px; padding: 14px;
  box-shadow: var(--shadow);
  transition: transform .2s;
}
.task-item:active { transform: scale(.98); }
.task-emoji {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: linear-gradient(135deg,#fbc2eb,#a6c1ee);
}
.task-info { flex: 1; }
.task-name { font-size: 14px; font-weight: 600; }
.task-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.task-check {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #d1d5db; background: transparent;
  display: flex; align-items: center; justify-content: center;
  transition: all .25s;
}
.task-item.done .task-check {
  background: linear-gradient(135deg, #4ade80, #22c55e);
  border-color: transparent; color: #fff;
}
.task-item.done { opacity: .7; }
.task-item.done .task-name { text-decoration: line-through; }

/* ===== 模块网格 ===== */
.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.module-card {
  position: relative;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  color: #fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  min-height: 130px;
  overflow: hidden;
}
.module-card:active { transform: scale(.97); }
.module-card::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(255,255,255,.4), transparent 60%);
  pointer-events: none;
}
.module-emoji { font-size: 30px; margin-bottom: 6px; }
.module-title { font-size: 16px; font-weight: 700; }
.module-sub { font-size: 11px; opacity: .9; margin-top: 2px; }
.module-tag {
  display: inline-block; margin-top: 10px;
  background: rgba(255,255,255,.25);
  padding: 3px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
  backdrop-filter: blur(4px);
}

/* ===== 数据 ===== */
.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  background: var(--card); border-radius: 16px; padding: 14px;
  box-shadow: var(--shadow);
}
.stat { text-align: center; }
.stat-num { font-size: 18px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

.badges { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: #fff; box-shadow: var(--shadow);
  font-size: 12px; font-weight: 600;
}
.badge.locked { opacity: .35; filter: grayscale(1); }

.footer-note {
  text-align: center; color: var(--muted); font-size: 11px;
  margin: 24px 0 8px;
}

/* ===== 返回 & 标题 ===== */
.back-btn {
  border: none; background: #fff; box-shadow: var(--shadow);
  width: 38px; height: 38px; border-radius: 12px; font-size: 14px;
  margin: 8px 0 6px;
}
.screen > h2 { margin: 4px 0 4px; font-size: 20px; }
.page-hint { margin: 0 0 14px; }

/* ===== 听力 ===== */
.scene-picker, .lvl-picker {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.scene-picker::-webkit-scrollbar, .lvl-picker::-webkit-scrollbar { display: none; }
.scene-pill {
  flex-shrink: 0;
  padding: 10px 16px; border-radius: 14px;
  background: #fff; box-shadow: var(--shadow);
  font-size: 13px; font-weight: 600; border: none;
  display: flex; align-items: center; gap: 6px;
}
.scene-pill.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}

.dialog-card {
  margin-top: 14px; padding: 16px; border-radius: 20px;
  background: #fff; box-shadow: var(--shadow);
}
.speaker-toggle { display: flex; gap: 6px; margin-bottom: 12px; }
.spk-btn {
  padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid #e5e7eb; background: #fff;
  font-size: 12px; font-weight: 600;
}
.spk-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.dialog-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.bubble {
  padding: 10px 14px; border-radius: 16px;
  max-width: 80%; font-size: 14px;
  position: relative; cursor: pointer;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bubble.A { align-self: flex-start; background: #eef2ff; color: #1f2937; border-bottom-left-radius: 4px; }
.bubble.B { align-self: flex-end; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-bottom-right-radius: 4px; }
.bubble .role { font-size: 11px; opacity: .7; display: block; margin-bottom: 2px; }
.bubble .trans { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.bubble.B .trans { color: rgba(255,255,255,.85); }

.dialog-actions { display: flex; gap: 10px; }
.big-btn {
  flex: 1; padding: 12px; border-radius: 14px;
  border: none; background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 700; font-size: 14px;
}
.big-btn.ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.big-btn.primary { background: linear-gradient(135deg,#fbbf24,#f97316); }
.big-btn.danger { background: linear-gradient(135deg,#f87171,#ef4444); }

/* ===== 阅读 ===== */
.reading-card {
  background: #fff; border-radius: 18px; padding: 16px;
  box-shadow: var(--shadow);
  font-size: 14px; line-height: 1.75;
  white-space: pre-line;
}
.reading-card h4 { margin: 0 0 8px; font-size: 15px; }
.reading-card .meta { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.lvl-btn {
  padding: 8px 14px; border-radius: 12px;
  border: 1.5px solid #e5e7eb; background: #fff;
  font-size: 13px; font-weight: 600;
}
.lvl-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; border-color: transparent;
}

.quiz-card {
  margin-top: 12px; background: #fff; border-radius: 18px;
  padding: 16px; box-shadow: var(--shadow);
}
.quiz-q { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.quiz-opt {
  display: block; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid #e5e7eb; margin-bottom: 8px;
  font-size: 13px; cursor: pointer;
  transition: all .2s; background: #fff;
}
.quiz-opt:active { transform: scale(.98); }
.quiz-opt.right {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border-color: #34d399; color: #065f46;
}
.quiz-opt.wrong {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border-color: #f87171; color: #991b1b;
}
.quiz-exp {
  margin-top: 8px; font-size: 12px; color: var(--muted);
  padding: 8px 10px; background: #f9fafb; border-radius: 10px;
}

/* ===== 单词 ===== */
.mode-tabs {
  display: flex; gap: 8px; background: #fff; border-radius: 14px;
  padding: 4px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.tab {
  flex: 1; padding: 10px; border-radius: 10px;
  border: none; background: transparent; font-weight: 600;
  font-size: 13px; color: var(--muted);
}
.tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}

.flashcard { perspective: 1200px; height: 240px; margin-bottom: 16px; }
.fc-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .6s;
  transform-style: preserve-3d;
}
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: #fff; border-radius: 22px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  box-shadow: var(--shadow);
}
.fc-front { background: linear-gradient(135deg, #a18cd1, #fbc2eb); color: #fff; }
.fc-back { transform: rotateY(180deg); }
.fc-word { font-size: 32px; font-weight: 800; }
.fc-phonetic { font-size: 14px; opacity: .85; margin-top: 6px; }
.fc-hint { margin-top: 14px; }
.fc-meaning { font-size: 22px; font-weight: 700; color: var(--primary); }
.fc-example {
  margin-top: 14px; font-size: 13px; color: var(--muted);
  line-height: 1.6; padding: 0 10px;
}

.card-actions { display: flex; justify-content: space-around; gap: 10px; margin-bottom: 14px; }
.round-btn {
  width: 90px; padding: 14px 0;
  border-radius: 18px; border: none;
  background: #fff; box-shadow: var(--shadow);
  font-size: 22px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.round-btn span { font-size: 11px; color: var(--muted); font-weight: 500; }
.round-btn.bad { background: linear-gradient(135deg,#fee2e2,#fecaca); }
.round-btn.good { background: linear-gradient(135deg,#d1fae5,#a7f3d0); }
.round-btn:active { transform: scale(.95); }

.progress-bar { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width .4s;
}
.progress-text { text-align: center; margin-top: 6px; font-size: 12px; }

/* ===== 打卡 ===== */
.checkin-hero {
  text-align: center; padding: 24px 16px;
  background: #fff; border-radius: 22px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.big-flame {
  font-size: 64px; display: inline-block;
  filter: drop-shadow(0 6px 12px rgba(251,146,60,.4));
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.05); }
}
.big-streak { font-size: 36px; font-weight: 800; color: var(--primary); margin: 6px 0; }
.big-streak span { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.checkin-hero .big-btn { margin: 12px 0 4px; max-width: 220px; display: inline-block; }

.calendar {
  background: #fff; border-radius: 18px; padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  margin-top: 8px;
}
.cal-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 11px;
  background: #f3f4f6; color: var(--muted);
}
.cal-day.done {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: #fff; font-weight: 700;
}
.cal-day.today { border: 2px solid var(--primary); }

.reward-card {
  background: #fff; border-radius: 18px; padding: 16px;
  box-shadow: var(--shadow);
}
.reward-card h4 { margin: 0 0 10px; font-size: 14px; }
.reward-list { display: flex; flex-direction: column; gap: 8px; }
.reward-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: #f9fafb; border-radius: 12px;
  font-size: 13px;
}
.reward-item b { color: var(--primary); font-size: 12px; }

/* ===== 错题本 ===== */
.wrong-hero {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  background: linear-gradient(135deg,#f87171,#fbbf24);
  border-radius: 18px; padding: 16px;
  color: #fff; box-shadow: 0 10px 24px rgba(248,113,113,.3);
  margin-bottom: 14px;
}
.wrong-stat { text-align: center; }
.ws-num { font-size: 24px; font-weight: 800; }
.ws-label { font-size: 11px; opacity: .9; margin-top: 2px; }

.wrong-actions { display: flex; gap: 10px; margin-bottom: 14px; }
.wrong-actions .big-btn { padding: 10px; font-size: 13px; }
.wrong-actions[hidden] { display: none; }

.wrong-list { display: flex; flex-direction: column; gap: 10px; }
.wrong-card {
  background: #fff; border-radius: 16px; padding: 14px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.wrong-card-head {
  display: flex; align-items: center; justify-content: space-between;
}
.wrong-card-word { font-size: 18px; font-weight: 700; color: var(--text); }
.wrong-count {
  background: linear-gradient(135deg,#f87171,#fbbf24);
  color: #fff; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.wrong-card-phonetic { font-size: 12px; color: var(--muted); margin-top: -4px; }
.wrong-card-meaning { font-size: 13px; color: #1f2937; }
.wrong-card-example {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  padding: 8px 10px; background: #f9fafb; border-radius: 10px;
}
.wrong-card-actions { display: flex; gap: 8px; margin-top: 4px; }
.wrong-card-actions button {
  flex: 1; padding: 8px; border-radius: 10px;
  border: 1.5px solid #e5e7eb; background: #fff;
  font-size: 12px; font-weight: 600;
}
.wrong-card-actions .btn-master { color: #059669; border-color: #a7f3d0; }

.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
}
.empty-emoji { font-size: 60px; margin-bottom: 8px; }
.empty-title { font-size: 16px; font-weight: 700; }
.empty-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== 底部 Tab ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; justify-content: space-around;
  padding: 8px 6px 14px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(0,0,0,.05);
  z-index: 50;
}
.tab-btn {
  flex: 1; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 9px; color: var(--muted); font-weight: 600;
  padding: 6px 0;
}
.tab-btn span { font-size: 20px; line-height: 1; }
.tab-btn.active { color: var(--primary); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%) scale(.9);
  background: rgba(0,0,0,.85); color: #fff;
  padding: 12px 20px; border-radius: 14px;
  font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 99;
  max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ===== Confetti ===== */
#confetti {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 100;
}

/* ===== 确认弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 24px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 340px;
  background: #fff; border-radius: 22px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  animation: popUp .3s ease;
}
.modal-card.small { padding: 22px 20px; }
@keyframes popUp {
  from { transform: scale(.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.confirm-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.confirm-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .big-btn { padding: 10px; font-size: 13px; }

/* ===== 抖动反馈 ===== */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.shake { animation: shake .35s ease; }