/* ============ AI CONCIERGE CHAT ============ */
/* 设计语言与 style.css 一致：深蓝主卡 × 象牙面板 × 沙金点缀 */

.chat-fab{
  position:fixed;right:22px;bottom:22px;z-index:9500;
  width:56px;height:56px;border-radius:999px;cursor:pointer;
  /* 沙金实底 + 象牙描边环：象牙底、深蓝底上都醒目 */
  background:var(--accent-ink);
  border:2px solid rgba(252,247,238,.9);
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 12px 30px rgba(40,65,90,.30),0 2px 8px rgba(40,65,90,.18);
  transition:transform .2s cubic-bezier(.16,1,.3,1),background .2s,box-shadow .2s;
}
.chat-fab:hover{transform:translateY(-3px);background:var(--accent);box-shadow:0 16px 36px rgba(40,65,90,.36);}
.chat-fab svg{width:24px;height:24px;fill:#ffffff;}
.chat-fab:focus-visible{outline:2px solid var(--deep);outline-offset:3px;}

.chat-panel{
  position:fixed;right:22px;bottom:90px;z-index:9600;
  width:372px;max-width:calc(100vw - 32px);
  height:min(580px,calc(100vh - 130px));
  display:flex;flex-direction:column;overflow:hidden;
  background:var(--surface);
  border:1px solid var(--line);border-radius:16px;
  box-shadow:0 32px 70px rgba(40,65,90,.30),0 6px 18px rgba(40,65,90,.14);
  opacity:0;transform:translateY(14px) scale(.97);pointer-events:none;
  transition:opacity .22s cubic-bezier(.16,1,.3,1),transform .22s cubic-bezier(.16,1,.3,1),
             width .25s cubic-bezier(.16,1,.3,1),height .25s cubic-bezier(.16,1,.3,1);
}
.chat-panel.open{opacity:1;transform:none;pointer-events:auto;}
/* 放大档位：宽幅对话视图 */
.chat-panel.wide{width:min(740px,calc(100vw - 32px));height:min(78vh,740px);}
.chat-panel.wide .chat-msg{max-width:78%;}

.chat-head{
  flex-shrink:0;padding:16px 18px 14px;
  background:var(--deep);color:var(--on-deep);
  border-top:2px solid var(--sand);
  display:flex;align-items:center;gap:12px;
}
.chat-head svg{width:20px;height:20px;fill:var(--sand);flex-shrink:0;}
.chat-head .ct{flex:1;min-width:0;}
.chat-head .ct b{display:block;font-family:var(--serif);font-size:17px;font-weight:600;letter-spacing:.02em;}
.chat-head .ct small{display:block;font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;color:rgba(245,239,223,.62);margin-top:2px;}
/* 头部按钮（放大 / 清空 / 关闭 共用） */
.chat-close,.chat-btn{
  flex-shrink:0;width:28px;height:28px;border-radius:8px;border:none;cursor:pointer;
  background:transparent;color:var(--on-deep);display:flex;align-items:center;justify-content:center;
  transition:background .15s;
}
.chat-close:hover,.chat-btn:hover{background:rgba(245,239,223,.12);}
.chat-close svg,.chat-btn svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.chat-btn[aria-pressed="true"]{background:rgba(201,161,94,.28);}
.chat-clear[aria-pressed="true"]{background:rgba(245,239,223,.12);}

.chat-msgs{flex:1;overflow-y:auto;padding:16px 14px 8px;display:flex;flex-direction:column;gap:10px;scroll-behavior:smooth;}
.chat-msgs::-webkit-scrollbar{width:5px;}
.chat-msgs::-webkit-scrollbar-thumb{background:rgba(40,65,90,.18);border-radius:3px;}

.chat-msg{max-width:86%;padding:9px 13px;border-radius:13px;font-size:13.5px;line-height:1.55;white-space:pre-wrap;word-break:break-word;}
.chat-msg.ai{align-self:flex-start;background:#F1EADC;color:var(--ink);border:1px solid rgba(51,65,78,.08);border-bottom-left-radius:4px;white-space:normal;}
.chat-msg.user{align-self:flex-end;background:var(--deep);color:var(--on-deep);border-bottom-right-radius:4px;}
.chat-msg.err{align-self:flex-start;background:#F7E8E0;color:var(--accent-ink);border:1px solid rgba(168,84,48,.25);font-size:12.5px;}
/* Markdown 渲染元素 */
.chat-msg.ai p.md-p{margin:0 0 6px;}
.chat-msg.ai p.md-p:last-child{margin-bottom:0;}
.chat-msg.ai .md-h{font-weight:700;color:var(--deep);margin:8px 0 4px;letter-spacing:.01em;}
.chat-msg.ai .md-h:first-child{margin-top:0;}
.chat-msg.ai .md-h1{font-size:15px;font-family:var(--serif);}
.chat-msg.ai .md-h2{font-size:14px;font-family:var(--serif);}
.chat-msg.ai .md-h3,.chat-msg.ai .md-h4{font-size:13px;}
.chat-msg.ai ul.md-list,.chat-msg.ai ol.md-list{margin:4px 0 6px;padding-left:18px;}
.chat-msg.ai ul.md-list{list-style:none;padding-left:16px;}
.chat-msg.ai ul.md-list>li{position:relative;}
.chat-msg.ai ul.md-list>li::before{content:"";position:absolute;left:-12px;top:.62em;width:5px;height:5px;border-radius:50%;background:var(--sand);}
.chat-msg.ai ol.md-list{list-style:decimal;}
.chat-msg.ai li{margin:3px 0;}
.chat-msg.ai .md-quote{margin:6px 0;padding:6px 10px;border-left:2px solid var(--sand);background:rgba(201,161,94,.10);border-radius:0 6px 6px 0;color:#5D6670;}
.chat-msg.ai .md-hr{border:0;border-top:1px solid rgba(51,65,78,.18);margin:8px 0;}
.chat-msg.ai .md-pre{margin:6px 0;padding:8px 10px;background:var(--deep);color:var(--on-deep);border-radius:8px;overflow-x:auto;font-size:11px;line-height:1.5;}
.chat-msg.ai .md-pre code{background:none;padding:0;color:inherit;font-size:inherit;}
.chat-msg.ai a{color:var(--accent-ink);text-decoration:underline;text-underline-offset:2px;word-break:break-all;}
.chat-msg.ai code{font-size:11.5px;background:rgba(40,65,90,.09);padding:1px 5px;border-radius:4px;}
.chat-msg.ai .md-img{max-width:100%;border-radius:8px;display:block;margin:6px 0;border:1px solid rgba(51,65,78,.12);}
.chat-msg.ai del{opacity:.6;}
.chat-msg.ai .md-t{width:100%;border-collapse:collapse;font-size:11px;line-height:1.4;margin:6px 0;white-space:normal;}
.chat-msg.ai .md-t th,.chat-msg.ai .md-t td{border:1px solid rgba(51,65,78,.18);padding:4px 6px;text-align:left;vertical-align:top;}
.chat-msg.ai .md-t th{background:rgba(201,161,94,.18);font-weight:700;}
.chat-msg.ai .md-t tr+tr td{border-top:1px solid rgba(51,65,78,.12);}
.chat-msg.ai strong{font-weight:700;}
/* 流式输出中的光标 */
.chat-msg.ai.streaming::after{
  content:"▍";color:var(--sand);font-size:12px;
  animation:chatBlink 1s steps(1) infinite;
}
@keyframes chatBlink{50%{opacity:0;}}

.chat-typing{align-self:flex-start;display:flex;gap:5px;padding:12px 14px;background:#F1EADC;border:1px solid rgba(51,65,78,.08);border-radius:13px;border-bottom-left-radius:4px;}
.chat-typing i{width:6px;height:6px;border-radius:50%;background:var(--sand);animation:chatDot 1.2s ease-in-out infinite;}
.chat-typing i:nth-child(2){animation-delay:.15s;}
.chat-typing i:nth-child(3){animation-delay:.3s;}
@keyframes chatDot{0%,60%,100%{transform:translateY(0);opacity:.5;}30%{transform:translateY(-4px);opacity:1;}}

.chat-chips{flex-shrink:0;display:flex;gap:7px;flex-wrap:wrap;padding:6px 14px 10px;}
.chat-chip{
  border:1px solid rgba(42,63,88,.30);background:transparent;color:var(--deep);
  font-family:inherit;font-size:12px;font-weight:500;
  padding:5px 12px;border-radius:999px;cursor:pointer;
  transition:background .15s,border-color .15s;
}
.chat-chip:hover{background:rgba(40,65,90,.07);border-color:var(--deep);}

.chat-input{
  flex-shrink:0;display:flex;gap:8px;align-items:center;
  padding:10px 12px;border-top:1px solid var(--line);background:#FBF8F0;
}
.chat-input input{
  flex:1;min-width:0;height:40px;padding:0 14px;
  border:1px solid rgba(51,65,78,.20);border-radius:999px;
  background:#fff;color:var(--ink);font-family:inherit;font-size:13.5px;
  transition:border-color .15s;
}
.chat-input input:focus{outline:none;border-color:var(--deep);}
.chat-input input::placeholder{color:#9AA3AB;}
.chat-send{
  flex-shrink:0;width:40px;height:40px;border-radius:50%;border:none;cursor:pointer;
  background:var(--deep);color:var(--on-deep);
  display:flex;align-items:center;justify-content:center;
  transition:background .15s,transform .15s;
}
.chat-send:hover{background:#1F3549;transform:translateY(-1px);}
.chat-send:disabled{opacity:.55;cursor:default;transform:none;}
.chat-send svg{width:16px;height:16px;fill:currentColor;}

@media (max-width:480px){
  .chat-fab{right:14px;bottom:14px;width:52px;height:52px;}
  .chat-panel{right:12px;left:12px;bottom:76px;width:auto;max-width:none;height:min(72vh,560px);}
  /* 放大档：移动端近全屏 */
  .chat-panel.wide{right:8px;left:8px;bottom:72px;width:auto;height:calc(100dvh - 90px);}
}
@media (prefers-reduced-motion:reduce){
  .chat-panel{transition:none;}
  .chat-typing i{animation:none;opacity:.7;}
}
