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

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background-color: #f3f5f8;
  color: #1f2937;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

.chat-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background-color: #f3f5f8;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* 顶部公告栏（对照参考站橙色横幅） */
.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #fff7ed;
  border-bottom: 1px solid #ffedd5;
  color: #ea580c;
  font-size: 13px;
  line-height: 1.4;
  flex-shrink: 0;
  z-index: 20;
}

.notice-content {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.notice-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.notice-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice-close {
  background: transparent;
  border: none;
  color: #ea580c;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  margin-left: 8px;
  flex-shrink: 0;
}

.notice-close:hover {
  background: rgba(234, 88, 12, 0.1);
}

/* 极简状态顶条 */
.chat-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.agent-badge-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.agent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
  transition: background-color 0.25s;
}

.agent-dot.connected {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.agent-current-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.typing-indicator {
  font-size: 12px;
  color: #3b82f6;
  animation: pulseFade 1.2s infinite;
}

@keyframes pulseFade {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #4b5563;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
}

.header-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.header-btn.muted {
  color: #9ca3af;
  text-decoration: line-through;
  opacity: 0.55;
}

/* 聊天主体滚动区 */
.chat-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 20px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat-body::-webkit-scrollbar {
  width: 5px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.35);
  border-radius: 4px;
}

.brand-pill-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 14px;
}

.brand-pill {
  display: inline-block;
  padding: 6px 18px;
  background: #ffffff;
  color: #9ca3af;
  font-size: 12px;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.message-list {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 时间分隔 / 系统提示 */
.msg-time-divider {
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
  margin: 4px 0;
}

.msg-system {
  align-self: center;
  background: rgba(229, 231, 235, 0.72);
  color: #6b7280;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  max-width: 85%;
  text-align: center;
}

/* 消息行 */
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
}

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

.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  background: #409eff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  user-select: none;
}

.msg-avatar.visitor-avatar {
  background: #64748b;
}

.msg-content-col {
  display: flex;
  flex-direction: column;
  max-width: min(76%, 560px);
  min-width: 0;
}

.msg-row.visitor .msg-content-col {
  align-items: flex-end;
}

.msg-sender-name {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 5px;
  padding-left: 2px;
}

.msg-bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.msg-row.visitor .msg-bubble-wrap {
  flex-direction: row-reverse;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}

.msg-row.agent .msg-bubble {
  background: #ffffff;
  color: #1f2937;
  border-top-left-radius: 4px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.msg-row.visitor .msg-bubble {
  background: #409eff;
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(64, 158, 255, 0.22);
}

.msg-meta-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.msg-meta-status {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
  flex-shrink: 0;
}

.msg-meta-status.read {
  color: #10b981;
}

.msg-recall-btn {
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 11px;
  padding: 2px 3px;
  cursor: pointer;
  line-height: 1.2;
}

.msg-recall-btn:hover {
  color: #ef4444;
}

/* 气泡内图片 */
.msg-bubble.image-bubble {
  padding: 5px;
  background: #ffffff !important;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

.msg-img {
  display: block;
  max-width: 220px;
  max-height: 240px;
  border-radius: 8px;
  cursor: zoom-in;
  object-fit: cover;
}

/* 气泡内语音条 */
.voice-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 90px;
  cursor: pointer;
  user-select: none;
}

.voice-waves {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.voice-waves span {
  display: inline-block;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.75;
}

.voice-waves span:nth-child(2) { height: 12px; }
.voice-waves span:nth-child(3) { height: 9px; }

.voice-msg.playing .voice-waves span {
  animation: waveBar 0.7s infinite ease-in-out alternate;
}

.voice-msg.playing .voice-waves span:nth-child(2) { animation-delay: 0.15s; }
.voice-msg.playing .voice-waves span:nth-child(3) { animation-delay: 0.3s; }

@keyframes waveBar {
  from { height: 4px; }
  to { height: 16px; }
}

/* 气泡内文件卡片 */
.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 170px;
}

.file-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(64, 158, 255, 0.12);
  color: #409eff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg-row.visitor .file-card-icon {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.file-card-info {
  min-width: 0;
  flex: 1;
}

.file-card-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card-size {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
}

/* 可选 FAQ 卡片 */
.faq-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  margin-top: 4px;
}

.faq-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.faq-item-link {
  display: block;
  color: #2563eb;
  font-size: 14px;
  padding: 5px 0;
  cursor: pointer;
  text-decoration: none;
}

.faq-item-link:hover {
  text-decoration: underline;
}

/* 悬浮回到底部按钮 */
.new-msg-float {
  position: absolute;
  right: 16px;
  bottom: 185px;
  background: #409eff;
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.35);
  cursor: pointer;
  z-index: 15;
}

/* 底部整体区域 */
.chat-footer {
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  position: relative;
}

/* 快捷标签栏（对照截图底部一排胶囊按钮） */
.quick-tags-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 4px;
  background: #f3f5f8;
  border-top: 1px solid #e5e7eb;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-tags-bar::-webkit-scrollbar {
  display: none;
}

.quick-tags-bar:empty {
  display: none;
}

.quick-tag-btn {
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #374151;
  font-size: 13px;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-tag-btn:hover {
  border-color: #409eff;
  color: #409eff;
}

.quick-tag-btn:active {
  transform: scale(0.97);
}

/* 语音录制条 */
.voice-recorder-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  gap: 10px;
}

.voice-rec-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
}

.rec-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
}

.rec-pulse.recording {
  background: #ef4444;
  animation: pulseRec 0.9s infinite;
}

@keyframes pulseRec {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.55; }
}

.rec-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #409eff;
}

.voice-rec-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v-btn {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.v-cancel {
  background: #e5e7eb;
  color: #374151;
}

.v-start {
  background: #409eff;
  color: #ffffff;
}

.v-start.recording {
  background: #ef4444;
}

.v-upload-audio {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #374151;
}

/* 弹出扩展面板（Emoji / 语言 / 更多） */
.popup-panel {
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 12px 14px;
  max-height: 210px;
  overflow-y: auto;
}

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 6px;
}

.emoji-item {
  font-size: 22px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
}

.emoji-item:hover {
  background: #e5e7eb;
}

.panel-title {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 10px;
}

.lang-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lang-opt {
  padding: 7px 16px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.lang-opt.active {
  border-color: #409eff;
  color: #409eff;
  background: #eff6ff;
  font-weight: 600;
}

.more-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #374151;
  font-size: 12px;
}

.more-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b5563;
}

.more-item:hover .more-icon {
  border-color: #409eff;
  color: #409eff;
}

/* 输入框区 */
.composer-box {
  background: #ffffff;
  padding: 8px 14px 10px;
  border-top: 1px solid #e5e7eb;
}

.toolbar-icons {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.tool-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s, background-color 0.15s;
}

.tool-btn:hover,
.tool-btn.active {
  color: #409eff;
  background: #eff6ff;
}

.input-row {
  width: 100%;
}

.msg-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: #1f2937;
  min-height: 46px;
  max-height: 120px;
  background: transparent;
}

.msg-textarea::placeholder {
  color: #9ca3af;
}

.send-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.paste-hint {
  font-size: 11px;
  color: #9ca3af;
}

.send-btn {
  border: none;
  border-radius: 6px;
  padding: 7px 22px;
  font-size: 14px;
  font-weight: 500;
  background: #409eff;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.18s, opacity 0.18s;
}

.send-btn:disabled {
  background: #a0cfff;
  cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
  background: #2b85e4;
}

/* 灯箱 */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.lightbox img {
  max-width: 95%;
  max-height: 92%;
  border-radius: 6px;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
}

/* 评价弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background: #ffffff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 14px;
}

.star-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.star {
  font-size: 28px;
  color: #d1d5db;
  cursor: pointer;
  user-select: none;
}

.star.active {
  color: #f59e0b;
}

.rate-textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  outline: none;
  margin-bottom: 14px;
}

.rate-textarea:focus {
  border-color: #409eff;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.m-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}

.m-cancel {
  background: #f3f4f6;
  color: #4b5563;
}

.m-submit {
  background: #409eff;
  color: #ffffff;
}

/* Toast */
.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.85);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 1200;
  pointer-events: none;
}

@media (max-width: 640px) {
  .msg-textarea,
  .rate-textarea {
    font-size: 16px;
  }
  .msg-textarea {
    min-height: 36px;
    line-height: 1.4;
  }
  .chat-app.keyboard-open .composer-box {
    padding: 6px 12px 8px;
  }
  .chat-app.keyboard-open .msg-textarea {
    min-height: 30px;
    max-height: 76px;
  }
  .chat-app.keyboard-open .quick-tags-bar {
    padding: 6px 10px 4px;
  }
  .paste-hint {
    display: none;
  }
  .send-row {
    justify-content: flex-end;
  }
  .msg-content-col {
    max-width: 80%;
  }
  .msg-avatar {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }
  .voice-recorder-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .voice-rec-actions {
    justify-content: flex-end;
  }
}
