/* AI 超级客服 - 顾客端样式（浅色主题） */
:root{
  --brand:#2563eb;
  --brand-soft:color-mix(in srgb, var(--brand) 10%, #fff);
  --bg:#f5f7fb;
  --panel:#ffffff;
  --text:#111827;
  --text-2:#4b5563;
  --text-3:#9ca3af;
  --line:#e8ebf2;
  --line-2:#f1f3f8;
  --radius:16px;
  --shadow:0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
}
*{box-sizing:border-box}
/* 必须保留：hidden 属性只是 UA 样式表里的 [hidden]{display:none}（优先级最低），
   会被 .chat-banner{display:flex} / .chat-quick{display:flex} 这类作者样式覆盖，
   导致「设了 hidden 却照样显示」（转人工横幅在 AI 模式下也一直挂着一条空白条）。 */
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  color:var(--text);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
}
.chat-body{display:flex;align-items:center;justify-content:center;padding:0}
.chat-shell{
  width:100%;max-width:720px;height:100dvh;display:flex;flex-direction:column;
  background:var(--panel);overflow:hidden;
}
@media (min-width:760px){
  .chat-body{padding:20px}
  .chat-shell{height:min(760px,calc(100dvh - 40px));border-radius:20px;box-shadow:var(--shadow);border:1px solid var(--line)}
}

/* 头部 */
.chat-head{
  display:flex;align-items:center;gap:12px;padding:14px 18px;
  border-bottom:1px solid var(--line);background:var(--panel);flex:0 0 auto;
}
.chat-head-avatar{
  width:38px;height:38px;border-radius:11px;display:grid;place-items:center;flex:0 0 auto;
  background:var(--brand-soft);color:var(--brand);overflow:hidden;
}
.chat-head-avatar img{width:100%;height:100%;object-fit:cover}
.chat-head-meta{flex:1;min-width:0}
.chat-head-name{font-size:15px;font-weight:600;letter-spacing:.2px}
.chat-head-status{font-size:12px;color:var(--text-3);display:flex;align-items:center;gap:5px;margin-top:2px}
.chat-head-status .dot{width:6px;height:6px;border-radius:50%;background:#22c55e;display:inline-block;box-shadow:0 0 0 3px rgba(34,197,94,.15)}
.chat-head-status.warn .dot{background:#f59e0b;box-shadow:0 0 0 3px rgba(245,158,11,.15)}
.chat-head-handoff{
  flex:0 0 auto;font-size:12.5px;color:var(--brand);text-decoration:none;font-weight:500;
  border:1px solid color-mix(in srgb, var(--brand) 30%, #fff);border-radius:999px;padding:5px 12px;
  transition:background .15s;
}
.chat-head-handoff:hover{background:var(--brand-soft)}

/* 消息区 */
.chat-list{flex:1;overflow-y:auto;padding:20px 18px 8px;display:flex;flex-direction:column;gap:16px;scroll-behavior:smooth}
.chat-list::-webkit-scrollbar{width:8px}
.chat-list::-webkit-scrollbar-thumb{background:#dfe3ec;border-radius:8px}
.msg{display:flex;gap:10px;max-width:100%;animation:fadeUp .25s ease}
@keyframes fadeUp{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.msg-avatar{
  width:30px;height:30px;border-radius:9px;flex:0 0 auto;display:grid;place-items:center;
  font-size:12px;font-weight:600;background:var(--line-2);color:var(--text-2);overflow:hidden;
}
.msg-avatar img{width:100%;height:100%;object-fit:cover}
.msg-main{min-width:0;max-width:86%}
.msg-bubble{
  padding:11px 14px;border-radius:14px;font-size:14.5px;line-height:1.72;
  background:var(--line-2);color:var(--text);word-break:break-word;white-space:pre-wrap;
}
.msg-bubble strong{font-weight:600}
.msg-bubble code{background:#eef1f7;padding:1px 5px;border-radius:5px;font-size:13px;font-family:ui-monospace,Menlo,Consolas,monospace}
.msg-bubble a{color:var(--brand)}
.msg.assistant .msg-avatar{background:var(--brand-soft);color:var(--brand)}
.msg.user{flex-direction:row-reverse}
.msg.user .msg-main{display:flex;flex-direction:column;align-items:flex-end}
.msg.user .msg-bubble{background:var(--brand);color:#fff}
.msg.user .msg-avatar{background:var(--brand);color:#fff}
.msg-extra{font-size:12px;color:var(--text-3);margin-top:6px;display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.msg.user .msg-extra{justify-content:flex-end}
.msg-error .msg-bubble{background:#fef2f2;color:#b91c1c}

/* 打字动画 */
.typing{display:inline-flex;gap:4px;align-items:center;height:20px}
.typing i{width:6px;height:6px;border-radius:50%;background:var(--text-3);animation:blink 1.2s infinite}
.typing i:nth-child(2){animation-delay:.18s}
.typing i:nth-child(3){animation-delay:.36s}
@keyframes blink{0%,60%,100%{opacity:.25;transform:translateY(0)}30%{opacity:1;transform:translateY(-3px)}}

/* 引用来源 */
.sources{margin-top:8px;font-size:12.5px}
.sources summary{cursor:pointer;color:var(--text-2);list-style:none;user-select:none;display:inline-flex;align-items:center;gap:4px}
.sources summary::-webkit-details-marker{display:none}
.sources summary::before{content:"";width:0;height:0;border-left:4px solid currentColor;border-top:3.5px solid transparent;border-bottom:3.5px solid transparent;transition:transform .15s}
.sources[open] summary::before{transform:rotate(90deg)}
.source-item{margin-top:6px;padding:8px 10px;border-radius:9px;background:#fafbfe;border:1px solid var(--line-2);color:var(--text-2);line-height:1.6}
.source-item b{color:var(--text);font-weight:600}
.source-score{color:var(--text-3);font-size:11.5px;margin-left:6px}

/* 反馈 */
.fb-btn{
  border:1px solid var(--line);background:#fff;border-radius:8px;padding:3px 8px;cursor:pointer;
  color:var(--text-2);font-size:12px;line-height:1.6;transition:.15s;
}
.fb-btn:hover{border-color:color-mix(in srgb, var(--brand) 40%, #fff);color:var(--brand)}
.fb-btn.active{background:var(--brand);border-color:var(--brand);color:#fff}
.fb-done{color:#16a34a}

/* 推荐问题 */
.chat-quick{flex:0 0 auto;padding:6px 18px 10px;display:flex;flex-wrap:wrap;gap:8px}
.qchip{
  border:1px solid var(--line);background:#fff;border-radius:999px;padding:6px 13px;font-size:12.5px;
  color:var(--text-2);cursor:pointer;transition:.15s;font-family:inherit;
}
.qchip:hover{border-color:color-mix(in srgb, var(--brand) 45%, #fff);color:var(--brand);background:var(--brand-soft)}

/* 输入区 */
.chat-foot{flex:0 0 auto;border-top:1px solid var(--line);padding:12px 18px 14px;background:var(--panel)}
.chat-input-wrap{
  display:flex;align-items:flex-end;gap:8px;background:#f7f8fc;border:1px solid var(--line);
  border-radius:14px;padding:6px 6px 6px 14px;transition:border-color .15s,box-shadow .15s;
}
.chat-input-wrap:focus-within{border-color:color-mix(in srgb, var(--brand) 55%, #fff);box-shadow:0 0 0 3px var(--brand-soft);background:#fff}
#chatInput{
  flex:1;border:0;outline:0;background:transparent;resize:none;font-family:inherit;font-size:14.5px;
  line-height:1.6;max-height:120px;padding:5px 0;color:var(--text);
}
#chatInput::placeholder{color:var(--text-3)}
.chat-send{
  flex:0 0 auto;width:36px;height:36px;border-radius:11px;border:0;background:var(--brand);color:#fff;
  display:grid;place-items:center;cursor:pointer;transition:.15s;
}
.chat-send:hover{filter:brightness(1.06)}
.chat-send:disabled{opacity:.45;cursor:not-allowed}
.chat-tip{font-size:11.5px;color:var(--text-3);text-align:center;margin-top:8px;line-height:1.5}

/* 错误页 */
.empty-state{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:40px 30px;text-align:center}
.empty-icon{width:72px;height:72px;border-radius:20px;display:grid;place-items:center;background:#fff7ed;color:#f59e0b;margin-bottom:18px}
.empty-state h2{font-size:17px;margin:0 0 10px}
.empty-state p{font-size:14px;color:var(--text-2);margin:0 0 6px;line-height:1.7}
.empty-hint{font-size:12.5px;color:var(--text-3)}

/* ---------- 人工客服相关 ---------- */
.chat-head-handoff{
  flex:0 0 auto;font-size:12.5px;color:var(--brand);text-decoration:none;font-weight:500;
  border:1px solid color-mix(in srgb, var(--brand) 30%, #fff);border-radius:999px;padding:5px 12px;
  transition:background .15s;background:#fff;font-family:inherit;cursor:pointer;white-space:nowrap;
}
.chat-head-handoff:hover{background:var(--brand-soft)}
.chat-head-handoff:disabled{opacity:.6;cursor:default}

.chat-banner{
  flex:0 0 auto;display:flex;align-items:center;gap:8px;padding:8px 18px;font-size:12.5px;line-height:1.5;
  border-bottom:1px solid var(--line);
}
.chat-banner.warn{background:#fffbeb;color:#92400e}
.chat-banner.ok{background:#ecfdf3;color:#166534}
.chat-banner-dot{width:7px;height:7px;border-radius:50%;background:currentColor;flex:0 0 auto}
.chat-banner.warn .chat-banner-dot{animation:banPulse 1.4s ease-in-out infinite}
@keyframes banPulse{0%,100%{opacity:1}50%{opacity:.25}}
@media (prefers-reduced-motion: reduce){.chat-banner.warn .chat-banner-dot{animation:none}}

.msg-sys{align-self:center;max-width:86%;text-align:center;font-size:12px;color:var(--text-3);
  background:#f4f6fb;border-radius:9px;padding:6px 12px;line-height:1.6;animation:fadeUp .25s ease}

.msg.assistant.agent .msg-avatar{background:#e7f7ef;color:#0f6e56}
.msg.assistant.agent .msg-bubble{background:#f2fbf7;border:1px solid #d7f0e6;color:#0f4a37}

.handoff-card{
  align-self:center;max-width:92%;background:#fff;border:1px solid var(--line);border-radius:13px;
  padding:13px 16px;text-align:center;box-shadow:var(--shadow);animation:fadeUp .25s ease;
}
.handoff-card-txt{font-size:13px;color:var(--text-2);margin-bottom:9px}
.btn-handoff{
  border:0;background:var(--brand);color:#fff;border-radius:10px;padding:8px 20px;font-size:13.5px;
  font-family:inherit;cursor:pointer;transition:.15s;font-weight:500;
}
.btn-handoff:hover{filter:brightness(1.06)}
.btn-handoff:disabled{opacity:.6;cursor:default}
.handoff-alt{display:block;margin-top:9px;font-size:12px;color:var(--text-3);text-decoration:underline}

/* 超宽屏（≥1600）下把聊天窗口放宽一点：原来固定 720px，2560 屏两侧各空 920px，
   视觉上像一根居中的窄条。放宽到 860px 后一行约 50~60 字，仍在舒适阅读区间内。 */
@media (min-width:1600px){
  .chat-shell{max-width:860px}
}
