/* ===== 说对话 App 样式 v2 ===== */
:root {
  --primary: #5B8C5A;
  --primary-light: #7CB67B;
  --primary-dark: #3E6B3D;
  --accent: #E8A87C;
  --accent-light: #F5D0B5;
  --bg: #F5F3EE;
  --bg-card: #FFFFFF;
  --text: #2D2D2D;
  --text-light: #6B6B6B;
  --text-muted: #9B9B9B;
  --border: #E8E4DE;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  overflow-x: hidden;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ===== 通用 ===== */
.page { display: none; min-height: 100vh; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin: 12px 16px;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:active { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-block { display: flex; width: 100%; }

/* ===== 注册页 ===== */
#registerPage {
  background: linear-gradient(180deg, #F5F3EE 0%, #E8F5E9 100%);
}
.register-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}
.register-icon { font-size: 72px; margin-bottom: 16px; }
.register-title { font-size: 32px; font-weight: 700; color: var(--primary-dark); margin-bottom: 12px; }
.register-subtitle { font-size: 17px; color: var(--text-light); line-height: 1.8; margin-bottom: 40px; }
.register-input {
  width: 100%;
  max-width: 300px;
  padding: 14px 16px;
  border: 2px solid #e8e4dc;
  border-radius: 12px;
  font-size: 16px;
  text-align: center;
  outline: none;
  background: white;
  transition: border-color 0.2s;
}
.register-btn {
  margin-top: 16px;
  width: 100%;
  max-width: 300px;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.register-btn:active { background: var(--primary-dark); transform: scale(0.97); }
.register-note { font-size: 12px; color: var(--text-muted); margin-top: 16px; }

/* ===== 首页 ===== */
#homePage {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 40px;
}

#homePage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 0;
}

.home-top {
  text-align: center;
  padding: 24px 24px 16px;
}
.home-logo { font-size: 48px; margin-bottom: 4px; }
.home-brand { font-size: 26px; font-weight: 700; color: var(--primary-dark); margin-bottom: 8px; }
.home-tagline { font-size: 15px; color: var(--text-light); line-height: 1.8; }

.home-section-title {
  font-size: 20px;
  font-weight: 700;
  padding: 16px 20px 12px;
  color: var(--text);
}

.module-cards { display: flex; gap: 12px; padding: 0 16px; }
.module-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.module-card:active { transform: scale(0.97); }
.module-card.emergency { box-shadow: 0 2px 16px rgba(255, 100, 100, 0.15); }
.module-card.reflect { box-shadow: 0 2px 16px rgba(91, 140, 90, 0.15); }
.module-card-icon { font-size: 44px; margin-bottom: 10px; }
.module-card-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.module-card-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ===== 场景卡片列表 ===== */
.section-title {
  font-size: 18px;
  font-weight: 700;
  padding: 20px 20px 8px;
  color: var(--text);
}

.scenario-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px; }
.scenario-chip {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.scenario-chip:active { transform: scale(0.97); background: #f0ede8; }
.scenario-chip-icon { font-size: 24px; }
.scenario-chip-text { font-size: 14px; font-weight: 600; }
.scenario-chip-desc { font-size: 11px; color: var(--text-muted); }

/* ===== 场景详情页 ===== */
.scenario-header {
  padding: 20px;
  text-align: center;
}
.scenario-header-icon { font-size: 48px; margin-bottom: 8px; }
.scenario-header-title { font-size: 22px; font-weight: 700; }
.scenario-header-desc { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.say-card {
  margin: 12px 16px;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.say-card.wrong { background: #FFF0F0; border-left: 4px solid #FF6B6B; }
.say-card.right { background: #F0FFF4; border-left: 4px solid var(--primary); }
.say-card.why { background: #FFF8F0; border-left: 4px solid var(--accent); }
.say-card.behind { background: #F0F4FF; border-left: 4px solid #6B8CFF; }
.say-card-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.say-card.wrong .say-card-label { color: #FF6B6B; }
.say-card.right .say-card-label { color: var(--primary); }
.say-card.why .say-card-label { color: #C87F55; }
.say-card.behind .say-card-label { color: #6B8CFF; }
.say-card-text { font-size: 15px; line-height: 1.7; color: var(--text); }

.insight-cards { padding: 0 16px; }
.insight-card {
  background: linear-gradient(135deg, #F7F5F0, #E8F5E9);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  border: 1px solid #D4E8D4;
}
.insight-card-title { font-size: 14px; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.insight-card-text { font-size: 13px; color: var(--text-light); line-height: 1.6; }

/* ===== 反思引导页（AI对话）===== */
.reflect-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border-radius: 0 0 20px 20px;
}
.reflect-scenario { font-size: 14px; opacity: 0.8; }
.reflect-title { font-size: 20px; font-weight: 700; }

.step-progress {
  display: flex;
  gap: 4px;
  padding: 12px 20px;
  align-items: center;
}
.step-dot {
  width: 32px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: all 0.3s ease;
}
.step-dot.active { background: var(--primary); }
.step-dot.done { background: var(--primary-light); }
.step-label { font-size: 12px; color: var(--text-muted); margin-left: 8px; }

.chat-area {
  padding: 12px 16px;
  padding-bottom: 80px;
  min-height: calc(100vh - 200px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  animation: bubbleIn 0.3s ease;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.chat-bubble.ai {
  background: var(--bg-card);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.chat-bubble.user {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.chat-bubble.insight {
  background: linear-gradient(135deg, #FFF8E1, #FFF3E0);
  border: 1px solid #FFE082;
  border-radius: 12px;
  align-self: center;
  max-width: 90%;
  text-align: center;
  font-size: 14px;
  color: #8D6E20;
  padding: 10px 16px;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  align-self: flex-end;
}
.quick-reply {
  padding: 8px 14px;
  border-radius: 20px;
  background: #E8F5E9;
  color: var(--primary-dark);
  font-size: 13px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.quick-reply:active { background: var(--primary); color: white; }

.chat-input-area {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: none;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
  resize: none;
  max-height: 100px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.chat-send:active { background: var(--primary-dark); transform: scale(0.92); }
.chat-send:disabled { background: var(--border); }

body.chat-mode .chat-input-area { display: flex; }

/* ===== 返回按钮 ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  margin: 12px 16px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}
.back-btn:active { color: var(--text); }

/* ===== 加载动画 ===== */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
}
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* ===== 弹窗 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
#paywallModal { z-index: 300; background: rgba(255,255,255,0.97); overflow-y: auto; }
#paywallModal .modal-content { border-radius: 20px; max-width: 360px; }
.modal-content {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px 20px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
