/* 沿用原小程序的聊天样式，rpx 按 375px 手机视口转换为 px。 */
.chat-screen { position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; width: 100%; overflow: hidden; background: #ededed; color: #111; box-sizing: border-box; }
.chat-navbar { flex: 0 0 auto; width: 100%; box-sizing: border-box; background: #ededed; border-bottom: 0.5px solid #dcdcdc; }
/* 清除浏览器按钮内边距，给左右图标相同的 44px 点击区域，避免箭头被挤小。 */
.nav-control { position: absolute; top: 0; display: flex; align-items: center; justify-content: center; width: 44px; height: 100%; padding: 0; line-height: 1; -webkit-appearance: none; appearance: none; box-sizing: border-box; }
.nav-back { left: 6px; }
/* 箭头从 9px 放大到 12px，并禁止 flex 收缩，旋转后的两条边完整显示。 */
.back-chevron { display: block; flex: 0 0 auto; width: 12px; height: 12px; border-left: 2px solid #171717; border-bottom: 2px solid #171717; transform: rotate(45deg); }
.nav-title { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 90px; text-align: center; font-size: 17px; font-weight: 600; line-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-warning { padding: 6px 12px; background: #fff4db; color: #94651f; font-size: 11px; line-height: 1.5; flex: 0 0 auto; box-sizing: border-box; }
/* 聊天区收缩到导航和输入栏之间，由自身滚动，避免页面出现第二条纵向滚动条。 */
.chat-list { flex: 1 1 0%; min-height: 0; height: 0; width: 100%; box-sizing: border-box; }
.empty-chat-tip { padding: 18px 0 0; text-align: center; }
.empty-chat-tip span { display: inline-block; padding: 3px 7px; border-radius: 3px; background: #dadada; color: #fff; font-size: 11px; line-height: 16px; }
.message-stack { padding: 7px 0 10px; }
.message-row { display: flex; align-items: flex-start; padding: 9px 12px 0; box-sizing: border-box; width: 100%; }
.message-user { flex-direction: row-reverse; }
.message-avatar { flex: 0 0 40px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 4px; background: #07c160; color: #fff; font-size: 14px; font-weight: 600; }
.message-user .message-avatar { background: #7c97b5; }
.avatar-person { position: relative; width: 26px; height: 30px; overflow: hidden; }
.avatar-person::before { content: ''; position: absolute; width: 11px; height: 11px; top: 2px; left: 7.5px; border-radius: 50%; background: #fff; }
.avatar-person::after { content: ''; position: absolute; width: 24px; height: 16px; top: 16px; left: 1px; border-radius: 14px 14px 3px 3px; background: #fff; }
.message-content { min-width: 0; max-width: calc(100% - 66px); margin-left: 10px; }
.message-user .message-content { margin-left: 0; margin-right: 10px; }
.message-bubble { position: relative; padding: 10px 12px; border-radius: 4px; background: #fff; box-sizing: border-box; min-height: 40px; }
.message-bubble::before { content: ''; position: absolute; left: -6px; top: 14px; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 7px solid #fff; }
.message-user .message-bubble { background: #95ec69; }
.message-user .message-bubble::before { left: auto; right: -6px; border-right: 0; border-left: 7px solid #95ec69; }
.chat-message-text { display: block; color: #111; font-size: 16px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; word-break: break-word; }
.message-image-block { width: 190px; max-width: 100%; margin-top: 5px; }
.chat-image { display: block; width: 100%; border-radius: 3px; }
.message-progress { display: flex; align-items: center; max-width: 100%; font-size: 11.5px; line-height: 1.5; color: #777; }
.typing-dots { display: flex; flex: 0 0 auto; margin-right: 6px; }
.typing-dots span { width: 4px; height: 4px; margin-right: 2.5px; border-radius: 50%; background: #999; animation: typing-pulse 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-pulse { 0%, 80%, 100% { opacity: .35; } 40% { opacity: 1; } }
.message-error { display: block; margin-top: 5px; font-size: 11.5px; color: #bd4848; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.message-end { height: 6px; }
.image-unavailable { padding: 14px 5px; color: #999; font-size: 11.5px; background: #f5f5f5; }
/* 输入栏使用一行 flex 布局，并显式限制控件宽度，避免发送按钮挤出屏幕。 */
.chat-composer { flex: 0 0 auto; width: 100%; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); box-sizing: border-box; background: #f7f7f7; border-top: 0.5px solid #dcdcdc; }
.composer-input-row { display: flex; align-items: flex-end; width: 100%; box-sizing: border-box; }
.input-shell { flex: 1 1 0%; min-width: 0; width: 0; min-height: 36px; max-height: 96px; padding: 6px 8px; border-radius: 5px; background: #fff; box-sizing: border-box; overflow: hidden; }
.chat-input { display: block; width: 100%; min-height: 24px; height: 24px; max-height: 84px; padding: 0; border: 0; box-sizing: border-box; color: #111; background: #fff; font-size: 16px; line-height: 24px; }
/* 发送按钮使用固定宽度，输入框占用剩余空间。 */
.chat-composer .send-button { display: flex; align-items: center; justify-content: center; flex: 0 0 56px; width: 56px; min-width: 56px; max-width: 56px; height: 36px; padding: 0; margin: 0 0 0 6px; box-sizing: border-box; border-radius: 4px; background: #07c160; color: #fff; font-size: 14px; font-weight: 500; line-height: 1; }
.chat-composer .send-button[disabled] { background: #e5e5e5; color: #aaa; }
.composer-error { display: block; padding: 0 4px 6px; font-size: 11.5px; color: #bd4848; line-height: 1.5; }
.draft-photos { width: 100%; white-space: nowrap; margin-bottom: 7px; }
.draft-photo { display: inline-block; position: relative; width: 52px; height: 52px; margin-right: 7px; }
.draft-photo img { width: 100%; height: 100%; border-radius: 4px; }
/* 选图后提示提前上传进度，沿用原缩略图尺寸，不改变聊天页面布局。 */
.draft-upload-status { position: absolute; bottom: 0; left: 0; width: 100%; padding: 2px 0; border-radius: 0 0 4px 4px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; text-align: center; pointer-events: none; }
.draft-remove { position: absolute; top: 0; right: 0; width: 17px; height: 17px; line-height: 15px; text-align: center; border-radius: 0 4px 0 4px; color: #fff; background: rgba(0, 0, 0, .55); font-size: 15px; }
/* 相册、拍摄各占下方一半宽度，使用紧凑的一行按钮；明确 flex 和宽度，避免默认按钮样式撑出屏幕。
   图标沿用原来的相册、相机绘制方式，缩小后与文字水平居中。 */
.composer-photo-actions { display: flex; width: 100%; margin-top: 6px; box-sizing: border-box; }
.composer-photo-actions .composer-photo-button { display: flex; align-items: center; justify-content: center; flex: 1 1 0%; width: 0; min-width: 0; height: 34px; padding: 0; margin: 0; border-radius: 5px; background: #fff; color: #555; font-size: 13px; line-height: 1; box-sizing: border-box; }
.composer-photo-button + .composer-photo-button { margin-left: 6px; }
.composer-photo-button .album-icon, .composer-photo-button .camera-icon { flex: 0 0 auto; margin-right: 6px; transform: scale(.72); }
.composer-photo-actions .composer-photo-button[disabled] { opacity: .45; }
.album-icon { position: relative; width: 24px; height: 21px; border: 2px solid #555; border-radius: 3px; overflow: hidden; }
.album-icon::before { content: ''; position: absolute; right: 3.5px; top: 3px; width: 4px; height: 4px; border-radius: 50%; background: #555; }
.album-icon span { position: absolute; width: 14px; height: 14px; left: 3px; top: 11px; transform: rotate(45deg); background: #555; border-radius: 1.5px; }
.camera-icon { position: relative; width: 26px; height: 18px; border: 2px solid #555; border-radius: 3px; }
.camera-icon::before { content: ''; position: absolute; left: 6.5px; top: -6px; width: 13px; height: 5px; background: #555; border-radius: 2px 2px 0 0; }
.camera-icon span { position: absolute; left: 7.5px; top: 3.5px; width: 9px; height: 9px; border: 1.5px solid #555; border-radius: 50%; }
/* 历史采用微信式会话列表，独立占用导航栏以下区域，不再使用悬浮面板。 */
.history-panel { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; height: 0; width: 100%; background: #fff; }
/* 顶部新建按钮固定在独立操作区；只有下方记录滚动，避免记录多时新建入口被卷走。
   显式设置按钮宽高与内边距，避免按钮越界或文字不居中。 */
.history-actions { flex: 0 0 auto; padding: 12px; border-bottom: 0.5px solid #eee; box-sizing: border-box; }
.history-actions .history-new-button { display: flex; align-items: center; justify-content: center; width: 100%; height: 44px; padding: 0; margin: 0; border-radius: 6px; background: #07c160; color: #fff; font-size: 15px; font-weight: 600; line-height: 1; box-sizing: border-box; }
.history-actions .history-new-button[disabled] { background: #e5e5e5; color: #999; }
.history-list { flex: 1 1 0%; min-height: 0; width: 100%; height: 0; }
.history-row { display: flex; align-items: center; padding: 12px; width: 100%; box-sizing: border-box; border-bottom: 0.5px solid #eee; }
.history-avatar { flex: 0 0 48px; width: 48px; height: 48px; line-height: 48px; text-align: center; border-radius: 5px; background: #07c160; color: #fff; font-size: 15px; font-weight: 600; }
.history-body { flex: 1 1 0%; width: 0; min-width: 0; margin: 0 10px; }
.history-title { display: block; color: #111; font-size: 15.5px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-preview { display: block; margin-top: 4px; color: #999; font-size: 12.5px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.current-chat-dot { flex: 0 0 6px; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #07c160; }
.history-row .delete-chat { flex: 0 0 36px; width: 36px; min-width: 36px; height: 26px; line-height: 26px; margin: 0; padding: 0; background: transparent; color: #b85d5d; font-size: 11px; box-sizing: border-box; }

/* H5 标签的必要适配：独立滚动、真实按钮、手机安全区和电脑宽度。 */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, textarea, input { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible { outline: 2px solid #07c160; outline-offset: 2px; }
.chat-navbar { position: relative; min-height: calc(52px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
.nav-control { height: 52px; top: auto; bottom: 0; background: transparent; }
.nav-title { margin: 0; width: min(55%, 280px); top: auto; bottom: 0; height: 52px; line-height: 52px; transform: translateX(-50%); }
.nav-more { right: 6px; font-size: 30px; font-weight: 300; }
.chat-list, .history-list { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.chat-screen { bottom: auto; height: 100dvh; }
.chat-input { resize: none; outline: none; overflow-y: auto; }
.chat-input::placeholder { color: #b0b0b0; }
.draft-photos { overflow-x: auto; }
.draft-photo img { object-fit: cover; }
.album-icon, .camera-icon { display: inline-block; }
.chat-image { object-fit: contain; height: auto; cursor: zoom-in; }
.typing-dots span { display: inline-block; }
.history-open { display: flex; align-items: center; flex: 1; min-width: 0; background: transparent; padding: 0; text-align: left; }
.history-open:hover { background: #f8f8f8; }
.local-note { flex: 0 0 auto; margin: 0; padding: 12px; text-align: center; color: #999; font-size: 12px; border-top: 1px solid #eee; }
.clipboard-helper { position: fixed; top: -1000px; }
/* 不依赖浏览器的 dialog 默认样式隐藏关闭的弹窗，防止“×”叠到导航栏。 */
dialog:not([open]) { display: none !important; }
dialog { max-width: min(94vw, 900px); max-height: 92dvh; padding: 36px 14px 14px; border: 0; border-radius: 8px; }
dialog::backdrop { background: rgba(0,0,0,.75); }
/* 缺少 showModal 的浏览器使用页面遮罩和固定定位；关闭按钮定位在弹窗内。 */
.dialog-backdrop { position: fixed; inset: 0; top: 0; right: 0; bottom: 0; left: 0; z-index: 1000; background: rgba(0,0,0,.75); }
dialog.dialog-fallback[open] { display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1001; width: calc(100% - 32px); max-width: 900px; max-height: calc(100% - 32px); margin: 0; overflow: auto; background: #fff; color: #111; }
/* 小尺寸图片也保留足够的弹窗宽度，避免等宽按钮中的长文字溢出。 */
#image-viewer { width: calc(100% - 32px); }
#preview-image { display: block; max-width: 100%; max-height: 72dvh; margin: auto; object-fit: contain; }
/* 保留 iPhone 的图片长按菜单；提示只在点击微信保存按钮后出现。 */
#preview-image { -webkit-touch-callout: default; }
.image-save-hint { margin: 12px 0 0; color: #666; font-size: 14px; line-height: 20px; text-align: center; }
.viewer-close { position: absolute; right: 8px; top: 4px; font-size: 26px; background: transparent; }
.viewer-actions { display: flex; justify-content: center; gap: 12px; margin-top: 14px; }
/* 两个操作平分可用宽度，min-width: 0 防止较长文字撑大左侧按钮。
   button 和 a 统一高度、字体、边框和居中方式，消除手机浏览器默认样式差异。 */
.viewer-actions button, .viewer-actions a { flex: 1 1 0; min-width: 0; height: 44px; display: flex; align-items: center; justify-content: center; box-sizing: border-box; margin: 0; border: 0; appearance: none; -webkit-appearance: none; background: #07c160; color: #fff; padding: 0 6px; border-radius: 6px; text-decoration: none; font-family: inherit; font-size: 14px; font-weight: 400; line-height: 20px; white-space: nowrap; }
@media (min-width: 800px) {
  body { background: #dcdcdc; }
  .chat-screen { max-width: 960px; margin: auto; border-left: 1px solid #ccc; border-right: 1px solid #ccc; }
  .message-content { max-width: 75%; }
  .message-image-block { width: 320px; }
}
