/* 前台客服对话 */
.chat-body{min-height:100vh;background:var(--page-bg)}
.chat-app{
  width:100%;max-width:none;margin:0;
  height:calc(100dvh - var(--ios-nav-inline-h));
  display:flex;flex-direction:column;
  background:var(--page-bg);
}
.chat-subtitle{
  flex-shrink:0;text-align:center;font-size:12px;color:var(--text-muted);
  padding:12px 14px 8px;
  background:var(--page-bg);
}

.chat-msgs{
  flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;
  padding:16px 14px 10px;
  display:flex;flex-direction:column;gap:10px;
}
.chat-tip{
  align-self:center;font-size:12px;color:var(--text-muted);
  background:var(--card-bg);border:1px solid var(--card-border);
  border-radius:999px;padding:6px 12px;margin-bottom:6px;
}
.chat-bubble{
  max-width:78%;padding:10px 12px;border-radius:14px;
  font-size:14px;line-height:1.45;word-break:break-word;
  box-shadow:0 2px 8px rgba(0,0,0,.04);
}
.chat-bubble.visitor{
  align-self:flex-end;
  background:var(--primary);color:#fff;
  border-bottom-right-radius:4px;
}
.chat-bubble.admin{
  align-self:flex-start;
  background:var(--card-bg);color:var(--text);
  border:1px solid var(--card-border);
  border-bottom-left-radius:4px;
}
.chat-bubble .t{
  display:block;margin-top:4px;font-size:11px;opacity:.65;
}

.chat-input-bar{
  flex-shrink:0;
  display:flex;gap:6px;align-items:center;
  padding:10px 10px;padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));
  border-top:1px solid var(--divider);
  background:var(--card-bg);
}
.chat-tool-btn{
  width:36px;height:36px;border:none;border-radius:50%;
  background:var(--icon-plate,rgba(0,0,0,.06));color:var(--text-muted);
  display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer;
}
.chat-tool-btn:active{opacity:.7}
.chat-voice-btn.is-recording{background:#ff3b30;color:#fff}
.chat-voice-panel{
  flex-shrink:0;padding:0 10px 8px;background:var(--card-bg);
  border-top:1px solid var(--divider);
}
.chat-voice-panel[hidden]{display:none!important}
.chat-voice-panel-inner{
  display:flex;align-items:center;gap:10px;
  padding:10px 12px;border-radius:12px;
  background:rgba(255,59,48,.08);border:1px solid rgba(255,59,48,.18);
}
.chat-voice-dot{
  width:10px;height:10px;border-radius:50%;background:#ff3b30;flex-shrink:0;
  animation:chatVoicePulse 1s ease-in-out infinite;
}
@keyframes chatVoicePulse{
  0%,100%{opacity:1;transform:scale(1)}
  50%{opacity:.45;transform:scale(.88)}
}
.chat-voice-tip{flex:1;min-width:0;font-size:13px;color:var(--text);font-weight:600}
.chat-voice-time{font-size:12px;color:var(--text-muted);font-variant-numeric:tabular-nums;flex-shrink:0}
.chat-voice-cancel,.chat-voice-send{
  border:none;border-radius:999px;padding:8px 14px;font-size:13px;font-weight:600;cursor:pointer;flex-shrink:0;
}
.chat-voice-cancel{background:var(--icon-plate,rgba(0,0,0,.06));color:var(--text)}
.chat-voice-send{background:var(--primary);color:#fff}
.chat-file-input{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip:rect(0,0,0,0);white-space:nowrap;border:0;
}
.chat-input-bar input{
  flex:1;min-width:0;border:1px solid var(--card-border);border-radius:20px;
  padding:11px 12px;font-size:14px;outline:none;
  background:var(--page-bg);color:var(--text);
}
.chat-input-bar input:focus{border-color:var(--primary)}
.chat-send{
  border:none;background:var(--primary);color:#fff;
  border-radius:20px;padding:11px 14px;font-size:14px;font-weight:600;
  cursor:pointer;flex-shrink:0;
}
.chat-send:disabled{opacity:.55;cursor:not-allowed}
.chat-msg-img{max-width:220px;max-height:180px;width:auto;height:auto;object-fit:contain;border-radius:10px;display:block;background:rgba(0,0,0,.04)}
.chat-img-open{border:none;background:transparent;padding:0;margin:0;display:block;cursor:zoom-in;line-height:0}
.chat-bubble.visitor .chat-img-open{background:transparent}
.chat-msg-audio{max-width:220px;height:36px;display:block}
.chat-voice-player{display:inline-flex;align-items:center;gap:8px;min-width:120px;max-width:220px;padding:8px 12px;border-radius:999px;background:rgba(0,0,0,.06);color:inherit}
.chat-bubble.visitor .chat-voice-player{background:rgba(255,255,255,.2);color:#fff}
.chat-bubble.admin .chat-voice-player{background:rgba(0,0,0,.05);color:var(--text)}
.chat-voice-play{width:28px;height:28px;border-radius:50%;border:none;background:var(--primary);color:#fff;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer;padding:0}
.chat-bubble.visitor .chat-voice-play{background:#fff;color:var(--primary)}
.chat-bubble.admin .chat-voice-play{background:var(--primary);color:#fff}
.chat-voice-wave{display:inline-flex;align-items:center;gap:3px;height:16px}
.chat-voice-wave i{display:block;width:3px;height:6px;border-radius:2px;background:currentColor;opacity:.45}
.chat-voice-player.is-playing .chat-voice-wave i{animation:chatVoiceBar .8s ease-in-out infinite}
.chat-voice-player.is-playing .chat-voice-wave i:nth-child(1){animation-delay:0s}
.chat-voice-player.is-playing .chat-voice-wave i:nth-child(2){animation-delay:.15s}
.chat-voice-player.is-playing .chat-voice-wave i:nth-child(3){animation-delay:.3s}
.chat-voice-player.is-playing .chat-voice-wave i:nth-child(4){animation-delay:.45s}
@keyframes chatVoiceBar{0%,100%{height:6px}50%{height:14px}}
.chat-voice-label{font-size:12px;opacity:.85}
.chat-voice-audio{display:none!important}
.chat-msg-html{font-size:14px;line-height:1.5;word-break:break-word}
.chat-msg-html p{margin:0 0 .35em}
.chat-msg-html p:last-child{margin-bottom:0}
.chat-msg-html strong,.chat-msg-html b{font-weight:700}
.chat-msg-html em,.chat-msg-html i{font-style:italic}
.chat-msg-html u{text-decoration:underline}
.chat-msg-html s{text-decoration:line-through}
.chat-msg-html ul,.chat-msg-html ol{margin:.25em 0;padding-left:1.25em}
.chat-msg-html li{margin:.12em 0}
.chat-msg-html img{max-width:100%;height:auto;border-radius:8px}
.chat-msg-html a{color:var(--primary);text-decoration:underline}
.chat-bubble.admin .chat-msg-html a{color:var(--primary)}
.chat-img-lightbox{display:none;position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.88);align-items:center;justify-content:center;padding:20px}
.chat-img-lightbox.show{display:flex}
.chat-img-lightbox img{max-width:100%;max-height:100%;object-fit:contain;border-radius:8px}
.chat-img-lightbox-close{position:absolute;top:calc(16px + env(safe-area-inset-top,0px));right:16px;width:40px;height:40px;border:none;border-radius:50%;background:rgba(255,255,255,.15);color:#fff;font-size:28px;line-height:1;cursor:pointer}
.chat-emoji-panel{
  flex-shrink:0;padding:8px 10px 10px;background:var(--card-bg);
  border-top:1px solid var(--divider);
}
.chat-emoji-panel[hidden]{display:none!important}
.chat-emoji-grid{display:grid;grid-template-columns:repeat(8,1fr);gap:6px;max-height:160px;overflow-y:auto}
.chat-emoji-grid button{
  border:none;background:var(--icon-plate,rgba(0,0,0,.04));border-radius:10px;
  font-size:22px;line-height:1;padding:8px 0;cursor:pointer;
}
.chat-emoji-grid button:active{transform:scale(.92)}
.chat-tool-btn.chat-tool-btn--emoji{font-size:18px;line-height:1}
.chat-sound-btn .icon-off{display:none}
.chat-sound-btn.is-off{color:var(--text-muted);opacity:.55}
.chat-sound-btn.is-off .icon-on{display:none}
.chat-sound-btn.is-off .icon-off{display:block}
.chat-voice-tag{font-style:italic;opacity:.85}
.chat-bubble.is-pending{opacity:.72}
.chat-bubble.is-failed{background:#ff3b30;border-color:#ff3b30;color:#fff}
.chat-subtitle.is-offline{color:#ff3b30}
