/* ========== 念头 — 覆盖层样式 ========== */
/* 基于游戏主 style.css，只补充念头专属组件 */

/* ── 欢迎页 ── */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
}

.welcome-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.welcome-gradient {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(212, 163, 115, 0.08), transparent 70%),
              radial-gradient(ellipse at 30% 70%, rgba(184, 160, 216, 0.06), transparent 60%);
}

.welcome-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px 24px;
  max-width: 480px;
}

.app-title {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: 0.08em;
  animation: fadeUp 0.7s ease 0.3s both;
}

.app-subtitle {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  letter-spacing: 0.05em;
  animation: fadeUp 0.7s ease 0.5s both;
}

.app-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 40px;
  line-height: 1.8;
  animation: fadeUp 0.7s ease 0.7s both;
}

.welcome-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  animation: fadeUp 0.7s ease 0.9s both;
}

.welcome-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  animation: fadeUp 0.7s ease 1.1s both;
}

.welcome-links .btn-text {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  padding: 6px 8px;
  transition: color var(--transition-fast);
}
.welcome-links .btn-text:hover { color: var(--accent); }

/* ── 聊天界面 ── */
.awareness-container,
.renewal-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  background: var(--bg-primary);
}

.awareness-header,
.renewal-header,
.card-header,
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.awareness-header span,
.renewal-header span,
.card-header span,
.history-header span {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--text-secondary);
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  max-width: 85%;
  animation: msgFadeIn 0.3s ease;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-ai { align-self: flex-start; }
.chat-user { align-self: flex-end; }

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-ai .chat-bubble {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
}

.chat-user .chat-bubble {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── 场景选择 ── */
.scene-choices-area {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  max-height: 50vh;
  overflow-y: auto;
}

.scene-choices-area.hidden { display: none; }

.scene-choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  color: var(--text-primary);
}

.scene-choice-btn:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}

.scene-choice-btn .choice-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

.choice-text {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.choice-pattern {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── 输入区域 ── */
.input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.thought-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color var(--transition-fast);
  background: var(--bg-card);
  color: var(--text-primary);
  min-height: 44px;
  max-height: 120px;
}

.thought-input:focus {
  border-color: var(--accent);
}

.thought-input::placeholder {
  color: var(--text-muted);
}

.input-hint {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 16px 0;
  min-height: 20px;
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.btn-send:hover { background: var(--accent-light); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── 生成卡片按钮 ── */
.generate-card-wrap {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 16px 0;
  animation: msgFadeIn 0.3s ease;
}

/* ── 觉察卡片 ── */
.card-container {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  background: var(--bg-primary);
}

.card-display {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.awareness-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: 0 8px 32px var(--shadow);
  max-width: 400px;
  width: 100%;
  animation: cardAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardAppear {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.card-date {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.card-trigger {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text-primary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.card-section {
  margin-bottom: 20px;
}

.card-section-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.card-section-content {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.7;
}

.card-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 12px;
  margin-right: 8px;
}

.card-stage {
  font-size: 13px;
  color: var(--text-secondary);
}

.card-pattern {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(232, 160, 180, 0.15);
  color: var(--rose);
  font-size: 13px;
  font-weight: 500;
}

.card-seed {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.card-seed-question {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--accent);
  font-style: italic;
  margin: 8px 0;
  line-height: 1.6;
}

.card-seed-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 16px;
}

/* ── 历史页面 ── */
.history-container {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  background: var(--bg-primary);
}

.history-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  padding: 0 16px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.tab-btn {
  padding: 12px 16px;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.history-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 14px;
  line-height: 2;
}

.history-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.history-card:hover {
  box-shadow: 0 4px 12px var(--shadow);
  border-color: var(--border);
  transform: translateY(-1px);
}

.history-card-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.history-card-trigger {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.history-card-insight {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.6;
}

.history-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-renewal {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
}

.renewal-broken {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 6px;
}

.renewal-action {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.renewal-body {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.renewal-learning {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.patterns-overview { padding: 8px 0; }

.pattern-stat {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.pattern-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.pattern-name { font-weight: 500; flex: 1; color: var(--text-primary); }
.pattern-freq { font-size: 12px; color: var(--text-muted); }
.pattern-domains { font-size: 12px; color: var(--text-muted); }

.stages-overview { margin-top: 24px; }
.stages-overview h4 { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }

.stage-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}
.stage-domain { color: var(--text-secondary); }
.stage-current { color: var(--accent); font-weight: 500; }

/* ── AI 设置面板（覆盖定位） ── */
.ai-settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px var(--shadow-lg);
  width: 90%;
  max-width: 420px;
  z-index: 1000;
  overflow: hidden;
}

.ai-settings-panel.hidden { display: none; }

.ai-settings-panel .panel-header {
  border-bottom: 1px solid var(--border-light);
}

.ai-settings-panel .panel-header h3 {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.panel-field { margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.field-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast);
  background: var(--bg-card);
  color: var(--text-primary);
}
.field-input:focus { border-color: var(--accent); }

.ai-config-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

.panel-actions { display: flex; gap: 10px; }

/* ── 滚动条 ── */
.chat-area::-webkit-scrollbar,
.history-content::-webkit-scrollbar {
  width: 4px;
}
.chat-area::-webkit-scrollbar-track,
.history-content::-webkit-scrollbar-track {
  background: transparent;
}
.chat-area::-webkit-scrollbar-thumb,
.history-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── 移动端 ── */
@media (max-width: 480px) {
  .app-title { font-size: 2.5rem; }
  .app-subtitle { font-size: 1rem; }
  .chat-msg { max-width: 90%; }
  .chat-bubble { font-size: 14px; padding: 10px 14px; }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .input-area { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
