/* =========================================================
 * 小词匠 · 快乐记单词 — 温暖童趣主题
 * 设计：Impeccable 原则 · 玩具俏皮风
 * 字体：Baloo 2 (标题) + Nunito (正文)
 * ========================================================= */

/* ===== 基础 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 品牌暖橙 */
  --primary: #ff9f43;
  --primary-dark: #e86a17;
  --primary-light: #ffd9a8;
  /* 糖果辅助色 */
  --secondary: #4d9fff;
  --secondary-light: #d3e9ff;
  --success: #3ecf8e;
  --success-light: #d8f5e8;
  --danger: #ff6b6b;
  --danger-light: #ffe3e3;
  --purple: #a78bfa;
  --purple-light: #ece6ff;
  --pink: #f472b6;
  --pink-light: #fde3f1;
  --mint: #34d399;
  /* 中性 */
  --bg: #fff8f0;
  --card: #ffffff;
  --text: #4a3f35;
  --text-light: #7d6e5e;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 8px 24px rgba(232, 106, 23, 0.10), 0 2px 6px rgba(74, 63, 53, 0.06);
  --shadow-sm: 0 4px 12px rgba(74, 63, 53, 0.08);
  --shadow-hover: 0 14px 34px rgba(232, 106, 23, 0.16), 0 4px 10px rgba(74, 63, 53, 0.08);
}

html, body {
  min-height: 100%;
}

body {
  font-family: "Nunito", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 8% 12%, rgba(255, 159, 67, 0.14) 0, transparent 42%),
    radial-gradient(circle at 92% 8%, rgba(77, 159, 255, 0.12) 0, transparent 42%),
    radial-gradient(circle at 85% 88%, rgba(62, 207, 142, 0.12) 0, transparent 42%),
    radial-gradient(circle at 12% 90%, rgba(167, 139, 250, 0.10) 0, transparent 40%);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .word-item-english, .progress-count, .result-emoji {
  font-family: "Baloo 2", "Nunito", "PingFang SC", sans-serif;
}

/* ===== 键盘焦点可见性 ===== */
:focus {
  outline: none;
}
:focus-visible {
  outline: 3px solid var(--secondary);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(77, 159, 255, 0.18);
}
.topbar :focus-visible {
  outline-color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35);
}
/* 可点击卡片（div 模拟按钮）统一键盘可达 */
.book-card:focus-visible,
.user-item:focus-visible,
.unit-item:focus-visible {
  outline: 3px solid var(--secondary);
  outline-offset: 2px;
}
/* 已有专属聚焦样式的输入框，避免双层指示 */
.letter-input:focus-visible,
.daily-count-sel:focus-visible,
.form-row input:focus-visible,
.form-row select:focus-visible {
  outline: none;
}

/* ===== 顶部导航 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(120deg, #ffb066 0%, #ff9f43 45%, #ff8a5c 100%);
  box-shadow: 0 4px 16px rgba(232, 106, 23, 0.30);
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-emoji {
  font-size: 36px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.12));
  animation: floaty 3.2s ease-in-out infinite;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo h1 {
  font-size: 27px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(180, 80, 0, 0.35);
}

.logo-sub {
  color: rgba(255,255,255,0.96);
  font-size: 13px;
  font-weight: 700;
  background: rgba(255,255,255,0.22);
  padding: 4px 12px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab {
  border: none;
  background: rgba(255,255,255,0.22);
  color: #fff;
  padding: 9px 16px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.25, 1, 0.5, 1), background 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(4px);
}

.tab:hover {
  background: rgba(255,255,255,0.38);
  transform: translateY(-1px);
}

.tab:active {
  transform: scale(0.95);
}

.tab.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(180, 80, 0, 0.25);
}

/* ===== 主容器 ===== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 22px 16px 60px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewIn 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 按钮 ===== */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: 16px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 800;
  font-family: "Nunito", sans-serif;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.2s, background 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #ffb066, #ff9f43);
  color: #fff;
  box-shadow: 0 5px 14px rgba(232, 106, 23, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(232, 106, 23, 0.42);
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary {
  background: #fff;
  color: var(--primary-dark);
  border: 2.5px solid var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: scale(0.96);
}

.btn-primary.small, .btn-secondary.small {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 14px;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== 进度卡 ===== */
.progress-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 1px solid rgba(255, 159, 67, 0.12);
}

.progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
}

.progress-count {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-dark);
}

.progress-bar {
  height: 14px;
  background: #fdf0e2;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffb066, #ff9f43, #ff8a5c);
  border-radius: 20px;
  transition: width 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  position: relative;
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: shimmer 2.2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ===== 每日学习头部 ===== */
.daily-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.daily-head h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

.daily-date {
  background: linear-gradient(135deg, #fff3e0, #ffe8cc);
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--primary-light);
}

/* 每日数量选择 */
.daily-count-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 2px solid var(--primary-light);
  border-radius: 22px;
  padding: 5px 12px;
  box-shadow: var(--shadow-sm);
}

.daily-count-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
  white-space: nowrap;
}

.daily-count-sel {
  border: 2px solid var(--primary);
  background: #fff8ef;
  color: var(--primary-dark);
  font-size: 15px;
  font-weight: 800;
  font-family: "Nunito", sans-serif;
  border-radius: 14px;
  padding: 4px 10px;
  width: 72px;
  text-align: center;
  outline: none;
  transition: box-shadow 0.2s;
}

.daily-count-sel:focus {
  box-shadow: 0 0 0 3px rgba(255, 159, 67, 0.25);
}

/* ===== 当前词库书签 ===== */
.book-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 2px solid var(--primary-light);
  border-radius: 18px;
  padding: 12px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.book-chip strong {
  color: var(--primary-dark);
  font-size: 16px;
}

.chip-note {
  color: var(--text-light);
  font-size: 13px;
  margin-left: auto;
}

.chip-btn {
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--primary-dark);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.chip-btn:hover {
  background: #fff3e0;
  transform: translateY(-1px);
}

.learn-tip {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 14px;
  background: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
}

/* ===== 复习横幅 ===== */
.review-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #d3e9ff, #e3f1ff);
  border: 2px solid #bcdcff;
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  animation: viewIn 0.35s ease;
}

.review-banner-emoji {
  font-size: 26px;
  animation: floaty 2.4s ease-in-out infinite;
}

.review-banner-text {
  color: #1a5f9e;
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}

.review-btn {
  border: none;
  background: linear-gradient(135deg, #4d9fff, #3d8bf5);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  font-family: "Nunito", sans-serif;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(61, 139, 245, 0.3);
  white-space: nowrap;
}

.review-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(61, 139, 245, 0.4);
}

.review-btn:active {
  transform: scale(0.95);
}

/* ===== 打卡区 ===== */
.checkin-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 159, 67, 0.12);
}

.checkin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.checkin-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.checkin-streak {
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
  background: var(--danger-light);
  padding: 5px 14px;
  border-radius: 20px;
}

.checkin-streak strong {
  font-size: 18px;
  font-family: "Baloo 2", sans-serif;
}

.checkin-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.checkin-cell {
  text-align: center;
  padding: 10px 4px;
  border-radius: 14px;
  background: #faf4ec;
  border: 2px solid transparent;
  transition: transform 0.15s, background 0.2s;
}

.checkin-cell.learned {
  background: linear-gradient(135deg, #d8f5e8, #c3efd9);
  border-color: #9be0bd;
}

.checkin-cell.today {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 159, 67, 0.18);
}

.checkin-dow {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 3px;
}

.checkin-dot {
  font-size: 16px;
}

.checkin-note {
  font-size: 12.5px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 12px;
}

.checkin-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== 单词卡片 ===== */
.card-stage {
  min-height: 150px;
  margin-bottom: 20px;
}

.word-card {
  background: var(--card);
  border-radius: 26px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px solid rgba(255, 159, 67, 0.15);
  position: relative;
  overflow: hidden;
  animation: cardIn 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.word-card::before {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 130px;
  height: 130px;
  background: radial-gradient(circle, rgba(255, 159, 67, 0.10) 0%, transparent 70%);
  pointer-events: none;
}

.card-tag {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  background: #fff3e0;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 18px;
}

.mean-hint {
  font-size: 44px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  font-family: "Baloo 2", sans-serif;
  letter-spacing: 2px;
}

.letter-tip {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.word-card .speak-btn {
  border: none;
  background: linear-gradient(135deg, var(--secondary-light), #e8f3ff);
  color: #1a5f9e;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(77, 159, 255, 0.25);
  margin-top: 8px;
}

.word-card .speak-btn:hover {
  transform: scale(1.1);
}

.word-card .speak-btn:active {
  transform: scale(0.92);
}

.word-card.correct {
  border-color: var(--success);
  animation: popCorrect 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popCorrect {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.word-card.wrong {
  border-color: var(--danger);
  animation: shakeX 0.45s ease;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ===== 字母输入 ===== */
.answer-area {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 159, 67, 0.12);
}

.letter-boxes {
  display: flex;
  gap: 9px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.letter-input {
  width: 52px;
  height: 64px;
  border: 3px solid #efe6d8;
  border-radius: 16px;
  font-size: 32px;
  font-weight: 800;
  font-family: "Baloo 2", sans-serif;
  text-align: center;
  outline: none;
  background: #fffdf9;
  color: var(--text);
  transition: border-color 0.2s, transform 0.12s, box-shadow 0.2s, background 0.2s;
  caret-color: var(--primary);
}

.letter-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 159, 67, 0.15);
  transform: translateY(-2px);
}

.letter-input.filled {
  border-color: #ffcf9e;
  background: #fff8ef;
}

.letter-input.correct-box {
  border-color: var(--success);
  background: var(--success-light);
  color: #1d7a4f;
  animation: popIn 0.3s ease;
}

.letter-input.wrong-box {
  border-color: var(--danger);
  background: var(--danger-light);
  color: var(--danger);
  animation: shakeX 0.4s ease;
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0.5; }
  to { transform: scale(1); opacity: 1; }
}

.check-row {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.feedback {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  min-height: 24px;
  padding: 6px;
  border-radius: 12px;
  transition: all 0.2s;
}

.feedback.reveal-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.reveal-btn {
  border: none;
  background: linear-gradient(135deg, var(--secondary), #3d8bf5);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  font-family: "Nunito", sans-serif;
  padding: 7px 18px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(61, 139, 245, 0.3);
  transition: transform 0.15s, box-shadow 0.2s;
}

.reveal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(61, 139, 245, 0.4);
}

.reveal-btn:active {
  transform: scale(0.95);
}

.feedback-txt strong {
  color: var(--secondary);
}

.feedback.correct-msg {
  color: #1d7a4f;
  background: var(--success-light);
  animation: popIn 0.35s ease;
}

.feedback.wrong-msg {
  color: var(--danger);
  background: var(--danger-light);
  animation: shakeX 0.4s ease;
}

/* ===== 结果页 ===== */
.result-page {
  background: var(--card);
  border-radius: var(--radius);
  padding: 44px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid rgba(62, 207, 142, 0.25);
}

.result-emoji {
  font-size: 84px;
  margin-bottom: 10px;
  animation: bounce 1.2s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.result-page h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--primary-dark);
}

.result-text {
  color: var(--text-light);
  margin-bottom: 24px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== 词库管理头部 ===== */
.manage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.manage-head h2 {
  font-size: 24px;
  font-weight: 800;
}

.manage-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== 添加表单 ===== */
.add-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  animation: popIn 0.3s ease;
  border: 1px solid rgba(255, 159, 67, 0.12);
}

.add-form h3 {
  margin-bottom: 14px;
  color: var(--primary-dark);
  font-size: 18px;
  font-weight: 800;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.form-row label {
  flex: 1;
  min-width: 180px;
  font-size: 14px;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row input,
.form-row select {
  padding: 11px 14px;
  font-size: 16px;
  font-family: "Nunito", sans-serif;
  border: 2.5px solid #f0e6d8;
  border-radius: 14px;
  outline: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-row input:focus,
.form-row select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 159, 67, 0.12);
}

.hint-note {
  color: var(--text-light);
  font-size: 14px;
  background: #fff7ec;
  border: 2px dashed var(--primary-light);
  padding: 10px 14px;
  border-radius: 12px;
  width: 100%;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== 单词列表 ===== */
.word-list {
  display: grid;
  gap: 12px;
}

.word-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  gap: 10px;
  border: 1px solid rgba(255, 159, 67, 0.10);
  transition: transform 0.15s, box-shadow 0.2s;
}

.word-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.word-item-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.word-item-english {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.word-item-mean {
  color: var(--text-light);
  font-size: 15px;
}

.word-item-gap {
  font-size: 12px;
  font-weight: 700;
  color: var(--secondary);
  background: var(--secondary-light);
  padding: 2px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

/* 错词本徽章 */
.wrong-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
  background: var(--danger-light);
  padding: 2px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.wrong-badge.progress {
  color: var(--secondary);
  background: var(--secondary-light);
}

.wrong-count-chip {
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 800;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 20px;
}

.word-item-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  border: none;
  background: #f6f0e8;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.icon-btn:hover {
  background: #ece0d0;
  transform: scale(1.08);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.delete:hover {
  background: var(--danger-light);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-light);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px dashed #f0e6d8;
}

.empty-emoji {
  font-size: 64px;
  margin-bottom: 12px;
  animation: floaty 3s ease-in-out infinite;
}

.empty-state p {
  margin-bottom: 16px;
  font-weight: 600;
}

.empty-sub {
  color: var(--text-light);
  font-size: 13px;
  margin-top: 4px;
}

/* ===== 词库选择 ===== */
.library-head {
  margin-bottom: 18px;
}

.library-head h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.library-sub {
  color: var(--text-light);
  font-size: 14px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.book-card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.2s, box-shadow 0.2s;
}

.book-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-hover);
}

.book-card.selected {
  border-color: var(--primary);
  background: linear-gradient(160deg, #fff8ef, #fff);
  box-shadow: 0 10px 26px rgba(232, 106, 23, 0.18);
}

.book-emoji {
  font-size: 42px;
  margin-bottom: 6px;
  display: inline-block;
  animation: floaty 3.4s ease-in-out infinite;
}

.book-card:nth-child(2n) .book-emoji {
  animation-delay: 0.8s;
}

.book-grade {
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 2px;
}

.book-label {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.book-meta {
  font-size: 12px;
  color: var(--text-light);
}

/* ===== 单元面板 ===== */
.unit-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  animation: popIn 0.3s ease;
  border: 1px solid rgba(255, 159, 67, 0.12);
}

.unit-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.unit-panel-head h3 {
  color: var(--primary-dark);
  font-size: 18px;
  font-weight: 800;
}

.unit-actions {
  display: flex;
  gap: 8px;
}

.unit-list {
  display: grid;
  gap: 8px;
}

.unit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid #f0e6d8;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  flex-wrap: wrap;
}

.unit-item:hover {
  border-color: var(--primary);
  background: #fff8ef;
  transform: translateX(3px);
}

.unit-item.checked {
  border-color: var(--primary);
  background: #fff8ef;
}

.unit-item input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.unit-title {
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
}

.unit-name {
  color: var(--text-light);
  font-size: 13px;
  flex: 1;
  min-width: 60px;
}

.unit-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--secondary);
  background: var(--secondary-light);
  padding: 2px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

/* ===== 学习模式切换 ===== */
.mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--card);
  border-radius: 18px;
  padding: 6px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 159, 67, 0.12);
}

.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  font-family: "Nunito", sans-serif;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: linear-gradient(135deg, #ffb066, #ff9f43);
  color: #fff;
  box-shadow: 0 4px 12px rgba(232, 106, 23, 0.3);
}

.mode-btn:not(.active):hover {
  color: var(--primary-dark);
  background: #fff3e0;
}

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 63, 53, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 440px;
  width: 100%;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(74, 63, 53, 0.28);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 85vh;
  overflow-y: auto;
  border: 2px solid rgba(255, 159, 67, 0.15);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal-head h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-dark);
}

.modal-close {
  border: none;
  background: #f6f0e8;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close:hover {
  background: #ece0d0;
  transform: rotate(90deg);
}

.modal-sub {
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ===== 徽章 ===== */
.badge-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.badge-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: #faf6f0;
  border: 2px solid #f0e8dd;
  transition: transform 0.15s;
}

.badge-item.unlocked {
  background: linear-gradient(135deg, #fff8ef, #ffe9cc);
  border-color: var(--primary);
  animation: badgeUnlock 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgeUnlock {
  0% { transform: scale(0.8) rotate(-4deg); opacity: 0.4; }
  60% { transform: scale(1.06) rotate(2deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.badge-item.locked {
  opacity: 0.55;
  filter: grayscale(0.4);
}

.badge-emoji {
  font-size: 30px;
}

.badge-item.unlocked .badge-emoji {
  animation: floaty 2.8s ease-in-out infinite;
}

.badge-info {
  min-width: 0;
}

.badge-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  display: block;
}

.badge-desc {
  font-size: 11.5px;
  color: var(--text-light);
  display: block;
  line-height: 1.4;
}

/* ===== 周报 ===== */
.week-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.week-stat {
  background: #faf6f0;
  border-radius: 16px;
  padding: 14px;
  text-align: center;
  border: 2px solid #f0e8dd;
}

.week-stat-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 4px;
}

.week-stat-value {
  font-size: 24px;
  font-weight: 800;
  font-family: "Baloo 2", sans-serif;
  color: var(--primary-dark);
}

.week-wrong-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.week-wrong-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.week-wrong-item {
  background: var(--danger-light);
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
}

.week-wrong-empty {
  color: var(--success);
  font-size: 14px;
  font-weight: 700;
  background: var(--success-light);
  padding: 10px 14px;
  border-radius: 14px;
}

/* ===== 用户列表 ===== */
.user-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 3px solid #f0e6d8;
  border-radius: 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.user-item:hover {
  border-color: var(--primary);
  background: #fff8ef;
  transform: translateX(3px);
}

.user-item.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff8ef, #ffe9cc);
}

.user-item-emoji {
  font-size: 36px;
  animation: floaty 3s ease-in-out infinite;
}

.user-item-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  flex: 1;
}

.user-item-active-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--success);
  background: var(--success-light);
  padding: 3px 10px;
  border-radius: 12px;
}

.user-item-del {
  border: none;
  background: var(--danger-light);
  color: var(--danger);
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s;
}

.user-item-del:hover {
  transform: scale(1.1);
}

.modal-actions {
  display: flex;
  justify-content: center;
}

.add-user-form {
  margin-top: 14px;
  border-top: 2px dashed #f0e6d8;
  padding-top: 16px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(74, 63, 53, 0.92);
  color: #fff;
  padding: 13px 28px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: 88vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-8px);
}

/* ===== 工具类 ===== */
.hidden {
  display: none !important;
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .topbar {
    padding: 12px 14px;
  }
  .logo h1 {
    font-size: 22px;
  }
  .tab {
    padding: 8px 12px;
    font-size: 13px;
  }
  .mean-hint {
    font-size: 34px;
    padding: 8px 20px;
  }
  .letter-input {
    width: 44px;
    height: 56px;
    font-size: 28px;
  }
  .letter-boxes {
    gap: 7px;
  }
  .word-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .daily-date {
    width: 100%;
    text-align: center;
  }
  .badge-list, .week-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .result-emoji {
    font-size: 64px;
  }
}

/* ===== 移动端 / 微信内触控优化 ===== */
@media (hover: none) {
  button, .tab, .letter-input, .reveal-btn, .book-card, .unit-item, .user-item {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* 去除双击缩放延迟，儿童连续拼写更跟手 */
  }
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .btn-primary, .btn-secondary { min-height: 48px; }
  .speak-btn { min-height: 44px; }
  .word-card .speak-btn { font-size: 16px; padding: 10px 22px; }
  .check-row .btn-primary {
    min-height: 54px;
    font-size: 18px;
    min-width: 180px;
  }
}

/* 刘海屏安全区适配 */
@supports (padding: env(safe-area-inset-top)) {
  .topbar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  .container {
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }
}

/* ===== 登录 / 注册遮罩 ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 15%, rgba(255, 159, 67, 0.18) 0, transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(77, 159, 255, 0.15) 0, transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(62, 207, 142, 0.15) 0, transparent 45%);
}
.auth-overlay:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 36px 30px 28px;
  text-align: center;
}
.auth-logo { font-size: 52px; line-height: 1; margin-bottom: 8px; }
.auth-title { font-family: "Baloo 2", "PingFang SC", sans-serif; color: var(--primary-dark); font-size: 22px; }
.auth-sub { color: var(--text-light); font-size: 13px; margin: 6px 0 22px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 2px solid #eee6dc;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 159, 67, 0.18);
}
.auth-btn { width: 100%; }
.auth-msg { min-height: 18px; font-size: 13px; color: var(--danger); margin: 0; }
.auth-msg:empty { display: none; }
.auth-switch { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.auth-switch a { color: var(--primary-dark); font-weight: 700; text-decoration: none; }

/* 动效偏好：减弱动画 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
