﻿* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* 禁用 iOS 双击缩放(double-tap zoom)：双击上一页/下一页等控件会触发视觉视口缩放、显示错位。
     viewport 的 user-scalable=no 在 iOS 常被部分忽略，touch-action:manipulation 是可靠补充；
     它保留平移/滚动，仅禁用双击缩放，不影响组内列表滚动。 */
  touch-action: manipulation;
}

:root {
  --brand: #6366f1;
  --brand-light: #818cf8;
  --brand-dark: #4f46e5;
  --brand-purple: #a855f7;
  --brand-purple-light: #c084fc;
  --ink: #1e293b;
  --ink-soft: #64748b;
  --radius-card: 16px;
  --radius-pill: 30px;
  --radius-bubble: 20px;
  --shadow-card: 0 4px 16px rgba(148,163,184,0.10), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 12px 40px rgba(148,163,184,0.18);
  --shadow-btn: 0 4px 12px rgba(99,102,241,0.30);
  --shadow-btn-hover: 0 6px 20px rgba(99,102,241,0.42);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  /* overscroll-behavior ֻ�� body.practice-active ���ƣ�����ϰҳ�汣�� pull-to-refresh */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #F8F9FA;
  min-height: 100vh;
  color: #1e293b;
  overscroll-behavior: none;
}

/* ��ϰ/ѧϰģʽ����ʱ������ body ��ֹ iOS ��Ե�һ����� */
/* ע�⣺��ʹ�� position:fixed��iOS Safari �ڿ��ٻ���ʱ fixed Ԫ�ػ�ƫ�Ƶ���ҳ�����?*/
body.practice-active {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== 页面容器：桌面端限制宽度并居�?===== */
/* .word-select-page 不设 max-width，因为内含底�?selection-bar 要突�?800px */
.book-select-page,
.practice-page,
.result-page {
  max-width: 800px;
  margin: 0 auto;
}

/* ===== ѡ��ҳ�� ===== */
.word-select-page {
  display: flex;
  flex-direction: column;
  /* 与首页(.book-select-page)统一用 position:fixed; inset:0：
     这是双版本 iOS 实测「进书不跳」的模型。之前回退 relative+100svh 会进书整页上跳。
     hit-test 错位由底部 .selection-bar 从 sticky+100vw 负 margin 改为 fixed(left/right/bottom:0) 修复
     （fixed 父内的 sticky 找不到滚动祖先 + 100vw 在 iOS 令全页 layout 偏移，是错位根因）。
     顶部留白仍用纯 env()（无 px floor），与首页一致且跨版本不跳。 */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  overflow: hidden;
  /* 与首页共用纯 env()（无 px floor）：两页计算结果一致 → 顶部留白完全相同，且不触发跨版本跳变 */
  padding-top: env(safe-area-inset-top, 0px);
}

.word-select-page > .page-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.app-header {
  text-align: center;
  padding: 12px 20px 8px;
  color: #1e293b;
  flex-shrink: 0;
}

/* ѡ��ҳ������ - ���в��֣����� | ���� | ���� */
.select-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 0 10px;
  flex-shrink: 0;
}

.select-page-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: #1e293b;
  text-align: center;
  flex: 1;
}

/* Dark mode: app header (��ҳ��) */
.dark-mode .app-header,
body.dark-mode .app-header {
  color: #e2e8f0;
}
.dark-mode .app-header h1 {
  color: #ffffff;
}
.dark-mode .app-header p {
  color: rgba(255,255,255,0.7);
}

.dark-mode .select-page-title {
  color: #e2e8f0;
}

/* ѡ��ҳ������ѡ�������� */
.word-select-page .voice-selector-bar {
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: #1e293b;
}

.app-header p {
  font-size: 0.95rem;
  color: #64748b;
}

.word-categories {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 16px 20px;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.word-categories::-webkit-scrollbar {
  width: 4px;
}

.word-categories::-webkit-scrollbar-track {
  background: transparent;
}

.word-categories::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.3);
  border-radius: 2px;
}

.word-categories::-webkit-scrollbar-thumb:hover {
  background: rgba(148,163,184,0.5);
}

.category-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(148,163,184,0.10);
  overflow: hidden;
  width: 100%;
  min-height: fit-content;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.category-card:active {
  transform: scale(0.99);
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}

.category-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.category-header .badge {
  background: #6366f1;
  color: white;
  padding: 2px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
}

.category-header .toggle-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  margin-left: 12px;
  flex-shrink: 0;
}

.toggle-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #888;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}

.category-header.open .toggle-icon svg {
  transform: rotate(90deg);
}

/* 分隔线只在卡片展开（标题与词表之间）时显示；折叠时卡片只剩标题栏，
   若此处仍画线会与卡片自身的 border-bottom 叠成"双线" */
.category-header.open {
  border-bottom: 1px solid rgba(148,163,184,0.15);
}

/* 组头「已选标记」徽标：仅在该组有选中时显示，折叠后也能看出选了几个 */
.group-selected-badge {
  display: none;
  align-items: center;
  background: #6366f1;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.group-selected-badge.show {
  display: inline-flex;
}

/* 整组有选中时：左侧色条 + 淡背景，列表里一眼扫出哪些组处于已选状态 */
.category-card.has-selection {
  border-color: rgba(99,102,241,0.55);
  box-shadow: 0 4px 18px rgba(99,102,241,0.20);
}
.category-card.has-selection .category-header {
  background: rgba(99,102,241,0.08);
  border-left: 4px solid #6366f1;
  padding-left: 16px;
}

/* 选中态分隔线也只在展开时显示（避免折叠态与卡片边框叠成双线） */
.category-card.has-selection .category-header.open {
  border-bottom: 1px solid rgba(99,102,241,0.12);
}

/* ����������ӣ�Ĭ�����أ�չ�������?*/
.category-actions {
  display: none;
}

.category-header.open .category-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.category-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.category-body.open {
  max-height: 2000px;
}

.category-body.open.reading-mode {
  max-height: none;
  overflow: visible;
}

.word-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 16px 20px;
}

.word-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(99,102,241,0.06);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.word-checkbox-item:hover {
  background: rgba(99,102,241,0.12);
}

.word-checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #6366f1;
  cursor: pointer;
  flex-shrink: 0;
}

.word-checkbox-item .word-label {
  font-size: 1rem;
  font-weight: 500;
  color: #444;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ������䣺��ѡ��?Ӣ��ͬ�У��������廻�� */
.collocations-grid {
  grid-template-columns: 1fr !important;
}
.collocations-grid .collocations-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 6px 4px;
}
.collocations-grid .collocations-item .word-en {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: #1e293b;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}
.collocations-grid .collocations-item .word-cn {
  flex: 0 0 100%;
  font-size: 0.85rem;
  font-weight: 400;
  color: #64748b;
  line-height: 1.4;
  padding-left: 28px;
  box-sizing: border-box;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}
.collocations-grid .collocations-item .word-example {
  flex: 0 0 100%;
  font-size: 0.8rem;
  font-weight: 400;
  color: #94a3b8;
  font-style: italic;
  line-height: 1.3;
  padding-left: 28px;
  box-sizing: border-box;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}
.collocations-grid .collocations-item input[type="checkbox"] {
  flex-shrink: 0;
}

/* 选词底部�?- 全屏宽度，内部居中限�?1000px */
.selection-bar {
  /* fixed 贴底：相对 .word-select-page(fixed 父, 创建包含块) 定位，坐标稳定，
     消除此前 sticky(fixed 父内找不到滚动祖先)+width:100vw 负 margin 在 iOS 造成的 hit-test 错位 */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  padding: 0;
  box-shadow: 0 -6px 24px rgba(148,163,184,0.18);
  box-sizing: border-box;
  border-top: 1px solid rgba(255,255,255,0.6);
}

.selection-bar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}

.selection-count {
  font-size: 1rem;
  color: #64748b;
  font-weight: 500;
  /* 允许收缩：选中数>20时追加警告图标会撑宽文字，需避免挤到右侧按钮换行 */
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}

/* 底部栏按钮组：永不换行、不被挤压 */
.btn-group {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

.selection-count strong {
  color: #6366f1;
  font-size: 1.3rem;
  font-weight: 800;
}

.btn-start,
.btn-learn {
  background: rgba(0,0,0,0.04);
  color: #cbd5e1;
  border: 1px solid rgba(0,0,0,0.06);
  padding: 10px 30px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: none;
  letter-spacing: 1px;
}

.btn-start:hover,
.btn-learn:hover {
  transform: translateY(-2px);
}

.btn-start:disabled,
.btn-learn:disabled {
  background: rgba(0,0,0,0.03);
  color: rgba(0,0,0,0.2);
  border-color: rgba(0,0,0,0.04);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 选中单词后按钮生效，文字变亮 */
.btn-start:not(:disabled),
.btn-learn:not(:disabled) {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.btn-start:not(:disabled):hover,
.btn-learn:not(:disabled):hover {
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-2px);
}

.btn-start:not(:disabled):active,
.btn-learn:not(:disabled):active {
  transform: translateY(0) scale(0.97);
  box-shadow: var(--shadow-btn);
}

/* 控件内扁平 SVG 图标：尺寸与对齐 */
.btn-icon,
.hdr-icon,
.btn-search-learn svg,
.btn-search-practice svg {
  width: 1.05em;
  height: 1.05em;
  margin-right: 6px;
  vertical-align: -0.18em;
  flex-shrink: 0;
}
.btn-start, .btn-learn { display: inline-flex; align-items: center; justify-content: center; }
.btn-search-learn, .btn-search-practice { display: inline-flex; align-items: center; justify-content: center; }
.search-hint-icon svg { width: 34px; height: 34px; }

/* ===== 练习页面 ===== */
.practice-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh; /* 恒定视口高度，避免 iOS 地址栏显隐导致整页上跳 */
  position: relative;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  /* iOS 安全区：固定全屏页(dvh)手动顶出状态栏，避免练习页顶部栏与系统状态栏重叠 */
  padding-top: env(safe-area-inset-top, 0px); /* 已去掉 44px 兜底：用户要求与其他页(统计/账户)统一为最短贴顶；env() 在刘海设备仍优雅避让，env=0(部分 webview)时为 0 与各页一致 */
}
.practice-page > .page-container { flex: 1; min-height: 0; }

/* ����ҳ�涥�������� */
.practice-topbar {
  position: absolute;
  top: 12px; /* 与其他页顶栏统一：去掉安全区避让，贴顶 12px（与统计/账户页一致） */
  left: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

/* ��ϰ/ѧϰģʽ���������ð�ť����������˳���ǰ���̣������û�����?*/
.practice-topbar .btn-settings {
  display: none;
}

/* Բ�Ƿ��ΰ׵װ�ť �� ѡ��ҳ & ��ϰҳ���� */
.btn-back,
.btn-settings {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.06);
  color: #334155;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  pointer-events: auto;
  padding: 0;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}

.btn-back:hover,
.btn-settings:hover {
  background: #f8fafc;
  border-color: rgba(0,0,0,0.10);
  transform: scale(1.04);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.btn-back:active,
.btn-settings:active {
  transform: scale(0.96);
  background: #f1f5f9;
  transition: transform 0.1s, background 0.1s;
}

/* ��ɫģʽ */
.dark-mode .btn-back,
.dark-mode .btn-settings {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.08);
  color: #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.dark-mode .btn-back:hover,
.dark-mode .btn-settings:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

/* 进度�?*/
.progress-section {
  text-align: center;
  padding: 50px 20px 8px;
  color: #1e293b;
}

.progress-text {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 12px;
}

.progress-bar-wrapper {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  height: 8px;
  background: rgba(99,102,241,0.12);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #818cf8, #6366f1);
  border-radius: 10px;
  transition: width 0.5s ease;
}

/* 对话�?*/
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 24px 40px;
  gap: 24px;
}

/* 判定卡片态：改为顶对齐，卡片永远落在进度条下方、绝不向上溢出钻到头部栏下 */
.chat-window.feedback-mode {
  justify-content: flex-start;
  padding-top: 24px;
}


/* 消息气泡 */
.chat-bubble {
  max-width: 580px;
  width: 100%;
  padding: 24px;
  border-radius: 20px;
  font-size: 1.3rem;
  line-height: 1.6;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.chat-bubble.ai {
  background: linear-gradient(180deg, #ffffff 0%, #f7f8ff 100%);
  color: #333;
  border: 1px solid rgba(99,102,241,0.14);
  border-bottom-left-radius: 20px;
  text-align: center;
  font-weight: 500;
}

.chat-bubble.user {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  color: white;
  text-align: center;
  font-weight: 500;
}

.chat-bubble.feedback {
  background: #f0f4ff;
  color: #333;
  font-size: 1.1rem;
}
.chat-bubble.feedback svg { width: 1.1em; height: 1.1em; vertical-align: -0.16em; }

.chat-bubble.feedback.correct {
  background: #e8f5e9;
  border: 2px solid #4caf50;
}

.chat-bubble.feedback.wrong {
  background: #fce4ec;
  border: 2px solid #e53935;
}

.chat-bubble.feedback.acceptable {
  background: #fff8e1;
  border: 2px solid #f59e0b;
}

/* ===== 判定结果卡片（新版 · 仅 practice 单词判定使用） ===== */
.chat-bubble.feedback.judge-result {
  position: relative;
  max-width: 560px;
  width: 100%;
  background: #ffffff;
  border: 2px solid #6366f1;
  border-radius: 22px;
  box-shadow: 0 10px 40px rgba(99,102,241,0.12);
  padding: 0;
  overflow: hidden;
  text-align: left;
  font-size: 1rem;
  animation: judgeCardIn 0.35s ease;
  margin-top: 8px;
}
@keyframes judgeCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-bubble.feedback.judge-result.correct { border-color: #22c55e; box-shadow: 0 10px 40px rgba(34,197,94,0.16); }
.chat-bubble.feedback.judge-result.wrong   { border-color: #ef4444; box-shadow: 0 10px 40px rgba(239,68,68,0.16); }

.judge-card-badge {
  position: absolute;
  top: 16px; right: 16px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(34,197,94,0.12);
  color: #16a34a;
}
.judge-result.wrong .judge-card-badge { background: rgba(239,68,68,0.12); color: #dc2626; }
.judge-card-badge svg { width: 1.05em; height: 1.05em; vertical-align: -0.16em; margin-right: 5px; }

.judge-card-word {
  padding: 30px 24px 20px;
  border-bottom: 1px solid #f1f5f9;
}
.judge-card-cn {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6366f1;
  background: rgba(99,102,241,0.1);
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.judge-card-en {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #1e293b;
}
.judge-result.correct .judge-card-en { color: #16a34a; }
.judge-result.wrong   .judge-card-en { color: #dc2626; }
.judge-card-ph {
  margin-top: 6px;
  font-size: 1.1rem;
  font-style: italic;
  color: #94a3b8;
}

.judge-card-heard { padding: 18px 24px; }
.judge-card-heard-label {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 8px;
}
.judge-card-heard-text {
  background: #f1f5f9;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 1.05rem;
  line-height: 1.5;
  color: #334155;
  word-break: break-word;
}
.judge-card-heard-text.no-speech {
  background: #fef2f2;
  color: #dc2626;
  font-weight: 600;
}

.judge-card-mic {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
  pointer-events: none;
}
.judge-card-mic i {
  width: 62px; height: 62px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 1.5rem;
  color: #fff;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  box-shadow: 0 8px 20px rgba(34,197,94,0.35);
  animation: judgeMicPulse 1.4s ease-in-out infinite;
}
.judge-result.wrong .judge-card-mic i {
  background: linear-gradient(135deg, #f87171, #ef4444);
  box-shadow: 0 8px 20px rgba(239,68,68,0.35);
}
@keyframes judgeMicPulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}

.judge-card-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: #16a34a;
}
.judge-card-status .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 1.5s ease-in-out infinite;
}
.judge-result.wrong .judge-card-status { color: #dc2626; }
.judge-result.wrong .judge-card-status .dot { background: #ef4444; }

@media (max-width: 480px) {
  .judge-card-en { font-size: 2.1rem; }
  .judge-card-word { padding: 24px 18px 16px; }
  .judge-card-heard, .judge-card-status { padding-left: 18px; padding-right: 18px; }
  .chat-bubble.feedback.judge-result { margin-top: 16px; }
  /* 三按钮挤在一行时缩小留白，避免换行 */
  .selection-bar-inner { padding: 14px 14px; }
  .btn-start, .btn-learn { padding: 10px 18px; font-size: 0.92rem; }
}

/* 状态指示器 */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #64748b;
  font-size: 1.1rem;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.listening {
  background: #4caf50;
}

.status-dot.speaking {
  background: #ff9800;
}

.status-dot.processing {
  background: #2196f3;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* 底部MIC图标 */
.mic-icon {
  font-size: 3rem;
  color: #64748b;
  opacity: 0.6;
  transition: all 0.3s;
}
.mic-icon svg { width: 3rem; height: 3rem; }

.mic-icon.active {
  opacity: 1;
  animation: mic-pulse 1s ease-in-out infinite;
}

.mic-icon.listening {
  color: #4caf50;
  opacity: 1;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ===== 结果页面 ===== */
.result-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  color: #1e293b;
}
.result-page > .result-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.result-page .result-body {
  margin: auto;
  text-align: center;
  width: 88%;
  max-width: 480px;
  padding: 20px 0;
}

.result-score {
  font-size: 5rem;
  font-weight: 800;
  margin-bottom: 10px;
  text-align: center;
  background: linear-gradient(135deg, var(--brand-light) 0%, var(--brand-purple) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.result-text {
  font-size: 1.3rem;
  margin-bottom: 30px;
  color: #64748b;
  text-align: center;
}

.dark-mode .result-score {
  background: linear-gradient(135deg, var(--brand-light) 0%, var(--brand-purple-light) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.result-details {
  background: white;
  border-radius: 16px;
  color: #333;
  width: 100%;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.result-details h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: #666;
}

.result-word-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 1rem;
}

.result-word-item:last-child {
  border-bottom: none;
}

.result-word-item .word-name {
  font-weight: 600;
}

.result-word-item .word-status {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.word-status.correct {
  background: #e8f5e9;
  color: #2e7d32;
}

.word-status.wrong {
  background: #fce4ec;
  color: #c62828;
}

.word-status.acceptable {
  background: #fff8e1;
  color: #b45309;
}

/* Judgment SVG icons (replace legacy [OK]/[X]/[*] text placeholders) */
.judge-ico {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 5px;
}
.judge-text.judge-correct { color: #2e7d32; }
.judge-text.judge-wrong   { color: #c62828; }
.judge-text.judge-acceptable { color: #b45309; }

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.btn-again {
  background: white;
  color: #6366f1;
  border: none;
  padding: 14px 40px;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
  display: inline-flex;
  align-items: center;
}

.btn-again:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(99,102,241,0.18);
}

.btn-again:active {
  transform: translateY(0) scale(0.97);
  box-shadow: var(--shadow-btn);
}

.btn-retry-wrong {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border: none;
  padding: 14px 40px;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(220,38,38,0.25);
  display: inline-flex;
  align-items: center;
}

.btn-retry-wrong:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220,38,38,0.35);
}

.btn-retry-wrong:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 4px 14px rgba(220,38,38,0.30);
}

/* 结果页"下一组"：主行动按钮（连续学习） */
.btn-next-group {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  color: #fff;
  border: none;
  padding: 14px 40px;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(99,102,241,0.3);
  display: inline-flex;
  align-items: center;
}
.btn-next-group:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(99,102,241,0.4);
}
.btn-next-group:active {
  transform: translateY(0) scale(0.97);
  box-shadow: var(--shadow-btn);
}

/* ===== 词库选择（首页）===== */
.book-select-page {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  /* 页面级不滚动(overflow:hidden)，滚动下移到内部 .book-list，
     与其他页(选词/搜索)模型一致：页面级无原生滚动抢手势，自定义下拉更稳定 */
  overflow: hidden;
  overscroll-behavior: none;
  /* iOS 安全区：viewport-fit=cover 后需手动顶出状态栏 */
  padding-top: env(safe-area-inset-top, 0px); /* 已去掉 44px 兜底：用户要求与其他页(统计/账户)统一为最短贴顶；env() 在刘海设备仍优雅避让，env=0(部分 webview)时为 0 与各页一致 */
}
.book-select-page > .page-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 书目首页下拉刷新（pull-to-refresh）指示器：默认藏在状态栏上方(translateY(-60px))，下拉时露出 */
.ptr {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #64748b;
  font-size: 0.85rem;
  pointer-events: none;
  transform: translateY(-60px);
  background: rgba(248,250,252,0.96);
  transition: transform 0.25s ease;
  z-index: 1000;
}
.ptr.show { transform: translateY(0); }
.dark-mode .ptr { background: rgba(15,23,42,0.96); }

.ptr-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-top-color: #6366f1;
  border-radius: 50%;
}
.ptr.spinner-on .ptr-spinner { animation: ptr-spin 0.8s linear infinite; }
.header-refresh-btn.spinning i { animation: ptr-spin 0.8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }


.book-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 16px 24px;
  overflow-y: auto;
  overscroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}

.book-card {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 4px 16px rgba(148,163,184,0.10);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  gap: 14px;
}

.book-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.book-card:active {
  transform: scale(0.985);
  box-shadow: var(--shadow-card);
}

.book-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.book-card-icon svg {
  display: block;
}

.book-card-info {
  flex: 1;
  min-width: 0;
}

.book-card-info h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 8px;
}

.book-card-progress-bar {
  height: 6px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.book-card-progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.book-card-count {
  font-size: 0.8rem;
  color: #999;
  font-weight: 500;
}

.book-card-arrow {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-left: 8px;
}
.book-card-arrow svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #888;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== 隐藏 ===== */
.hidden {
  display: none !important;
}

/* ===== 页面入场淡入（切显隐时重播；纯 opacity 以免破坏 fixed 子元素）===== */
.book-select-page,
.word-select-page,
.practice-page,
.result-page,
.stats-page,
.account-page,
.search-page {
  animation: pageEnter 0.3s ease both;
}

@keyframes pageEnter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== 页面容器：桌面端居中限宽 ===== */
.page-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

/* ===== 响应�?===== */
@media (max-width: 800px) {
  .page-container {
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .app-header h1 { font-size: 1.25rem; }
  .app-header p { font-size: 0.85rem; }
  .select-page-title { font-size: 1rem; }
  .chat-bubble { font-size: 1.1rem; padding: 20px; }
  .word-checkbox-grid { grid-template-columns: repeat(2, 1fr); }
  .result-score { font-size: 4rem; }
}

/* ===== Skeleton Loading ===== */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

.skeleton-card {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  gap: 14px;
  width: 100%;
}

.skeleton-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  flex-shrink: 0;
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
}

.skeleton-line-sm {
  width: 60%;
  height: 10px;
  border-radius: 6px;
}

.skeleton-category {
  background: white;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.skeleton-category .skeleton-line {
  width: 120px;
}

.skeleton-category .skeleton-badge {
  width: 60px;
  height: 22px;
  border-radius: 20px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 12px 20px 16px;
}

.skeleton-grid .skeleton {
  height: 38px;
  border-radius: 10px;
}

.skeleton-bubble {
  max-width: 500px;
  width: 100%;
  height: 120px;
  border-radius: 20px;
}

.skeleton-processing {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255,255,255,0.8);
  font-size: 1.1rem;
  padding: 24px;
}

.skeleton-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* ===== 动画 ===== */
.fade-in {
  animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   新版UI 精细�?- 字体 / 暗色模式 / 交互微增�?
   ============================================================ */

/* ---- 4. 字体与排�?---- */
/* 英文释义使用衬线字体，更清晰易读 */
.chat-bubble.ai {
  font-family: Georgia, 'Times New Roman', Times, 'Noto Serif SC', serif;
  font-size: 1.5rem;
  line-height: 1.7;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* 用户回答气泡 */
.chat-bubble.user {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
}

/* 反馈气泡中的英文单词加粗突出 */
.chat-bubble.feedback .word-answer {
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-weight: 700;
  color: #1a1a2e;
}

.feedback.correct .word-answer {
  color: #2e7d32;
}

.feedback.wrong .word-answer {
  color: #c62828;
}

/* 释义气泡内增加英文单词高亮容器（�?JS 动态注入） */
.definition-word {
  display: block;
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 2rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.definition-text {
  display: block;
  font-size: 1.1rem;
  color: #555;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
}

.cn-text {
  display: block;
  font-size: 1.1rem;
  color: #7c3aed;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.6;
  margin-top: 4px;
  padding: 2px 6px;
  background: rgba(124,58,237,0.08);
  border-radius: 6px;
}

.word-phonetic {
  font-size: 0.9rem;
  color: #7c3aed;
  font-family: 'Lucida Sans Unicode', 'Arial Unicode MS', sans-serif;
  opacity: 0.85;
  letter-spacing: 0.02em;
}

/* ---- Reading mode ---- */
.word-reading-grid {
  width: 100%;
  margin-top: 8px;
}
.word-reading-item {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #e0e0e0;
  padding: 8px 8px;
}
.word-reading-item:last-child {
  border-bottom: none;
}
.word-reading-item:nth-child(even) {
  background: #f5f5f5;
}
.word-reading-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.word-reading-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  flex-shrink: 0;
}
.word-reading-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #6366f1;
  margin: 0;
}
.dark-mode .word-reading-check {
  border-bottom-color: #334155;
}
.dark-mode .word-reading-check input[type="checkbox"] {
  accent-color: #a855f7;
}
.word-reading-word {
  font-weight: 700;
  font-size: 1rem;
  color: #1a1a2e;
  padding: 0 4px;
  flex-shrink: 0;
}
.word-reading-phonetic {
  font-size: 0.85rem;
  color: #7c3aed;
  font-family: 'Lucida Sans Unicode', 'Arial Unicode MS', sans-serif;
  padding: 0 4px;
  opacity: 0.85;
  white-space: nowrap;
  flex-shrink: 0;
}
.word-reading-def {
  font-size: 0.9rem;
  color: #555;
  padding: 4px 0 0 38px;
  line-height: 1.45;
  word-break: break-word;
}
.dark-mode .word-reading-item {
  border-bottom-color: #334155;
}
.dark-mode .word-reading-item:nth-child(even) {
  background: #263548;
}
.dark-mode .word-reading-word {
  color: #e2e8f0;
}
.dark-mode .word-reading-phonetic {
  color: #c4b5fd;
}
.dark-mode .word-reading-def {
  color: #cbd5e1;
}

/* ---- 5. 暗色模式 ---- */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(165deg, #1e1b4b 0%, #311042 40%, #110723 100%);
  }

  /* App header title / subtitle */
  .app-header h1 { color: #ffffff; }
  .app-header p { color: rgba(255,255,255,0.7); }

  .category-card,
  .book-card,
  .skeleton-card,
  .skeleton-category {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  }

  .category-header h3,
  .book-card-info h3 {
    color: #ffffff;
  }

  .category-header .badge {
    background: #7c3aed;
  }

  .word-checkbox-item {
    background: rgba(255,255,255,0.06);
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,0.06);
  }

  .word-checkbox-item:hover {
    background: rgba(255,255,255,0.12);
  }

  .word-checkbox-item .word-label {
    color: #cbd5e1;
  }

  .word-checkbox-item input[type="checkbox"] {
    accent-color: #a855f7;
  }

  .selection-bar {
    background: rgba(20,15,40,0.75);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    box-shadow: 0 -6px 24px rgba(0,0,0,0.5);
    border-top: 1px solid rgba(255,255,255,0.08);
  }

  .selection-count {
    color: rgba(255,255,255,0.85);
  }

  .selection-count strong {
    color: #c084fc;
  }

  .btn-start,
  .btn-learn {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.35);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  }

  .btn-start:not(:disabled),
  .btn-learn:not(:disabled) {
    background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(168,85,247,0.35);
  }

  .btn-start:not(:disabled):hover,
  .btn-learn:not(:disabled):hover {
    box-shadow: 0 6px 20px rgba(168,85,247,0.4);
  }

  .chat-bubble.ai {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #e2e8f0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  }

  .chat-bubble.ai .definition-word {
    color: #f1f5f9;
  }

  .chat-bubble.ai .definition-text {
    color: #cbd5e1;
  }

  .word-phonetic {
    color: #a78bfa;
    opacity: 0.9;
  }

  .chat-bubble.user {
    background: linear-gradient(135deg, #a855f7, #6366f1);
  }

  .chat-bubble.feedback {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.06);
    color: #e2e8f0;
  }

  .chat-bubble.feedback.correct {
    background: #0d3320;
    border-color: #22c55e;
  }

  .chat-bubble.feedback.wrong {
    background: #3b0d1a;
    border-color: #ef4444;
  }

  .feedback.correct .word-answer {
    color: #4ade80;
  }

  .feedback.wrong .word-answer {
    color: #f87171;
  }

  .result-details {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #e2e8f0;
  }

  .result-details h3 {
    color: #cbd5e1;
  }

  .result-word-item {
    border-bottom-color: #334155;
  }

  .btn-again {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.08);
    color: #c084fc;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  }

  .btn-retry-wrong {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    box-shadow: 0 4px 15px rgba(185,28,28,0.3);
  }

  .book-card-icon {
    opacity: 0.9;
  }


  /* Purple tint for book card progress bar in dark */

  .book-card-count,
  .book-card-arrow svg {
    stroke: #94a3b8;
  }

  .book-card-progress-bar {
    background: #334155;
  }

  .word-select-page .voice-selector-bar select {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
  }

  .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 800px 100%;
  }

  .brand-box { opacity: 0.5; color: #cbd5e1; }
  .settings-group-label i { color: #a855f7; }
}

/* 手动暗色模式切换（通过 .dark-mode class�?*/
.dark-mode body,
body.dark-mode {
  background: linear-gradient(165deg, #1e1b4b 0%, #311042 40%, #110723 100%);
  color: #e2e8f0;
}

/* ---- 6. 交互效果增强 ---- */
/* 录音脉冲光环 */
.mic-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.mic-icon.listening::before {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.15);
  animation: mic-ring 1.5s ease-out infinite;
  z-index: -1;
}

.mic-icon.listening::after {
  content: '';
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.08);
  animation: mic-ring 1.5s ease-out 0.5s infinite;
  z-index: -1;
}

@keyframes mic-ring {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* 状态指示器增强 - 录音时文字加�?*/
.status-text.listening-active {
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* 进度条微�?- 更圆�?*/
.progress-bar-wrapper {
  height: 6px;
  border-radius: 8px;
}

.progress-bar-fill {
  background: linear-gradient(90deg, #818cf8, #6366f1);
  border-radius: 8px;
}


/* Dark mode progress bar - purple accent */
.dark-mode .progress-bar-fill {
  background: linear-gradient(90deg, #a855f7, #6366f1);
}

/* ===== Manual dark-mode: UI elements (mirrors @media dark) ===== */
.dark-mode .category-card,
.dark-mode .book-card,
.dark-mode .skeleton-card,
.dark-mode .skeleton-category {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.dark-mode .category-header h3,
.dark-mode .book-card-info h3 {
  color: #ffffff;
}

.dark-mode .category-header .badge {
  background: #7c3aed;
}

/* 暗色模式下「已选」高亮同样生效 */
.dark-mode .category-card.has-selection {
  border-color: rgba(124,58,237,0.7);
  box-shadow: 0 4px 18px rgba(124,58,237,0.35), 0 1px 3px rgba(0,0,0,0.2);
}
.dark-mode .category-header {
  border-bottom-color: rgba(255,255,255,0.08);
}
.dark-mode .category-card.has-selection .category-header {
  background: rgba(124,58,237,0.14);
  border-left-color: #a78bfa;
  border-bottom-color: rgba(124,58,237,0.20);
}
}

.dark-mode .word-checkbox-item {
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
  border: 1px solid rgba(255,255,255,0.06);
}

.dark-mode .word-checkbox-item:hover {
  background: rgba(255,255,255,0.12);
}

.dark-mode .word-checkbox-item .word-label {
  color: #e2e8f0;
}

.dark-mode .word-checkbox-item input[type="checkbox"] {
  accent-color: #a855f7;
}

.dark-mode .selection-bar {
  background: rgba(20,15,40,0.75);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  box-shadow: 0 -6px 24px rgba(0,0,0,0.5);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.dark-mode .selection-count {
  color: rgba(255,255,255,0.85);
}

.dark-mode .selection-count strong {
  color: #c084fc;
}

.dark-mode .btn-start,
.dark-mode .btn-learn {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.dark-mode .btn-start:not(:disabled),
.dark-mode .btn-learn:not(:disabled) {
  background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(168,85,247,0.35);
}

.dark-mode .btn-start:not(:disabled):hover,
.dark-mode .btn-learn:not(:disabled):hover {
  box-shadow: 0 6px 20px rgba(168,85,247,0.4);
}

.dark-mode .chat-bubble.ai {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #e2e8f0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.dark-mode .chat-bubble.ai .definition-word {
  color: #ffffff;
}

.dark-mode .chat-bubble.ai .definition-text {
  color: #cbd5e1;
}

.dark-mode .word-phonetic {
  color: #c4b5fd;
}

.dark-mode .cn-text {
  color: #c4b5fd;
  background: rgba(196,181,253,0.1);
}

.dark-mode .chat-bubble.user {
  background: linear-gradient(135deg, #a855f7, #6366f1);
}

.dark-mode .chat-bubble.feedback {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  color: #e2e8f0;
}

.dark-mode .chat-bubble.feedback.correct {
  background: rgba(34,197,94,0.12);
  border-color: rgba(34,197,94,0.4);
}

.dark-mode .chat-bubble.feedback.wrong {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.4);
}

.dark-mode .chat-bubble.feedback.acceptable {
  background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.4);
}

.dark-mode .chat-bubble.feedback.judge-result {
  background: #1e293b;
  border-color: #6366f1;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
}

.dark-mode .btn-next-group {
  box-shadow: 0 4px 15px rgba(99,102,241,0.45);
}
.dark-mode .chat-bubble.feedback.judge-result.correct { border-color: #22c55e; }
.dark-mode .chat-bubble.feedback.judge-result.wrong { border-color: #ef4444; }
.dark-mode .judge-card-word { border-bottom-color: rgba(255,255,255,0.08); }
.dark-mode .judge-card-cn { background: rgba(99,102,241,0.22); color: #a5b4fc; }
.dark-mode .judge-card-en { color: #f1f5f9; }
.dark-mode .judge-card-ph { color: #64748b; }
.dark-mode .judge-card-heard-label { color: #64748b; }
.dark-mode .judge-card-heard-text { background: rgba(255,255,255,0.06); color: #cbd5e1; }
.dark-mode .judge-card-heard-text.no-speech { background: rgba(239,68,68,0.15); color: #fca5a5; }
.dark-mode .judge-card-status { color: #4ade80; }
.dark-mode .judge-result.wrong .judge-card-status { color: #f87171; }

.dark-mode .result-details {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #e2e8f0;
}

.dark-mode .result-details h3 {
  color: #cbd5e1;
}

.dark-mode .result-word-item {
  border-bottom-color: #334155;
}

.dark-mode .btn-again {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  color: #d8b4fe;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.dark-mode .btn-retry-wrong {
  background: linear-gradient(135deg, #b91c1c, #991b1b);
  box-shadow: 0 4px 15px rgba(185,28,28,0.3);
}


.dark-mode .book-card-icon {
  opacity: 0.9;
}

.dark-mode .book-card-count,
.dark-mode .book-card-arrow svg {
  stroke: #94a3b8;
}

.dark-mode .book-card-progress-bar {
  background: #334155;
}

.dark-mode .voice-selector-bar select {
  background: rgba(30,20,50,0.7);
  color: #e2e8f0;
  border-color: rgba(255,255,255,0.1);
}

.dark-mode .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 800px 100%;
}

.dark-mode .progress-bar-fill {
  background: linear-gradient(90deg, #a855f7, #6366f1);
}


/* ===== Settings Panel (Glass Design) ===== */
#voiceSelector.settings-open {
  display: block !important;
}

.settings-scroll {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 4px 0 20px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding-left: 4px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-group-label i {
  font-size: 0.8rem;
  color: #a855f7;
}

.settings-surface {
  background: rgba(255,255,255,0.65);
  border: 1px solid rgba(255,255,255,0.7);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: 20px;
  padding: 4px 0;
  box-shadow: 0 8px 32px rgba(148,163,184,0.15);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  position: relative;
}

.settings-row:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 18px;
  right: 18px;
  height: 1px;
  background: rgba(0,0,0,0.06);
}

.settings-row-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.settings-row-title {
  font-size: 0.93rem;
  font-weight: 500;
  color: #1e293b;
}

.settings-row-sub {
  font-size: 0.75rem;
  color: #cbd5e1;
}

/* Custom select */
.settings-select-wrap {
  position: relative;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 7px 30px 7px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.settings-select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  outline: none;
  color: #1e293b;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-width: 110px;
}

.settings-select-wrap::after {
  content: "\f107";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  right: 12px;
  font-size: 0.75rem;
  color: #cbd5e1;
  pointer-events: none;
}

/* Pill toggle */
.settings-pills {
  display: flex;
  background: rgba(0,0,0,0.06);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.04);
}

.settings-pill {
  border: none;
  background: transparent;
  color: #cbd5e1;
  padding: 6px 14px;
  font-size: 0.82rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-pill.active {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.35);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* iOS toggle switch */
.settings-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 26px;
  background: rgba(0,0,0,0.1);
  border-radius: 50px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
  border: 1px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
}

.settings-switch::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 1px;
  left: 1px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.settings-switch:checked {
  background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
}

.settings-switch:checked::before {
  left: 21px;
}

/* Dark mode book progress */
.dark-mode .book-card-progress-fill {
  background: linear-gradient(135deg, #a855f7, #6366f1);
}

/* Dark mode result score - purple accent */
.dark-mode .result-score {
  color: #a855f7;
}
.result-score.is-check {
  background: none;
  -webkit-text-fill-color: #22c55e;
  color: #22c55e;
  display: flex; align-items: center; justify-content: center;
}
.result-score.is-check svg { width: 4.5rem; height: 4.5rem; }

/* Dark mode overrides for settings panel */

.dark-mode .brand-box { opacity: 0.5; color: #cbd5e1; }
.dark-mode .settings-group-label { color: rgba(255,255,255,0.7); }
.dark-mode .settings-group-label i { color: #a855f7; }

/* Dark mode settings surface - deep glass (not white glass) */
/* Dark mode settings surface �� deep dark solid (NO blur, blur kills contrast) */
.dark-mode .settings-surface {
  background: rgba(8, 4, 20, 0.7);
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.dark-mode .settings-row-title { color: #ffffff; }
.dark-mode .settings-row-sub { color: rgba(255,255,255,0.75); }
.dark-mode .settings-row:not(:last-child)::after { background: rgba(255,255,255,0.05); }
.dark-mode .settings-select-wrap { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.1); }
.dark-mode .settings-select-wrap select { color: #e2e8f0; }
.dark-mode .settings-select-wrap::after { color: rgba(255,255,255,0.5); }
.dark-mode .settings-pills { background: rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.08); }
.dark-mode .settings-pill { color: rgba(255,255,255,0.5); }
.dark-mode .settings-switch { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.05); }

/* ===== ������ʾ���� ===== */
.landscape-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(165deg, #f4f4f7 0%, #eef1f6 50%, #e5e9f0 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
}

.landscape-warning-inner {
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 24px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.08);
}

.landscape-icon {
  margin-bottom: 20px;
  color: #a855f7;
  display: flex; align-items: center; justify-content: center;
  animation: landscapeBounce 2s ease-in-out infinite;
}
.landscape-icon svg { width: 64px; height: 64px; }

@keyframes landscapeBounce {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-90deg); }
  50% { transform: rotate(0deg); }
  75% { transform: rotate(-90deg); }
}

.landscape-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 12px 0;
}

.landscape-desc {
  font-size: 1rem;
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 28px 0;
}

.landscape-rotate-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  border-radius: 50%;
  color: white;
  font-size: 1.5rem;
  animation: landscapeSpin 3s linear infinite;
  box-shadow: 0 4px 20px rgba(99,102,241,0.35);
}

@keyframes landscapeSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ������ʾ�� JS inline �ű����ƣ��������豸 + ����ʱ�Ƴ� .hidden */

/* ��ɫģʽ */
.dark-mode .landscape-warning {
  background: linear-gradient(165deg, #1e1b4b 0%, #311042 40%, #110723 100%);
}

.dark-mode .landscape-warning-inner {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
}

.dark-mode .landscape-title { color: #f1f5f9; }
.dark-mode .landscape-desc { color: #cbd5e1; }

/* ===== ����Ͽ���������?===== */
.disconnect-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.disconnect-inner {
  background: rgba(255,255,255,0.95);
  border-radius: 24px;
  padding: 36px 28px 28px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.8);
}

.disconnect-icon {
  margin-bottom: 16px;
  color: #dc2626;
  display: flex; align-items: center; justify-content: center;
  animation: disconnectPulse 1.8s ease-in-out infinite;
}
.disconnect-icon svg { width: 56px; height: 56px; }

@keyframes disconnectPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.1); }
}

.disconnect-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #dc2626;
  margin: 0 0 8px 0;
}

.disconnect-desc {
  font-size: 0.95rem;
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 24px 0;
}

.disconnect-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.disconnect-btn-reconnect {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}
.disconnect-btn-reconnect:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

.disconnect-btn-exit {
  width: 100%;
  padding: 12px 20px;
  background: transparent;
  color: #64748b;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.disconnect-btn-exit:active {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* ��ɫģʽ - �Ͽ����� */
.dark-mode .disconnect-overlay {
  background: rgba(0,0,0,0.7);
}

.dark-mode .disconnect-inner {
  background: rgba(30,27,75,0.97);
  border-color: rgba(255,255,255,0.1);
}

/* ===== 退出确认弹窗 ===== */
.exit-confirm-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exit-confirm-inner {
  background: rgba(255,255,255,0.96);
  border-radius: 24px;
  padding: 32px 28px 24px;
  width: 88%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.8);
}

.exit-confirm-icon {
  margin-bottom: 12px;
  color: #f59e0b;
  display: flex; align-items: center; justify-content: center;
}
.exit-confirm-icon svg { width: 48px; height: 48px; }

.exit-confirm-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 8px 0;
}

.exit-confirm-desc {
  font-size: 0.92rem;
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 22px 0;
}

.exit-confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exit-confirm-btn-cancel {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}
.exit-confirm-btn-cancel:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

.exit-confirm-btn-ok {
  width: 100%;
  padding: 12px 20px;
  background: transparent;
  color: #ef4444;
  border: 2px solid #fecaca;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.exit-confirm-btn-ok:active {
  background: #fef2f2;
  border-color: #fca5a5;
}

/* 深色模式 - 退出确认 */
.dark-mode .exit-confirm-overlay {
  background: rgba(0,0,0,0.7);
}
.dark-mode .exit-confirm-inner {
  background: rgba(30,27,75,0.97);
  border-color: rgba(255,255,255,0.1);
}
.dark-mode .exit-confirm-title {
  color: #f1f5f9;
}
.dark-mode .exit-confirm-desc {
  color: #94a3b8;
}
.dark-mode .exit-confirm-btn-ok {
  color: #f87171;
  border-color: rgba(248,113,113,0.4);
}
.dark-mode .exit-confirm-btn-ok:active {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.6);
}

.dark-mode .disconnect-desc {
  color: #cbd5e1;
}

.dark-mode .disconnect-btn-exit {
  color: #94a3b8;
  border-color: #334155;
}

.dark-mode .disconnect-btn-exit:active {
  background: #1e293b;
  border-color: #475569;
}

/* ===== Auth Modal ===== */
#authModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
#authModal.show {
  display: flex;
  opacity: 1;
}

.auth-modal-inner {
  position: relative;
  background: white;
  border-radius: 24px;
  padding: 32px 28px 24px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.25);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
#authModal.show .auth-modal-inner {
  transform: translateY(0) scale(1);
}

#authCloseX {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  line-height: 1;
}
#authCloseX:hover {
  background: #f1f5f9;
}

#authTitle {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
  text-align: center;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 20px;
  text-align: center;
}

.auth-field-group {
  margin-bottom: 10px;
}

#authName {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
  background: #f8fafc;
}
#authName:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
  background: white;
}

#authEmail,
#authPassword {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  background: #f8fafc;
}

#authEmail:focus,
#authPassword:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
  background: white;
}

/* Password wrapper with toggle */
.auth-password-wrapper {
  position: relative;
}
.auth-password-wrapper input {
  padding-right: 44px;
}
.auth-password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.auth-password-toggle:hover {
  color: #6366f1;
  background: #f1f5f9;
}

/* Password strength indicator */
.auth-strength {
  height: 4px;
  border-radius: 2px;
  margin: -4px 0 10px 0;
  background: transparent;
  overflow: hidden;
  transition: all 0.3s;
}
.auth-strength.has-value {
  background: #e2e8f0;
}
.auth-strength-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease, background 0.3s ease;
  width: 0%;
}

#authError {
  color: #e53935;
  font-size: 0.85rem;
  margin-bottom: 12px;
  display: none;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: 10px;
  border: 1px solid #fecaca;
}
#authError.show {
  display: block;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}

.auth-tab.active {
  background: white;
  color: #6366f1;
  box-shadow: 0 2px 8px rgba(99,102,241,0.15);
}

#authSubmitBtn {
  position: relative;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: opacity 0.25s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
}
#authSubmitBtn:active {
  opacity: 0.85;
  transform: scale(0.98);
}
#authSubmitBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Spinner */
@keyframes auth-spin {
  to { transform: rotate(360deg); }
}
.auth-btn-spinner svg {
  animation: auth-spin 0.8s linear infinite;
}

.auth-footer {
  text-align: center;
}
#authCloseLink {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.88rem;
  padding: 6px 4px;
  display: inline-block;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s;
}
#authCloseLink:hover {
  color: #64748b;
}

/* Dark mode - Auth Modal */
.dark-mode #authModal {
  background: rgba(0,0,0,0.6);
}
.dark-mode .auth-modal-inner {
  background: #1e1b4b;
  border: 1px solid rgba(255,255,255,0.08);
}
.dark-mode #authCloseX {
  color: #94a3b8;
}
.dark-mode #authCloseX:hover {
  background: rgba(255,255,255,0.08);
}
.dark-mode #authTitle {
  color: #e2e8f0;
}
.dark-mode .auth-subtitle {
  color: #64748b;
}
.dark-mode #authName,
.dark-mode #authEmail,
.dark-mode #authPassword {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
  color: #e2e8f0;
}
.dark-mode #authName:focus,
.dark-mode #authEmail:focus,
.dark-mode #authPassword:focus {
  background: rgba(255,255,255,0.1);
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168,85,247,0.15);
}
.dark-mode #authName::placeholder,
.dark-mode #authEmail::placeholder,
.dark-mode #authPassword::placeholder {
  color: #475569;
}
.dark-mode .auth-password-toggle:hover {
  color: #a855f7;
  background: rgba(255,255,255,0.08);
}
.dark-mode .auth-strength.has-value {
  background: rgba(255,255,255,0.08);
}
.dark-mode #authCloseLink {
  color: #64748b;
}
.dark-mode #authCloseLink:hover {
  color: #94a3b8;
}
.dark-mode .auth-tabs {
  background: rgba(255,255,255,0.06);
}
.dark-mode .auth-tab {
  color: #64748b;
}
.dark-mode .auth-tab.active {
  background: rgba(255,255,255,0.1);
  color: #a855f7;
  box-shadow: 0 2px 8px rgba(168,85,247,0.2);
}
.dark-mode #authError {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.25);
  color: #fca5a5;
}

/* ===== User Menu �� inline header buttons ===== */
.book-header-row {
  display: flex;
  align-items: center;
}
.book-header-row h1 {
  flex: 1;
  text-align: center;
  margin: 0;
}
.book-header-row .header-user-btn {
  flex-shrink: 0;
}
.book-header-row h1 {
  margin-bottom: 0;
}

.header-user-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.header-user-btn:active {
  transform: scale(0.95);
}
/* Logged-in state: show initial letter */
.header-user-btn.logged-in {
  font-size: 0.9rem;
  font-weight: 700;
}

/* Dropdown �� positioned by JS, shown on click */
/* ===== User Dropdown ===== */
.user-dropdown {
  display: none;
  position: fixed;
  background: #ffffff;
  border-radius: 14px;
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,0.06),
    0 16px 40px -4px rgba(0,0,0,0.12),
    0 0 0 1px rgba(0,0,0,0.04);
  padding: 0;
  min-width: 240px;
  max-width: 300px;
  z-index: 10001;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transition:
    opacity 0.18s ease,
    transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
    visibility 0.18s;
}
.user-dropdown.show {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ---- Header area ---- */
.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #f1f5f9;
}
.user-dropdown-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #a78bfa 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.user-dropdown-info {
  flex: 1;
  min-width: 0;
}
.user-dropdown-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.user-dropdown-email {
  font-size: 0.75rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 2px;
}

/* ---- Badge row ---- */
.user-dropdown-badge {
  padding: 6px 16px 10px;
  font-size: 0.74rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e1;
  display: inline-block;
  flex-shrink: 0;
}
.premium .badge-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245,158,11,0.35);
}
.premium {
  color: #d97706;
  font-weight: 600;
}

/* ---- Menu items (account / stats) ---- */
.user-dropdown-item {
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border-radius: 0;
  transition: background 0.15s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  position: relative;
}
.user-dropdown-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.user-dropdown-item:hover {
  background: #f8fafc;
}
.user-dropdown-item:hover svg {
  opacity: 1;
}
.user-dropdown-item:active {
  background: #f1f5f9;
}
.user-dropdown-item + .user-dropdown-item {
  border-top: 1px solid #f8fafc;
}

/* Separator before logout */
.user-dropdown-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 4px 0;
}

/* ---- Logout button ---- */
.user-dropdown-logout {
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  border-top: 1px solid #f1f5f9;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border-radius: 0;
  transition: background 0.15s ease;
  font-family: inherit;
  color: #ef4444;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-dropdown-logout::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ef4444' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4'%3E%3C/path%3E%3Cpolyline points='16 17 21 12 16 7'%3E%3C/polyline%3E%3Cline x1='21' y1='12' x2='9' y2='12'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.7;
}
.user-dropdown-logout:hover {
  background: #fef2f2;
}
.user-dropdown-logout:active {
  background: #fee2e2;
}

/* Legacy alias for stats button (kept for backward compat) */
.user-dropdown-stats {
  /* same as user-dropdown-item */
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border-radius: 0;
  transition: background 0.15s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
}
.user-dropdown-stats:hover { background: #f8fafc; }
.user-dropdown-stats:active { background: #f1f5f9; }

/* ===== Dark mode - User Dropdown ===== */
.dark-mode .header-user-btn {
  box-shadow: 0 2px 8px rgba(99,102,241,0.45);
}
.dark-mode .user-dropdown {
  background: rgba(30,27,75,0.96);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,0.2),
    0 20px 44px -4px rgba(0,0,0,0.35);
}
.dark-mode .user-dropdown-header {
  border-bottom-color: rgba(255,255,255,0.07);
}
.dark-mode .user-dropdown-name {
  color: #f1f5f9;
}
.dark-mode .user-dropdown-email {
  color: #94a3b8;
}
.dark-mode .user-dropdown-item {
  color: #cbd5e1;
}
.dark-mode .user-dropdown-item:hover {
  background: rgba(255,255,255,0.04);
}
.dark-mode .user-dropdown-item:active {
  background: rgba(255,255,255,0.08);
}
.dark-mode .user-dropdown-item + .user-dropdown-item {
  border-top-color: rgba(255,255,255,0.05);
}
.dark-mode .user-dropdown-divider {
  background: rgba(255,255,255,0.06);
}
.dark-mode .user-dropdown-logout {
  border-top-color: rgba(255,255,255,0.07);
  color: #f87171;
}
.dark-mode .user-dropdown-logout:hover {
  background: rgba(239,68,68,0.08);
}
.dark-mode .user-dropdown-logout:active {
  background: rgba(239,68,68,0.12);
}
.dark-mode .user-dropdown-stats {
  color: #cbd5e1;
}
.dark-mode .user-dropdown-stats:hover {
  background: rgba(255,255,255,0.04);
}
.dark-mode .user-dropdown-stats:active {
  background: rgba(255,255,255,0.08);
}

/* ===== Dark mode - Subscribe popover ===== */
.dark-mode .subscribe-popover-inner {
  background: rgba(30, 27, 75, 0.98);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,0.2),
    0 20px 44px -4px rgba(0,0,0,0.35);
}
.dark-mode .subscribe-popover-title {
  color: #f1f5f9;
}
.dark-mode .subscribe-popover-desc {
  color: #94a3b8;
}
.dark-mode .subscribe-qr {
  background: #fff;
  border-color: rgba(255,255,255,0.08);
}
.dark-mode .subscribe-row {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.06);
}
.dark-mode .subscribe-label {
  color: #94a3b8;
}
.dark-mode .subscribe-value {
  color: #f1f5f9;
}
.dark-mode .subscribe-footer {
  color: #64748b;
}
.dark-mode .copy-toast {
  background: rgba(248, 250, 252, 0.92);
  color: #0f172a;
}

/* ---- Stats Page ---- */
.stats-page {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: #F8F9FA;
  display: flex; flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.stats-page.hidden { display: none; }
.stats-page .stats-container { flex: 1; }

.stats-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 5;
}
.stats-topbar .btn-back {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: white;
  color: #475569;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stats-topbar .btn-back:active { background: #f1f5f9; }
.stats-page-title {
  font-size: 1.1rem; font-weight: 700; color: #1e293b; flex: 1; text-align: center;
}
.stats-topbar-spacer { width: 34px; flex-shrink: 0; }

.stats-container {
  flex: 1; padding: 16px; max-width: 700px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 16px;
}

/* Overview Cards */
.stats-overview {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
@media (min-width: 500px) {
  .stats-overview { grid-template-columns: repeat(4, 1fr); }
}
.stats-ov-card {
  background: white; border-radius: 16px; padding: 16px 12px;
  text-align: center;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stats-ov-icon { margin-bottom: 4px; display: flex; align-items: center; justify-content: center; }
.stats-ov-icon svg { width: 1.5rem; height: 1.5rem; }
.stats-ov-card:nth-child(1) .stats-ov-icon { color: #6366f1; }
.stats-ov-card:nth-child(2) .stats-ov-icon { color: #10b981; }
.stats-ov-card:nth-child(3) .stats-ov-icon { color: #f97316; }
.stats-ov-card:nth-child(4) .stats-ov-icon { color: #6366f1; }
.stats-ov-value { font-size: 1.5rem; font-weight: 800; color: #1e293b; line-height: 1.2; }
.stats-ov-label { font-size: 0.72rem; color: #64748b; margin-top: 2px; }
.stats-ov-card:nth-child(1) .stats-ov-value { color: #6366f1; }
.stats-ov-card:nth-child(2) .stats-ov-value { color: #10b981; }
.stats-ov-card:nth-child(3) .stats-ov-value { color: #f59e0b; }
.stats-ov-card:nth-child(4) .stats-ov-value { color: #6366f1; }

/* Stats Card */
.stats-card {
  background: white; border-radius: 16px; padding: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stats-card-title { font-size: 0.95rem; font-weight: 700; color: #1e293b; margin: 0 0 12px; }
.stats-chart-wrap { position: relative; width: 100%; }
.stats-chart-wrap canvas { width: 100% !important; max-height: 250px; }
.stats-chart-donut { max-width: 260px; margin: 0 auto; }
.stats-chart-donut canvas { max-height: 200px !important; }

/* Grid layout for side-by-side */
.stats-grid-2 {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
@media (min-width: 600px) {
  .stats-grid-2 { grid-template-columns: 1fr 1fr; }
}

/* Book Progress */
.stats-book-item {
  padding: 12px 0; border-bottom: 1px solid #f1f5f9;
}
.stats-book-item:last-child { border-bottom: none; }
.stats-book-header {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px;
}
.stats-book-name { font-size: 0.85rem; font-weight: 600; color: #334155; }
.stats-book-nums { font-size: 0.78rem; color: #64748b; }
.stats-book-bar {
  height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden;
}
.stats-book-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Recent Sessions �� card rows */
.stats-session-list { display: flex; flex-direction: column; gap: 8px; }
.stats-session-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stats-session-row:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }

/* Left: date + mode badge */
.stats-session-left { display: flex; align-items: center; gap: 8px; min-width: 100px; }
.stats-session-date { font-size: 0.8rem; color: #475569; font-weight: 500; white-space: nowrap; }
.stats-session-mode {
  font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
.stats-session-mode.mode-learn  { background: #ede9fe; color: #7c3aed; }
.stats-session-mode.mode-practice { background: #e0f2fe; color: #0369a1; }

/* Mid: book name + word count */
.stats-session-mid { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stats-session-book { font-size: 0.85rem; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-session-words { font-size: 0.7rem; color: #94a3b8; }

/* Right: accuracy badge + duration */
.stats-session-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.stats-session-score {
  font-size: 0.82rem; font-weight: 700; padding: 3px 10px; border-radius: 8px;
  white-space: nowrap; min-width: 44px; text-align: center;
}
.stats-session-score.high { background: #d1fae5; color: #065f46; }
.stats-session-score.mid  { background: #fef3c7; color: #92400e; }
.stats-session-score.low  { background: #fee2e2; color: #991b1b; }
.stats-session-dur { font-size: 0.72rem; color: #94a3b8; white-space: nowrap; }

/* Empty state */
.stats-empty {
  text-align: center; padding: 40px 20px; color: #94a3b8;
}
.stats-empty-icon { margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(168,85,247,0.12)); color: #6366f1; }
.stats-empty-icon svg { width: 34px; height: 34px; }
.stats-empty-text { font-size: 0.95rem; }

/* ===== Dark Mode �� Stats Page ===== */
.dark-mode .stats-page { background: linear-gradient(165deg, #1e1b4b, #311042, #110723); }
.dark-mode .stats-topbar {
  background: rgba(30,27,75,0.95); border-bottom-color: rgba(255,255,255,0.08);
  backdrop-filter: blur(20px);
}
.dark-mode .stats-topbar .btn-back {
  background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); color: #e2e8f0;
}
.dark-mode .stats-page-title { color: #e2e8f0; }
.dark-mode .stats-ov-card {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.06);
}
.dark-mode .stats-ov-value { color: #e2e8f0; }
.dark-mode .stats-ov-label { color: #94a3b8; }
.dark-mode .stats-card {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.06);
}
.dark-mode .stats-card-title { color: #e2e8f0; }
.dark-mode .stats-book-item { border-bottom-color: rgba(255,255,255,0.06); }
.dark-mode .stats-book-name { color: #cbd5e1; }
.dark-mode .stats-book-nums { color: #64748b; }
.dark-mode .stats-book-bar { background: rgba(255,255,255,0.08); }
/* Dark mode �� session rows */
.dark-mode .stats-session-row { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.06); }
.dark-mode .stats-session-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.3); background: rgba(255,255,255,0.06); }
.dark-mode .stats-session-date { color: #94a3b8; }
.dark-mode .stats-session-book { color: #e2e8f0; }
.dark-mode .stats-session-mode.mode-learn  { background: rgba(124,58,237,0.15); color: #a78bfa; }
.dark-mode .stats-session-mode.mode-practice { background: rgba(3,105,161,0.15); color: #7dd3fc; }
.dark-mode .stats-session-score.high { background: rgba(16,185,129,0.15); color: #34d399; }
.dark-mode .stats-session-score.mid  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.dark-mode .stats-session-score.low  { background: rgba(239,68,68,0.15); color: #f87171; }
.dark-mode .stats-empty { color: #64748b; }

.dark-mode .user-dropdown-logout {
  color: #f87171;
}
.dark-mode .user-dropdown-logout:active {
  background: rgba(248,113,113,0.1);
}

/* ===== Account Center Page ===== */
.account-page {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: #f8fafc;
  display: flex; flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.account-page.hidden { display: none; }
.account-page .account-container { flex: 1; }

/* Top bar */
.account-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: #ffffff;
  border-bottom: 1px solid #eef2f6;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 5;
}
.account-topbar .btn-back {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.account-topbar .btn-back:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.account-topbar .btn-back:active {
  background: #f1f5f9;
  transform: scale(0.96);
}
.account-page-title {
  font-size: 1.02rem; font-weight: 700; color: #0f172a; flex: 1; text-align: center;
  letter-spacing: -0.01em;
}
.account-topbar-spacer { width: 34px; flex-shrink: 0; }

/* Scrollable content area */
.account-container {
  flex: 1;
  padding: 14px 16px 24px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Hero Card ===== */
.account-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 40%, #8b5cf6 80%, #a78bfa 100%);
  box-shadow:
    0 4px 14px rgba(79,70,229,0.3),
    0 1px 3px rgba(0,0,0,0.06);
  color: #fff;
  position: relative;
  overflow: hidden;
}
/* Subtle decorative circle in hero bg */
.account-hero::after {
  content: '';
  position: absolute;
  top: -28px;
  right: -18px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  pointer-events: none;
}

.account-hero-avatar {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 14px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.account-hero-info { min-width: 0; flex: 1; position: relative; z-index: 1; }
.account-hero-name {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.account-hero-email {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.78);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.account-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 9px;
  padding: 3px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,0.17);
  font-size: 0.7rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  letter-spacing: 0.01em;
}
.account-hero-badge .badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(226,232,240,0.7);
}
.account-hero-badge.premium {
  background: rgba(255,255,255,0.92);
  color: #4338ca;
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 4px 12px;
  font-weight: 700;
}
.account-hero-badge.premium .badge-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.22);
}

/* ===== Section Cards ===== */
.account-section {
  background: #ffffff;
  border-radius: 14px;
  padding: 15px 16px;
  border: 1px solid #eef2f6;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.03),
    0 4px 12px rgba(0,0,0,0.02);
  transition: box-shadow 0.2s ease;
}
.account-section:hover {
  box-shadow:
    0 1px 2px rgba(0,0,0,0.04),
    0 6px 16px rgba(0,0,0,0.04);
}
.account-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  letter-spacing: -0.005em;
}
.account-section-title svg {
  color: #6366f1;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* 入场动画：账户页每次从 hidden 切回显示时重放（display 切换会重置动画） */
@keyframes accountFadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.account-hero,
.account-section {
  animation: accountFadeUp 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.account-container > *:nth-child(1) { animation-delay: 0.02s; }
.account-container > *:nth-child(2) { animation-delay: 0.06s; }
.account-container > *:nth-child(3) { animation-delay: 0.10s; }
.account-container > *:nth-child(4) { animation-delay: 0.14s; }
.account-container > *:nth-child(5) { animation-delay: 0.18s; }

/* 自定义滚动条 + 平滑滚动 */
.account-page { scroll-behavior: smooth; }
.account-page::-webkit-scrollbar { width: 8px; }
.account-page::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,0.22);
  border-radius: 999px;
}
.account-page::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.4); }

/* 微交互：头像轻微放大、会员卡 hover 上浮 */
.account-hero-avatar { transition: transform 0.2s ease; }
.account-hero:hover .account-hero-avatar { transform: scale(1.04); }
.member-card { transition: box-shadow 0.2s ease, transform 0.2s ease; }
.member-card:hover { box-shadow: 0 6px 18px rgba(99,102,241,0.10); transform: translateY(-2px); }

/* 退出按钮键盘焦点态 */
.account-btn-logout:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(229,57,53,0.18);
}

/* 小屏适配 */
@media (max-width: 380px) {
  .account-container { padding: 12px 12px 20px; }
  .account-hero { padding: 16px 14px; gap: 12px; }
  .account-hero-avatar { width: 46px; height: 46px; font-size: 1.2rem; }
  .member-benefits { grid-template-columns: 1fr; gap: 8px; }
  .account-stat-grid { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .account-hero, .account-section { animation: none; }
  .account-page { scroll-behavior: auto; }
}

/* Stat grid for learning stats (Phase 2) */
.account-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 500px) {
  .account-stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.account-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  color: #94a3b8;
  font-size: 0.82rem;
  padding: 16px 0;
  letter-spacing: 0.01em;
}

/* Stat cards */
.account-stat-card {
  background: #f8fafc;
  border: 1px solid #eef2f7;
  border-radius: 14px;
  padding: 14px 10px 12px;
  text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.account-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99,102,241,0.12);
  border-color: #e0e7ff;
}
.account-stat-icon {
  width: 38px;
  height: 38px;
  margin: 0 auto 8px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.stat-flame { background: linear-gradient(135deg, #fb923c, #f97316); }
.stat-book  { background: linear-gradient(135deg, #818cf8, #6366f1); }
.stat-star  { background: linear-gradient(135deg, #c084fc, #a855f7); }
.stat-clock { background: linear-gradient(135deg, #2dd4bf, #14b8a6); }
.account-stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.account-stat-label {
  margin-top: 3px;
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}

/* ===== Dark Mode - Account Page ===== */
.dark-mode .account-page {
  background: linear-gradient(165deg, #0c0a1d 0%, #161235 50%, #0c0a1d 100%);
}
.dark-mode .account-topbar {
  background: rgba(22,19,55,0.92);
  border-bottom-color: rgba(255,255,255,0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.dark-mode .account-topbar .btn-back {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.08);
  color: #cbd5e1;
}
.dark-mode .account-topbar .btn-back:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.12);
}
.dark-mode .account-page-title { color: #f1f5f9; }

.dark-mode .account-section {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
  box-shadow: none;
}
.dark-mode .account-section:hover {
  background: rgba(255,255,255,0.045);
  border-color: rgba(255,255,255,0.08);
}
.dark-mode .account-section-title { color: #e2e8f0; }
.dark-mode .account-placeholder { color: #64748b; }

.dark-mode .account-stat-card {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.07);
}
.dark-mode .account-stat-card:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(139,92,246,0.35);
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}
.dark-mode .account-stat-value { color: #f1f5f9; }
.dark-mode .account-stat-label { color: #8b95b5; }

/* ===== Account Forms (Phase 3) ===== */
.account-form-block { display: block; }
.account-form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}
.account-form-inline {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.account-form-inline .account-input { flex: 1; min-width: 0; }
.account-field-group { margin-bottom: 10px; }
.account-input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  font-size: 0.92rem;
  color: #1e293b;
  background: #fff;
  transition: border-color 0.18s, box-shadow 0.18s;
  font-family: inherit;
}
.account-input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129,140,248,0.15);
}
.account-input::placeholder { color: #94a3b8; }
.account-btn-primary {
  padding: 11px 22px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.account-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99,102,241,0.3);
}
.account-btn-primary:active:not(:disabled) { transform: translateY(0); }
.account-btn-primary:disabled { opacity: 0.6; cursor: default; }
.account-btn-block { width: 100%; margin-top: 2px; }
.account-divider {
  height: 1px;
  background: #eef2f7;
  margin: 18px 0;
}
.account-strength {
  height: 5px;
  border-radius: 3px;
  background: #eef2f7;
  overflow: hidden;
  margin: 4px 0 10px;
}
.account-strength-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.25s, background 0.25s;
}
.account-form-msg {
  font-size: 0.8rem;
  margin-top: 8px;
  min-height: 1em;
  display: none;
}
.account-form-msg.ok { display: block; color: #16a34a; }
.account-form-msg.err { display: block; color: #e53935; }
.account-form-msg.error { display: block; color: #e53935; }
.account-form-msg.success { display: block; color: #16a34a; }

/* 会员状态卡片 */
.member-card {
  border-radius: 16px;
  padding: 18px 18px 16px;
  border: 1px solid #eef2f7;
  background: #f8fafc;
}
.member-card.premium {
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(168,85,247,0.10));
  border-color: rgba(139,92,246,0.28);
}
.member-card-head {
  display: flex; align-items: center; justify-content: space-between;
}
.member-plan {
  font-size: 1.05rem; font-weight: 800; color: #1e293b;
}
.member-card.premium .member-plan { color: #6d28d9; }
.member-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.76rem; font-weight: 600; color: #64748b;
  background: #eef2f7; padding: 3px 10px; border-radius: 999px;
}
.member-badge .badge-dot { background: #94a3b8; }
.member-card.premium .member-badge { color: #b45309; background: rgba(245,158,11,0.16); }
.member-card.premium .member-badge .badge-dot { background: #f59e0b; }
.member-expire {
  margin-top: 8px; font-size: 0.82rem; color: #475569;
}
.member-benefits {
  list-style: none; padding: 0; margin: 14px 0 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
}
.member-benefits li {
  position: relative; padding-left: 22px;
  font-size: 0.85rem; color: #475569; line-height: 1.4;
}
.member-benefits li::before {
  content: ""; position: absolute; left: 0; top: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/></svg>") center/11px no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/></svg>") center/11px no-repeat;
}
.member-tip {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid #eef2f7;
  font-size: 0.8rem; color: #94a3b8; text-align: center;
}

/* 意见反馈文本框 */
.account-textarea {
  width: 100%; min-height: 96px; resize: vertical;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid #e2e8f0; background: #fff;
  font-family: inherit; font-size: 0.9rem; color: #1e293b;
  line-height: 1.5; box-sizing: border-box;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.account-textarea:focus {
  outline: none; border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129,140,248,0.18);
}

/* 退出登录按钮 */
.account-btn-logout {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 12px 16px;
  border: 1px solid rgba(229,57,53,0.30);
  border-radius: 12px;
  background: #fff; color: #e53935;
  font-family: inherit; font-size: 0.92rem; font-weight: 600;
  cursor: pointer; box-sizing: border-box;
  transition: background 0.15s, transform 0.12s;
}
.account-btn-logout:hover { background: #fef2f2; }
.account-btn-logout:active { transform: scale(0.98); }

/* Dark Mode - Account Forms */
.dark-mode .account-form-label { color: #cbd5e1; }
.dark-mode .account-input {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
  color: #e2e8f0;
}
.dark-mode .account-input::placeholder { color: #64748b; }
.dark-mode .account-input:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167,139,250,0.18);
}
.dark-mode .account-divider { background: rgba(255,255,255,0.08); }
.dark-mode .account-strength { background: rgba(255,255,255,0.08); }
.dark-mode .member-card { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); }
.dark-mode .member-card.premium { background: rgba(139,92,246,0.12); border-color: rgba(167,139,250,0.30); }
.dark-mode .member-plan { color: #e2e8f0; }
.dark-mode .member-card.premium .member-plan { color: #c4b5fd; }
.dark-mode .member-badge { color: #8b95b5; background: rgba(255,255,255,0.06); }
.dark-mode .member-expire { color: #a5b4fc; }
.dark-mode .member-benefits li { color: #cbd5e1; }
.dark-mode .member-tip { color: #64748b; border-top-color: rgba(255,255,255,0.08); }
.dark-mode .account-textarea {
  background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: #e2e8f0;
}
.dark-mode .account-textarea::placeholder { color: #64748b; }
.dark-mode .account-textarea:focus {
  border-color: #a78bfa; box-shadow: 0 0 0 3px rgba(167,139,250,0.18);
}
.dark-mode .account-btn-logout {
  background: rgba(255,255,255,0.04); border-color: rgba(248,113,113,0.35); color: #f87171;
}
.dark-mode .account-btn-logout:hover { background: rgba(248,113,113,0.12); }
.dark-mode .account-page::-webkit-scrollbar-thumb { background: rgba(167,139,250,0.3); }
.dark-mode .account-page::-webkit-scrollbar-thumb:hover { background: rgba(167,139,250,0.5); }
.dark-mode .member-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.35); background: rgba(255,255,255,0.06); }
.dark-mode .account-btn-logout:focus-visible { box-shadow: 0 0 0 3px rgba(248,113,113,0.28); }

/* ========== ICP ������ ========== */
.icp-footer {
  text-align: center;
  padding: 12px 0 16px;
  font-size: 12px;
  color: #999;
  background: transparent;
}
.icp-footer a {
  color: #999;
  text-decoration: none;
  transition: color 0.2s;
}
.icp-footer a:hover {
  color: #666;
  text-decoration: underline;
}

/* ��ɫģʽ */
.dark-mode .icp-footer {
  color: #64748b;
}
.dark-mode .icp-footer a {
  color: #64748b;
}
.dark-mode .icp-footer a:hover {
  color: #94a3b8;
}

/* ���ʿ��ڴ�׺ */
.search-word-affixes {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e2e8f0;
}
.search-word-affixes-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.search-word-affixes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.search-affix-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.82rem;
  background: #faf5ff;
  color: #7c3aed;
}
.search-affix-item .affix-cn {
  font-size: 0.75rem;
  color: #9333ea;
}
.dark-mode .search-word-affixes {
  border-top-color: #334155;
}
.dark-mode .search-word-affixes-title {
  color: #94a3b8;
}
.dark-mode .search-affix-item {
  background: rgba(126,34,206,0.15);
  color: #c4b5fd;
}
.dark-mode .search-affix-item .affix-cn {
  color: #a78bfa;
}

/* ��ҳ������ť */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #64748b;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-icon-btn:hover {
  background: rgba(0,0,0,0.04);
  color: #334155;
}

.dark-mode .header-icon-btn {
  color: #94a3b8;
}

.dark-mode .header-icon-btn:hover {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
}

/* ===== Subscribe button & popover ===== */
.header-subscribe-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.32);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.header-subscribe-btn svg {
  width: 16px;
  height: 16px;
}
.header-subscribe-btn:hover {
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.42);
}
.header-subscribe-btn:active {
  transform: scale(0.96);
}

.subscribe-popover {
  position: fixed;
  z-index: 10002;
  display: none;
  visibility: hidden;
}
.subscribe-popover.show {
  display: block;
  visibility: visible;
}
.subscribe-popover-inner {
  width: 260px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border-radius: 18px;
  padding: 16px;
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,0.06),
    0 16px 40px -4px rgba(0,0,0,0.12),
    0 0 0 1px rgba(0,0,0,0.04);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.subscribe-popover.show .subscribe-popover-inner {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.subscribe-popover-header {
  text-align: center;
  margin-bottom: 12px;
}
.subscribe-popover-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}
.subscribe-popover-desc {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 3px;
}
.subscribe-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}
.subscribe-qr {
  width: 160px;
  height: 160px;
  border-radius: 12px;
  object-fit: contain;
  border: 1px solid rgba(0,0,0,0.06);
  background: #f8fafc;
  /* 放开长按菜单：让微信/浏览器长按能弹出“识别二维码 / 保存图片” */
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}
.subscribe-qr-hint {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6366f1;
  letter-spacing: 0.02em;
}
.subscribe-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  margin-bottom: 10px;
  border: 1px solid rgba(0,0,0,0.04);
}
.subscribe-row:last-of-type {
  margin-bottom: 0;
}
.subscribe-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  width: 36px;
  flex-shrink: 0;
}
.subscribe-value {
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subscribe-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 8px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.subscribe-copy-btn svg {
  width: 14px;
  height: 14px;
}
.subscribe-copy-btn:hover {
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}
.subscribe-copy-btn:active {
  transform: scale(0.95);
}
.subscribe-copy-btn.copied {
  background: linear-gradient(135deg, #10b981 0%, #22c55e 100%);
}
.subscribe-footer {
  margin-top: 12px;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.4;
}

.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px;
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 10003;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.2s;
}
.copy-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ===== �������ҳ ===== */
.search-page {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh; /* 恒定视口高度，避免 iOS 地址栏显隐导致整页上跳 */
  width: 100vw;
  box-sizing: border-box;
  max-width: 800px;
  margin: 0 auto;
  overflow: hidden;
  padding: 0;
  /* iOS 安全区：固定全屏页(dvh)手动顶出状态栏，避免搜索页顶部栏与系统状态栏重叠 */
  padding-top: env(safe-area-inset-top, 0px); /* 已去掉 44px 兜底：用户要求与其他页(统计/账户)统一为最短贴顶；env() 在刘海设备仍优雅避让，env=0(部分 webview)时为 0 与各页一致 */
}

.search-page > .page-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0 16px;
}

.search-topbar {
  display: flex;
  align-items: center;
  padding: 12px 4px;
  gap: 12px;
  flex-shrink: 0;
}

.search-page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
}

.search-input-wrapper {
  position: relative;
  flex-shrink: 0;
  margin-bottom: 12px;
}

.search-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 38px 12px 42px;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  font-size: 1rem;
  background: #fff;
  color: #1e293b;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.search-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
}

.search-clear-btn:hover {
  color: #64748b;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 12px;
  padding-right: 8px;
}

/* ����������Ƭ */
.search-word-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
  padding: 16px;
  margin-bottom: 12px;
}

.search-word-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.search-word-header .word {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1e293b;
}

.search-word-header .phonetic {
  font-size: 0.85rem;
  color: #64748b;
}

.search-word-header .badge-level {
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}

.search-word-cn {
  font-size: 0.9rem;
  color: #475569;
  margin-bottom: 12px;
}

.search-word-actions {
  display: flex;
  gap: 8px;
}

.search-word-actions button {
  padding: 6px 14px;
  border-radius: 10px;
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-search-learn {
  background: #eef2ff;
  color: #4f46e5;
}
.btn-search-learn:hover {
  background: #e0e7ff;
}

.btn-search-practice {
  background: #4f46e5;
  color: #fff;
}
.btn-search-practice:hover {
  background: #4338ca;
}

/* ������Ϣ���� */
.search-section {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.search-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-section-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.search-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.82rem;
  background: #f1f5f9;
  color: #334155;
  cursor: default;
  transition: background 0.15s;
}

.search-tag .tag-cn {
  font-size: 0.75rem;
  color: #64748b;
}

.search-tag.affix-tag {
  background: #faf5ff;
  color: #7c3aed;
}

.search-tag.pv-tag {
  background: #f5f3ff;
  color: #4f46e5;
}

.search-tag.col-tag {
  background: #f0fdf4;
  color: #15803d;
}

/* �޽�� */
.search-empty {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}
.search-empty-icon {
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  width: 68px; height: 68px; border-radius: 50%;
  background: linear-gradient(135deg, rgba(99,102,241,0.10), rgba(168,85,247,0.10));
  color: #6366f1;
}
.search-empty-icon svg { width: 32px; height: 32px; }
.search-empty-text {
  font-size: 0.9rem;
}

/* ��ʾ���� */
.search-hint {
  text-align: center;
  padding: 80px 20px;
  color: #94a3b8;
}
.search-hint-icon {
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, rgba(99,102,241,0.10), rgba(168,85,247,0.10));
  color: #6366f1;
}
.search-hint-text {
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ��ɫģʽ */
.dark-mode .search-page {
  background: #0f172a;
}
.dark-mode .search-page-title {
  color: #e2e8f0;
}
.dark-mode .search-input {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.dark-mode .search-input:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129,140,248,0.15);
}
.dark-mode .search-word-card,
.dark-mode .search-section {
  background: rgba(30,41,59,0.85);
  border-color: rgba(51,65,85,0.5);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.dark-mode .search-word-header .word {
  color: #e2e8f0;
}
.dark-mode .search-word-cn {
  color: #94a3b8;
}
.dark-mode .search-tag {
  background: #1e293b;
  color: #cbd5e1;
}
.dark-mode .search-tag.affix-tag {
  background: rgba(124,58,237,0.15);
  color: #a78bfa;
}
.dark-mode .search-tag.pv-tag {
  background: rgba(99,102,241,0.15);
  color: #818cf8;
}
.dark-mode .search-tag.col-tag {
  background: rgba(34,197,94,0.15);
  color: #4ade80;
}
.dark-mode .search-empty,
.dark-mode .search-hint {
  color: #64748b;
}
.dark-mode .btn-search-learn {
  background: rgba(99,102,241,0.15);
  color: #818cf8;
}
.dark-mode .btn-search-learn:hover {
  background: rgba(99,102,241,0.25);
}
.dark-mode .btn-search-practice {
  background: #6366f1;
}
.dark-mode .btn-search-practice:hover {
  background: #4f46e5;
}

/* ========== ������������ ========== */
.word-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.word-detail-panel {
  background: #fff;
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  max-height: 60vh;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
}
.word-detail-body {
  overflow: hidden;
}
.word-detail-scroll {
  max-height: calc(60vh - 48px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 16px 20px 20px;
  box-sizing: border-box;
  scrollbar-width: thin;
}
.word-detail-scroll::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
.word-detail-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.word-detail-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.25);
  border-radius: 3px;
}
.word-detail-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.4);
}

.word-detail-scrollbar-thumb {
  position: absolute;
  top: 0;
  left: 1px;
  right: 1px;
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
  cursor: pointer;
  min-height: 24px;
  transition: background 0.2s;
}
.word-detail-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.5);
}

.word-detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}
.word-detail-close:hover {
  background: #f1f5f9;
  color: #475569;
}
.word-detail-content {
  padding-right: 16px;
}
.word-detail-section {
  margin-right: 8px;
}

.word-detail-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.word-detail-head .word {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1e293b;
}
.word-detail-head .phonetic {
  font-size: 0.9rem;
  color: #64748b;
  font-family: 'IPAexMincho', 'Times New Roman', serif;
}
.word-detail-head .badge-level {
  font-size: 0.7rem;
  background: #e2e8f0;
  color: #475569;
  padding: 1px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
}
.word-detail-pos {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 8px;
}
.word-detail-def {
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.6;
  margin-bottom: 4px;
}
.word-detail-cn {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 16px;
}

.word-detail-section {
  margin-top: 14px;
  margin-right: 8px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}
.word-detail-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.word-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.word-detail-tag {
  font-size: 0.8rem;
  background: #f1f5f9;
  color: #475569;
  padding: 3px 10px;
  border-radius: 20px;
}
.word-detail-tag .tag-cn {
  color: #94a3b8;
  margin-left: 4px;
}
.word-detail-tag.affix-tag {
  background: #ede9fe;
  color: #6d28d9;
}
.word-detail-tag.pv-tag {
  background: #eef2ff;
  color: #4f46e5;
}
.word-detail-tag.col-tag {
  background: #ecfdf5;
  color: #059669;
}
.word-detail-tag.parent-tag {
  background: #fef3c7;
  color: #b45309;
}
.word-detail-parent-link {
  cursor: pointer;
  transition: all 0.2s;
}
.word-detail-parent-link:hover {
  opacity: 0.7;
}
.word-detail-affix-item {
  display: block;
  font-size: 0.85rem;
  padding: 4px 0;
  color: #475569;
}
.word-detail-affix-item .affix-type {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-right: 6px;
}
.word-detail-phrase-item {
  display: block;
  font-size: 0.85rem;
  padding: 6px 0;
  color: #475569;
  border-bottom: 1px solid #f8fafc;
}
.word-detail-phrase-item:last-child {
  border-bottom: none;
}
.word-detail-phrase-item .phrase-word {
  font-weight: 600;
}
.word-detail-phrase-item .phrase-def {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 2px;
}
.word-detail-def-example {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 2px;
  line-height: 1.4;
  display: block;
}
.dark-mode .word-detail-def-example {
  color: #64748b;
}
.phrase-example {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 2px;
  line-height: 1.4;
}
.dark-mode .phrase-example {
  color: #64748b;
}


.dark-mode .word-detail-panel {
  background: #1e293b;
}
.dark-mode .word-detail-head .word {
  color: #e2e8f0;
}
.dark-mode .word-detail-pos {
  color: #64748b;
}
.dark-mode .word-detail-def {
  color: #cbd5e1;
}
.dark-mode .word-detail-cn {
  color: #94a3b8;
}
.dark-mode .word-detail-section {
  border-top-color: #334155;
}
.dark-mode .word-detail-section-title {
  color: #64748b;
}
.dark-mode .word-detail-tag {
  background: #334155;
  color: #cbd5e1;
}
.dark-mode .word-detail-tag.affix-tag {
  background: rgba(109,40,217,0.2);
  color: #a78bfa;
}
.dark-mode .word-detail-tag.pv-tag {
  background: rgba(79,70,229,0.2);
  color: #818cf8;
}
.dark-mode .word-detail-tag.col-tag {
  background: rgba(5,150,105,0.2);
  color: #34d399;
}
.dark-mode .word-detail-tag.parent-tag {
  background: rgba(180,83,9,0.2);
  color: #fbbf24;
}
.dark-mode .word-detail-affix-item {
  color: #cbd5e1;
}
.dark-mode .word-detail-phrase-item {
  color: #cbd5e1;
  border-bottom-color: #1e293b;
}
.dark-mode .word-detail-close:hover {
  background: #334155;
  color: #94a3b8;
}
/* 修复全选/释义按钮字体 */
.select-all-link,
.reading-toggle-btn {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif !important;
}

