/* ===== TypeUp 全局样式 ===== */

/* --- 默认主题 --- */
:root {
  --bg-primary: #f5f6fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef0f5;
  --bg-hover: #e8eaf0;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #4a6cf7;
  --accent-light: #6b8aff;
  --accent-bg: rgba(74, 108, 247, 0.08);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --border: #e5e7eb;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* --- 护眼绿主题 --- */
.theme-green {
  --bg-primary: #f0f7f0;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8f5e9;
  --bg-hover: #dcecde;
  --text-primary: #1b3a1b;
  --text-secondary: #4a6741;
  --accent: #2e7d32;
  --accent-light: #4caf50;
  --accent-bg: rgba(46, 125, 50, 0.08);
  --border: #c8e6c9;
}

/* --- 深色模式 --- */
.theme-dark {
  --bg-primary: #1a1a2e;
  --bg-secondary: #232342;
  --bg-tertiary: #2a2a4a;
  --bg-hover: #33335a;
  --text-primary: #e4e4ef;
  --text-secondary: #a0a0c0;
  --text-muted: #707090;
  --accent: #6b8aff;
  --accent-light: #8aa0ff;
  --accent-bg: rgba(107, 138, 255, 0.12);
  --border: #3a3a5a;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

/* --- 暖黄主题 --- */
.theme-warm {
  --bg-primary: #fdf8f0;
  --bg-secondary: #fffcf5;
  --bg-tertiary: #f5ede0;
  --bg-hover: #efe5d4;
  --text-primary: #4a3c28;
  --text-secondary: #8a7355;
  --accent: #d4882a;
  --accent-light: #f0a040;
  --accent-bg: rgba(212, 136, 42, 0.10);
  --border: #e8dcc8;
}

/* --- 高对比主题 --- */
.theme-contrast {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #1a1a1a;
  --bg-hover: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --text-muted: #888888;
  --accent: #00ddff;
  --accent-light: #44eeff;
  --accent-bg: rgba(0, 221, 255, 0.15);
  --success: #00ff44;
  --error: #ff3333;
  --border: #333333;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ===== 自定义标题栏拖拽区 ===== */
.titlebar-drag {
  -webkit-app-region: drag;
  height: 38px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
}

/* ===== App 容器 ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-top: 38px;
  overflow: hidden;
}

/* ===== 顶部导航栏 ===== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
}

.navbar-logo .logo-icon {
  font-size: 24px;
}
.navbar-logo img {
  border-radius: 6px;
}

.navbar-score {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--accent-bg);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.navbar-nav {
  display: flex;
  gap: 4px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--accent-bg); color: var(--accent); }

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ===== 页面切换 ===== */
.page { display: none; }
.page.active { display: block; }

/* 登录/忘记密码页面：填充#app容器并支持滚动 */
#page-login.active,
#page-forgot-password.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

/* ===== 首页 ===== */
.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius);
  color: white;
  margin-bottom: 24px;
}

.home-hero-left h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.home-hero-left p {
  font-size: 15px;
  opacity: 0.9;
  margin-bottom: 20px;
}

.home-hero-stats {
  display: flex;
  gap: 32px;
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  font-size: 24px;
  font-weight: 700;
}

.hero-stat-label {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

.btn-continue {
  padding: 14px 32px;
  background: white;
  color: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-continue:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* 阶段网格 */
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stage-card {
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.stage-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.stage-card.locked { opacity: 0.5; cursor: not-allowed; }
.stage-card.locked:hover { border-color: var(--border); box-shadow: none; }
.stage-card.current { border-color: var(--accent); background: var(--accent-bg); }

.stage-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stage-card-title {
  font-size: 16px;
  font-weight: 600;
}

.stage-card-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
}

.stage-card-badge.locked { background: var(--bg-tertiary); color: var(--text-muted); }
.stage-card-badge.completed { background: var(--success-bg); color: var(--success); }

.stage-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.stage-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.stage-card-progress {
  margin-top: 8px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.stage-card-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* 快捷入口 */
.quick-entry {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.quick-card {
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 16px;
}

.quick-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.quick-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.quick-card-info h3 { font-size: 15px; margin-bottom: 4px; }
.quick-card-info p { font-size: 13px; color: var(--text-secondary); }

/* ===== 阶段选择页 ===== */
.level-select-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.btn-back {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--transition);
}

.btn-back:hover { background: var(--bg-hover); }

.stage-info-block {
  flex: 1;
}

.stage-info-block h2 { font-size: 22px; margin-bottom: 4px; }
.stage-info-block p { font-size: 14px; color: var(--text-secondary); }

.level-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.level-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.level-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.level-item.locked { opacity: 0.5; cursor: not-allowed; }
.level-item.locked:hover { border-color: var(--border); box-shadow: none; }
.level-item.completed { border-left: 3px solid var(--success); }

.level-item-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.level-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.level-number.completed { background: var(--success-bg); color: var(--success); }
.level-number.locked { background: var(--bg-tertiary); color: var(--text-muted); }

.level-info h3 { font-size: 15px; margin-bottom: 2px; }
.level-info p { font-size: 13px; color: var(--text-secondary); }

.level-item-right {
  text-align: right;
}

.level-score { font-size: 14px; font-weight: 600; color: var(--accent); }
.level-status { font-size: 12px; color: var(--text-muted); }

/* ===== 练习页面 ===== */
.practice-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 98px);
  min-height: 0;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  flex: 0 0 auto;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px 12px;
  text-align: center;
}

.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin: 0 0 2px; }
.stat-card .stat-value { font-size: 30px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.keyboard-area {
  display: flex;
  gap: 12px;
  flex: 0 0 auto;
  align-items: stretch;
}

.keyboard-area .virtual-keyboard { flex: 1; min-width: 0; }

/* ===== 练习文本区：基础结构（让它吃剩余空间，不锁高度，不抢键盘） ===== */
.practice-text-area {
  flex: 0 0 auto;
  max-height: 160px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  position: relative;
}
/* 场景装饰层（固定在背景，不参与滚动） */
.practice-scene-decor { position:absolute; inset:0; pointer-events:none; overflow:hidden; z-index:0; }
/* 顶部任务栏：现在只放进度胶囊，压缩到极致 */
.practice-stage-taskbar { position:relative; z-index:1; margin-bottom: 0; flex-shrink:0; min-height:0; }
.practice-text-display {
  position:relative; z-index:1;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 4px 2px;
  display:flex;
  align-items:flex-start;
  justify-content:flex-start;
  flex-wrap:wrap;
  align-content:flex-start;
}
.practice-stage-progress-decor { position:relative; z-index:1; margin-top:0 !important; min-height:0 !important; flex-shrink:0; padding:0 !important; height:0 !important; display:none !important; }

.practice-text-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px; position:relative; z-index:2;
  min-height: 0;
}
.practice-level-label { font-size: 26px; font-weight: 600; color: var(--text-secondary); line-height: 1.2; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.practice-timer { font-size: 16px; font-weight: 600; color: var(--accent); font-family: var(--font-mono); }

/* 字符状态通用 + ★ 空格显示可见符 */
.char-correct { color: var(--success); }
.char-incorrect { color: var(--error); background: var(--error-bg); border-radius: 2px; }
.char-pending { color: var(--text-muted); }
.char-current { color: var(--text-primary); border-bottom: 3px solid var(--accent); animation: blink 1s infinite; }
/* 空格可见符：打空格键时显示 ␣，颜色稍淡，提示用户这是需要按的键 */
.space-visible { color: var(--text-muted); opacity: 0.55; font-size: 0.8em; padding: 0 2px; }
.word-space { display: inline; }
@keyframes blink { 0%, 50% { opacity:1; } 51%, 100% { opacity:0.55; } }

/* ============ 通用一行式任务栏：现在只有进度胶囊，不再重复标题 ============ */
.taskbar-row {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.taskbar-row .tb-title { display:none; }
.taskbar-row .tb-right { display:flex; align-items:center; gap:10px; flex-shrink: 0; }
.taskbar-row .tb-extra { display:flex; align-items:center; gap:2px; font-size: 14px; }
.taskbar-row .tb-progress {
  position:relative;
  width: 300px;
  min-width: 200px;
  height: 25px;
  border-radius: 7px;
  overflow:hidden;
  background: #f1f5f9;
}
.taskbar-row .tb-progress-fill { position:absolute; inset:0 auto 0 0; background:linear-gradient(90deg, #60a5fa, #f472b6, #fbbf24); transition:width 0.35s ease; }
.taskbar-row .tb-progress-text { position:relative; text-align:center; line-height:20px; font-size:16px; font-weight:700; color:#fff; text-shadow:0 1px 2px rgba(0,0,0,0.25); }
.taskbar-row .tb-hero { position:relative; font-size: 16px; margin-right: 2px; }
.taskbar-row .tb-hero-item { position:absolute; top:-5px; right:-5px; font-size: 10px; }
/* 各阶段主题色（只改进度胶囊和extra）*/
.taskbar-row.tb-cute   .tb-progress { background:#fee2e2; }
.taskbar-row.tb-doodle .tb-progress { background:#ffedd5; }
.taskbar-row.tb-doodle .tb-progress-fill { background:linear-gradient(90deg,#fb923c,#facc15); }
.taskbar-row.tb-school .tb-progress { background:#e2e8f0; }
.taskbar-row.tb-school .tb-progress-fill { background:linear-gradient(90deg,#fb923c,#f97316); }
.taskbar-row.tb-tech   .tb-progress { background:#1e293b; border:1px solid #334155; }
.taskbar-row.tb-tech   .tb-progress-fill { background:linear-gradient(90deg,#4ade80,#22d3ee); box-shadow:0 0 6px rgba(74,222,128,0.7); }
.taskbar-row.tb-pro    .tb-progress { background:#0f172a; border:1px solid #1f2937; }
.taskbar-row.tb-pro    .tb-progress-text { font-family:var(--font-mono); }
.taskbar-row.tb-pro    .tb-progress-fill { background:linear-gradient(90deg,#6366f1,#06b6d4); }

/* ============ 阶段1：流式句子（去卡片）============ */
/* 背景场景依旧保留（天空草地）但装饰压低高度避免浪费 */
.content-stage-cute .scene-sky { height: 36%; opacity:0.5; }        /* 从50%压到36% */
.content-stage-cute .scene-mountains { bottom: 28%; font-size:24px; letter-spacing:30px; }   /* 之前是bottom:36%+30px，现在整体靠下移点+小一点 */
.content-stage-cute .scene-fence { bottom: 18%; font-size:14px; letter-spacing:6px; }
.content-stage-cute .scene-grass { font-size:12px; letter-spacing:4px; opacity:0.6; padding-bottom:2px; }
.content-stage-cute .s1-sun { font-size: 30px; top: 8px; right: 14px; }
.content-stage-cute .s1-cloud { font-size: 20px; }

/* 流式句子行：句子与句子之间保留空格，不加卡片 */
.stage1-sentence-flow {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 30px;
  line-height: 1.65;
  padding: 4px 6px;
  color: #0f172a;
  text-align: left;
}
.s1-word-chunk {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border-radius: 6px;
  margin-bottom: 2px;
  position: relative;
  transition: all 0.2s ease;
}
.s1-word-chunk.active { background: rgba(244,114,182,0.15);   /* 代替方框卡片：当前词高亮粉色背景 */
                        box-shadow: 0 0 0 2px #f472b6; transform: scale(1.02); z-index: 2; }
.s1-word-chunk.done   { background: rgba(34,197,94,0.12); color: #166534; }
.s1-word-chunk.done.active { box-shadow: 0 0 0 2px #22c55e; }
.s1-word-chunk .wc-hero { font-size: 15px; }
.s1-word-chunk .wc-item { font-size: 15px; }
.s1-word-chunk .wc-item.got { animation: bounce-pop 0.5s; }
.s1-word-chunk .wc-word { font-weight: 700; letter-spacing: 0.8px; }

/* ============ 阶段2：手账涂鸦内容区（流式） ============ */
.content-stage-doodle, .content-stage-school { background: #fffbeb; background-image: repeating-linear-gradient(180deg, transparent 0 22px, #fde68a 22px 23px), linear-gradient(90deg, rgba(251,191,36,0.08) 1px, transparent 1px); background-size: 100% 100%, 28px 100%; border: 3px solid #fbbf24; box-shadow: 4px 4px 0 #fcd34d, inset 0 0 0 2px #fff; background-position: 0 4px; }
.scene-doodle-corner { position:absolute; font-size:20px; opacity:0.7; }       /* 26→20缩小 */
.scene-doodle-corner.tl { top:8px; left:10px; transform:rotate(-12deg); }
.scene-doodle-corner.tr { top:10px; right:12px; transform:rotate(15deg); }
.scene-doodle-corner.bl { bottom:10px; left:14px; transform:rotate(8deg); }
.scene-doodle-corner.br { bottom:14px; right:10px; transform:rotate(-20deg); }

/* 阶段2流式句子：每个词只是贴纸+文字，不加卡片方框 */
.stage2-sentence-flow {
  width: 100%;
  font-family: 'Comic Sans MS','Segoe Print',cursive;
  font-size: 30px; font-weight: 600; color: #44403c;
  line-height: 1.65;
  padding: 4px 6px;
  text-align: left;
}
.s2-word-chunk {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 1px 3px;
  border-radius: 4px;
  margin-bottom: 2px;
  transition: all 0.18s ease;
}
.s2-word-chunk.active { background: #fff7ed; box-shadow: 0 0 0 2px #ea580c dashed; transform: scale(1.02); z-index: 2; }
.s2-word-chunk.done   { background: #dcfce7; color: #166534; }
.s2-word-chunk .wc-sticker { font-size: 13px; transform: translateY(-4px) rotate(-10deg); margin-right: 1px; }

/* ============ 阶段3：校园活力内容区（复用阶段2手账涂鸦风样式，仅词前不显示贴纸图标） ============ */

/* ============ 阶段4：内容区样式与阶段5保持一致 ============ */
.content-stage-minimal .scene-arena-grid, .content-stage-tech .scene-arena-grid, .content-stage-pro .scene-arena-grid { background-size:24px 24px; }
.content-stage-minimal .scene-arena-label, .content-stage-tech .scene-arena-label, .content-stage-pro .scene-arena-label { top:8px; left:10px; font-size:9px; }
.content-stage-minimal .scene-arena-glow, .content-stage-tech .scene-arena-glow, .content-stage-pro .scene-arena-glow { width:180px; height:180px; filter:blur(60px); }
.content-stage-minimal .scene-arena-glow.tl, .content-stage-tech .scene-arena-glow.tl, .content-stage-pro .scene-arena-glow.tl { top:-60px; left:-60px; }
.content-stage-minimal .scene-arena-glow.br, .content-stage-tech .scene-arena-glow.br, .content-stage-pro .scene-arena-glow.br { bottom:-60px; right:-60px; }
.stage5-arena-wrap { width:100%; padding:8px 12px; font-family:'Consolas','JetBrains Mono',monospace; font-size:30px; line-height:1.8; letter-spacing:1.1px; color:#e2e8f0; text-align:left; }

/* ============ 阶段6：内容区样式与阶段5保持一致 ============ */
.content-stage-pro { background:var(--bg-secondary); border:1px solid var(--border); }
.stage6-editor-wrap { width:100%; padding:8px 12px; font-family:'Consolas','JetBrains Mono',monospace; font-size:30px; line-height:1.8; letter-spacing:1.1px; color:#e2e8f0; text-align:left; }

/* 实时统计栏（压缩高度，给键盘腾空间） */
.stats-bar {
  display: flex;
  gap: 20px;
  padding: 10px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 0 0 auto;         /* 不参与flex空间分配，自身高度固定 */
  min-height: 0;
}

.stat-item { text-align: center; flex: 1; }
.stat-value { font-size: 20px; font-weight: 700; font-family: var(--font-mono); line-height: 1.1; }
.stat-value.wpm { color: var(--accent); }
.stat-value.accuracy { color: var(--success); }
.stat-value.combo { color: var(--warning); }
.stat-value.time { color: var(--text-secondary); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* 虚拟键盘：高度提高 40px，让按键和图例有更充分的显示空间 */
.virtual-keyboard {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  flex: 0 0 auto;
  min-height: 200px;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.virtual-keyboard.stage-cute   { min-height: 250px; padding: 14px; }
.virtual-keyboard.stage-doodle { min-height: 220px; }
.virtual-keyboard.stage-school { min-height: 220px; }
.virtual-keyboard.stage-minimal{ min-height: 200px; }
.virtual-keyboard.stage-tech   { min-height: 200px; }
.virtual-keyboard.stage-pro    { min-height: 200px; }

/* ===== 模拟手型指法引导层 ===== */
.hands-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}
.hands-overlay .hand-palm {
  fill: rgba(255,255,255,0.10);
  stroke: rgba(148,163,184,0.55);
  stroke-width: 1.5;
}
.hands-overlay .hand-finger {
  fill: rgba(255,255,255,0.14);
  stroke: rgba(148,163,184,0.6);
  stroke-width: 1.5;
  transition: fill 0.15s ease, stroke 0.15s ease, filter 0.15s ease;
}
/* 各阶段手型风格：低阶（1-3）明显醒目，高阶（4-6）半透明科技感 */
.virtual-keyboard.stage-cute .hands-overlay,
.virtual-keyboard.stage-doodle .hands-overlay { opacity: 0.95; }
.virtual-keyboard.stage-school .hands-overlay { opacity: 0.8; }
.virtual-keyboard.stage-minimal .hands-overlay,
.virtual-keyboard.stage-tech .hands-overlay,
.virtual-keyboard.stage-pro .hands-overlay { opacity: 0.55; }
.virtual-keyboard .keyboard-row .keyboard-key.side-key { width: 80px; font-size: 11px; }
.virtual-keyboard .keyboard-row .keyboard-key.space-key { width: 240px; letter-spacing: 2px; }
.virtual-keyboard .keyboard-row.space-row .keyboard-key { height: 36px; }

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 5px;
  flex: 0 0 auto;
  min-height: 0;
}
.keyboard-row:last-child { margin-bottom: 0; }

.keyboard-key {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  transition: all 0.1s ease;
  box-sizing: border-box;
}

.keyboard-key.wide { width: 60px; }
.keyboard-key.extra-wide { width: 180px; }
.keyboard-key.tab { width: 54px; }

.keyboard-key.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--accent-bg);
}

.keyboard-key.pressed {
  background: var(--accent);
  color: white;
  transform: translateY(1px);
}

.keyboard-key.next-key {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-bg); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

/* ===== 6阶段键盘主题样式 ===== */
/* 通用键子元素 */
.keyboard-key .kb-main { display: block; font-size: 15px; font-weight: 700; }
.keyboard-key .kb-ip { display: block; font-size: 11px; line-height: 1; margin-top: 2px; opacity: 0.85; }
.keyboard-key .kb-ip-outline { display: block; font-size: 11px; line-height: 1; margin-top: 2px; opacity: 0.45; filter: grayscale(0.3); }
.keyboard-key .kb-finger-dot { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; }
.keyboard-key { position: relative; }
.keyboard-key.fj-mark::after { content: ''; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); width: 10px; height: 2px; background: var(--text-muted); border-radius: 1px; }

/* 手指颜色背景映射 */
.finger-bg-lp { background: #e0f2fe; }
.finger-bg-lr { background: #dcfce7; }
.finger-bg-lm { background: #ffedd5; }
.finger-bg-li { background: #dbeafe; }
.finger-bg-ri { background: #fce7f3; }
.finger-bg-rm { background: #f3e8ff; }
.finger-bg-rr { background: #fef3c7; }
.finger-bg-rp { background: #ffe4e6; }

/* ===== 阶段1：萌趣具象风（cute）===== */
.virtual-keyboard.stage-cute {
  background: linear-gradient(135deg, #fff5f7, #fef3c7);
  border: 2px dashed #fbbf24;        /* 从3px缩小 */
  border-radius: 18px;               /* 从24px缩小 */
  padding: 12px;
}
.virtual-keyboard.stage-cute .keyboard-row { gap: 6px; margin-bottom: 6px; }
.virtual-keyboard.stage-cute .keyboard-key {
  width: 42px; height: 42px;         /* 从52缩小到42 */
  border: 2px solid #fff;
  border-radius: 12px;               /* 从14缩小 */
  box-shadow: 0 3px 0 rgba(0,0,0,0.08), inset 0 2px 4px rgba(255,255,255,0.5);
  font-size: 14px; color: #475569;
  font-weight: 700;
  transition: transform 0.15s cubic-bezier(0.68, -0.55, 0.27, 1.55), box-shadow 0.15s;
  flex-direction: column;
  padding: 2px 0;
}
.virtual-keyboard.stage-cute .keyboard-key.tab, .virtual-keyboard.stage-cute .keyboard-key.extra-wide { width: 180px; }
.virtual-keyboard.stage-cute .keyboard-key .kb-main { font-size: 13px; }
.virtual-keyboard.stage-cute .keyboard-key .kb-ip { font-size: 11px; }
.virtual-keyboard.stage-cute .keyboard-key.next-key {
  border: 3px solid #f472b6;
  transform: scale(1.05);     /* 从1.1缩小，避免挤破布局 */
  box-shadow: 0 0 16px rgba(244, 114, 182, 0.45), 0 4px 0 rgba(0,0,0,0.1);
  background: linear-gradient(135deg, #fecdd3, #fda4af);
  animation: cute-bounce 0.6s ease infinite;
  color: #881337;
  z-index: 2;
}
@keyframes cute-bounce {
  0%, 100% { transform: scale(1.05) translateY(0); }
  50% { transform: scale(1.08) translateY(-3px); }
}
.virtual-keyboard.stage-cute .keyboard-key.finger-highlight {
  box-shadow: 0 0 0 3px var(--finger-color, #f472b6), 0 4px 0 rgba(0,0,0,0.08);
}
.virtual-keyboard.stage-cute .keyboard-key.pressed {
  transform: scale(0.95) translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}
.virtual-keyboard.stage-cute .finger-legend {
  display: flex; justify-content: center; gap: 12px; margin-top: 12px; flex-wrap: wrap;
  padding-top: 12px; border-top: 2px dashed #fcd34d;
}
.virtual-keyboard.stage-cute .finger-legend-group {
  display: flex; align-items: center; gap: 6px;
}
.virtual-keyboard.stage-cute .legend-hand {
  font-size: 12px; font-weight: 600; color: #64748b; margin-right: 4px;
}
.virtual-keyboard.stage-cute .legend-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 10px; font-size: 11px; color: #475569; font-weight: 500;
}
.virtual-keyboard.stage-cute .legend-dot {
  width: 8px; height: 8px; border-radius: 50%;
}

/* ===== 阶段2：手账涂鸦风（doodle）===== */
.virtual-keyboard.stage-doodle {
  background: #fffbeb;
  border: 2px solid #fbbf24;
  border-radius: 4px;
  padding: 12px;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 27px, #fde68a 27px, #fde68a 28px);
}
.virtual-keyboard.stage-doodle .keyboard-row { gap: 4px; margin-bottom: 4px; }
.virtual-keyboard.stage-doodle .keyboard-key {
  width: 40px; height: 40px;          /* 从46缩小 */
  border: 2px solid #78716c;
  border-radius: 6px;
  background: rgba(255,255,255,0.7);
  font-family: 'Comic Sans MS', 'Segoe Print', cursive, var(--font-mono);
  font-size: 14px; color: #44403c;
  box-shadow: 2px 2px 0 rgba(120, 113, 108, 0.3);
  transition: all 0.12s ease;
  transform: rotate(-0.3deg);
}
.virtual-keyboard.stage-doodle .keyboard-key.tab, .virtual-keyboard.stage-doodle .keyboard-key.extra-wide { width: 180px; }
.virtual-keyboard.stage-doodle .keyboard-key.next-key {
  border: 2.5px dashed #ea580c;
  border-radius: 10px;
  animation: doodle-breath 1.5s ease-in-out infinite;
  background: rgba(254, 215, 170, 0.5);
}
@keyframes doodle-breath {
  0%, 100% { box-shadow: 2px 2px 0 rgba(120,113,108,0.3), 0 0 0 0 rgba(234, 88, 12, 0.4); }
  50% { box-shadow: 2px 2px 0 rgba(120,113,108,0.3), 0 0 0 4px rgba(234, 88, 12, 0.15); }
}
.virtual-keyboard.stage-doodle .keyboard-key.finger-highlight {
  border-color: var(--finger-color, #ea580c);
  background: var(--finger-color, #fed7aa) !important;
  opacity: 0.75;
}
.virtual-keyboard.stage-doodle .keyboard-key.pressed {
  transform: translateY(2px) rotate(0deg);
  box-shadow: 0 0 0 rgba(120,113,108,0.3);
  background: #fed7aa;
}

/* ===== 阶段3：校园活力风（school）===== */
.virtual-keyboard.stage-school {
  background: linear-gradient(180deg, #eff6ff, #ffffff);
  border: 1px solid #bfdbfe;
  border-radius: 10px;             /* 从12缩小 */
  padding: 12px;
}
.virtual-keyboard.stage-school .keyboard-row { gap: 5px; margin-bottom: 5px; }
.virtual-keyboard.stage-school .keyboard-key {
  width: 40px; height: 40px;       /* 从46缩小 */
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;              /* 从8缩小 */
  background: #ffffff;
  font-size: 13px; color: #334155;
  font-weight: 600;
  box-shadow: 0 2px 0 #e2e8f0;
  transition: all 0.1s ease;
}
.virtual-keyboard.stage-school .keyboard-key.tab, .virtual-keyboard.stage-school .keyboard-key.extra-wide { width: 180px; }
.virtual-keyboard.stage-school .keyboard-key.next-key {
  background: var(--finger-color, #3b82f6);
  border-color: var(--finger-color, #3b82f6);
  color: white;
  box-shadow: 0 2px 0 rgba(0,0,0,0.1), 0 0 12px color-mix(in srgb, var(--finger-color, #3b82f6) 50%, transparent);
  animation: school-flash 0.8s ease-in-out infinite;
}
@keyframes school-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}
.virtual-keyboard.stage-school .keyboard-key.finger-highlight {
  border-color: var(--finger-color, #3b82f6);
}
.virtual-keyboard.stage-school .keyboard-key.pressed {
  transform: translateY(2px);
  box-shadow: 0 0 0 #e2e8f0;
  background: #1e40af;
  color: white;
}
.virtual-keyboard.stage-school .keyboard-key .kb-finger-dot {
  width: 8px; height: 8px;
  box-shadow: 0 0 4px currentColor;
}

/* ===== 阶段4：键盘样式与阶段5保持一致 ===== */
.virtual-keyboard.stage-minimal {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.1), inset 0 0 60px rgba(0,0,0,0.5);
}
.virtual-keyboard.stage-minimal .keyboard-row { gap: 5px; margin-bottom: 5px; }
.virtual-keyboard.stage-minimal .keyboard-key {
  width: 40px; height: 40px;
  border: 1px solid #475569;
  border-radius: 4px;
  background: #334155;
  font-size: 12px; color: #94a3b8;
  font-weight: 500;
  box-shadow: inset 0 -3px 0 #1e293b, 0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.08s ease;
}
.virtual-keyboard.stage-minimal .keyboard-key.tab, .virtual-keyboard.stage-minimal .keyboard-key.extra-wide { width: 180px; }
.virtual-keyboard.stage-minimal .keyboard-key.next-key {
  border-color: #22c55e;
  background: #166534;
  color: #4ade80;
  box-shadow: inset 0 -3px 0 #14532d, 0 0 15px rgba(34, 197, 94, 0.6), 0 0 30px rgba(34, 197, 94, 0.3);
  animation: tech-neon 0.5s ease-in-out infinite;
  text-shadow: 0 0 8px #4ade80;
}
.virtual-keyboard.stage-minimal .keyboard-key.pressed {
  background: #4ade80;
  color: #0f172a;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.3), 0 0 12px rgba(74, 222, 128, 0.6);
  transform: translateY(2px);
}

/* ===== 阶段5：竞技科技风（tech） ===== */
.virtual-keyboard.stage-tech {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.1), inset 0 0 60px rgba(0,0,0,0.5);
}
.virtual-keyboard.stage-tech .keyboard-row { gap: 5px; margin-bottom: 5px; }
.virtual-keyboard.stage-tech .keyboard-key {
  width: 40px; height: 40px;          /* 从44缩小 */
  border: 1px solid #475569;
  border-radius: 4px;
  background: #334155;
  font-size: 12px; color: #94a3b8;
  font-weight: 500;
  box-shadow: inset 0 -3px 0 #1e293b, 0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.08s ease;
}
.virtual-keyboard.stage-tech .keyboard-key.tab, .virtual-keyboard.stage-tech .keyboard-key.extra-wide { width: 180px; }
.virtual-keyboard.stage-tech .keyboard-key.next-key {
  border-color: #22c55e;
  background: #166534;
  color: #4ade80;
  box-shadow: inset 0 -3px 0 #14532d, 0 0 15px rgba(34, 197, 94, 0.6), 0 0 30px rgba(34, 197, 94, 0.3);
  animation: tech-neon 0.5s ease-in-out infinite;
  text-shadow: 0 0 8px #4ade80;
}
@keyframes tech-neon {
  0%, 100% { box-shadow: inset 0 -3px 0 #14532d, 0 0 15px rgba(34, 197, 94, 0.6); }
  50% { box-shadow: inset 0 -3px 0 #14532d, 0 0 25px rgba(34, 197, 94, 0.8), 0 0 40px rgba(34, 197, 94, 0.4); }
}
.virtual-keyboard.stage-tech .keyboard-key.tech-highlight {
  border-color: #4ade80;
  box-shadow: inset 0 -3px 0 #14532d, 0 0 12px rgba(34, 197, 94, 0.4);
}
.virtual-keyboard.stage-tech .keyboard-key.pressed {
  background: #4ade80;
  color: #0f172a;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.3), 0 0 12px rgba(74, 222, 128, 0.6);
  transform: translateY(2px);
}

/* ===== 阶段6：键盘样式与阶段5保持一致 ===== */
.virtual-keyboard.stage-pro {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.1), inset 0 0 60px rgba(0,0,0,0.5);
}
.virtual-keyboard.stage-pro .keyboard-row { gap: 5px; margin-bottom: 5px; }
.virtual-keyboard.stage-pro .keyboard-key {
  width: 40px; height: 40px;
  border: 1px solid #475569;
  border-radius: 4px;
  background: #334155;
  font-size: 12px; color: #94a3b8;
  font-weight: 500;
  box-shadow: inset 0 -3px 0 #1e293b, 0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.08s ease;
}
.virtual-keyboard.stage-pro .keyboard-key.tab, .virtual-keyboard.stage-pro .keyboard-key.extra-wide { width: 180px; }
.virtual-keyboard.stage-pro .keyboard-key.next-key {
  border-color: #22c55e;
  background: #166534;
  color: #4ade80;
  box-shadow: inset 0 -3px 0 #14532d, 0 0 15px rgba(34, 197, 94, 0.6), 0 0 30px rgba(34, 197, 94, 0.3);
  animation: tech-neon 0.5s ease-in-out infinite;
  text-shadow: 0 0 8px #4ade80;
}
.virtual-keyboard.stage-pro .keyboard-key.pressed {
  background: #4ade80;
  color: #0f172a;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.3), 0 0 12px rgba(74, 222, 128, 0.6);
  transform: translateY(2px);
}

/* ===== 通用：真实键盘风格（阶段4-6） ===== */
.virtual-keyboard.real-kb .keyboard-key.wide { width: 60px; }

/* ===== 手指图例（阶段1） ===== */
.virtual-keyboard.stage-cute .finger-legend {
  display: flex; justify-content: center; gap: 8px; margin-top: 8px; flex-wrap: wrap;
  padding-top: 8px; border-top: 2px dashed #fcd34d;
}
.virtual-keyboard.stage-cute .finger-legend-group { display: flex; align-items: center; gap: 4px; }
.virtual-keyboard.stage-cute .legend-hand { font-size: 11px; font-weight: 600; color: #64748b; margin-right: 3px; }
.virtual-keyboard.stage-cute .legend-item { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 8px; font-size: 10px; color: #475569; font-weight: 500; }
.virtual-keyboard.stage-cute .legend-dot { width: 6px; height: 6px; border-radius: 50%; }
.virtual-keyboard:not(.stage-cute) .finger-legend { display: none; }


/* 右侧进度面板 */
.progress-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.progress-panel h3 {
  font-size: 15px;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.stage-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all var(--transition);
}

.tree-item.current { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.tree-item.completed { color: var(--success); }
.tree-item.locked { color: var(--text-muted); }

.tree-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tree-dot.completed { background: var(--success); }
.tree-dot.current { background: var(--accent); }
.tree-dot.locked { background: var(--text-muted); }

.practice-actions {
  flex: 0 0 230px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-bottom: 6px;
}

.btn-action {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-action:hover { background: var(--bg-hover); }
.btn-action.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-action.primary:hover { background: var(--accent-light); }

/* ===== 结果页 ===== */
.result-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.result-overlay.show { display: flex; }

.result-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 40px;
  width: 480px;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.result-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.result-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.result-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.result-stat {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.result-stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.result-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.score-breakdown {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.score-breakdown-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.score-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  color: var(--text-secondary);
}

.score-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
}

.result-actions {
  display: flex;
  gap: 12px;
}

.result-actions button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-next { background: var(--accent); color: white; }
.btn-next:hover { background: var(--accent-light); }
.btn-retry { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-retry:hover { background: var(--bg-hover); }

/* ===== 数据中心 ===== */
.data-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.data-card {
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.data-card-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
}

.data-card-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.chart-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.chart-canvas {
  width: 100%;
  height: 200px;
}

.error-keys-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.error-key-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.error-key-char {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  width: 32px;
  text-align: center;
}

.error-key-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
}

.error-key-bar-fill {
  height: 100%;
  background: var(--error);
  border-radius: 4px;
}

.error-key-count {
  font-size: 13px;
  color: var(--text-muted);
  width: 60px;
  text-align: right;
}

/* ===== 设置页 ===== */
.settings-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px;
  width: 100%;
}

.settings-list .setting-item {
  width: 100% !important;
  margin-bottom: 0 !important;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.setting-info h3 { font-size: 15px; margin-bottom: 2px; }
.setting-info p { font-size: 13px; color: var(--text-secondary); }

/* Toggle 开关 */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle.on { background: var(--accent); }

.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle.on::after { transform: translateX(20px); }

/* 主题选择 */
.theme-selector {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-option {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  min-width: 100px;
}

.theme-option:hover { border-color: var(--accent); }
.theme-option.active { border-color: var(--accent); background: var(--accent-bg); }
.theme-option.owned { }
.theme-option.locked { opacity: 0.6; }

.theme-option-name { font-size: 14px; font-weight: 500; }
.theme-option-cost { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== 里程碑提示 ===== */
.milestone-toast {
  position: fixed;
  top: 110px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* ===== 准备遮罩 ===== */
.practice-ready-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.7);
  z-index: 10;
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 500;
}

.theme-dark .practice-ready-overlay { background: rgba(26,26,46,0.7); }
.theme-contrast .practice-ready-overlay { background: rgba(0,0,0,0.7); }
.theme-warm .practice-ready-overlay { background: rgba(253,248,240,0.7); }
.theme-green .practice-ready-overlay { background: rgba(240,247,240,0.7); }

/* ===== 每日挑战 ===== */
.daily-banner {
  padding: 24px 32px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  border-radius: var(--radius);
  color: white;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.daily-banner.completed {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.daily-banner-info h2 { font-size: 20px; margin-bottom: 4px; }
.daily-banner-info p { font-size: 14px; opacity: 0.9; }

.daily-start-btn {
  padding: 12px 28px;
  background: white;
  color: #f59e0b;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
}

.daily-start-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.daily-start-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .practice-layout { height: auto; min-height: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .keyboard-area { flex-direction: column; }
  .practice-actions { flex: none; padding-bottom: 0; }
  /* 小屏时为了键盘完整显示，直接按阶段1的最大高度兜底 */
  .virtual-keyboard { min-height: 420px !important; overflow-x: auto; }
  .virtual-keyboard .keyboard-row { justify-content: flex-start; }
  .stage-grid { grid-template-columns: repeat(2, 1fr); }
  .data-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 登录/注册页 ===== */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 20px;
  background: linear-gradient(135deg, #e8eaf0 0%, #f5f6fa 50%, #eef0f5 100%);
}

.auth-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 32px 30px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  margin: 20px auto;
}

.auth-logo {
  text-align: center;
  margin-bottom: 8px;
}
.auth-logo .logo-icon { font-size: 40px; display: inline-block; }
.auth-logo .logo-icon img { width: 56px; height: 56px; border-radius: 12px; }
.auth-logo .logo-icon img { width: 56px; height: 56px; }
.auth-logo h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-top: 4px; }

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}
.auth-tab.active {
  background: var(--bg-secondary);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.auth-form .form-group { margin-bottom: 16px; }
.auth-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.auth-form input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: var(--transition);
  box-sizing: border-box;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-secondary);
}

.btn-auth {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
  margin-bottom: 4px;
}
.btn-auth:hover { background: var(--accent-light); transform: translateY(-1px); }
.btn-auth:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-error {
  background: var(--error-bg);
  color: var(--error);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

/* ===== 验证码输入组合 ===== */
.input-btn-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-btn-row input {
  flex: 1;
  width: auto;
  min-width: 0;
}
.btn-send-code {
  padding: 0 14px;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  min-width: 100px;
  line-height: 1;
}
.btn-send-code:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}
.btn-send-code:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== 登录/注册额外行 ===== */
.auth-extra-row {
  margin-top: 12px;
  text-align: center;
}
.auth-link {
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

/* ===== 通用弹窗 ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 440px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalFadeIn 0.2s ease-out;
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  border: none; background: transparent;
  color: var(--text-muted);
  font-size: 22px; line-height: 1;
  cursor: pointer; border-radius: 6px;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.modal-footer .btn-action { min-width: 88px; }

/* 弹窗中的表单样式 */
.modal-body .form-group { margin-bottom: 16px; }
.modal-body label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.modal-body input,
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: border-color 0.15s;
  box-sizing: border-box;
  font-family: inherit;
}
.modal-body textarea { resize: vertical; min-height: 100px; line-height: 1.5; }
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== 按钮通用 ===== */
.btn-action {
  padding: 10px 20px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-action:hover { background: var(--bg-hover); }
.btn-action.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-action.primary:hover { background: var(--accent-light); }
.btn-action:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-offline {
  margin-top: 20px;
  text-align: center;
}
.btn-offline {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}
.btn-offline:hover { color: var(--text-secondary); }

.auth-server-config {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.auth-server-config label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}
.auth-server-config input {
  width: calc(100% - 70px);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-primary);
  box-sizing: border-box;
}
.btn-sm {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
}
.btn-sm:hover { background: var(--accent-light); }

.auth-company {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== 导航栏用户区 ===== */
.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  /* 确保下拉菜单的堆叠上下文正确，不被其他导航元素遮挡 */
  z-index: 100;
  /* 防止 transform 导致的层叠问题 */
  backface-visibility: hidden;
}

.user-avatar-wrapper {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  background: var(--accent-bg);
}

.user-avatar-wrapper:hover {
  transform: scale(1.08);
}

.user-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar-placeholder {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  /* 默认显示作为 JS 未执行时的兜底 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sync-status {
  font-size: 16px;
  cursor: help;
  transition: var(--transition);
}
.nav-username {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* 用户下拉菜单 */
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  z-index: 1000;
  /* 防止下拉菜单内容被裁剪 */
  overflow: visible;
}

.user-dropdown.show {
  display: block;
}

.dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.dropdown-header .dropdown-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

/* 邮箱项：不可点击、纯展示 */
.dropdown-email-item {
  cursor: default !important;
  color: var(--text-secondary);
  font-size: 13px;
  pointer-events: none;
}

.dropdown-email-item:hover {
  background: transparent !important;
}

.dropdown-header:hover {
  background: var(--bg-hover);
}

.dropdown-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  background: var(--accent-bg);
  /* 防止图片加载失败时显示裂图边框 */
  display: none;
}

/* 下拉菜单头像文字占位符（无自定义头像时显示） */
.dropdown-avatar-placeholder {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-bg);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}



.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-logout {
  color: var(--error);
  justify-content: center;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 10px;
}

/* ===== 排行榜 ===== */
.leaderboard-container {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row:hover { background: var(--bg-hover); }
.leaderboard-row.me {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
}
.lb-rank {
  width: 50px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}
.lb-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}
.lb-score {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-right: 16px;
}
.lb-extra {
  font-size: 13px;
  color: var(--text-muted);
  text-align: right;
  width: 160px;
}

/* ===== 底部版权与备案 ===== */
.app-footer {
  flex-shrink: 0;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
}
.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.app-footer a:hover { color: var(--accent); }
.app-footer .footer-divider { color: var(--border); }
.app-footer .police-icon {
  width: 12px;
  height: 12px;
  vertical-align: -2px;
  margin-right: 3px;
}
