/* ════════════════════════════════════════════════════════
   苏苏情感室 · 主样式
   策略：Mobile-first → 桌面端居中卡片
   ════════════════════════════════════════════════════════ */

/* ── CSS 变量 ──────────────────────────────────────────── */
:root {
  --rose:        #C95472;
  --rose-lt:     #E07A92;
  --rose-dk:     #A83C58;
  --cream:       #FFF5F8;
  --blush:       #FAF1F5;        /* 聊天区背景 */
  --bubble-ai:   #FFFFFF;
  --text:        #2A1820;
  --text-2:      #7A5A6A;
  --border:      #EDD4DE;
  --sh-sm:       0 1px 4px rgba(170,55,85,0.09);
  --sh-md:       0 4px 16px rgba(170,55,85,0.13);
  --r-msg:       16px;
  --r-input:     18px;
}

/* ── 重置 ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  height: 100%;
  font-family: -apple-system, "PingFang SC", "Helvetica Neue",
               "Microsoft YaHei UI", sans-serif;
  color: var(--text);
  background: var(--blush);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App 容器（移动端全屏） ────────────────────────────── */
.app {
  width: 100%;
  height: 100vh;
  height: 100dvh;                /* 动态视口，规避移动端地址栏遮挡 */
  display: flex;
  flex-direction: column;
  background: var(--bubble-ai);
  overflow: hidden;
}

/* ── 桌面端：居中卡片 ─────────────────────────────────── */
@media (min-width: 620px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    /* 三色柔和渐变背景 */
    background: linear-gradient(145deg, #FFF0F5 0%, #FFF8F0 55%, #F4F0FF 100%);
  }
  .app {
    width: 460px;
    height: min(840px, calc(100dvh - 56px));
    border-radius: 24px;
    box-shadow:
      0 0 0 1px rgba(200,84,114,0.08),
      0 8px 32px rgba(170,55,85,0.12),
      0 32px 80px rgba(0,0,0,0.07);
  }
  /* 桌面隐藏 hint（用键盘，提示有用） */
  .input-hint { display: block; }
}

/* ── 顶部导航栏 ───────────────────────────────────────── */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  /* iOS 安全区 */
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 苏苏头像 */
.susu-avatar {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), var(--rose-lt));
  color: #fff;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(201,84,114,0.28);
}

.topbar-meta { display: flex; flex-direction: column; gap: 1px; }

.topbar-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text);
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-2);
}

/* 在线绿点 */
.live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #3ECB8A;
  animation: blink 2.5s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.topbar-actions { display: flex; gap: 2px; }

.icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover  { background: var(--cream); color: var(--rose); }
.icon-btn:active { background: #F2D8E4; }

/* ── 消息区域 ─────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--blush);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
/* 细滚动条 */
.messages::-webkit-scrollbar { width: 3px; }
.messages::-webkit-scrollbar-thumb { background: #DDBBCA; border-radius: 2px; }

/* ── 欢迎卡片（与普通 AI 消息同结构） ──────────────────── */
.welcome-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.welcome-body {
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-radius: 4px var(--r-msg) var(--r-msg) var(--r-msg);
  padding: 15px 17px;
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.72;
  font-size: 14.5px;
  max-width: calc(100% - 44px);
}

.welcome-hi {
  font-size: 16px;
  font-weight: 600;
  color: var(--rose);
}

/* 快捷话题 */
.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

.quick-btn {
  padding: 6px 13px;
  background: var(--cream);
  border: 1px solid #F2C4D4;
  border-radius: 20px;
  color: var(--rose);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.quick-btn:hover {
  background: var(--rose);
  border-color: var(--rose);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(201,84,114,0.22);
}
.quick-btn:active { transform: none; box-shadow: none; }

/* ── 消息气泡行 ───────────────────────────────────────── */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: pop-in 0.22s cubic-bezier(.34,1.5,.64,1) both;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* AI 消息（左） */
.msg-row.ai  { flex-direction: row; }

/* 用户消息（右，无头像） */
.msg-row.user {
  flex-direction: row-reverse;
  padding-left: 48px;      /* 留出右侧不与左边贴边 */
}

/* ── 头像（仅 AI 使用） ───────────────────────────────── */
.msg-avatar.ai {
  width: 34px; height: 34px; min-width: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), var(--rose-lt));
  color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-sm);
  flex-shrink: 0;
}

/* ── 气泡内容 ─────────────────────────────────────────── */
.msg-bubble {
  padding: 11px 15px;
  border-radius: var(--r-msg);
  font-size: 14.5px;
  line-height: 1.72;
  word-break: break-word;
  white-space: pre-wrap;
}

/* AI 气泡 */
.msg-row.ai .msg-bubble {
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--sh-sm);
  color: var(--text);
  max-width: calc(100% - 50px);
}

/* 用户气泡 */
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, var(--rose) 0%, var(--rose-dk) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 12px rgba(168,60,88,0.28);
  max-width: 100%;
}

/* ── 打字动画 ─────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: pop-in 0.2s ease both;
}

.typing-dots {
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-radius: var(--r-msg) var(--r-msg) var(--r-msg) 4px;
  padding: 12px 15px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: var(--sh-sm);
}
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--rose-lt);
  animation: dot-hop 1.4s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes dot-hop {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30%           { transform: translateY(-7px); opacity: 1; }
}

/* ── 输入栏 ───────────────────────────────────────────── */
.inputbar {
  flex-shrink: 0;
  padding: 10px 12px;
  /* iOS 底部安全区（Home Bar） */
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: var(--r-input);
  padding: 8px 8px 8px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-row:focus-within {
  border-color: var(--rose-lt);
  box-shadow: 0 0 0 3px rgba(201,84,114,0.10);
}

textarea {
  flex: 1;
  border: none; outline: none; resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;     /* ≥16px 防止 iOS Safari 自动放大 */
  color: var(--text);
  line-height: 1.55;
  max-height: 116px;
  overflow-y: auto;
}
textarea::placeholder { color: #C8AABB; }

/* 发送按钮 */
.btn-send {
  width: 38px; height: 38px; min-width: 38px;
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--rose), var(--rose-dk));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: opacity 0.18s, transform 0.15s, box-shadow 0.18s;
  box-shadow: 0 3px 10px rgba(201,84,114,0.32);
  -webkit-tap-highlight-color: transparent;
}
.btn-send:disabled {
  opacity: 0.32; cursor: default;
  box-shadow: none; transform: none !important;
}
.btn-send:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(201,84,114,0.42);
}
.btn-send:not(:disabled):active { transform: scale(0.93); }

/* 语音按钮 */
.btn-voice {
  width: 38px; height: 38px; min-width: 38px;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-voice:hover { color: var(--rose); border-color: var(--rose-lt); }
.btn-voice:active { transform: scale(0.93); }
.btn-voice.recording {
  color: var(--rose);
  border-color: var(--rose);
  animation: voice-pulse 1.2s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(201,84,114,0.18); }
  50%       { box-shadow: 0 0 0 7px rgba(201,84,114,0.06); }
}

.input-hint {
  display: none;       /* 移动端默认隐藏，桌面端媒体查询中显示 */
  font-size: 11px;
  color: var(--text-2);
  opacity: 0.6;
  text-align: center;
  margin-top: 7px;
  user-select: none;
}
