/* 千牛 AI 客服 · 站点浮窗样式 */
#qn-bot-root, #qn-bot-root * { box-sizing: border-box; }
#qn-bot-root {
  --qn-green: #003630;
  --qn-green-2: #0b4a3f;
  --qn-mint: #e7efe9;
  --qn-gold: #c99a3f;
  --qn-ink: #1d2a26;
  --qn-muted: #6b7a74;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--qn-ink);
  font-size: 14px;
  line-height: 1.6;
}

/* 启动按钮 */
.qn-launcher {
  width: 58px; height: 58px; border-radius: 50%;
  border: 0; cursor: pointer; padding: 0;
  background: var(--qn-green);
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 54, 48, .28);
  display: grid; place-items: center;
  transition: transform .18s ease, box-shadow .18s ease;
}
.qn-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0, 54, 48, .34); }
.qn-launcher svg { width: 26px; height: 26px; }
.qn-launcher-dot {
  position: absolute; right: 44px; bottom: 46px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #38c172; border: 2px solid #fff;
  animation: qn-pulse 2.4s infinite;
}
@keyframes qn-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(56,193,114,.5); } 50% { box-shadow: 0 0 0 6px rgba(56,193,114,0); } }

/* 面板 */
.qn-panel {
  position: absolute; right: 0; bottom: 74px;
  width: 384px; height: 620px; max-height: calc(100vh - 120px);
  background: #fbfaf7;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 30, 26, .28), 0 2px 8px rgba(0, 30, 26, .08);
  display: none; overflow: hidden;
  transform-origin: bottom right;
  animation: qn-in .18s ease-out;
}
.qn-panel.is-open { display: flex; flex-direction: column; }
@keyframes qn-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.qn-head {
  background: linear-gradient(135deg, #003630 0%, #0b4a3f 100%);
  color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 11px;
  flex: none;
}
.qn-avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: rgba(255,255,255,.14);
  display: grid; place-items: center; font-weight: 700; letter-spacing: .5px; font-size: 13px;
  border: 1px solid rgba(255,255,255,.22);
}
.qn-head-text { flex: 1; min-width: 0; }
.qn-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.qn-sub { font-size: 12px; opacity: .82; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.qn-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #38c172; }
.qn-status-dot.is-human { background: var(--qn-gold); }
.qn-close {
  background: transparent; border: 0; color: #fff; cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; font-size: 20px; line-height: 1;
  opacity: .8;
}
.qn-close:hover { background: rgba(255,255,255,.12); opacity: 1; }

/* 转人工条 */
.qn-handoff {
  display: none; flex: none;
  background: #fdf3dd; border-bottom: 1px solid #f0dfb8;
  color: #6b4e12; padding: 9px 14px; font-size: 12.5px; line-height: 1.5;
}
.qn-handoff.is-on { display: block; }
.qn-handoff b { color: #4a3608; }

/* 消息区 */
.qn-body {
  flex: 1; overflow-y: auto; padding: 16px 14px 6px;
  background:
    radial-gradient(circle at 100% 0%, rgba(0,54,48,.045), transparent 42%),
    #fbfaf7;
  scroll-behavior: smooth;
}
.qn-body::-webkit-scrollbar { width: 6px; }
.qn-body::-webkit-scrollbar-thumb { background: #cfd8d2; border-radius: 3px; }

.qn-msg { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.qn-msg.is-user { justify-content: flex-end; }
.qn-bubble {
  max-width: 78%; padding: 10px 13px; border-radius: 14px;
  background: #fff; border: 1px solid #e8e6df;
  box-shadow: 0 1px 2px rgba(20, 40, 34, .04);
  white-space: pre-wrap; word-break: break-word;
}
.qn-msg.is-bot .qn-bubble { border-bottom-left-radius: 4px; }
.qn-msg.is-user .qn-bubble {
  background: var(--qn-green-2); color: #fff; border-color: transparent;
  border-bottom-right-radius: 4px;
}
.qn-msg.is-agent .qn-bubble { background: #fff8e8; border-color: #efdfb9; }
.qn-msg .qn-who { font-size: 11px; color: var(--qn-muted); margin-bottom: 3px; }
.qn-mini-avatar {
  width: 26px; height: 26px; border-radius: 9px; flex: none;
  background: var(--qn-mint); color: var(--qn-green);
  display: grid; place-items: center; font-size: 10px; font-weight: 700;
}
.qn-msg.is-user .qn-mini-avatar { display: none; }

/* 常见问题固定栏（参照参考机器人：问题常驻在输入框上方） */
.qn-chips {
  flex: none; display: flex; flex-wrap: wrap; gap: 6px;
  padding: 9px 12px 5px; background: #fff; border-top: 1px solid #e8e6df;
}
.qn-chips:empty { display: none; }
.qn-chip {
  border: 1px solid #d7e2dc; background: #f7faf8; color: var(--qn-green);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; line-height: 1.45;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.qn-chip:hover { background: var(--qn-mint); border-color: #a9c3b8; }

/* 留资卡片 */
.qn-lead-card {
  background: #fff; border: 1px solid #e2e8e4; border-radius: 14px;
  padding: 13px; margin: 4px 0 14px;
  box-shadow: 0 6px 18px rgba(0, 54, 48, .06);
}
.qn-lead-card h4 { margin: 0 0 4px; font-size: 13.5px; color: var(--qn-green); }
.qn-lead-card p { margin: 0 0 10px; font-size: 12.5px; color: var(--qn-muted); }
.qn-field { width: 100%; margin-bottom: 8px; }
.qn-field input {
  width: 100%; padding: 9px 11px; border: 1px solid #d9e1dc; border-radius: 9px;
  font-size: 13px; font-family: inherit; color: var(--qn-ink); background: #fcfdfc;
  outline: none;
}
.qn-field input:focus { border-color: var(--qn-green-2); box-shadow: 0 0 0 3px rgba(11,74,63,.08); }
.qn-lead-actions { display: flex; gap: 8px; }
.qn-btn {
  flex: 1; border: 0; border-radius: 9px; padding: 9px 12px; font-size: 13px;
  cursor: pointer; font-family: inherit; font-weight: 600;
}
.qn-btn-primary { background: var(--qn-green); color: #fff; }
.qn-btn-primary:hover { background: #065041; }
.qn-btn-ghost { background: #f1f4f2; color: var(--qn-green); }
.qn-btn:disabled { opacity: .55; cursor: wait; }
.qn-lead-msg { font-size: 12px; margin-top: 8px; min-height: 16px; color: var(--qn-muted); }
.qn-lead-msg.is-ok { color: #1c7a52; }
.qn-lead-msg.is-err { color: #a3402f; }

/* 输入区 */
.qn-foot { flex: none; border-top: 1px solid #e8e6df; background: #fff; padding: 10px 12px 8px; }
.qn-input-row { display: flex; gap: 8px; align-items: flex-end; }
.qn-input {
  flex: 1; resize: none; border: 1px solid #dbe2dd; border-radius: 11px;
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; line-height: 1.5;
  max-height: 96px; min-height: 40px; outline: none; color: var(--qn-ink);
}
.qn-input:focus { border-color: var(--qn-green-2); box-shadow: 0 0 0 3px rgba(11,74,63,.07); }
.qn-send {
  width: 40px; height: 40px; border-radius: 11px; border: 0; cursor: pointer;
  background: var(--qn-green); color: #fff; display: grid; place-items: center;
  flex: none;
}
.qn-send:disabled { opacity: .4; cursor: default; }
.qn-send svg { width: 18px; height: 18px; }
.qn-foot-note { font-size: 11px; color: #9aa8a1; margin-top: 6px; text-align: center; }
.qn-foot-note a { color: var(--qn-green-2); text-decoration: none; }

/* 打字中 */
.qn-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.qn-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #9fb3aa;
  animation: qn-blink 1.2s infinite;
}
.qn-typing i:nth-child(2) { animation-delay: .18s; }
.qn-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes qn-blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

/* 桌面：启动图标挂到首页视频框上方，面板改为向下展开 */
#qn-bot-root.qn-hero .qn-panel { top: 68px; bottom: auto; right: 0; }

/* 移动端 */
@media (max-width: 640px) {
  #qn-bot-root { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .qn-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: 0;
    width: 100%; height: 100vh; height: 100dvh; max-height: none;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .qn-panel.is-open { animation: none; }
  .qn-launcher { width: 54px; height: 54px; }
  .qn-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .qn-chips {
    flex-wrap: wrap; overflow: visible;
    padding: 8px 12px; gap: 7px;
  }
  .qn-chip { flex: 0 1 auto; font-size: 12px; }
  .qn-input, .qn-field input { font-size: 16px; }
  .qn-send { width: 44px; height: 44px; }
}

body.qn-locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .qn-panel, .qn-launcher, .qn-typing i, .qn-launcher-dot { animation: none !important; transition: none !important; }
}
