* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --cream: #FFF6F0;
  --pink: #FFB7C9;
  --pink-deep: #FF9DBB;
  --pink-border: #FFE0E9;
  --ink: #5C4A52;
  --ink-soft: #A8939B;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--cream);
  color: var(--ink);
  display: flex; justify-content: center;
}

#app { width: 100%; max-width: 640px; height: 100dvh; display: flex; flex-direction: column; }

/* 顶栏 */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: #fff; border-bottom: 2px solid var(--pink-border);
  position: sticky; top: 0; z-index: 5;
}
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; box-shadow: 0 2px 8px rgba(255,155,187,.4);
}
.who h1 { font-size: 17px; color: var(--ink); }
.who p { font-size: 12px; color: var(--ink-soft); }

/* 消息区 */
#chat { flex: 1; overflow-y: auto; padding: 16px 14px; scroll-behavior: smooth; }
.msg { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; animation: pop .25s ease; }
.msg.user { flex-direction: row-reverse; }
.msg.ai { justify-content: flex-start; }

/* 消息头像：与语音条等高（微信样式） */
.mavatar {
  width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  flex-shrink: 0; border: 2px solid #fff;
  background: var(--pink-border);
  box-shadow: 0 2px 6px rgba(255,155,187,.3);
}
.mavatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  max-width: 40px; max-height: 40px;
}
.top .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.msg .inner { max-width: 82%; min-width: 0; }
.msg.user .inner { text-align: right; }
.msg.ai .inner { text-align: left; }
.msg .bubble {
  display: inline-block; max-width: 100%; padding: 10px 14px;
  font-size: 15px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
}
.msg.user .bubble {
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; border-radius: 20px 20px 6px 20px;
  box-shadow: 0 3px 10px rgba(255,155,187,.35);
}
.msg.ai { justify-content: flex-start; }
.msg.ai .bubble {
  background: #fff; border: 2px solid var(--pink-border);
  color: var(--ink); border-radius: 20px 20px 20px 6px;
  box-shadow: 0 3px 10px rgba(255,190,205,.25);
}
.msg .meta { font-size: 10px; color: var(--ink-soft); margin-top: 4px; padding: 0 4px; }
.playbtn {
  margin-top: 8px; border: none; cursor: pointer;
  background: var(--pink); color: #fff; font-size: 13px;
  padding: 6px 12px; border-radius: 999px; box-shadow: 0 2px 6px rgba(255,155,187,.4);
}
.playbtn:active { transform: scale(.95); }

/* 语音条（AI 语音回复，点"转文字"显示文字） */
.vbar {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; max-width: 230px; padding: 0 12px;
  background: #fff; border: 2px solid var(--pink-border);
  border-radius: 20px 20px 20px 6px;
  box-shadow: 0 3px 10px rgba(255,190,205,.25);
}
.vplay {
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; font-size: 13px; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(255,155,187,.4);
}
.vplay:active { transform: scale(.92); }
.vbar-track { flex: 1; display: flex; align-items: center; gap: 2px; height: 22px; }
/* 未播放：静态波形（微信样式）；播放中：上下波动 */
.vbar-track i { width: 3px; background: var(--pink-deep); border-radius: 2px; }
.vbar-track i:nth-child(3n+1) { height: 6px; }
.vbar-track i:nth-child(3n+2) { height: 12px; }
.vbar-track i:nth-child(3n) { height: 9px; }
.vbar.playing .vbar-track i { animation: wave 1s ease-in-out infinite; }
.vbar.playing .vbar-track i:nth-child(odd) { animation-delay: .18s; }
@keyframes wave { 0%,100% { height: 6px; } 50% { height: 17px; } }
/* 转文字：语音条正下方、左边缘对齐（微信样式） */
.conv {
  display: block; width: fit-content; margin-top: 6px;
  border: none; background: #FFF0F4; color: var(--pink-deep);
  font-size: 12px; cursor: pointer; padding: 4px 10px; border-radius: 10px;
}
.rec-chip {
  display: inline-block; font-size: 12px; color: #fff; background: #FF6B8A;
  border-radius: 999px; padding: 2px 8px; margin-bottom: 6px; animation: blink 1s infinite;
}

/* 表情包面板与表情消息 */
#stickerPanel {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 10px; background: #fff; border-top: 2px solid var(--pink-border);
  max-height: 230px; overflow-y: auto;
}
#stickerPanel.hidden { display: none; }
#stickerPanel img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: 10px; background: var(--cream); cursor: pointer;
}
#stickerPanel img:active { transform: scale(.92); }
.sticker-img {
  width: 140px; max-width: 62%; border-radius: 14px; display: block;
  background: var(--cream); box-shadow: 0 3px 10px rgba(255,190,205,.25);
}

/* 正在输入（左下角提示） */
#typing {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px 2px; font-size: 12px; color: var(--ink-soft);
}
.typing-avatar {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid #fff; box-shadow: 0 1px 4px rgba(255,155,187,.3);
}
.typing-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--pink); animation: bounce 1.2s infinite;
}
.typing-dot:nth-of-type(2) { animation-delay: .15s; }
.typing-dot:nth-of-type(3) { animation-delay: .3s; }

/* 输入栏 */
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: #fff; border-top: 2px solid var(--pink-border);
}
.emoji {
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  background: #fff; border: 2px solid var(--pink-border);
  font-size: 20px; box-shadow: 0 3px 8px rgba(255,155,187,.3); flex-shrink: 0;
}
.emoji:active { transform: scale(.93); }
.mic {
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  font-size: 20px; box-shadow: 0 3px 8px rgba(255,155,187,.4); flex-shrink: 0;
}
.mic.recording { background: #FF6B8A; animation: blink 1s infinite; }
#input {
  flex: 1; border: 2px solid var(--pink-border); border-radius: 999px;
  padding: 10px 16px; font-size: 15px; background: var(--cream); color: var(--ink);
  outline: none;
}
#input:focus { border-color: var(--pink); }
.send {
  border: none; cursor: pointer; border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; font-size: 15px; padding: 10px 18px;
  box-shadow: 0 3px 8px rgba(255,155,187,.4); flex-shrink: 0;
}
.send:active { transform: scale(.95); }

/* 登录 */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(255,246,240,.92); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.card {
  background: #fff; border-radius: 24px; padding: 32px 28px; text-align: center;
  width: 100%; max-width: 320px; box-shadow: 0 10px 30px rgba(255,155,187,.3);
  border: 2px solid var(--pink-border);
}
.card .big { font-size: 52px; margin-bottom: 8px; }
.card h2 { font-size: 18px; margin-bottom: 16px; }
.card input {
  width: 100%; border: 2px solid var(--pink-border); border-radius: 999px;
  padding: 12px 16px; font-size: 15px; text-align: center; outline: none; margin-bottom: 14px;
}
.card input:focus { border-color: var(--pink); }
.card button {
  width: 100%; border: none; cursor: pointer; border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; font-size: 16px; padding: 12px;
}
.card .tip { font-size: 12px; color: var(--ink-soft); margin-top: 12px; }

.hidden { display: none !important; }

@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes blink { 50% { opacity: .55; } }
