* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", sans-serif;
  background: #1a1a1a;
  color: #f0f0f0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

#header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: #242424;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

#avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5b8ee6, #9b6ee6);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: bold;
  color: #fff;
}

#name { flex: 1; font-size: 17px; font-weight: 600; }

#btnMode {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid #5b8ee6;
  background: transparent;
  color: #5b8ee6;
  cursor: pointer;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.bubble.him {
  background: #2e2e2e;
  color: #f0f0f0;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.bubble.me {
  background: #5b8ee6;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bubble.thinking {
  background: #2e2e2e;
  color: #888;
  align-self: flex-start;
  font-style: italic;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse { 0%,100%{opacity:.5} 50%{opacity:1} }

.ts-label {
  font-size: 11px;
  color: #555;
  text-align: center;
  margin: 4px 0;
}

#footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: #242424;
  border-top: 1px solid #333;
  flex-shrink: 0;
}

#input {
  flex: 1;
  background: #333;
  border: none;
  border-radius: 18px;
  padding: 10px 14px;
  color: #f0f0f0;
  font-size: 15px;
  resize: none;
  max-height: 120px;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
}

#sendBtn {
  background: #5b8ee6;
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}

#sendBtn:disabled { opacity: 0.5; cursor: default; }

#status-bar {
  font-size: 11px;
  color: #666;
  text-align: center;
  padding: 4px 0;
  background: #1a1a1a;
  flex-shrink: 0;
}

/* 微信风格圆圈按钮 */
.wc-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid #666;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
  color: #bbb;
  transition: background 0.12s, border-color 0.12s;
}
.wc-btn:active { background: #333; }
.wc-btn svg { display: block; }

/* + 按钮开启 TTS 时高亮 */
#moreBtn.tts-on {
  background: #5b8ee6;
  border-color: #5b8ee6;
  color: #fff;
}

/* emoji 面板 */
.emoji-panel {
  background: #242424;
  border-top: 1px solid #333;
  padding: 10px 12px;
  flex-shrink: 0;
}
.emoji-panel.hidden { display: none; }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.emoji-grid button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  line-height: 1;
}
.emoji-grid button:active { background: #3a3a3a; }

/* ===== 按住说话按钮（微信风格）===== */
#voiceHoldBtn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  background: #3a3a3a;
  border: 1px solid #555;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s;
}

#voiceHoldBtn.recording {
  background: #4a4a4a;
  border-color: #888;
}

#voiceHoldBtn.cancel {
  background: rgba(180, 50, 50, 0.85);
  border-color: #c04040;
  color: #fff;
}

/* 波形动画 */
.wave {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
}

.wave i {
  display: block;
  width: 3px;
  background: #aaa;
  border-radius: 2px;
  animation: wave-bar 0.6s ease-in-out infinite;
}

.wave i:nth-child(1) { height: 8px;  animation-delay: 0s; }
.wave i:nth-child(2) { height: 16px; animation-delay: 0.15s; }
.wave i:nth-child(3) { height: 8px;  animation-delay: 0.3s; }

@keyframes wave-bar {
  0%, 100% { transform: scaleY(0.4); }
  50%       { transform: scaleY(1); }
}

