html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  background-color: #f7f8fa;
  color: #333;
}

.app {
  display: flex;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.app.mobile-voice {
  flex-direction: column;
}

.header {
  padding: 12px 16px;
  background-color: #ffffff;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #d9d9d9;
  flex-shrink: 0;
}

.conn-dot.ok {
  background-color: #52c41a;
  box-shadow: 0 0 8px rgba(82, 196, 26, 0.6);
}

.conn-dot.bad {
  background-color: #ff4d4f;
  box-shadow: 0 0 8px rgba(255, 77, 79, 0.6);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 45vh;
  display: flex;
  flex-direction: column;
}

.asr-box {
  padding: 12px;
  background-color: #fffbe6;
  border: 1px solid #ffe58f;
  border-radius: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.asr-label {
  font-size: 12px;
  color: #faad14;
  margin-bottom: 4px;
}

.asr-text {
  font-size: 14px;
  color: #333;
  min-height: 24px;
}

.chat {
  display: none;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.chat.has-messages {
  display: flex;
}

.msg {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.msg.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg.assistant {
  margin-right: auto;
}

.avatar-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.msg.user .avatar-small {
  background-image: url("/web/man.png");
  background-color: #ffffff;
  border: 2px solid #52c41a;
}

.msg.assistant .avatar-small {
  background-image: url("/web/beauty.png");
  background-color: #f0f0f0;
}

.bubble-wrapper {
  flex: 1;
}

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
  color: #ffffff;
  border-radius: 18px 4px 18px 18px;
}

.msg.assistant .bubble {
  background-color: #ffffff;
  color: #333;
  border: 1px solid #e8e8e8;
  border-radius: 4px 18px 18px 18px;
}

.msg.assistant .bubble.thinking {
  color: #999;
}

@keyframes thinkingGlow {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.meta {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.voice-section {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40vh;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(247, 248, 250, 0) 0%, #f7f8fa 30%, #ffffff 100%);
  padding: 20px;
  flex-shrink: 0;
  z-index: 10;
}

.voice-btn-container {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-btn {
  position: absolute;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.voice-btn-inner {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 30px rgba(82, 196, 26, 0.5);
  z-index: 2;
  cursor: pointer;
}

.voice-btn-inner svg {
  width: 56px;
  height: 56px;
}

.voice-btn:active .voice-btn-inner,
.voice-btn.recording .voice-btn-inner {
  transform: scale(0.92);
  box-shadow: 0 3px 15px rgba(82, 196, 26, 0.35);
}

.voice-btn.recording .voice-btn-inner {
  background: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%);
  box-shadow: 0 6px 30px rgba(255, 77, 79, 0.5);
}

.voice-ripple {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(82, 196, 26, 0.4) 0%, rgba(56, 158, 13, 0.4) 100%);
  opacity: 0;
  transform: scale(1);
  z-index: 1;
}

.voice-btn.recording .voice-ripple {
  animation: ripple-expand 1.8s ease-out infinite;
}

.voice-btn.recording .ripple-1 {
  animation-delay: 0s;
}

.voice-btn.recording .ripple-2 {
  animation-delay: 0.4s;
}

.voice-btn.recording .ripple-3 {
  animation-delay: 0.8s;
}

@keyframes ripple-expand {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

.voice-btn.fade-out .voice-ripple {
  animation: ripple-fade 1.2s ease-out forwards;
}

@keyframes ripple-fade {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

.mic-hint {
  margin-top: 16px;
  font-size: 14px;
  color: #999;
  text-align: center;
  min-height: 20px;
}

.audio-visualizer {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 24px;
  width: 48px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.voice-btn.recording .audio-visualizer {
  opacity: 1;
}

.audio-visualizer .bar {
  width: 6px;
  height: 4px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 3px;
  animation: audio-bar 0.5s ease-in-out infinite alternate;
}

.audio-visualizer .bar-1 {
  animation-delay: 0s;
}

.audio-visualizer .bar-2 {
  animation-delay: 0.1s;
}

.audio-visualizer .bar-3 {
  animation-delay: 0.2s;
}

.audio-visualizer .bar-4 {
  animation-delay: 0.3s;
}

.audio-visualizer .bar-5 {
  animation-delay: 0.4s;
}

@keyframes audio-bar {
  0% {
    height: 6px;
  }
  50% {
    height: 18px;
  }
  100% {
    height: 12px;
  }
}

.interrupt-btn {
  position: absolute;
  display: none;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%);
  border: none;
  border-radius: 50%;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 6px 30px rgba(255, 77, 79, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  z-index: 3;
}

.interrupt-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 35px rgba(255, 77, 79, 0.6);
}

.interrupt-btn:active {
  transform: scale(0.92);
  box-shadow: 0 3px 15px rgba(255, 77, 79, 0.35);
}
