/* ===== CSS Variables — 暖橙童趣风 ===== */
:root {
  /* 主色 — 暖橙 */
  --primary: #FF9F43;
  --primary-hover: #F09030;
  --primary-light: #FFF0DB;
  /* 功能色 */
  --success: #4ADE80;
  --success-bg: #ECFDF5;
  --danger: #F87171;
  --danger-bg: #FEF2F2;
  /* 文字色 */
  --text-h1: #1D2129;
  --text-body: #4A4A4A;
  --text-aux: #8B8B8B;
  --text-aux-light: #C0C0C0;
  /* 背景 */
  --bg-card: #FFFFFF;
  --bg-page: #FFF8F0;
  --bg-hover: #FFF8F0;
  --bg-active: #FFF0DB;
  /* 边框 */
  --border: #E8E8E8;
  --border-light: #F0F0F0;
  /* 圆角 */
  --radius-card: 20px;
  --radius-input: 14px;
  --radius-btn: 14px;
  --radius-tag: 10px;
  /* 间距 */
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 24px;
  /* 字体 */
  --font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Helvetica Neue", sans-serif;
  --font-h1: 24px;
  --font-title: 20px;
  --font-body: 16px;
  --font-sm: 14px;
  --font-xs: 12px;
  /* 阴影 */
  --shadow-card: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 6px 18px rgba(0,0,0,0.06);
  --shadow-btn: 0 4px 12px rgba(255,159,67,0.25);
  /* 渐变色（辅助用，不能放 var 里的放这里） */
  --primary-gradient: linear-gradient(135deg, #FF9F43, #FFB347);
  --primary-gradient-strong: linear-gradient(160deg, #FF9F43 0%, #FFB347 60%, #FFC96B 100%);
  --dark-brand-gradient: linear-gradient(135deg, #2A1F10, #1A1208);
  /* 语义色 */
  --star-color: #FFB300;
  --star-bg: #FFF8E1;
  --gold-border: rgba(255, 215, 0, 0.4);
  --ai-purple: #6C5CE7;
  --ai-purple-light: #F0EDFF;
  --warning: #FBBF24;
  --warning-bg: #FFF8E1;
  /* 动画 */
  --transition: all 0.2s ease;
}

/* ===== Dark Theme ===== */
.dark {
  --primary-light: #3D2E1A;
  --success-bg: #1A2E1A;
  --danger-bg: #2E1A1A;
  --text-h1: #E8E8E8;
  --text-body: #B8B8B8;
  --text-aux: #888888;
  --text-aux-light: #555555;
  --bg-card: #1E1E1E;
  --bg-page: #121212;
  --bg-hover: #2A2A2A;
  --bg-active: #3A3A3A;
  --border: #333333;
  --border-light: #2A2A2A;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-card-hover: 0 6px 18px rgba(0,0,0,0.4);
  --shadow-btn: 0 4px 12px rgba(255,159,67,0.15);
  --star-color: #FFD700;
  --star-bg: #3D2E1A;
  --gold-border: rgba(255, 215, 0, 0.2);
  --ai-purple: #A855F7;
  --ai-purple-light: #2A1F3D;
  --warning: #FBBF24;
  --warning-bg: #3D2E1A;
  color-scheme: dark;
}

.dark body { background: var(--bg-page); }
.dark .brand-header { background: var(--dark-brand-gradient); }
.dark .mode-tab:has(input:checked) { background: var(--bg-active) !important; color: var(--primary) !important; }
.dark .mode-tabs-row { background: #1A1A1A; }
.dark .toggle-item { background: var(--bg-hover); }
.dark input, .dark textarea, .dark select { background: var(--bg-hover); color: var(--text-body); border-color: var(--border); }
.dark .toast { background: #333; }
.dark .modal-content { background: var(--bg-card); }
.dark .missed-item { background: var(--bg-hover); }

/* === Phase 1: Dark mode additions === */
.dark .modal-box { background: var(--bg-card); }
.dark .modal-header { border-bottom-color: var(--border); }
.dark .modal-header h3 { color: var(--text-h1); }
.dark .modal-close { color: var(--text-aux); }

.dark .badge-modal-content { background: var(--bg-card); }
.dark .badge-modal-desc { color: var(--text-aux); }
.dark .confirm-modal-content { background: var(--bg-card); }
.dark .confirm-modal-btn-cancel { background: var(--bg-hover); color: var(--text-aux); }

.dark .stars-section { background: var(--bg-card); }
.dark .level-card { background: var(--bg-card); }
.dark .chart-container canvas { filter: brightness(0.8); }

.dark .lib-picker-content { background: var(--bg-card); }
.dark .lib-btn { background: var(--bg-hover); border-color: var(--border); }
.dark .lib-btn-active { background: linear-gradient(135deg, var(--bg-active), var(--primary-light)); border-color: var(--primary); }
.dark .lib-btn-text { color: var(--text-body); }
.dark .lib-btn-active .lib-btn-text { color: var(--primary); }
.dark .lib-search-input { background: var(--bg-hover); border-color: var(--border); color: var(--text-body); }
.dark .lib-result-group { border-color: var(--border); }
.dark .lib-word-tag { background: var(--bg-active); color: var(--primary); }
.dark .lib-word-tag.selected { background: var(--primary); color: #fff; }
.dark .lib-ai-section { background: var(--ai-purple-light); border-color: var(--border); }

.dark .login-tabs { border-bottom-color: var(--border); }
.dark .login-form input { background: var(--bg-hover); border-color: var(--border); color: var(--text-h1); }
.dark .login-footer { border-top-color: var(--border); }

.dark .btn-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(248,113,113,0.3); }
.dark .badge-cell.locked { background: var(--bg-hover); }
.dark .badge-cell-name { color: var(--text-aux); }
.dark .stat-card-new { background: var(--bg-hover); }
.dark .word-table-example { background: var(--bg-active); }
.dark .example-item { background: var(--ai-purple-light); }
.dark .dragon-evolve-banner { background: linear-gradient(135deg, var(--star-bg), var(--primary-light)); border-color: var(--gold-border); }
.dark .inline-settings-row input { background: var(--bg-hover); border-color: var(--border); color: var(--text-body); }

/* Chart & Stats */
.chart-container {
  position: relative;
  height: 200px;
  margin-top: 12px;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-page);
  background-image: radial-gradient(circle at 20% 10%, rgba(255,159,67,0.04) 0%, transparent 50%),
                    radial-gradient(circle at 80% 90%, rgba(255,159,67,0.03) 0%, transparent 50%);
  min-height: 100vh;
  color: var(--text-body);
  font-size: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--gap-4);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===== Brand Header ===== */
.brand-header {
  background: var(--primary-gradient-strong);
  border-radius: 0 0 20px 20px;
  padding: 22px 16px 26px;
  margin-bottom: var(--gap-3);
  box-shadow: 0 4px 14px rgba(255,159,67,0.25);
}
.brand-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.brand-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}
.brand-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  margin-top: 4px;
}

/* ===== Quick Nav ===== */
.quick-nav {
  display: flex;
  gap: 10px;
  margin-top: -14px;
  margin-bottom: var(--gap-3);
  position: relative;
  z-index: 2;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: var(--radius-btn);
  padding: 10px 6px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  min-height: 60px;
}
.nav-item:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.nav-item:active { transform: scale(0.97); }
.nav-icon {
  font-size: 22px;
  margin-bottom: 4px;
}
.nav-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-body);
  white-space: nowrap;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 18px 16px;
  margin: 10px 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  border: none;
}
.card-import { padding: 18px 16px; }
.card-editor { padding: 18px 16px; }
.card-actions { padding: 18px 16px; }

/* Card header */
.card-header {
  margin-bottom: 14px;
}
.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-h1);
  display: block;
}
.card-desc {
  font-size: 13px;
  color: var(--text-aux);
  margin-top: 2px;
  display: block;
}

/* Import grid */
.import-grid {
  display: flex;
  gap: 12px;
}
.import-grid-3 .import-card {
  flex: 1;
}
.import-grid-2 .import-card {
  flex: 1;
  min-height: 100px;
}
.import-grid-2 .import-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.import-grid-2 .import-title {
  font-size: 14px;
}
.import-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-hover), var(--border-light));
  border-radius: 16px;
  padding: 16px 8px;
  cursor: pointer;
  transition: var(--transition);
  border: 1.5px solid var(--border);
  min-height: 88px;
}
.import-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.import-card:active {
  transform: scale(0.97);
}
.import-icon {
  font-size: 28px;
  margin-bottom: 6px;
}
.import-icon-camera,
.import-icon-file,
.import-icon-library {
  background: var(--primary-gradient);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(255,159,67,0.25);
}
.import-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  white-space: nowrap;
}

/* Editor toolbar */
.editor-toolbar {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: var(--gap-3);
}
.editor-title-row {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
}
.editor-title { font-size: 17px; font-weight: 700; color: var(--text-h1); }
.editor-list-info { font-size: var(--font-sm); color: var(--primary); font-weight: 600; background: var(--primary-light); padding: 4px 10px; border-radius: 20px; }
.editor-actions { display: flex; gap: var(--gap-2); width: 100%; }
.btn-icon {
  flex: 1; text-align: center;
  background: var(--bg-hover); border: none;
  border-radius: var(--radius-btn); padding: 10px 6px;
  font-size: var(--font-sm); color: var(--text-body);
  cursor: pointer; transition: var(--transition);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 44px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); transform: translateY(-1px); }
.btn-icon:active { transform: scale(0.95); }
.btn-icon.add-btn { background: var(--success-bg); color: var(--success); }
.btn-icon.add-btn:hover { background: #DCFCE7; }

/* Import buttons */
.import-buttons-row { gap: var(--gap-2); flex-wrap: wrap; }
.import-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px 10px;
  font-size: var(--font-sm);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  min-height: 50px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.import-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.import-btn:active { transform: scale(0.97); }
.import-btn:first-child {
  background: linear-gradient(135deg, var(--success-bg), #D4EDDA);
  color: var(--success);
}
.import-btn-ai {
  background: linear-gradient(135deg, var(--ai-purple-light), #D6E8FA);
  color: var(--ai-purple);
}
.import-btn-ai:active { background: linear-gradient(135deg, #D6E8FA, #BFDBFE); }

/* Dictation button */
.btn-dictate {
  margin-top: var(--gap-4);
  margin-bottom: var(--gap-2);
  min-height: 58px;
  font-size: 18px;
  border-radius: 14px;
  background: var(--primary-gradient-strong);
  box-shadow: 0 4px 16px rgba(255,159,67,0.3);
  letter-spacing: 1px;
  transition: all 0.2s ease;
}
.btn-dictate:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255,159,67,0.4);
}
.btn-dictate:active {
  transform: translateY(0) scale(0.98);
}

/* AI topic inline input */
#aiTopicInput { display: flex; gap: var(--gap-2); margin-top: var(--gap-3); align-items: center; flex-wrap: wrap; }
#aiTopicInput input {
  flex: 1; min-width: 200px; border: none; border-radius: var(--radius-btn);
  padding: 11px 14px; font-size: var(--font-sm); outline: none;
  font-family: inherit; color: var(--text-body);
  background: var(--bg-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
#aiTopicInput input:focus { box-shadow: 0 0 0 2px var(--primary); }
.upload-row {
  display: flex; align-items: center; gap: var(--gap-3); margin-top: var(--gap-3);
}
.upload-btn {
  display: inline-flex; align-items: center; gap: var(--gap-2);
  border: none;
  border-radius: var(--radius-btn);
  padding: var(--gap-2) var(--gap-4);
  background: var(--bg-hover);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-body);
  font-size: var(--font-sm);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.upload-btn:hover { background: var(--primary-light); color: var(--primary); }
.upload-btn:active { transform: scale(0.97); }
#fileInput { display: none; }
#importFileInput { display: none; }
.preview-mini { max-height: 60px; border-radius: var(--radius-btn); margin-left: auto; }
.preview-img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius-input);
  margin: var(--gap-3) auto 0;
  background: var(--bg-hover);
  overflow: auto;
  touch-action: pan-y;
}

.progress-inline { width: 100%; margin-top: var(--gap-2); }
.progress-inline .progress-bar { height: 6px; }
.progress-inline .progress-text { font-size: var(--font-xs); }

.grade-preview-img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius-input);
  margin: var(--gap-3) auto 0;
  background: var(--bg-hover);
  overflow: auto;
  touch-action: pan-y;
}

.grade-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 20px; font-weight: 700; cursor: pointer;
  background: var(--bg-hover); border: 2px solid var(--border);
  transition: var(--transition);
  touch-action: manipulation;
}
.grade-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ===== Buttons — 三级分级 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--gap-2);
  border: none; border-radius: var(--radius-input); padding: 12px 20px; font-size: 20px;
  font-weight: 700; cursor: pointer; transition: var(--transition); width: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* 一级主按钮 */
.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover { opacity: 0.95; box-shadow: 0 6px 18px rgba(255,159,67,0.35); transform: translateY(-1px); }

/* 成功按钮 */
.btn-success {
  background: linear-gradient(135deg, var(--success), #3CC96E);
  color: #fff;
  box-shadow: 0 4px 12px rgba(74,222,128,0.25);
}
.btn-success:hover { opacity: 0.95; }

/* 橙色按钮（次要操作） */
.btn-orange {
  background: var(--primary-gradient);
  color: #fff;
}
.btn-orange:hover { opacity: 0.95; }

/* AI 按钮 */
.btn-ai {
  background: var(--primary-gradient);
  color: #fff;
}
.btn-ai:hover { opacity: 0.95; }

/* 三级辅助（灰色） */
.btn-gray {
  background: var(--bg-hover);
  color: var(--text-body);
  border: none;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.btn-gray:hover { background: var(--border-light); box-shadow: 0 2px 6px rgba(0,0,0,0.06); }

.btn-sm { font-size: 20px; padding: 10px 18px; width: auto; border-radius: var(--radius-input); min-height: auto; }

/* ===== Progress ===== */
.progress-bar {
  width: 100%; height: 8px; background: var(--border-light);
  border-radius: var(--radius-tag); overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--primary);
  transition: width 0.3s ease;
}
.progress-text { font-size: var(--font-sm); color: var(--text-aux); margin-top: var(--gap-2); text-align: center; }

/* ===== Word list ===== */
.word-input-area {
  width: 100%;
  height: 160px;
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: var(--font-body);
  resize: none;
  font-family: inherit;
  outline: none;
  color: var(--text-body);
  transition: var(--transition);
  background: var(--bg-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  box-sizing: border-box;
}
.word-input-area:focus { background: var(--bg-card); box-shadow: 0 0 0 2px var(--primary); }
.word-input-area::placeholder { color: var(--text-aux-light); }
.word-input-area.hidden { display: none !important; }

/* Mode config row — segmented control + inline shuffle */
.mode-config-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Mode tabs — iOS-style segmented control (white slider) */
.mode-tabs-row {
  display: flex;
  gap: 0;
  background: var(--bg-hover);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 10px;
}
.mode-tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 10px 6px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--font-sm);
  color: var(--text-aux);
  background: transparent;
  text-align: center;
  min-height: 40px;
  font-weight: 600;
}
.mode-tab:hover { color: var(--primary); }
.mode-tab:has(input:checked) {
  background: var(--bg-card) !important;
  color: var(--text-h1) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.mode-tab input { display: none; }
.mode-icon { font-size: 17px; }

/* Toggle items — 随机 + 暗色（像小程序一样的开关） */
.toggles-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-bottom: 10px;
}
.toggle-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-hover);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle-label-text {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-body);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* Switch style (iOS-style toggle) */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ddd;
  border-radius: 24px;
  transition: 0.3s;
}
.dark .switch-slider {
  background: var(--text-aux-light);
}
.switch-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-slider {
  background: var(--primary);
}
.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* Config row (legacy, keep for other uses) */
.config-row {
  display: flex; align-items: center; gap: var(--gap-2); margin-top: var(--gap-3);
}
.config-check {
  flex: 1; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: var(--gap-1);
  font-size: var(--font-sm); color: var(--text-aux); cursor: pointer;
  font-weight: 600;
}
.config-check input { width: 14px; height: 14px; cursor: pointer; }

.word-list { max-height: 300px; overflow-y: auto; }

/* Structured word table panel — matches mini-program word-list-panel */
.word-table {
  border: none;
  border-radius: 14px;
  max-height: 300px;
  overflow-y: auto;
  touch-action: pan-y;
  background: var(--bg-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-top: 12px;
}
.word-table-row {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
  padding: 8px 10px;
}
.word-table-row:hover { background: var(--primary-light); }
.word-table-row:last-child { border-bottom: none; }
.word-table-cell { padding: 4px 4px; }
.word-cell-en { flex: 2; }
.word-cell-zh { flex: 2; }
.word-cell-actions { flex: 0; display: flex; align-items: center; gap: 4px; }
.word-input-en, .word-input-zh {
  width: 100%; border: none; background: transparent;
  font-size: var(--font-body); color: var(--text-body);
  padding: 6px 8px; outline: none;
  font-family: inherit; line-height: 1.4;
}
.word-input-en { font-weight: 700; color: var(--text-h1); }
.word-input-zh { color: var(--text-aux); font-size: var(--font-sm); }
.word-example-btn {
  flex: 0; width: 30px; text-align: center;
  font-size: 16px; cursor: pointer; min-height: 30px; line-height: 30px;
  background: none; border: none; border-radius: 8px;
  transition: var(--transition); margin-right: 4px;
}
.word-example-btn:hover { background: var(--primary-light); }
.word-example-btn:active { transform: scale(0.9); }
.word-del-btn {
  flex: 0; width: 36px; text-align: center;
  font-size: 24px; color: #C0C0C0; cursor: pointer;
  min-height: 30px; line-height: 30px; margin-left: 8px;
  background: none; border: none; border-radius: 8px;
  transition: var(--transition);
  touch-action: manipulation;
}
.word-del-btn:hover { color: var(--danger); background: var(--danger-bg); }
.word-table-example {
  border-bottom: 1px solid var(--border-light);
  padding: 8px 12px 10px;
  background: #FFFBF0;
}

/* Add row — matches mini-program add-row */
.add-row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.add-input-wrap { flex: 1; position: relative; }
.add-input {
  width: 100%; border: none; border-radius: 14px;
  padding: 10px 14px; font-size: var(--font-sm); box-sizing: border-box;
  background: var(--bg-hover); color: var(--text-body); min-height: 40px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  font-family: inherit; outline: none;
}
.add-input:focus { background: var(--bg-card); box-shadow: 0 0 0 2px var(--primary); }
.add-preview {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--font-xs);
  color: var(--primary);
  font-weight: 500;
  pointer-events: none;
}

/* Textarea wrap — matches mini-program textarea-wrap */
.textarea-wrap { position: relative; width: 100%; margin-top: 12px; }
.textarea-placeholder {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 12px 14px; font-size: var(--font-sm);
  pointer-events: none; line-height: 1.6;
  display: flex; flex-direction: column;
}
.textarea-placeholder .ph-title { color: var(--text-aux); font-weight: 500; }
.textarea-placeholder .ph-label { color: var(--text-aux); margin-top: 4px; }
.textarea-placeholder .ph-line { color: var(--text-body); }
.textarea-placeholder .ph-note { color: var(--text-aux); font-size: var(--font-xs); margin-top: 6px; }

/* Old word list items */
.word-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--gap-3);
  border-bottom: 1px solid var(--border-light);
}
.word-item:last-child { border-bottom: none; }
.word-item .word-text { font-size: var(--font-body); font-weight: 700; color: var(--text-h1); }
.word-item .word-translation { font-size: var(--font-sm); color: var(--text-aux); margin-top: var(--gap-1); }
.word-item .delete-btn {
  background: none; border: none; font-size: 20px; color: var(--text-aux-light);
  cursor: pointer; padding: var(--gap-1) var(--gap-2); border-radius: var(--radius-tag); flex-shrink: 0;
  transition: var(--transition);
}
.word-item .delete-btn:hover { color: var(--danger); }
.word-item .delete-btn:active { background: var(--danger-bg); color: var(--danger); }

/* Example button and panel */
.example-btn {
  background: none; border: 1px solid var(--primary-light); color: var(--primary);
  border-radius: 20px; padding: 6px 14px; font-size: var(--font-sm);
  cursor: pointer; transition: all 0.2s;
}
.example-btn:hover { background: var(--primary-light); }
.example-btn:active { transform: scale(0.95); }

.example-panel { margin-top: var(--gap-2); }
.example-loading {
  padding: 12px 14px; background: rgba(123,97,255,0.08);
  border-radius: 10px; color: var(--primary); font-size: var(--font-sm);
}
.example-item {
  padding: 12px 14px; background: rgba(123,97,255,0.06);
  border-left: 3px solid var(--primary); border-radius: 0 10px 10px 0;
}
.example-sentence { font-size: var(--font-sm); color: var(--text-body); line-height: 1.7; }
.example-translation { font-size: var(--font-xs); color: var(--text-aux); margin-top: 6px; }
.example-empty { padding: 12px; color: var(--text-aux); font-size: var(--font-sm); text-align: center; }

/* ===== Dictation page ===== */
.dictation-progress-text { text-align: center; font-size: var(--font-body); color: var(--text-aux); margin-bottom: var(--gap-5); font-weight: 600; }
.dictation-controls { text-align: center; margin-bottom: 10px; }
.controls-row { display: flex; gap: var(--gap-3); justify-content: center; margin-bottom: var(--gap-2); }
.controls-row select {
  flex: 1; border: none; border-radius: var(--radius-btn);
  padding: 11px 14px; font-size: var(--font-sm); color: var(--text-body); background: var(--bg-hover);
  text-align: center; font-weight: 600;
  transition: var(--transition);
  min-height: 48px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  cursor: pointer;
}
.controls-row select:focus { background: var(--bg-card); box-shadow: 0 0 0 2px var(--primary); outline: none; }
.dictation-word-wrap {
  text-align: center; padding: 48px 0 32px; min-height: 160px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.dictation-word {
  font-size: 56px; font-weight: 800; color: var(--text-h1);
  line-height: 1.2; word-break: break-word;
  transition: color 0.2s;
}
.dictation-word.speaking { color: var(--primary); }
.dictation-phonetic {
  font-size: var(--font-title); color: var(--text-aux); margin-top: var(--gap-3);
  min-height: 28px; font-style: italic;
}
.dictation-translation { font-size: var(--font-body); color: var(--text-aux); margin-top: var(--gap-3); min-height: 28px; }
.read-count-inline { font-size: var(--font-body); color: var(--text-aux); margin-top: var(--gap-1); }
#voiceSelect { outline: none; cursor: pointer; }
#voiceSelect:focus { border-color: var(--primary); }
.dictation-buttons { display: flex; gap: var(--gap-2); margin-top: var(--gap-4); }
.dictation-buttons .btn { flex: 1; white-space: nowrap; font-size: 20px; padding: 12px 10px; min-height: 48px; }

/* ===== Done page ===== */
.done-icon { text-align: center; font-size: 72px; margin: 20px 0; }
.done-stats { text-align: center; font-size: var(--font-sm); color: var(--text-aux); margin-top: var(--gap-1); }
.done-text { text-align: center; font-size: var(--font-title); font-weight: 700; color: var(--text-h1); }
.done-sub { text-align: center; font-size: var(--font-body); color: var(--text-body); margin-top: var(--gap-2); }
.missed-list { max-height: none; margin-top: 10px; }

/* Missed item on result page — word + buttons on same row, example panel below */
.missed-item {
  padding: var(--gap-2) var(--gap-3);
  border-bottom: 1px solid var(--border-light);
}
.missed-item:last-child { border-bottom: none; }
.missed-item-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--gap-2);
}
.missed-word { display: flex; align-items: baseline; gap: var(--gap-2); min-width: 0; }
.missed-word .word-text { font-size: var(--font-body); font-weight: 700; color: var(--text-h1); flex-shrink: 0; }
.missed-word-zh { font-size: var(--font-sm); color: var(--text-aux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.missed-item-actions {
  display: flex; gap: 24px; align-items: center; flex-shrink: 0;
}
.missed-item-actions .delete-btn {
  background: none; border: none; font-size: 18px; color: var(--text-aux-light);
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-tag);
  transition: var(--transition);
}
.missed-item-actions .delete-btn:hover { color: var(--danger); }
.missed-item-actions .delete-btn:active { background: var(--danger-bg); color: var(--danger); }
.done-buttons { display: flex; flex-direction: column; gap: var(--gap-2); margin-top: var(--gap-3); }
.done-buttons .btn { flex: none; }

.result-buttons { display: flex; flex-direction: column; gap: var(--gap-2); margin-top: var(--gap-3); max-width: 480px; margin-left: auto; margin-right: auto; }
.result-buttons .btn-lg { min-height: 56px; font-size: 18px; }
.result-buttons .btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-2); }
.result-buttons .btn-half { min-height: 48px; font-size: 16px; padding: 12px 16px; max-width: none; width: 100%; }

/* ===== Judge list ===== */
.judge-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--gap-3); border-bottom: 1px solid var(--border-light); gap: var(--gap-3);
}
.judge-item:last-child { border-bottom: none; }
.judge-word { font-size: var(--font-body); font-weight: 700; color: var(--text-h1); flex-shrink: 0; margin-right: var(--gap-3); }
.judge-phonetic { font-size: 15px; color: var(--text-aux); text-align: right; flex: 1 1 0; min-width: 0; }
.judge-btns { display: flex; gap: var(--gap-2); flex-shrink: 0; margin-left: var(--gap-2); }
.judge-btn {
  border: none; border-radius: var(--radius-input); padding: 10px 16px; font-size: var(--font-sm);
  cursor: pointer; font-weight: 700; transition: var(--transition);
  min-height: 40px;
}
.judge-btn:active { transform: scale(0.95); }
.judge-btn-correct { background: var(--success-bg); color: var(--success); }
.judge-btn-correct.active { background: var(--success); color: #fff; }
.judge-btn-wrong { background: var(--danger-bg); color: var(--danger); }
.judge-btn-wrong.active { background: var(--danger); color: #fff; }

/* ===== Page visibility ===== */
.page { display: none; }
.page.active {
  display: block;
  animation: pageIn 0.25s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Star pop animation */
.star-rating-text > span {
  display: inline-block;
  animation: starPop 0.4s ease backwards;
}
.star-rating-text > span:nth-child(1) { animation-delay: 0.1s; }
.star-rating-text > span:nth-child(2) { animation-delay: 0.2s; }
.star-rating-text > span:nth-child(3) { animation-delay: 0.3s; }
@keyframes starPop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  70% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ===== Section label ===== */
.section-label { font-size: 17px; font-weight: 700; color: var(--text-h1); margin-bottom: 12px; letter-spacing: 0.5px; }

/* ===== 徽章详情弹窗 ===== */
.badge-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.badge-modal-content {
  width: 280px; background: var(--bg-card);
  border-radius: 16px; padding: 24px 20px;
  text-align: center;
}
.badge-modal-icon { font-size: 40px; margin-bottom: 8px; }
.badge-modal-name { font-size: 18px; font-weight: 700; color: var(--text-h1); margin-bottom: 6px; }
.badge-modal-desc { font-size: 14px; color: #666; margin-bottom: 12px; }
.badge-modal-status {
  padding: 8px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 600; margin-bottom: 12px;
}
.badge-modal-status.unlocked { background: #E8F5EC; color: #4ADE80; }
.badge-modal-status.locked { background: #FFF0EB; color: #F87171; }
.badge-modal-close {
  display: inline-block; padding: 8px 24px;
  background: var(--primary); color: #fff;
  border-radius: 20px; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.badge-modal-close:active { transform: scale(0.97); }

/* ===== 确认弹窗 ===== */
.confirm-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1001;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.confirm-modal-content {
  width: 300px; background: #fff;
  border-radius: 16px; padding: 24px;
  text-align: center;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.confirm-modal-title {
  font-size: 18px; font-weight: 700; color: var(--text-h1);
  margin-bottom: 8px;
}
.confirm-modal-message {
  font-size: 14px; color: var(--text-aux);
  margin-bottom: 20px; line-height: 1.5;
}
.confirm-modal-buttons {
  display: flex; gap: 10px; justify-content: center;
}
.confirm-modal-btn {
  flex: 1; padding: 10px 16px;
  border: none; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.confirm-modal-btn:active { transform: scale(0.96); }
.confirm-modal-btn-cancel {
  background: #f5f5f5; color: var(--text-aux);
}
.confirm-modal-btn-cancel:hover { background: #ebebeb; }
.confirm-modal-btn-no {
  background: var(--primary-light); color: var(--primary-hover);
}
.confirm-modal-btn-no:hover { background: var(--bg-active); }
.confirm-modal-btn-yes {
  background: var(--primary); color: #fff;
}
.confirm-modal-btn-yes:hover { background: var(--primary-hover); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(29,33,41,0.9); color: #fff; padding: 12px 24px;
  border-radius: var(--radius-input); font-size: var(--font-sm); z-index: 999;
  animation: fadeInOut 2s forwards;
}
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ===== Back button ===== */
.back-btn {
  display: block; width: fit-content;
  background: none; border: none; font-size: var(--font-sm); color: var(--text-aux);
  cursor: pointer; padding: var(--gap-2) 0; margin-bottom: var(--gap-1); text-align: left;
  transition: var(--transition);
  font-weight: 600;
}
.back-btn:hover { color: var(--primary); }

/* ===== Photo grading ===== */
.upload-area {
  border: none;
  border-radius: var(--radius-btn);
  padding: 28px 16px;
  background: linear-gradient(135deg, var(--bg-hover), #FFF0DB);
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.grade-correct { background: var(--success-bg); color: var(--success); border-radius: var(--radius-tag); padding: 4px 10px; font-weight: 700; }
.grade-wrong  { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-tag); padding: 4px 10px; font-weight: 700; }
.ocr-word { font-size: var(--font-sm); color: var(--text-aux); margin-top: var(--gap-2); font-style: italic; }

/* ===== Confetti ===== */
.confetti-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -20px;
  width: 10px; height: 20px; border-radius: 2px;
  animation: confettiBurst 0.6s ease-out, confettiFall linear forwards;
}
@keyframes confettiBurst {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
.result-icon { transition: transform 0.3s ease; }
.result-icon.bounce, .done-icon.bounce { animation: iconBounce 0.8s ease; }
@keyframes iconBounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.4); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* ===== My lists ===== */
.list-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  cursor: pointer;
  transition: var(--transition);
  border-radius: var(--radius-btn);
  margin-bottom: 10px;
  background: var(--bg-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.list-card:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,0.06); }
.list-card:active { transform: scale(0.98); }
.list-card.active-list {
  background: linear-gradient(135deg, var(--primary-light), #FFF0DB);
  border-left: 4px solid var(--primary);
  box-shadow: 0 3px 12px rgba(255,159,67,0.2);
}
.list-card .list-name { font-size: 16px; font-weight: 700; color: var(--text-h1); display: block; }
.list-card .list-meta { font-size: var(--font-sm); color: var(--text-aux); margin-top: 4px; display: block; }
.list-card.active-list .list-name { color: var(--primary); }
.list-card .list-del {
  background: none; border: none; font-size: 18px; color: var(--text-aux-light);
  cursor: pointer; padding: 8px 10px; border-radius: var(--radius-tag);
  transition: var(--transition);
}
.list-card .list-del:hover { color: var(--danger); background: var(--danger-bg); }
.list-card .list-del:active { color: var(--danger); background: var(--danger-bg); }
.new-list-row { display: flex; gap: var(--gap-2); margin-top: var(--gap-5); padding-top: var(--gap-4); border-top: 2px dashed var(--border-light); }
.new-list-row input {
  flex: 1; border: none; border-radius: var(--radius-btn);
  padding: 12px 16px; font-size: var(--font-body); outline: none;
  color: var(--text-body);
  transition: var(--transition);
  background: var(--bg-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  font-weight: 500;
}
.new-list-row input:focus { background: var(--bg-card); box-shadow: 0 0 0 2px var(--primary); }
.new-list-row .btn-sm { border-radius: var(--radius-btn); box-shadow: 0 2px 6px rgba(255,159,67,0.2); }

/* ===== History / Achievements ===== */
.history-item {
  padding: var(--gap-4);
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius-input);
}
.history-item:last-child { border-bottom: none; }
.history-date { font-size: 15px; font-weight: 700; color: var(--text-h1); }
.history-stats { font-size: var(--font-sm); color: var(--text-aux); margin-top: var(--gap-1); }
.history-rate { font-size: var(--font-sm); font-weight: 700; margin-top: var(--gap-1); }
.history-rate.good { color: var(--success); }
.history-rate.bad { color: var(--danger); }
.history-footer {
  display: flex; justify-content: space-around; align-items: center;
  padding: 0 var(--gap-2);
}
.footer-text-btn {
  background: none; border: none; color: var(--text-aux);
  font-size: var(--font-xs); cursor: pointer; padding: var(--gap-2) var(--gap-2);
  transition: var(--transition);
  font-weight: 600;
}
.footer-text-btn:hover { color: var(--primary); }
.footer-text-btn:active { color: var(--primary-hover); }
.footer-text-danger { color: var(--danger) !important; }
.footer-text-danger:hover { color: #E53E3E !important; }
.history-del-btn { cursor: pointer; opacity: 0.4; font-size: 14px; margin-left: 4px; transition: opacity 0.2s; }
.history-del-btn:hover { opacity: 1; }

/* ===== Rewards ===== */
.reward-section { text-align: center; margin-top: var(--gap-4); }
.reward-new-badge {
  display: inline-block; margin: var(--gap-2); padding: 8px 16px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-input);
  font-weight: 700;
  font-size: var(--font-sm);
}
.level-section {
  padding: 16px;
  background: var(--primary);
  border-radius: var(--radius-card);
  color: #fff;
}
.level-title { font-size: 15px; font-weight: 700; color: var(--text-h1); }
.xp-bar { height: 8px; background: rgba(255,255,255,0.3); border-radius: 4px; overflow: hidden; margin-top: var(--gap-2); }
.xp-fill { height: 100%; background: #FFD700; border-radius: 4px; }
.streak-section {
  display: flex; align-items: center; justify-content: center; gap: var(--gap-1);
  margin-top: var(--gap-3); font-size: var(--font-sm); color: #FFD700;
}
.stats-row { display: flex; justify-content: space-around; margin-top: var(--gap-3); }
.stat-item { text-align: center; }
.stat-num { font-size: var(--font-title); font-weight: 700; color: #fff; }
.stat-label { font-size: var(--font-xs); color: rgba(255,255,255,0.8); }
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-2); margin-top: var(--gap-3); }
.badge-item { text-align: center; padding: var(--gap-2) var(--gap-1); border-radius: var(--radius-input); background: var(--bg-hover); }
.badge-item.unlocked { background: var(--primary-light); }
.badge-item .badge-icon { font-size: 28px; }
.badge-item .badge-name { font-size: var(--font-xs); color: var(--text-aux); margin-top: var(--gap-1); }
.badge-item.locked .badge-icon { filter: grayscale(1); opacity: 0.3; }
.ai-encourage {
  margin-top: var(--gap-3); padding: 12px 16px;
  background: var(--primary-light);
  border-radius: var(--radius-input);
  font-size: var(--font-sm);
  color: var(--primary);
  text-align: center;
  font-style: italic;
  font-weight: 600;
}

/* ===== 龙宝冒险成就系统 ===== */

/* 星星区 */
.stars-section {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #fff;
  border-radius: 12px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.stars-total { display: flex; align-items: baseline; gap: 4px; }
.stars-icon { font-size: 18px; }
.stars-num { font-size: 24px; font-weight: 700; color: #FFB300; }
.stars-label { font-size: 13px; color: var(--text-aux); }
.stars-recent { display: flex; align-items: center; gap: 4px; }
.stars-recent-label { font-size: 11px; color: var(--text-aux); }
.stars-recent-items { display: flex; gap: 3px; }
.star-badge { display: flex; gap: 1px; padding: 2px 4px; border-radius: 6px; font-size: 9px; }
.star-badge.star-3 { background: #FFF8E1; }
.star-badge.star-2 { background: #E8F5EC; }
.star-badge.star-1 { background: #F5F5F5; }
.star-badge.star-0 { background: #F5F5F5; opacity: 0.5; }
.star-empty { color: #CCC; }

/* 等级卡片 */
.level-card {
  padding: 16px; border-radius: 16px;
  margin-bottom: 12px; color: var(--text-body);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}
.level-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.level-icon { font-size: 24px; }
.level-name { font-size: 18px; font-weight: 700; color: var(--text-h1); }
.level-progress-area { margin-top: 4px; }
.level-progress-bar { height: 8px; background: rgba(0,0,0,0.06); border-radius: 4px; overflow: hidden; }
.level-progress-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.level-progress-text { display: block; font-size: 12px; color: var(--text-aux); margin-top: 6px; }

/* 徽章区 */
.badges-section { margin-bottom: 12px; }
.section-title { font-size: 16px; font-weight: 700; color: var(--text-h1); margin-bottom: 8px; }
.badge-grid-new { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.badge-cell {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 2px; border-radius: 10px; min-height: 65px;
}
.badge-cell.unlocked {
  background: linear-gradient(135deg, #FFF8E1, #FFF3E0);
  border: 1px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 1px 4px rgba(255, 215, 0, 0.15);
}
.badge-cell.locked { background: #F0F0F0; opacity: 0.7; }
.badge-cell-icon { font-size: 20px; }
.badge-cell-name { font-size: 9px; color: #666; margin-top: 3px; text-align: center; line-height: 1.2; }
.badge-cell.locked .badge-cell-icon { filter: grayscale(1); opacity: 0.4; }
.badge-lock { position: absolute; bottom: 3px; right: 3px; font-size: 8px; }
.badge-check { position: absolute; bottom: 3px; right: 3px; font-size: 7px; }
.badge-hint { display: block; text-align: center; font-size: 11px; color: #AAA; margin-top: 6px; }

/* 战绩区 */
.stats-section { margin-bottom: 12px; }
.stats-grid-new { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat-card-new {
  border-radius: 12px; padding: 10px 6px;
  text-align: center; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.stat-card-icon { font-size: 20px; }
.stat-card-num { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat-card-label { font-size: 11px; color: #8B8B8B; margin-top: 1px; }

/* 最近听写 */
.history-section { margin-bottom: 12px; }
.history-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 6px;
}
.history-left { display: flex; align-items: center; gap: 6px; }
.history-icon { font-size: 18px; }
.history-score { font-size: 15px; font-weight: 600; color: var(--text-h1); }
.history-list { font-size: 12px; color: var(--text-aux); }
.history-right { display: flex; align-items: center; gap: 6px; }
.history-stars { font-size: 11px; }
.history-rate { font-size: 14px; font-weight: 700; }

/* ===== 结果页星级 + 龙宝 ===== */
.star-rating-section { margin-top: 12px; text-align: center; }
.star-rating-display { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.star-rating-text { font-size: 28px; }
.star-rating-gained { font-size: 16px; font-weight: 700; color: #FFB300; }
.dragon-mood-row { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; }
.dragon-mood-face { font-size: 20px; }
.dragon-mood-text { font-size: 14px; color: #666; font-weight: 600; }
.dragon-evolve-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 12px; padding: 12px;
  background: linear-gradient(135deg, #FFF8E1, #FFF3E0);
  border-radius: 12px;
  border: 1px solid rgba(255, 215, 0, 0.4);
}
.evolve-icon { font-size: 28px; animation: evolvePulse 1s ease-in-out infinite; }
.evolve-text { font-size: 15px; font-weight: 700; color: var(--primary); }
@keyframes evolvePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* AI Topic Input */
.ai-topic-row { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; width: 100%; box-sizing: border-box; }
.ai-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-btn-row .btn-sm { min-height: 44px; font-size: 16px; padding: 12px 0; text-align: center; }

/* ===== Squad Mode ===== */
/* Visual indicator when in squad mode */
body.squad-mode {
  background: linear-gradient(180deg, #FFF0DB 0%, #FFF8F0 100px);
}

body.squad-mode::before {
  content: '🏰 ' attr(data-squad-name) ' (' attr(data-squad-id) ')';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #FF9F43 0%, #F09030 100%);
  color: white;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(255, 159, 67, 0.3);
}

body.squad-mode .container {
  padding-top: 40px;
}

/* Squad mode sync button */
body.squad-mode #syncBtn {
  background: var(--primary);
  color: white !important;
  border-color: var(--primary);
}

body.squad-mode #syncBtn:hover {
  background: var(--primary-hover);
}

/* ===== 词库面板样式 ===== */

/* 级联选择器 */
.lib-cascade-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.lib-btn {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 8px;
  background: #fff;
  border-radius: 12px;
  border: 1.5px solid #e8e8e8;
  min-height: 48px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  user-select: none;
}
.lib-btn:active {
  transform: scale(0.97);
}
.lib-btn-active {
  background: linear-gradient(135deg, #FFF8ED 0%, #FFEED4 100%);
  border-color: #FFB84D;
  box-shadow: 0 3px 10px rgba(255,184,77,0.25);
}
.lib-btn-disabled {
  opacity: 0.45;
  background: #f5f5f5;
  pointer-events: none;
}
.lib-btn-text {
  font-size: 14px;
  color: #333;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
  text-align: center;
}
.lib-btn-active .lib-btn-text {
  color: #D4760A;
  font-weight: 600;
}
.lib-btn-arrow {
  position: absolute;
  right: 8px;
  font-size: 12px;
  color: #ccc;
}
.lib-btn-active .lib-btn-arrow {
  color: #D4760A;
}

/* 搜索框 */
.lib-search-box {
  position: relative;
  margin-bottom: 16px;
}
.lib-search-input {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px 48px;
  border: 1.5px solid #eee;
  border-radius: 12px;
  font-size: 15px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  box-sizing: border-box;
  background: #f8f9fa;
}
.lib-search-input:focus {
  border-color: var(--primary);
}
.lib-search-placeholder {
  position: absolute;
  top: 12px;
  left: 14px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lib-ph-line {
  font-size: 14px;
  color: #bbb;
  line-height: 1.5;
}
.lib-search-btn-inner {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--primary), #FFB347);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 6px 28px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255,159,67,0.35);
  transition: all 0.2s;
}
.lib-search-btn-inner:hover {
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 4px 14px rgba(255,159,67,0.45);
}
.lib-search-btn-inner:active {
  transform: translateX(-50%) scale(0.97);
}

/* 搜索结果 */
.library-results {
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.lib-result-group {
  margin-bottom: 12px;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  overflow: hidden;
}
.lib-result-header {
  background: #f8f9fa;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.lib-result-header .lib-import-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.lib-result-header .lib-import-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}
.lib-word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
}
.lib-word-tag {
  background: #FFF5E6;
  color: #E8850C;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}
.lib-word-tag:hover {
  background: #FFE8C8;
}
.lib-word-tag.selected {
  background: var(--primary);
  color: white;
}
.lib-empty {
  text-align: center;
  color: #999;
  padding: 20px;
  font-size: 14px;
}

/* AI 推荐区 */
.lib-ai-section {
  margin-top: 12px;
  padding: 12px;
  background: #F8F5FF;
  border-radius: 12px;
  border: 1px solid #E8E0F5;
}
.lib-ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.lib-ai-badge {
  background: linear-gradient(135deg, #6C5CE7, #A855F7);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
}
.lib-ai-desc {
  font-size: 12px;
  color: #999;
}
.lib-ai-actions {
  margin-top: 10px;
  text-align: right;
}
.lib-ai-import {
  display: inline-block;
  background: #6C5CE7;
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.lib-ai-import:hover {
  background: #5A4BD1;
  transform: translateY(-1px);
}

/* 词库选择器弹窗 */
.lib-picker-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.lib-picker-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
}
.lib-picker-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 70vh;
  background: #fff;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  animation: libSlideUp 0.3s ease;
}
@keyframes libSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.lib-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.lib-picker-title {
  font-size: 17px;
  font-weight: 600;
  color: #333;
}
.lib-picker-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #999;
  border-radius: 50%;
  background: #f5f5f5;
  cursor: pointer;
  transition: var(--transition);
}
.lib-picker-close:hover {
  background: #e8e8e8;
}
.lib-picker-list {
  max-height: 55vh;
  overflow-y: auto;
  padding: 8px 0;
}
.lib-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid #f8f8f8;
  cursor: pointer;
  transition: background 0.15s;
}
.lib-picker-item:hover {
  background: #f8f8f8;
}
.lib-picker-item:active {
  background: #f0f0f0;
}
.lib-picker-item-active {
  background: #FFF8ED;
}
.lib-picker-item-text {
  font-size: 16px;
  color: #333;
}
.lib-picker-item-active .lib-picker-item-text {
  color: #D4760A;
  font-weight: 600;
}
.lib-picker-item-check {
  font-size: 18px;
  color: var(--primary);
  font-weight: 700;
}

/* ===== 通用弹窗 ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--bg-card); border-radius: 20px; padding: 0;
  max-width: 420px; width: 90%; overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 12px; border-bottom: 1px solid #F0F0F0;
}
.modal-header h3 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 20px;
  cursor: pointer; color: #999; padding: 4px 8px;
}

/* ===== 登录弹窗 ===== */
.login-tabs {
  display: flex; border-bottom: 1px solid #F0F0F0;
}
.login-tab {
  flex: 1; padding: 14px; text-align: center;
  background: none; border: none; border-bottom: 3px solid transparent;
  font-size: 15px; font-weight: 600; color: #888;
  cursor: pointer; transition: all 0.2s;
}
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.login-form {
  padding: 20px 24px; display: flex; flex-direction: column; gap: 12px;
}
.login-form input {
  padding: 12px 14px; border: 1.5px solid #E8E8E8;
  border-radius: 10px; font-size: 15px; outline: none;
  transition: border-color 0.2s;
  color: #1D2129; font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
.login-form input:focus { border-color: var(--primary); }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-img {
  width: 120px; height: 50px; border-radius: 8px;
  border: 1px solid #E8E8E8; cursor: pointer;
  background: #F8F8F8;
}
.captcha-row input { flex: 1; letter-spacing: 2px; text-align: center; font-size: 18px; }
.login-submit {
  margin-top: 8px; padding: 14px; width: 100%;
  font-size: 16px; font-weight: 600;
}
.login-error {
  color: #F87171; font-size: 13px; min-height: 18px;
  text-align: center;
}

/* ===== 微信扫码登录 ===== */
.wechat-qr-form {
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 24px 24px;
  gap: 12px;
}
.qr-code-wrap {
  width: 180px; height: 180px;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed #E8E8E8; border-radius: 12px;
  overflow: hidden;
}
.qr-code-wrap img { display: block; margin: 0 auto; }
.qr-code-wrap canvas { display: block; margin: 0 auto; }
.qr-loading {
  text-align: center; color: var(--text-aux);
  font-size: 13px; padding: 20px;
}
.qr-status-text {
  font-size: 14px; color: var(--text-body);
  text-align: center; font-weight: 500;
}

/* ===== 登录弹窗底部链接 ===== */
.login-footer {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; flex-wrap: wrap;
  padding: 14px 24px 20px;
  border-top: 1px solid #F0F0F0;
  font-size: 13px;
}
.login-footer-label {
  color: var(--text-aux);
}
.login-footer-sep {
  color: #E8E8E8;
}
.login-footer-link {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.login-footer-link:hover {
  text-decoration: underline;
}

/* ===== 内联设置面板 (used by 个人中心) ===== */
.btn-danger {
  padding: 10px 16px; background: #FEF2F2; color: #F87171;
  border: 1px solid #FECACA; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  align-self: flex-start;
  box-sizing: border-box;
}
.btn-danger:hover { background: #FEE2E2; }
.account-msg {
  padding: 12px 24px; font-size: 13px; min-height: 18px;
  text-align: center;
}

/* ===== Profile Card (个人中心顶部) ===== */
.user-dragon-section {
  background: linear-gradient(160deg, #FF9F43 0%, #FFB347 60%, #FFC96B 100%);
  border-radius: 20px;
  padding: 20px;
  margin: -16px -16px 16px;
  color: #fff;
}
.user-dragon-header {
  display: flex;
  align-items: center;
  gap: 14px;
}
/* ===== 头像选择弹窗 ===== */
.avatar-picker-modal {
  max-width: 360px;
  padding: 20px 24px 24px;
}
.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.avatar-option {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  background: #F8F8F8;
}
.avatar-option:hover {
  background: var(--primary-light);
  transform: scale(1.1);
}
.avatar-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ===== 微信绑定按钮 ===== */
.btn-danger-sm {
  padding: 6px 12px;
  background: #FEF2F2; color: #F87171;
  border: 1px solid #FECACA; border-radius: 6px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  margin-left: 8px;
}
.btn-danger-sm:hover { background: #FEE2E2; }

.user-dragon-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.5);
  flex-shrink: 0;
  cursor: pointer;
}
.user-dragon-info {
  flex: 1;
  min-width: 0;
}
.user-dragon-name {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-dragon-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  margin-top: 2px;
}
.user-dragon-settings {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  font-size: 18px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-dragon-settings:hover {
  background: rgba(255,255,255,0.35);
}

/* ===== Inline Settings Panel ===== */
.inline-settings-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 16px;
}
.inline-settings-section {
  display: flex; flex-direction: column; gap: 8px;
}
.inline-settings-section label {
  font-size: 13px; font-weight: 600; color: var(--text-aux);
}
.inline-settings-row {
  display: flex; gap: 8px; align-items: center;
}
.inline-settings-row input {
  flex: 1;
  padding: 10px 12px; border: 1.5px solid #E8E8E8;
  border-radius: 8px; font-size: 14px; outline: none;
}
.inline-settings-row input:focus { border-color: var(--primary); }
.btn-inline {
  flex-shrink: 0;
  padding: 10px 16px;
  background: linear-gradient(135deg, #FF9F43, #FFB347);
  color: #fff; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn-inline:hover { opacity: 0.9; }
.inline-settings-panel .btn-danger {
  width: 100%; text-align: center;
  align-self: stretch;
}

/* ===== Phase 4: Responsive ===== */
@media (min-width: 768px) {
  .container { max-width: 600px; padding: var(--gap-5); }
  .card { padding: 24px 28px; margin: 16px 0; }
  .brand-title { font-size: 28px; }
  .brand-subtitle { font-size: 15px; }
  .dictation-word { font-size: 72px; }
  .nav-item { padding: 14px 10px; min-height: 72px; }
  .btn { padding: 14px 28px; font-size: 22px; min-height: 54px; }
  .modal-box { max-width: 480px; }
}
@media (max-width: 360px) {
  .container { padding: var(--gap-3); }
  .card { padding: 14px 12px; margin: 8px 0; }
  .brand-title { font-size: 18px; }
  .nav-text { font-size: 11px; }
  .mode-tab { font-size: var(--font-xs); padding: 8px 4px; min-height: 36px; }
  .toggle-item { padding: 6px 8px; }
}
@media (max-height: 500px) {
  .brand-header { padding: 12px 16px; }
  .brand-title { font-size: 18px; }
  .quick-nav { margin-top: -8px; }
  .nav-item { padding: 6px 4px; min-height: 44px; }
  .card { padding: 12px 14px; margin: 8px 0; }
  .dictation-word { font-size: 36px; }
}
