/**
 * 英语AI老师 - 样式表
 * 移动端优先设计，浅色主题
 */

/* ====== 基础重置 ====== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #4A90D9;
  --primary-dark: #3A7BC8;
  --primary-light: #E8F1FC;
  --success: #52c41a;
  --warning: #faad14;
  --error: #ff4d4f;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #8c8c8c;
  --text-light: #bfbfbf;
  --border: #e8e8e8;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --max-width: 480px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ====== 视图切换 ====== */
.view {
  display: none;
  min-height: 100vh;
}
.view.active {
  display: block;
}

/* ====== 通用按钮 ====== */
.btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:active { transform: scale(0.98); background: var(--primary-dark); }

.btn-secondary {
  width: 100%;
  padding: 14px 20px;
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:active { background: #f5f5f5; }

.btn-large {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-icon { font-size: 18px; }

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
}
.btn-back { font-size: 16px; }

/* ====== 登录/注册页 ====== */
#view-login {
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--bg) 100%);
}
#view-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 360px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}
.app-logo {
  font-size: 56px;
  margin-bottom: 8px;
}
.login-header h1 {
  font-size: 28px;
  color: var(--text);
}
.app-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}
.app-tagline {
  font-size: 15px;
  color: var(--primary);
  margin-top: 8px;
}

.auth-panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 24px;
}

.auth-form h2 {
  font-size: 22px;
  margin-bottom: 20px;
  text-align: center;
}
.auth-title-register { display: none; }
.auth-panel.register-mode .auth-title-login { display: none; }
.auth-panel.register-mode .auth-title-register { display: block; }

.input-group {
  margin-bottom: 16px;
}
.input-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.input-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: border-color 0.2s;
  outline: none;
}
.input-group input:focus {
  border-color: var(--primary);
}

.nickname-group { display: none; }
.auth-panel.register-mode .nickname-group { display: block; }

.btn-register-submit { display: none; }
.auth-panel.register-mode .btn-login-submit { display: none; }
.auth-panel.register-mode .btn-register-submit { display: block; }

.auth-switch {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 16px;
}
.auth-switch a,
.auth-switch .btn-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  cursor: pointer;
  font-family: inherit;
}
.auth-switch-register { display: none; }
.auth-panel.register-mode .auth-switch-login { display: none; }
.auth-panel.register-mode .auth-switch-register { display: block; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--text-light);
  font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-outline {
  width: 100%;
  padding: 12px 20px;
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-outline:active { background: #f5f5f5; }

.btn-guest {
  margin-bottom: 10px;
  color: var(--primary);
  border-color: var(--primary-light);
}
.btn-guest:hover { background: var(--primary-light); }

.btn-wechat {
  width: 100%;
  padding: 12px 20px;
  background: #07C160;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-wechat:active { background: #06AD56; }

.login-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.6);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}
.feature-item span { font-size: 18px; }

/* ====== 顶部导航 ====== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 18px;
  font-weight: 600;
}

/* ====== 首页 ====== */
.home-content {
  padding: 20px;
}

.user-card {
  background: linear-gradient(135deg, var(--primary) 0%, #6BB6FF 100%);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(74,144,217,0.3);
}
.user-card-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.user-avatar-level {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.user-info {
  flex: 1;
}
.user-info h2 {
  font-size: 20px;
  margin-bottom: 2px;
}
.user-level {
  font-size: 13px;
  opacity: 0.9;
}
.user-xp-display {
  text-align: center;
}
.xp-number {
  display: block;
  font-size: 24px;
  font-weight: 700;
}
.xp-label {
  font-size: 11px;
  opacity: 0.8;
}
.level-progress {
  height: 8px;
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.level-progress-bar {
  height: 100%;
  background: #fff;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.level-progress-text {
  font-size: 12px;
  opacity: 0.85;
}

.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  flex: 1;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 12px;
}

.record-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.record-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.record-scene {
  font-size: 14px;
  font-weight: 500;
}
.record-date {
  font-size: 12px;
  color: var(--text-light);
}
.record-detail {
  font-size: 12px;
  color: var(--text-secondary);
}
.record-score {
  font-size: 18px;
  font-weight: 700;
}

.empty-hint {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  padding: 24px 0;
}

/* ====== 场景选择 ====== */
.scene-select-content {
  padding: 16px 20px;
}
.scene-select-hint {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: center;
}

.scene-category {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--scene-color);
}
.scene-category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.scene-icon {
  font-size: 32px;
}
.scene-category-header h3 {
  font-size: 18px;
}
.scene-name-en {
  font-size: 12px;
  color: var(--text-light);
}
.scene-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.scenario-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.scenario-card:active {
  transform: scale(0.98);
  background: var(--primary-light);
}
.scenario-avatar {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 50%;
  flex-shrink: 0;
}
.scenario-info {
  flex: 1;
}
.scenario-info h4 {
  font-size: 15px;
  margin-bottom: 2px;
}
.scenario-info p {
  font-size: 12px;
  color: var(--text-secondary);
}
.scenario-difficulty {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
  font-weight: 500;
}
.difficulty-1 { background: #f6ffed; color: #52c41a; }
.difficulty-2 { background: #e6f7ff; color: #1890ff; }
.difficulty-3 { background: #fff7e6; color: #fa8c16; }
.scenario-arrow {
  font-size: 18px;
  color: var(--text-light);
}

/* ====== 对话页 ====== */
#view-dialogue {
  display: none;
  height: 100vh;
  overflow: hidden;
  flex-direction: column;
}
#view-dialogue.active {
  display: flex;
}

.dialogue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--card-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  flex-shrink: 0;
}
.dialogue-header-info {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  flex: 1;
}
.dialogue-separator {
  margin: 0 6px;
  color: var(--text-light);
}
.dialogue-timer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.dialogue-timer span:first-child {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.dialogue-timer.timer-warning span:first-child {
  color: var(--error);
  animation: pulse 1s infinite;
}
.turn-badge {
  font-size: 11px;
  color: var(--text-secondary);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.timer-progress-bar {
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}
.timer-progress {
  height: 100%;
  background: var(--primary);
  transition: width 1s linear;
}

.character-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.character-avatar-large {
  font-size: 40px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
}
.character-avatar-large.speaking {
  animation: speakingPulse 0.8s infinite;
  background: #fff3cd;
}
@keyframes speakingPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(250,173,20,0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(250,173,20,0); }
}
.character-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.character-name {
  font-size: 16px;
  font-weight: 600;
}
.character-role {
  font-size: 12px;
  color: var(--text-secondary);
}
.btn-icon-small {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.npc-message {
  align-self: flex-start;
}
.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--primary-light);
  flex-shrink: 0;
}
.user-avatar {
  background: var(--success);
  color: #fff;
  font-size: 14px;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.npc-bubble {
  background: var(--card-bg);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow);
}
.user-bubble {
  background: var(--primary);
  color: #fff;
  border-top-right-radius: 4px;
}
.message-name {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.btn-replay-mini {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  cursor: pointer;
  margin-top: 4px;
  padding: 0;
}

/* 纠错消息 */
.correction-message {
  align-self: stretch;
  max-width: 100%;
}
.correction-bubble {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  border-radius: var(--radius);
  padding: 12px 14px;
  width: 100%;
}
.correction-header {
  font-size: 13px;
  font-weight: 600;
  color: #d48806;
  margin-bottom: 8px;
}
.correction-item {
  padding: 8px 0;
  border-top: 1px solid #fff1b8;
}
.correction-item:first-of-type { border-top: none; }
.correction-original {
  font-size: 14px;
  color: var(--error);
  text-decoration: line-through;
}
.correction-fix {
  font-size: 14px;
  color: var(--success);
  font-weight: 500;
  margin-top: 2px;
}
.correction-tip {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.correction-item.style .correction-original {
  color: #faad14;
  text-decoration: none;
}
.correction-score {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: right;
}

/* 反馈消息 */
.feedback-message {
  align-self: center;
  max-width: 70%;
}
.feedback-bubble {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  text-align: center;
}
.feedback-success {
  background: #f6ffed;
  color: var(--success);
  border: 1px solid #b7eb8f;
}
.feedback-tip {
  background: #fff7e6;
  color: #fa8c16;
  border: 1px solid #ffd591;
}
.feedback-score {
  font-weight: 600;
  margin-left: 4px;
}

/* 实时识别 */
.interim-text {
  display: none;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  background: var(--primary-light);
  flex-shrink: 0;
}
.interim-text.show { display: block; }

/* 建议回复 */
.suggestions-panel {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  max-height: 120px;
  overflow: hidden;
  transition: max-height 0.3s;
}
.suggestions-panel.collapsed {
  max-height: 40px;
}
.suggestions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.suggestions-toggle {
  transition: transform 0.3s;
}
.suggestions-panel.collapsed .suggestions-toggle {
  transform: rotate(-90deg);
}
.suggestions-list {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.suggestion-chip {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  border: 1px solid var(--primary);
  transition: all 0.2s;
}
.suggestion-chip:active {
  background: var(--primary);
  color: #fff;
}
.no-suggestion {
  font-size: 13px;
  color: var(--text-light);
}

/* 输入区 */
.dialogue-input-area {
  background: var(--card-bg);
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.text-input-row {
  display: flex;
  gap: 8px;
}
.text-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  outline: none;
}
.text-input-row input:focus {
  border-color: var(--primary);
}
.btn-send {
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-send:active { background: var(--primary-dark); }

.btn-skip {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}

/* 对话按钮 */
.btn-talk {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 3px 12px rgba(238,90,82,0.3);
}
.btn-talk:active { transform: scale(0.98); }
.btn-talk.listening {
  background: linear-gradient(135deg, #ff4d4f, #cf1322);
  animation: listeningPulse 1s infinite;
}
@keyframes listeningPulse {
  0%, 100% { box-shadow: 0 3px 12px rgba(255,77,79,0.3); }
  50% { box-shadow: 0 3px 20px rgba(255,77,79,0.6); }
}
.talk-icon { font-size: 20px; }

/* ====== 总结页 ====== */
.summary-content {
  padding: 20px;
}

.summary-score-section {
  text-align: center;
  margin-bottom: 24px;
}
.summary-score-circle {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  margin-bottom: 12px;
}
.summary-score-number {
  font-size: 42px;
  font-weight: 800;
}
.summary-score-unit {
  font-size: 16px;
  color: var(--text-secondary);
  margin-left: 2px;
}
.summary-level-badge {
  display: inline-block;
  padding: 4px 20px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 600;
  background: var(--primary-light);
}

.summary-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.summary-stat {
  flex: 1;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.summary-stat-number {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.xp-gain { color: var(--success) !important; }
.summary-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  display: block;
}

.summary-levelup {
  text-align: center;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.summary-card h3 {
  font-size: 15px;
  margin-bottom: 10px;
}
.summary-comment {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 8px;
}
.summary-focus-tip {
  font-size: 13px;
  color: var(--warning);
  background: #fff7e6;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.mistake-type-bar {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.mistake-type-bar:last-child { border-bottom: none; }
.mistake-type-count {
  color: var(--error);
  font-weight: 600;
}

.summary-correction-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.summary-correction-item:last-child { border-bottom: none; }
.correction-turn {
  font-size: 12px;
  color: var(--text-light);
  flex-shrink: 0;
  width: 40px;
  padding-top: 2px;
}
.correction-content {
  flex: 1;
}
.correction-user-text {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 4px;
}
.correction-detail {
  font-size: 13px;
  margin-bottom: 4px;
}
.fix-arrow {
  color: var(--text);
}
.correction-detail.error .fix-arrow { color: var(--error); }
.correction-detail.style .fix-arrow { color: var(--warning); }

.summary-level-card {
  display: flex;
  align-items: center;
  gap: 16px;
}
.summary-level-icon {
  font-size: 40px;
}
.summary-level-text {
  font-size: 16px;
  font-weight: 600;
}
.summary-level-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ====== 弹窗 ====== */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.show {
  display: flex;
}
.modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
}
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}

/* ====== Toast ====== */
.toast {
  display: none;
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 2000;
  max-width: 80%;
  text-align: center;
  white-space: nowrap;
}
.toast.show {
  display: block;
  animation: toastIn 0.3s ease;
}
.toast.error {
  background: var(--error);
  color: #fff;
}
.toast.success {
  background: var(--success);
  color: #fff;
}
.toast.info {
  background: var(--primary);
  color: #fff;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ====== 滚动条美化 ====== */
.chat-messages::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
.chat-messages::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ====== AI思考动画 ====== */
.thinking-bubble {
  display: flex;
  align-items: center;
  padding: 14px 18px;
}
.thinking-dots {
  display: flex;
  gap: 4px;
}
.thinking-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  animation: dotBounce 1.4s infinite ease-in-out;
}
.thinking-dots .dot:nth-child(2) {
  animation-delay: 0.2s;
}
.thinking-dots .dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes dotBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* AI语法反馈样式 */
.feedback-correction {
  background: #fffbe6;
  color: #d48806;
  border: 1px solid #ffe58f;
  text-align: left;
  line-height: 1.6;
}

/* ====== P0: 密码显示/隐藏 ====== */
.password-input-wrapper {
  position: relative;
}
.password-input-wrapper input {
  width: 100%;
  padding-right: 44px;
}
.btn-toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

/* ====== P0: 页头用户名显示 ====== */
.header-username {
  font-size: 14px;
  color: #666;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ====== P1: 双模式选择按钮 ====== */
.mode-select-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 20px 0 12px;
  padding-left: 4px;
}
.mode-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  margin-bottom: 12px;
  padding: 16px 20px;
}
.mode-btn .btn-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.mode-btn-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mode-btn-title {
  font-size: 17px;
  font-weight: 600;
}
.mode-btn-desc {
  font-size: 12px;
  opacity: 0.7;
}

/* ====== P1: 实用模式 - 分类列表 ====== */
.phrasebook-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}
.phrasebook-hint {
  text-align: center;
  color: #999;
  font-size: 14px;
  margin-bottom: 16px;
}
.phrase-category-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.phrase-category-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: #fff;
  border-radius: 12px;
  border-left: 4px solid var(--scene-color, #4ECDC4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.phrase-category-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.phrase-category-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.phrase-category-card h3 {
  font-size: 17px;
  margin: 0;
}
.phrase-category-card p {
  font-size: 13px;
  color: #999;
  margin: 2px 0 0;
}
.phrase-category-arrow {
  margin-left: auto;
  color: #ccc;
  font-size: 20px;
}

/* ====== P1: 实用模式 - 句式列表 ====== */
.phrases-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.phrases-header h3 {
  font-size: 18px;
  margin: 0;
}
.phrase-card {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 16px 50px 16px 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}
.phrase-card:active {
  transform: scale(0.98);
}
.phrase-card.speaking {
  border-color: #4ECDC4;
  background: #f0fffc;
}
.phrase-tag {
  display: inline-block;
  font-size: 11px;
  color: #4ECDC4;
  background: #e6fffa;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.phrase-en {
  font-size: 16px;
  color: #333;
  line-height: 1.5;
  font-weight: 500;
}
.phrase-zh {
  font-size: 14px;
  color: #888;
  margin-top: 4px;
}
.btn-speak-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: #f0f0f0;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.phrase-card.speaking .btn-speak-icon {
  background: #4ECDC4;
  color: #fff;
  animation: pulse 0.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(1.1); }
}
