/* ============ 单词远征 · 手机端样式 ============ */
:root {
  --bg-0: #0b0c1e;
  --bg-1: #13153a;
  --bg-2: #1c1f4d;
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.12);
  --text: #eef0ff;
  --text-dim: #9aa0d8;
  --text-faint: #6a70a8;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --cyan: #22d3ee;
  --green: #34d399;
  --red: #f87171;
  --gold: #fbbf24;
  --radius: 14px;
  --tabbar-h: 60px;
  --topbar-h: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(800px 500px at 12% -8%, rgba(99, 102, 241, 0.35), transparent 60%),
    radial-gradient(700px 400px at 95% 5%, rgba(34, 211, 238, 0.14), transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
  background-attachment: fixed;
  font-size: 15px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
.hidden { display: none !important; }

/* ============ 登录页 ============ */
.auth-view {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 22px;
  backdrop-filter: blur(20px);
}
.auth-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 24px; font-weight: 800; background: linear-gradient(90deg, #a5b4fc, #67e8f9); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim);
  border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .2s; font-family: inherit;
}
.auth-tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; padding: 12px 14px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 15px;
  outline: none; transition: border-color .15s; font-family: inherit;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.2); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.code-btn { white-space: nowrap; min-width: 100px; }
.auth-error { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .15s; min-height: 42px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-ghost { background: rgba(255,255,255,0.07); color: var(--text); border: 1px solid var(--border); }
.btn-gold { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.btn-green { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.btn-red { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 12px; min-height: 34px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ 顶部栏 ============ */
.m-topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 16px; padding-right: 16px;
  background: rgba(11, 12, 30, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.m-topbar-left { display: flex; align-items: center; gap: 8px; }
.m-logo { font-size: 22px; }
.m-title { font-size: 17px; font-weight: 700; }
.m-topbar-right { display: flex; gap: 10px; }
.m-res { font-size: 12px; color: var(--text-dim); background: rgba(255,255,255,0.06); padding: 4px 8px; border-radius: 8px; }
.m-res b { color: var(--text); font-size: 13px; }

/* ============ 内容区 ============ */
.app-view { position: fixed; inset: 0; display: flex; flex-direction: column; }
.m-content {
  flex: 1;
  padding-top: calc(var(--topbar-h) + var(--safe-top) + 8px);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  padding-left: 14px; padding-right: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============ 底部导航 ============ */
.m-tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(11, 12, 30, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 100;
}
.m-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--text-faint);
  cursor: pointer; position: relative; font-family: inherit;
  transition: color .15s;
}
.m-tab.active { color: var(--primary); }
.m-tab-icon { font-size: 20px; margin-bottom: 2px; }
.m-tab-label { font-size: 10px; font-weight: 600; }
.m-tab-badge {
  position: absolute; top: 6px; right: 50%;
  transform: translateX(16px);
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ============ 词书列表 ============ */
.page-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }
.m-book-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  transition: transform .15s;
}
.m-book-card:active { transform: scale(0.98); }
.m-book-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.m-book-icon { font-size: 32px; flex-shrink: 0; }
.m-book-info { flex: 1; min-width: 0; }
.m-book-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.m-book-meta { font-size: 12px; color: var(--text-dim); }
.m-progress-track { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; margin: 8px 0; overflow: hidden; }
.m-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--cyan)); border-radius: 3px; transition: width .3s; }
.m-book-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.m-stat { font-size: 11px; padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,0.05); color: var(--text-dim); }
.m-book-actions { display: flex; gap: 8px; }
.m-book-actions .btn { flex: 1; }

/* ============ 学习配置 ============ */
.m-config-section { margin-bottom: 20px; }
.m-config-label { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: var(--text-dim); }
.m-seg-group { display: flex; gap: 8px; flex-wrap: wrap; }
.m-seg-btn {
  padding: 10px 14px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-dim);
  border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.m-seg-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }
.m-seg-btn small { display: block; font-size: 10px; opacity: 0.8; font-weight: 400; }

/* ============ 记忆卡片 ============ */
.m-memo-wrap { display: flex; flex-direction: column; height: 100%; min-height: 400px; }
.m-memo-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.m-memo-progress-bar { flex: 1; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.m-memo-progress-fill { height: 100%; background: var(--cyan); border-radius: 2px; transition: width .3s; }
.m-memo-progress-text { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.m-memo-card {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--card-strong); border: 1px solid var(--border);
  border-radius: 20px; padding: 24px 20px;
  min-height: 280px; text-align: center;
  position: relative;
}
.m-memo-word { font-size: 32px; font-weight: 800; margin-bottom: 8px; letter-spacing: 0.5px; }
.m-memo-pos { font-size: 14px; color: var(--cyan); margin-bottom: 12px; }
.m-memo-meaning { font-size: 17px; color: var(--text); line-height: 1.6; }
.m-memo-hint { font-size: 13px; color: var(--text-faint); margin-top: 16px; }
.m-memo-speak {
  position: absolute; top: 14px; right: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: none;
  font-size: 18px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.m-memo-actions { display: flex; gap: 10px; margin-top: 16px; }
.m-memo-actions .btn { flex: 1; }
.m-tag-btn {
  padding: 6px 12px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); cursor: pointer; font-family: inherit;
}
.m-tag-btn.active { background: rgba(251,191,36,0.15); border-color: var(--gold); color: var(--gold); }
.m-tag-btn.ignore.active { background: rgba(248,113,113,0.15); border-color: var(--red); color: var(--red); }

/* ============ 默写 ============ */
.m-quiz-wrap { display: flex; flex-direction: column; height: 100%; }
.m-quiz-meaning {
  background: var(--card-strong); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; text-align: center;
  margin-bottom: 16px;
}
.m-quiz-pos { font-size: 13px; color: var(--cyan); margin-bottom: 6px; }
.m-quiz-meaning-text { font-size: 18px; font-weight: 600; line-height: 1.5; }
.m-quiz-input-wrap { margin-bottom: 16px; position: relative; }
.m-quiz-input {
  width: 100%; padding: 14px 16px;
  background: rgba(255,255,255,0.06); border: 2px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 20px;
  text-align: center; letter-spacing: 2px; font-weight: 600;
  outline: none; transition: border-color .15s; font-family: inherit;
  text-transform: lowercase;
}
.m-quiz-input:focus { border-color: var(--primary); }
.m-quiz-input.correct { border-color: var(--green); background: rgba(52,211,153,0.1); }
.m-quiz-input.wrong { border-color: var(--red); background: rgba(248,113,113,0.1); }
.m-quiz-feedback { text-align: center; margin-bottom: 12px; min-height: 24px; font-size: 14px; font-weight: 600; }
.m-quiz-feedback.correct { color: var(--green); }
.m-quiz-feedback.wrong { color: var(--red); }
.m-quiz-actions { display: flex; gap: 10px; }
.m-quiz-actions .btn { flex: 1; }

/* ============ 错词本 ============ */
.m-wrong-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
}
.m-wrong-word { font-size: 17px; font-weight: 700; min-width: 90px; color: #fda4af; }
.m-wrong-info { flex: 1; min-width: 0; }
.m-wrong-pos { font-size: 11px; color: var(--cyan); }
.m-wrong-meaning { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-wrong-speak { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.06); border: none; font-size: 16px; cursor: pointer; flex-shrink: 0; }

/* ============ 排行榜 ============ */
.m-rank-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.m-rank-num { font-size: 18px; font-weight: 800; min-width: 28px; text-align: center; }
.m-rank-num.gold { color: var(--gold); }
.m-rank-num.silver { color: #cbd5e1; }
.m-rank-num.bronze { color: #d97706; }
.m-rank-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-2); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.m-rank-info { flex: 1; }
.m-rank-name { font-size: 14px; font-weight: 600; }
.m-rank-sub { font-size: 11px; color: var(--text-faint); }
.m-rank-score { font-size: 15px; font-weight: 700; color: var(--gold); }

/* ============ 我的页面 ============ */
.m-profile-header {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; margin-bottom: 16px;
}
.m-avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-2)); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.m-profile-info { flex: 1; }
.m-profile-name { font-size: 18px; font-weight: 700; }
.m-profile-title { font-size: 12px; color: var(--gold); }
.m-profile-stats { display: flex; gap: 16px; margin-top: 4px; }
.m-profile-stat { font-size: 12px; color: var(--text-dim); }
.m-profile-stat b { color: var(--text); font-size: 14px; }

.m-menu-group { margin-bottom: 16px; }
.m-menu-group-title { font-size: 12px; color: var(--text-faint); font-weight: 600; margin-bottom: 8px; padding-left: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.m-menu-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 6px;
  cursor: pointer; transition: background .15s;
}
.m-menu-item:active { background: var(--card-strong); }
.m-menu-icon { font-size: 20px; width: 28px; text-align: center; }
.m-menu-text { flex: 1; font-size: 14px; font-weight: 500; }
.m-menu-desc { font-size: 11px; color: var(--text-faint); display: block; margin-top: 1px; }
.m-menu-arrow { color: var(--text-faint); font-size: 16px; }
.m-menu-badge { font-size: 11px; background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 10px; }

/* ============ 离线音频 ============ */
.m-offline-book {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 10px;
}
.m-offline-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.m-offline-name { font-size: 14px; font-weight: 600; }
.m-offline-size { font-size: 11px; color: var(--text-faint); }
.m-offline-progress { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; margin: 8px 0; overflow: hidden; }
.m-offline-progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan)); border-radius: 2px; transition: width .3s; }
.m-offline-status { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.m-offline-actions { display: flex; gap: 8px; }

/* ============ 弹窗 ============ */
.m-modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.m-modal {
  width: 100%; max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  max-height: 85vh; overflow-y: auto;
  padding-bottom: calc(20px + var(--safe-bottom));
  animation: slideUp .25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.m-modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.m-modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.m-modal-actions .btn { flex: 1; }

/* ============ Toast ============ */
#m-toast-wrap {
  position: fixed; top: calc(var(--topbar-h) + var(--safe-top) + 10px);
  left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; width: 90%; max-width: 360px;
}
.m-toast {
  background: rgba(20, 22, 50, 0.95);
  border: 1px solid var(--border);
  color: var(--text); padding: 10px 16px;
  border-radius: 10px; font-size: 13px; text-align: center;
  backdrop-filter: blur(10px);
  animation: toastIn .2s ease-out;
}
.m-toast.success { border-color: var(--green); }
.m-toast.error { border-color: var(--red); }
.m-toast.gold { border-color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ============ 空状态 ============ */
.m-empty { text-align: center; padding: 40px 20px; color: var(--text-faint); }
.m-empty-icon { font-size: 48px; margin-bottom: 12px; }
.m-empty-text { font-size: 14px; }

/* ============ 学习结果页 ============ */
.m-result-wrap { text-align: center; padding: 30px 16px; }
.m-result-icon { font-size: 56px; margin-bottom: 12px; }
.m-result-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.m-result-stats { display: flex; justify-content: center; gap: 24px; margin: 20px 0; }
.m-result-stat { text-align: center; }
.m-result-stat-num { font-size: 28px; font-weight: 800; }
.m-result-stat-num.green { color: var(--green); }
.m-result-stat-num.red { color: var(--red); }
.m-result-stat-num.gold { color: var(--gold); }
.m-result-stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ============ 分段控件 ============ */
.m-seg-inline { display: flex; gap: 6px; margin-bottom: 14px; }
.m-seg-inline button {
  flex: 1; padding: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim);
  border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.m-seg-inline button.active { background: var(--card-strong); color: var(--text); border-color: var(--primary); }

/* ============ 滚动条隐藏 ============ */
.m-content::-webkit-scrollbar { display: none; }
.m-content { scrollbar-width: none; }
