.layout-chat .top-header-shell {
  height: auto;
  background: rgba(255, 252, 248, 0.96);
}

.layout-chat .screen-content {
  padding-top: 130px;
  padding-bottom: 140px;
}

.layout-chat:has(#context-bar:not(.hidden)) .screen-content,
.layout-chat.has-chat-context .screen-content {
  padding-top: 172px;
}

.chat-header-shell { padding-bottom: 0; }

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 58px 20px 10px;
}

.chat-topbar-info {
  flex: 1;
  min-width: 0;
}

.chat-topbar-info strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.chat-topbar-info span {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-voice-call-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(212, 165, 116, 0.12);
  transition:
    background 0.15s var(--ease-soft),
    border-color 0.15s var(--ease-soft),
    transform 0.12s var(--ease-soft);
}

.chat-voice-call-btn:active {
  background: var(--spark-bg);
  border-color: var(--brand-light);
  transform: scale(0.96);
}

.xiaoxia-avatar-md {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: visible;
  background: #f5f6f8;
  box-shadow: 0 2px 10px rgba(212, 165, 116, 0.2);
  transition: box-shadow 0.35s var(--ease-soft), transform 0.35s var(--ease-soft);
}

.xiaoxia-avatar-md.xiaoxia-ip-host .xiaoxia-ip-svg {
  transform: scale(1.08);
  transform-origin: center 42%;
}

.xiaoxia-avatar-md.xiaoxia-ip-host[data-ip-state="listen"] {
  transform: scale(1.06);
  box-shadow:
    0 0 0 3px rgba(196, 112, 75, 0.22),
    0 4px 16px rgba(196, 112, 75, 0.32);
}

.xiaoxia-avatar-md.xiaoxia-ip-host[data-ip-state="listen"]::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(196, 112, 75, 0.28);
  animation: ipListenRing 1.8s ease-out infinite;
  pointer-events: none;
}

.xiaoxia-avatar-md.xiaoxia-ip-host[data-ip-state="think"] {
  box-shadow:
    0 0 0 3px rgba(212, 165, 116, 0.24),
    0 4px 14px rgba(212, 165, 116, 0.3);
  animation: ipThinkPulse 1.5s ease-in-out infinite;
}

@keyframes ipIdleBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

@keyframes ipListenRing {
  0% { transform: scale(0.92); opacity: 0.7; }
  70% { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

@keyframes ipThinkPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 10px;
  padding: 8px 12px;
  background: var(--worth-bg);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--worth);
  line-height: 1.45;
}

.context-bar.is-navigable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.context-bar.is-navigable:active {
  opacity: 0.88;
}

#context-bar-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-bar.hidden { display: none; }

.chat-shell { padding-top: 8px; }

.chat-starter {
  overflow: hidden;
  max-height: 320px;
  transition: max-height 0.35s var(--ease-soft), opacity 0.3s var(--ease-soft), margin 0.35s var(--ease-soft);
}

.chat-starter.is-collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.chat-starter.is-report-mode .chat-welcome {
  display: none;
  margin: 0;
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  justify-content: center;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.chat-welcome-hero {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: #f5f6f8;
  box-shadow: 0 4px 20px rgba(212, 165, 116, 0.28);
  margin-bottom: 14px;
}

.chat-welcome-hero.xiaoxia-ip-host[data-ip-state="idle"] {
  animation: ipIdleBreathe 4s ease-in-out infinite;
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 16px;
  max-width: 280px;
}

.ctx-quote-card {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--worth-bg);
  border: 1px solid rgba(107, 123, 126, 0.12);
  animation: fadeUp 0.45s var(--ease-soft) both;
}

.ctx-quote-card.hidden { display: none; }

.ctx-quote-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.ctx-quote-meta i {
  font-size: 11px;
  color: var(--brand-light);
}

.ctx-quote-text {
  margin: 0 0 10px;
  font-family: var(--font-family-display);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
}

.ctx-quote-play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  font-size: 12px;
  color: var(--brand);
  cursor: pointer;
  transition: background 0.15s var(--ease-soft), border-color 0.15s var(--ease-soft);
}

.ctx-quote-play:active {
  background: var(--spark-bg);
  border-color: var(--brand-light);
}

.ctx-quote-play i { font-size: 10px; }

.chip {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s var(--ease-soft);
}

.chip:active {
  background: var(--spark-bg);
  border-color: var(--brand-light);
}

.chip--highlight {
  background: var(--spark-bg);
  border-color: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 500;
}

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

.chat-time-divider {
  align-self: center;
  margin: 2px 0;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.04);
  user-select: none;
}

.chat-topic-anchor {
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  pointer-events: none;
}

.msg { display: flex; gap: 10px; align-items: flex-start; }

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

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: #f5f6f8;
  box-shadow: 0 1px 6px rgba(212, 165, 116, 0.16);
}

.msg-avatar.xiaoxia-ip-host[data-ip-state="think"] {
  box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.2), 0 2px 8px rgba(212, 165, 116, 0.22);
  animation: ipThinkPulse 1.5s ease-in-out infinite;
}

.xiaoxia-ip-svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: scale(1.08);
  transform-origin: center 42%;
}

.msg-bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
  font-size: 14px;
  line-height: 1.55;
  background: #FFF8F0;
  border-left: 3px solid var(--brand-light);
}

.msg--user .msg-bubble {
  background: #F0F4F3;
  border-left: none;
  border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
}

.msg-bubble--reply {
  min-width: 200px;
  padding: 12px 14px;
}

.reply-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
}

.reply-voice-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(196, 112, 75, 0.22);
}

.msg-bubble--reply.is-speaking {
  box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.28);
}

.msg-bubble--reply.is-speaking .voice-play-btn {
  background: rgba(196, 112, 75, 0.28);
}

.reply-voice-bar .voice-wave-bars span {
  background: var(--brand-light);
}

.anim-msg-in {
  animation: fadeUp 0.4s var(--ease-soft) both;
}

.msg-bubble--thinking {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 14px 18px;
}

.thinking-dots {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 18px;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-light);
  animation: typingDotBounce 1.35s ease-in-out infinite;
  will-change: transform, opacity;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingDotBounce {
  0%, 65%, 100% { transform: translateY(0); opacity: 0.38; }
  32% { transform: translateY(-5px); opacity: 1; }
}

.chat-compose {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 82px;
  z-index: 14;
}

.chat-quote-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px 8px;
  background: rgba(255, 252, 248, 0.98);
  border-top: 1px solid var(--divider);
}

.chat-quote-preview.hidden { display: none; }

.chat-quote-preview-body {
  flex: 1;
  min-width: 0;
  border-left: 3px solid var(--brand-light);
  padding-left: 10px;
}

.chat-quote-preview-label {
  display: block;
  font-size: 12px;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-quote-preview-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-quote-preview-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-tertiary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.msg-quote-block {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.msg-quote-label {
  display: block;
  font-size: 11px;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: 4px;
}

.msg-quote-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.msg--user .msg-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}

.chat-quote-menu {
  position: fixed;
  z-index: 30;
  padding: 4px;
  border-radius: var(--radius-md);
  background: rgba(40, 40, 40, 0.92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -100%);
}

.chat-quote-menu.hidden { display: none; }

.chat-quote-menu-btn {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.chat-quote-menu-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.chat-input-bar {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 252, 248, 0.96);
  border-top: 1px solid var(--divider);
  z-index: 14;
}

.chat-mode-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  transition: color 0.15s var(--ease-soft), border-color 0.15s var(--ease-soft);
}

.chat-mode-toggle:active {
  color: var(--brand);
  border-color: var(--brand-light);
}

.chat-mode-toggle .mode-icon-text,
.chat-mode-toggle .mode-icon-voice { display: none; }

.chat-input-bar[data-mode="voice"] .mode-icon-text { display: block; }
.chat-input-bar[data-mode="voice"] .mode-icon-voice { display: none; }
.chat-input-bar[data-mode="text"] .mode-icon-text { display: none; }
.chat-input-bar[data-mode="text"] .mode-icon-voice { display: block; }

.chat-input-bar[data-mode="voice"] .chat-voice-hold { display: flex; }
.chat-input-bar[data-mode="voice"] .chat-text-wrap,
.chat-input-bar[data-mode="voice"] .chat-send { display: none; }

.chat-input-bar[data-mode="text"] .chat-voice-hold { display: none; }
.chat-input-bar[data-mode="text"] .chat-text-wrap,
.chat-input-bar[data-mode="text"] .chat-send { display: flex; }

.chat-voice-hold {
  flex: 1;
  height: 40px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  background: var(--surface-card);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 0.12s var(--ease-soft), border-color 0.12s var(--ease-soft), transform 0.12s var(--ease-soft);
}

.chat-voice-hold:active,
.chat-voice-hold.is-recording {
  background: var(--spark-bg);
  border-color: var(--brand-light);
  transform: scale(0.98);
}

.chat-text-wrap {
  flex: 1;
  display: none;
  align-items: center;
}

.chat-input {
  flex: 1;
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 0 16px;
  font-size: 14px;
  background: var(--surface-card);
  outline: none;
}

.chat-input:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px var(--color-focus-ring, rgba(196, 112, 75, 0.2));
}

.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: var(--brand-on);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg-bubble--voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
  padding: 10px 14px;
  cursor: pointer;
}

.voice-play-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(196, 112, 75, 0.15);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  cursor: pointer;
}

.msg--user .voice-play-btn {
  background: rgba(44, 54, 57, 0.1);
  color: var(--text-primary);
}

.voice-wave-bars {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
}

.voice-wave-bars span {
  flex: 1;
  max-width: 3px;
  border-radius: 2px;
  background: var(--brand-light);
  animation: voiceBar 0.9s ease-in-out infinite;
}

.msg--user .voice-wave-bars span { background: var(--text-tertiary); }

.voice-wave-bars span:nth-child(2) { animation-delay: 0.12s; }
.voice-wave-bars span:nth-child(3) { animation-delay: 0.24s; }
.voice-wave-bars span:nth-child(4) { animation-delay: 0.36s; }
.voice-wave-bars span:nth-child(5) { animation-delay: 0.48s; }
.voice-wave-bars span:nth-child(6) { animation-delay: 0.6s; }
.voice-wave-bars span:nth-child(7) { animation-delay: 0.72s; }
.voice-wave-bars span:nth-child(8) { animation-delay: 0.84s; }

.voice-wave-bars.is-paused span { animation-play-state: paused; height: 4px !important; }

.voice-duration {
  font-family: var(--font-family-data);
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.chat-voice-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 140px;
  background: rgba(44, 54, 57, 0.28);
  pointer-events: none;
}

.chat-voice-overlay.hidden { display: none; }

.chat-voice-recording-panel {
  min-width: 160px;
  padding: 20px 28px;
  border-radius: var(--radius-lg);
  background: rgba(44, 54, 57, 0.88);
  color: var(--brand-on);
  text-align: center;
  box-shadow: var(--shadow-float);
}

.chat-voice-recording-panel.is-cancel {
  background: rgba(212, 132, 124, 0.92);
}

.chat-voice-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  margin-bottom: 10px;
}

.chat-voice-wave span {
  width: 4px;
  height: 8px;
  border-radius: 2px;
  background: var(--brand-light);
  animation: voiceBar 0.7s ease-in-out infinite;
}

.chat-voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.chat-voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.chat-voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.chat-voice-wave span:nth-child(5) { animation-delay: 0.4s; }

.chat-voice-hint {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
}

@keyframes voiceBar {
  0%, 100% { height: 6px; }
  50% { height: 22px; }
}

.chat-voice-call-btn.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.voice-call-widget {
  position: absolute;
  right: 16px;
  bottom: 150px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #3a3530 0%, #2c3639 100%);
  border: 1px solid rgba(232, 168, 124, 0.28);
  box-shadow:
    0 8px 24px rgba(44, 54, 57, 0.28),
    0 0 0 1px rgba(255, 252, 248, 0.06);
  color: var(--brand-on);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease-soft), box-shadow 0.2s var(--ease-soft);
  animation: widgetSlideIn 0.45s var(--ease-soft) both;
}

.voice-call-widget.hidden { display: none; }

.voice-call-widget:active {
  transform: scale(0.97);
}

.voice-call-widget-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(196, 112, 75, 0.32);
  color: var(--brand-light);
  font-size: 13px;
  flex-shrink: 0;
}

.voice-call-widget-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.voice-call-widget-info strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-on);
  white-space: nowrap;
}

.voice-call-widget-info span {
  font-family: var(--font-family-data);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: rgba(255, 252, 248, 0.62);
}

.voice-call-widget-expand {
  font-size: 12px;
  color: rgba(255, 252, 248, 0.45);
  margin-left: 2px;
}

@keyframes widgetSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .layout-chat .top-header-shell {
    display: block;
    padding-top: env(safe-area-inset-top);
    background: rgba(255, 252, 248, 0.96);
    border-bottom: 1px solid var(--divider);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .layout-chat .chat-topbar {
    padding: 10px 16px;
    position: relative;
    top: auto;
  }

  .voice-call-widget { bottom: 142px; }
  .layout-chat .screen-content { padding-top: 120px; padding-bottom: 128px; }
  .layout-chat:has(#context-bar:not(.hidden)) .screen-content,
  .layout-chat.has-chat-context .screen-content { padding-top: 162px; }
  .chat-compose { bottom: 64px; }
  .chat-voice-overlay { padding-bottom: 128px; }

  /* 移动端消息/引用卡入场动画易卡在 opacity:0 */
  .anim-msg-in,
  .ctx-quote-card {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .layout-chat.has-chat-context .chat-starter {
    max-height: none;
    opacity: 1;
    pointer-events: auto;
  }
}
