/*! 快企务原创，请尊重产权。抄袭必究 · Copyright © 快企务 www.kuaiqiwu.com */
/* 快企务访客聊天窗口：独立变量，避免依赖页面是否加载全站 tokens。 */
#kqw-chat.kc {
  --kc-navy: #212773;
  --kc-blue: #3558F0;
  --kc-amber: #E9A23B;
  --kc-ink: #2F333D;
  --kc-muted: #5B6170;
  --kc-line: #DCE1EC;
  --kc-pale: #F3F5FB;
  --kc-white: #FFFFFF;
  --kc-cut: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
  position: fixed;
  z-index: 10020;
  right: 22px;
  bottom: 22px;
  width: min(380px, calc(100vw - 44px));
  height: min(640px, calc(100vh - 120px));
  color: var(--kc-ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  text-align: left;
  isolation: isolate;
}
#kqw-chat.kc[hidden] { display: none !important; }
#kqw-chat .kc-dialog {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--kc-white);
  border: 1px solid var(--kc-line);
  clip-path: var(--kc-cut);
  box-shadow: 0 24px 56px rgba(33, 39, 115, .24);
}
/* 显式指定行，避免网络提示条 hidden 后各区块顺移（曾导致底部按钮被拉成 1fr 高度）。 */
#kqw-chat .kc-dialog > .kc-head { grid-row: 1; }
#kqw-chat .kc-dialog > .kc-network { grid-row: 2; }
#kqw-chat .kc-dialog > .kc-messages { grid-row: 3; }
#kqw-chat .kc-dialog > .kc-actions { grid-row: 4; }
#kqw-chat .kc-dialog > .kc-composer { grid-row: 5; }
#kqw-chat .kc-network[hidden],
#kqw-chat .kc-action[hidden] { display: none !important; }
#kqw-chat a.kc-action { display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; }
#kqw-chat button,
#kqw-chat textarea,
#kqw-chat input,
#kqw-chat select { font: inherit; }
#kqw-chat button { cursor: pointer; touch-action: manipulation; }
#kqw-chat :is(button, a, textarea, input, select):focus-visible {
  outline: 3px solid var(--kc-blue);
  outline-offset: 2px;
}
#kqw-chat .kc-head {
  position: relative;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 72px;
  padding: 15px 15px 12px 18px;
  color: var(--kc-white);
  background: var(--kc-navy);
}
#kqw-chat .kc-identity { min-width: 0; }
#kqw-chat .kc-title {
  margin: 0;
  color: inherit;
  font-family: inherit; font-size: 17px; font-weight: 700; line-height: 1.35; letter-spacing: 0;
  letter-spacing: 0;
}
#kqw-chat .kc-state {
  display: inline-block;
  margin: 5px 0 0;
  padding: 2px 7px;
  color: #DDE4FF;
  border: 1px solid rgba(255, 255, 255, .3);
  font-size: 11px;
  line-height: 1.4;
}
#kqw-chat .kc-head-actions { position: relative; display: flex; gap: 2px; flex: 0 0 auto; }
#kqw-chat .kc-icon-button {
  display: grid;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 22px;
  line-height: 1;
}
#kqw-chat .kc-icon-button:hover { background: rgba(255, 255, 255, .14); }
#kqw-chat .kc-menu {
  position: absolute;
  z-index: 4;
  top: 39px;
  right: 38px;
  width: 130px;
  padding: 4px;
  border: 1px solid var(--kc-line);
  background: var(--kc-white);
  box-shadow: 0 10px 26px rgba(33, 39, 115, .2);
}
#kqw-chat .kc-menu-end {
  width: 100%;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--kc-ink);
  text-align: left;
}
#kqw-chat .kc-menu-end:hover { color: var(--kc-blue); background: var(--kc-pale); }
#kqw-chat .kc-network {
  min-height: 0;
  margin: 0;
  padding: 6px 18px;
  border-bottom: 1px solid #F1D6A8;
  background: #FFF9EE;
  color: #76521B;
  font-size: 12px;
}
#kqw-chat .kc-messages {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 17px 15px 12px;
  scrollbar-color: rgba(33, 39, 115, .3) transparent;
}
#kqw-chat .kc-message { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 14px; }
#kqw-chat .kc-message--visitor { align-items: flex-end; }
#kqw-chat .kc-message--system { align-items: center; margin: 11px 0; }
#kqw-chat .kc-message-name {
  margin: 0 0 4px;
  color: var(--kc-muted);
  font-size: 11px;
  font-weight: 700;
}
#kqw-chat .kc-bubble {
  max-width: min(88%, 312px);
  padding: 10px 12px;
  border: 1px solid var(--kc-line);
  background: var(--kc-white);
  color: var(--kc-ink);
  white-space: pre-wrap;
  word-break: break-word;
  clip-path: var(--kc-cut);
}
#kqw-chat .kc-message--visitor .kc-bubble { border-color: var(--kc-navy); background: var(--kc-navy); color: var(--kc-white); }
#kqw-chat .kc-message--agent .kc-bubble { border-color: #D6DFFB; background: var(--kc-pale); }
#kqw-chat .kc-message--system .kc-bubble {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--kc-muted);
  font-size: 12px;
  text-align: center;
  clip-path: none;
}
#kqw-chat .kc-message.is-pending .kc-bubble { opacity: .72; }
#kqw-chat .kc-message.is-failed .kc-bubble { border-color: #C54444; }
#kqw-chat .kc-message-links,
#kqw-chat .kc-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
#kqw-chat .kc-message-links a {
  min-height: 30px;
  color: var(--kc-blue);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#kqw-chat .kc-chip,
#kqw-chat .kc-option,
#kqw-chat .kc-action {
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--kc-line);
  border-radius: 0;
  background: var(--kc-white);
  color: var(--kc-navy);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  clip-path: var(--kc-cut);
}
#kqw-chat .kc-chip:hover,
#kqw-chat .kc-option:hover,
#kqw-chat .kc-action:hover { border-color: var(--kc-blue); color: var(--kc-blue); background: #F8F9FF; }
#kqw-chat .kc-retry {
  min-height: 34px;
  margin-top: 6px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: #B02E2E;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#kqw-chat .kc-intro > .kc-message { margin-bottom: 9px; }
#kqw-chat .kc-intro > .kc-chips { margin: 0 0 14px; }
#kqw-chat .kc-privacy {
  margin: 12px 0 16px;
  padding-top: 12px;
  border-top: 1px solid var(--kc-line);
  color: var(--kc-muted);
  font-size: 11px;
  line-height: 1.65;
}
#kqw-chat .kc-privacy a,
#kqw-chat .kc-consent a { color: var(--kc-blue); text-decoration: underline; text-underline-offset: 3px; }
#kqw-chat .kc-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 14px;
  padding: 10px;
  border-left: 3px solid var(--kc-amber);
  background: #FFF9EE;
}
#kqw-chat .kc-option { border-color: #EACB96; background: var(--kc-white); }
#kqw-chat .kc-typing { margin: 4px 0 12px; color: var(--kc-muted); font-size: 12px; }
#kqw-chat .kc-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid var(--kc-line);
  background: var(--kc-pale);
}
#kqw-chat .kc-action { min-height: 40px; }
/* 转人工提示（10-31）：位于两枚操作按钮正上方，整行；琥珀短线提示“可转人工”，排班外改为中灰。 */
#kqw-chat .kc-handoff-tip {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1px 0 1px 10px;
  border-left: 3px solid var(--kc-amber, #E9A23B);
  color: var(--kc-ink);
  font-size: 12.5px;
  line-height: 1.55;
}
#kqw-chat .kc-handoff-tip.is-offline { border-left-color: #9AA3B8; color: var(--kc-muted); }
#kqw-chat .kc-handoff-tip[hidden] { display: none !important; }
#kqw-chat .kc-action--primary { border-color: var(--kc-navy); background: var(--kc-navy); color: var(--kc-white); }
#kqw-chat .kc-action--primary:hover { color: var(--kc-white); background: var(--kc-blue); }
#kqw-chat .kc-actions[hidden] { display: none !important; }
/* 排队中：保持藏青但降低强调，表示“已提交、正在处理”，不可重复点击。 */
#kqw-chat .kc-action--primary.is-busy,
#kqw-chat .kc-action--primary.is-busy:hover { background: #5A5F96; border-color: #5A5F96; color: var(--kc-white); cursor: default; }
#kqw-chat .kc-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--kc-line);
  background: var(--kc-white);
}
#kqw-chat .kc-textarea-wrap { min-width: 0; flex: 1; }
/* 输入预览提示（排队 / 人工接待期间）：输入框上方一行小字，明确告知顾问可看到未发送的文字。 */
#kqw-chat .kc-draft-note {
  margin: 0 0 6px;
  padding-left: 8px;
  border-left: 2px solid var(--kc-blue);
  color: var(--kc-muted);
  font-size: 12px;
  line-height: 1.5;
}
#kqw-chat .kc-draft-note[hidden] { display: none !important; }
#kqw-chat .kc-textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 106px;
  padding: 9px 10px;
  resize: none;
  overflow-y: auto;
  border: 1px solid var(--kc-line);
  border-radius: 0;
  background: #FAFBFE;
  color: var(--kc-ink);
  line-height: 22px;
}
#kqw-chat .kc-textarea:focus { border-color: var(--kc-blue); outline: 0; background: var(--kc-white); }
#kqw-chat .kc-send,
#kqw-chat .kc-lead-submit {
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: var(--kc-amber);
  color: var(--kc-navy);
  font-weight: 800;
  clip-path: var(--kc-cut);
}
#kqw-chat .kc-send:hover,
#kqw-chat .kc-lead-submit:hover { background: #F1B351; }
#kqw-chat :is(.kc-send, .kc-lead-submit):disabled { cursor: not-allowed; opacity: .55; }
#kqw-chat .kc-composer.is-closed .kc-textarea { background: #F3F5FB; }
.kc-continue-pill {
  position: fixed;
  z-index: 10021;
  right: 22px;
  bottom: 22px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  background: var(--kc-navy, #212773);
  color: #fff;
  box-shadow: 0 8px 22px rgba(33, 39, 115, .28);
  font-family: inherit; font-size: 14px; font-weight: 700; line-height: 1;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
}
.kc-continue-pill:hover { background: #3558F0; }
.kc-continue-pill:focus-visible { outline: 3px solid #3558F0; outline-offset: 3px; }
.kc-continue-pill[hidden] { display: none !important; }
#kqw-chat .kc-lead-layer {
  position: absolute;
  z-index: 10;
  inset: 0;
  overflow: auto;
  padding: 14px;
  background: rgba(33, 39, 115, .46);
}
#kqw-chat .kc-lead-layer[hidden] { display: none; }
#kqw-chat .kc-lead-panel {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--kc-line);
  background: var(--kc-white);
  clip-path: var(--kc-cut);
  box-shadow: 0 18px 44px rgba(33, 39, 115, .24);
}
#kqw-chat .kc-lead-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#kqw-chat .kc-lead-head h3 { margin: 0; color: var(--kc-navy); font-family: inherit; font-size: 18px; line-height: 1.35; }   /* 与窗口同字体：窗口未打开时也不触发标题字体分片下载 */
#kqw-chat .kc-lead-head .kc-icon-button { color: var(--kc-navy); }
#kqw-chat .kc-lead-head .kc-icon-button:hover { background: var(--kc-pale); }
#kqw-chat .kc-lead-form { display: grid; gap: 8px; }
#kqw-chat .kc-field { display: grid; gap: 5px; color: var(--kc-ink); font-size: 13px; font-weight: 700; }
#kqw-chat .kc-field-label { display: block; }
#kqw-chat .kc-field-label::first-letter { color: inherit; }
#kqw-chat .kc-field input,
#kqw-chat .kc-field select,
#kqw-chat .kc-field textarea,
#kqw-chat .kc-contact-row select,
#kqw-chat .kc-contact-row input {
  width: 100%;
  min-height: 40px;
  padding: 8px 9px;
  border: 1px solid var(--kc-line);
  border-radius: 0;
  background: var(--kc-white);
  color: var(--kc-ink);
  font-weight: 400;
}
#kqw-chat .kc-field textarea { min-height: 58px; resize: vertical; }
#kqw-chat .kc-contact-row { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 7px; }
#kqw-chat .kc-contact-row :is(select, input) { min-width: 0; }
#kqw-chat .kc-field-error { min-height: 0; margin: -4px 0 0; color: #B3261E; font-size: 11px; line-height: 1.45; }
#kqw-chat .kc-form-note { margin: -4px 0 0; color: var(--kc-muted); font-size: 11px; }
#kqw-chat .kc-consent { display: flex; gap: 7px; align-items: flex-start; color: var(--kc-muted); font-size: 12px; line-height: 1.55; }
#kqw-chat .kc-consent input { width: 17px; height: 17px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--kc-navy); }
#kqw-chat .kc-lead-status { min-height: 1.5em; margin: 0; color: var(--kc-muted); font-size: 12px; }
#kqw-chat .kc-lead-status.is-ok { color: #217149; }
#kqw-chat .kc-lead-status.is-error { color: #B3261E; }
#kqw-chat .kc-lead-submit { width: 100%; min-height: 46px; }
html.kc-open,
html.kc-open body { overflow: hidden; }
/* 聊天全屏期间明确压住站点咨询抽屉、顾问卡和手机固定栏。 */
html.kc-open .mobile-consult,
html.kc-open .mobile-bar,
html.kc-open [data-mobile-bar],
html.kc-open .consult-dock,
html.kc-open [data-advisor-card],
html.kc-open .advisor-card { visibility: hidden !important; pointer-events: none !important; }

@media (max-width: 640px) {
  #kqw-chat.kc {
    right: 0;
    bottom: 0;
    width: 100vw;
    width: 100dvw;
    height: var(--kc-vv-height, 100vh);
    height: var(--kc-vv-height, 100dvh);
  }
  #kqw-chat .kc-dialog { border: 0; clip-path: none; box-shadow: none; }
  #kqw-chat .kc-head { min-height: 68px; padding: max(13px, env(safe-area-inset-top)) 13px 10px 16px; }
  #kqw-chat .kc-title { font-size: 16px; }
  #kqw-chat .kc-icon-button { width: 40px; min-width: 40px; height: 40px; }
  #kqw-chat .kc-messages { padding: 14px 13px 10px; }
  #kqw-chat .kc-bubble { max-width: 89%; }
  #kqw-chat .kc-actions { padding: 8px 12px; }
  #kqw-chat .kc-action { min-height: 44px; }
  #kqw-chat .kc-composer { padding: 9px 12px calc(10px + env(safe-area-inset-bottom)); }
  #kqw-chat .kc-send { min-width: 56px; min-height: 44px; }
  /* iOS Safari 对小于 16px 的输入框会自动放大页面，手机端统一 16px。 */
  #kqw-chat :is(.kc-textarea, .kc-field input, .kc-field select, .kc-field textarea, .kc-contact-row input, .kc-contact-row select) { font-size: 16px; }
  #kqw-chat .kc-lead-layer { padding: max(12px, env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
  #kqw-chat .kc-lead-panel { min-height: calc(100% - 1px); }
  .kc-continue-pill { right: 12px; bottom: calc(62px + env(safe-area-inset-bottom)); min-height: 46px; }
}
@media (max-width: 340px) {
  #kqw-chat .kc-head { padding-left: 12px; padding-right: 8px; }
  #kqw-chat .kc-head-actions { gap: 0; }
  #kqw-chat .kc-title { font-size: 15px; }
  #kqw-chat .kc-actions { grid-template-columns: 1fr; }
  #kqw-chat .kc-contact-row { grid-template-columns: 82px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  #kqw-chat *,
  .kc-continue-pill { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media print {
  #kqw-chat.kc,
  .kc-continue-pill { display: none !important; }
}
/* 手机快速咨询栏（10-31）：在线接待启用后由窗口脚本加 .has-kqw-chat，底栏改为四格；
   未判定前按钮保持 hidden（作者样式 display:flex 会覆盖 hidden，这里显式隐藏）。 */
.mobile-consult > [data-mobile-chat][hidden] { display: none !important; }
@media (max-width: 800px) {
  .mobile-consult.has-kqw-chat { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .mobile-consult.has-kqw-chat > [data-mobile-chat]::before { content: "03"; }
  .mobile-consult.has-kqw-chat > button[data-mobile-message]::before { content: "04"; }
}
@media (max-width: 400px) {
  .mobile-consult.has-kqw-chat > a,
  .mobile-consult.has-kqw-chat > button { padding-left: 2px; padding-right: 2px; font-size: 13px; }
  .mobile-consult.has-kqw-chat > a::before,
  .mobile-consult.has-kqw-chat > button::before { display: none; }
}

/* 同意条款：复选框 + 一段连续文字。 */
#kqw-chat .kc-consent { align-items: flex-start; }
#kqw-chat .kc-consent-text { flex: 1 1 auto; min-width: 0; }
#kqw-chat .kc-consent-text a { display: inline; }
