/* 在线客服 · 访客端样式 */
:root {
  --theme: #1276e6;
  --bubble-me: var(--theme);
  --theme-d: #1272df;
  --page-bg: #ededed;
  --line: #e4e4e4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #e9eaec;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: #111;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.kf-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--page-bg);
  box-shadow: 0 0 30px rgba(0, 0, 0, .08);
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.kf-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(9px + env(safe-area-inset-top)) 12px 9px;
  background: var(--theme);
  background: linear-gradient(180deg, var(--theme) 0%, var(--theme-d) 100%);
  color: #fff;
  box-shadow: 0 1px 4px rgba(18, 114, 223, .25);
  z-index: 5;
}

.kf-head-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.kf-head-logo {
  width: 33px;
  height: 33px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .4);
}

.kf-head-logo img,
.kf-head-logo svg { width: 100%; height: 100%; display: block; object-fit: cover; }

.kf-head-title { min-width: 0; }

.kf-head-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.kf-site-name {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58vw;
}

.kf-cert {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 600;
  color: #12a04a;
  background: rgba(255, 255, 255, .95);
  border-radius: 3px;
  padding: 1.5px 4px;
  line-height: 1.3;
}

.kf-presence {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .88);
  white-space: nowrap;
}

.kf-presence i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cfd5dd;
  display: block;
}

.kf-presence.on i { background: #3ddc73; box-shadow: 0 0 6px rgba(61, 220, 115, .8); }

/* ---------- 公告条 ---------- */
.kf-notice {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: #fff8e3;
  border-bottom: 1px solid #f3e6c4;
  font-size: 12px;
  color: #6a6a6a;
  z-index: 4;
}

.kf-notice-icon { font-size: 13px; flex: 0 0 auto; opacity: .85; }

.kf-notice-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #5f5f5f;
}

.kf-notice-tag { flex: 0 0 auto; color: #2b7de9; font-size: 12px; }

.kf-notice-close {
  flex: 0 0 auto;
  color: #9b9b9b;
  font-size: 17px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

/* ---------- 消息区 ---------- */
.kf-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 11px 12px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.kf-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 14px 14px;
  margin: 6px 0 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

.kf-card-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 9px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 1px #eeeeee, 0 2px 6px rgba(0, 0, 0, .06);
}

.kf-card-logo img,
.kf-card-logo svg { width: 100%; height: 100%; display: block; object-fit: cover; }

.kf-card-title {
  font-size: 17px;
  font-weight: 700;
  color: #121212;
  letter-spacing: .2px;
  word-break: break-word;
}

.kf-card-sub {
  margin-top: 7px;
  font-size: 12.5px;
  color: #9d9d9d;
}

.kf-sys {
  text-align: center;
  margin: 4px 0 14px;
}

.kf-sys span {
  display: inline-block;
  background: rgba(255, 255, 255, .72);
  color: #8d8d8d;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  max-width: 88%;
}

.kf-time {
  text-align: center;
  color: #a5a5a5;
  font-size: 11.5px;
  margin: 8px 0 12px;
}

.kf-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 15px;
}

.kf-row.me { flex-direction: row-reverse; }

.kf-avatar {
  width: 33px;
  height: 33px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  background: #dfe4ea;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kf-avatar img,
.kf-avatar svg { width: 100%; height: 100%; display: block; object-fit: cover; }

.kf-body { max-width: calc(100% - 74px); min-width: 0; }

.kf-row.me .kf-body { display: flex; flex-direction: column; align-items: flex-end; }

.kf-name {
  font-size: 11.5px;
  color: #8e9aab;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kf-bubble {
  position: relative;
  background: #fff;
  color: #1b1b1b;
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 14.6px;
  line-height: 1.62;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.kf-bubble .warn { color: #e33c3c; }

.kf-row.me .kf-bubble {
  background: var(--bubble-me);
  color: #fff;
  box-shadow: 0 1px 2px rgba(75, 159, 245, .28);
}

.kf-bubble img {
  display: block;
  max-width: 180px;
  max-height: 220px;
  border-radius: 5px;
  cursor: zoom-in;
}

.kf-read {
  font-size: 10.5px;
  color: #a9b4c2;
  margin-top: 4px;
  text-align: right;
  padding-right: 2px;
}

/* ---------- 回到底部 ---------- */
.kf-tobottom {
  position: absolute;
  right: 12px;
  bottom: 108px;
  border: 0;
  border-radius: 999px;
  background: var(--bubble-me);
  color: #fff;
  font-size: 12.5px;
  padding: 7px 14px;
  box-shadow: 0 3px 10px rgba(75, 159, 245, .35);
  display: none;
  z-index: 6;
  cursor: pointer;
}

.kf-tobottom.show { display: block; }

/* ---------- 工具条 ---------- */
.kf-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 17px;
  padding: 8px 15px 3px;
  background: #f7f7f7;
  border-top: 1px solid #ededed;
}

.kf-tool {
  border: 0;
  background: transparent;
  padding: 0;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: .95;
}

.kf-tool:active { transform: scale(.92); }

.kf-tool svg { width: 23px; height: 23px; display: block; }

/* ---------- 表情面板 ---------- */
.kf-emoji {
  display: none;
  flex: 0 0 auto;
  background: #f7f7f7;
  padding: 6px 12px 2px;
  max-height: 132px;
  overflow-y: auto;
  border-top: 1px solid #f0f0f0;
}

.kf-emoji.show { display: block; }

.kf-emoji span {
  display: inline-block;
  font-size: 22px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
}

.kf-emoji span:active { background: #e8e8e8; }

/* ---------- 输入栏 ---------- */
.kf-inputbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  background: #f7f7f7;
}

.kf-input {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 108px;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  font-size: 14.5px;
  line-height: 1.4;
  color: #222;
  resize: none;
  outline: none;
  font-family: inherit;
  -webkit-appearance: none;
}

.kf-input:focus { border-color: #c9d9ee; }

.kf-input::placeholder { color: #b4b4b4; }

.kf-send {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 19px;
  border: 0;
  border-radius: 6px;
  background: var(--bubble-me);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.kf-send:active { background: #3b8ce6; }

.kf-send:disabled { background: #b9d5f3; cursor: default; }

/* ---------- toast ---------- */
.kf-toast {
  position: fixed;
  left: 50%;
  bottom: 130px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: .22s;
  z-index: 99;
  max-width: 78vw;
  text-align: center;
}

.kf-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 图片预览 ---------- */
.kf-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.kf-viewer img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
}

/* 桌面端 */
@media (min-width: 521px) {
  body { padding: 0; }
  .kf-wrap { height: 100vh; }
}

/* 滚动条 */
.kf-msgs::-webkit-scrollbar { width: 4px; }
.kf-msgs::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .12); border-radius: 4px; }
