/* style.css —— MoshiAI Web 视觉（PWA 移动优先）。
 * 质感：暖纸底 #faf6f1、墨色 #2b2622、杏色主调 #e9c4ab（她的暖）、
 * iOS safe-area 适配（刘海/底部横条）；桌面留宽，手机全宽。
 */

:root {
  --paper: #faf6f1;
  --paper-card: #fffdf9;
  --ink: #2b2622;
  --ink-soft: #6b6157;
  --ink-faint: #8a8178;
  --her: #e9c4ab;
  --her-deep: #d29d7c;
  --line: #e6ded1;
  --line-soft: #d8cdbf;
  --accent: #d29d7c;
  --danger: #a33;
  --radius: 14px;
  --shadow-card: 0 1px 3px rgba(43, 38, 34, 0.06), 0 6px 18px rgba(43, 38, 34, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  /* PWA 全屏下防止被 iOS 状态栏遮挡 */
  padding-top: env(safe-area-inset-top);
}

/* 衬线标题：品牌与区段标题（书生气质） */
.app-title,
.app-main h2 {
  font-family: Georgia, "Times New Roman", "Songti SC", STSong, serif;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.app-header {
  padding: 20px 20px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.app-title {
  margin: 0;
  font-size: 1.9rem;
  color: var(--ink);
}

.app-nav {
  display: flex;
  gap: 2px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.nav-btn {
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 6px 18px;
  cursor: pointer;
  opacity: 0.68;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.nav-btn:hover {
  opacity: 1;
}

.nav-btn.active {
  opacity: 1;
  background: var(--her);
  color: #3b2a1f;
  font-weight: 600;
}

.app-main {
  padding: 12px 20px 24px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  /* 底部安全区（iPhone 横条） */
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* 视图开关：默认仅 .active 视图显示 */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* 通用按钮 */
.btn {
  padding: 10px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--paper-card);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #f3ece1;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 发图按钮：圆钮 */
.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex: none;
}

/* 发送按钮：暖色主调（她回应你时的那抹暖） */
.send-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  flex: none;
}

.send-btn:hover:not(:disabled) {
  background: #c18a66;
}

/* 提示行 */
.chat-hint {
  min-height: 1.5em;
  margin: 4px 0;
  color: var(--danger);
  opacity: 0.85;
}

.chat-hint:empty {
  display: none;
}

.voice-hint {
  margin: 2px 0 8px;
  font-size: 0.86rem;
  color: var(--ink-faint);
}

/* === 对话视图 === */

/* 消息滚动区：手机撑满剩余高度，桌面限高 */
.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100dvh - 250px);
  min-height: 300px;
  max-height: 68vh;
  padding: 18px 12px;
  overflow-y: auto;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 8px 0 14px;
  box-shadow: var(--shadow-card);
  -webkit-overflow-scrolling: touch;
}

.bubble {
  max-width: 78%;
  padding: 11px 16px;
  border-radius: 18px;
  margin: 0;
  line-height: 1.55;
  font-size: 0.97rem;
}

/* 她：左对齐浅杏 + 「默」渐变圆徽（头像） */
.bubble.her {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin-right: auto;
  background: var(--her);
  color: #3b2a1f;
  border-bottom-left-radius: 6px;
}

.bubble.her .avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e9c4ab, #d29d7c);
  color: #fff;
  font-family: Georgia, "Times New Roman", "Songti SC", STSong, serif;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  box-shadow: 0 1px 3px rgba(210, 157, 124, 0.4);
}

.bubble.her .bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
}

/* 你：右对齐深色 */
.bubble.me {
  margin-left: auto;
  background: #4a4038;
  color: #f7f1ea;
  border-bottom-right-radius: 6px;
}

/* 她「正在想…」瞬态 */
.bubble.thinking {
  margin-right: auto;
  background: #f0ebe2;
  color: var(--ink-faint);
  font-style: italic;
}

/* 错误气泡 */
.bubble.error-bubble {
  background: #f6e3e0;
  color: var(--danger);
}

/* 你发的图缩略图 */
.photo-thumb {
  display: block;
  max-width: 180px;
  max-height: 180px;
  object-fit: cover;
  border-radius: 12px;
}

/* 输入行 */
.chat-input-bar {
  display: flex;
  gap: 10px;
  margin: 10px 0 0;
  align-items: center;
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 11px 18px;
  font: inherit;
  font-size: 1rem;  /* ≥16px 防 iOS 聚焦缩放 */
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--paper-card);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.chat-input:focus {
  outline: none;
  border-color: var(--her-deep);
}

.chat-input:disabled {
  opacity: 0.55;
}

/* 语音试听按钮（她气泡内） */
.voice-btn {
  flex: none;
  margin-top: 2px;
  padding: 2px 8px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.65);
  color: #3b2a1f;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.6;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.voice-btn:hover:not(:disabled) {
  background: #fffdf9;
}

.voice-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 她的表情（meme 行追加在 her 气泡尾部） */
.meme-line {
  flex-basis: 100%;
  margin-top: 4px;
  line-height: 1.4;
}

.meme-img {
  display: block;
  max-height: 72px;
  border-radius: 10px;
}

.meme-text {
  font-size: 0.9rem;
  color: #6b5340;
  opacity: 0.9;
}

/* === 回忆视图 === */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 8px 0 16px;
}

/* 时间线卡片：左暖竖线 + 白卡 */
.timeline-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--her-deep);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.timeline-time {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

.timeline-card-title {
  font-weight: 600;
  margin: 0 0 6px;
}

.timeline-card-content {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

/* 空状态 / 错误态 */
.timeline-empty {
  opacity: 0.62;
}

.timeline-empty.error {
  color: var(--danger);
  opacity: 0.85;
  font-size: 0.92rem;
}

/* === 桌面微调（浏览器全屏场景） === */
@media (min-width: 900px) {
  .app-header {
    padding: 32px 20px 8px;
  }

  .messages {
    height: 56vh;
  }
}
