* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: #ededed; color: #000;
  display: flex; flex-direction: column;
}

/* ===== 顶部导航（微信聊天页样式） ===== */
.wx-nav {
  background: #ededed;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  border-bottom: 0.5px solid #d6d6d6;
  flex-shrink: 0;
}
.wx-nav .icon-btn { color: #191919; font-size: 0; line-height: 1; }
.wx-nav .icon-btn svg { width: 24px; height: 24px; }
.wx-nav .nav-title {
  font-size: 17px; font-weight: 600; color: #111;
  max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===== 消息区 ===== */
.msgs {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 10px 16px;
}
.msg-time { text-align: center; font-size: 12px; color: #b2b2b2; margin: 8px 0 14px; }
/* 微信 1 对 1：带头像，对方=头像+白气泡（左），自己=绿气泡+头像（右） */
.msg { margin: 0 0 16px; display: flex; align-items: flex-start; }
.msg.deleted { opacity: .7; }
.msg .msg-deleted { font-size: 13px; color: #999; padding: 8px 12px; }
.msg.other { justify-content: flex-start; }
.msg.mine { flex-direction: row-reverse; justify-content: flex-start; }
.msg .avatar {
  width: 40px; height: 40px; border-radius: 6px; overflow: hidden;
  flex-shrink: 0; background: #d8d8d8; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.msg.other .avatar { margin-right: 10px; }
.msg.mine .avatar { margin-left: 10px; }
.msg .avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg .avatar svg { width: 68%; height: 68%; }
.msg .bubble {
  position: relative; max-width: 64%;
  padding: 9px 12px; border-radius: 6px;
  font-size: 16px; line-height: 1.5; word-break: break-word; white-space: pre-wrap;
}
/* 客服消息：白色气泡黑字（左侧） */
.msg.other .bubble { background: #fff; color: #000; box-shadow: 0 1px 0.5px rgba(0,0,0,.04); }
.msg.other .bubble::after {
  content: ''; position: absolute; left: -6px; bottom: 9px;
  width: 0; height: 0;
  border: 6px solid transparent; border-left: 0; border-right-color: #fff;
}
/* 访客自己：绿色气泡黑色字体（右侧） */
.msg.mine .bubble { background: #95ec69; color: #111; }
.msg.mine .bubble::after {
  content: ''; position: absolute; right: -6px; bottom: 9px;
  width: 0; height: 0;
  border: 6px solid transparent; border-right: 0; border-left-color: #95ec69;
}
.msg .bubble img { max-width: 100%; border-radius: 4px; display: block; }
.sys { text-align: center; color: #9a9a9a; font-size: 12px; margin: 10px 0; }

/* ===== 语音气泡（微信样式） ===== */
.msg .bubble .voice { display: flex; align-items: center; gap: 7px; min-width: 96px; }
.msg .bubble .voice .bars { display: flex; align-items: center; gap: 2.5px; height: 22px; }
.msg .bubble .voice .bars i { width: 3.5px; height: 6px; background: currentColor; border-radius: 2px; display: inline-block; }
.msg .bubble .voice .dur { font-size: 12px; line-height: 1; }
.msg.mine .bubble .voice { flex-direction: row-reverse; }
.msg .bubble .voice.playing .bars i { animation: kfbar .55s ease-in-out infinite alternate; }
.msg .bubble .voice.playing .bars i:nth-child(2) { animation-delay: .1s; }
.msg .bubble .voice.playing .bars i:nth-child(3) { animation-delay: .2s; }
.msg .bubble .voice.playing .bars i:nth-child(4) { animation-delay: .15s; }
.msg .bubble .voice.playing .bars i:nth-child(5) { animation-delay: .05s; }
@keyframes kfbar { from { height: 5px; } to { height: 20px; } }

/* 按住说话按钮 */
.input-wrap, .hold-talk { flex: 1; }
.hold-talk {
  background: #fff; border-radius: 6px; min-height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #333; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.hold-talk.recording { background: #e5e5e5; color: #07c160; }
.hold-talk.hidden { display: none; }

/* 微信式发送按钮：输入有文字时显示，隐藏表情和 + */
.kf-send {
  background: #07c160; color: #fff; border-radius: 6px;
  min-width: 62px; min-height: 38px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 500; cursor: pointer;
}
.kf-send.hidden { display: none; }

/* 微信式录音浮层 */
.rec-hint {
  position: fixed; left: 50%; top: 36%; transform: translate(-50%,-50%);
  background: rgba(17,17,17,.75); color: #fff; border-radius: 12px; padding: 14px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 100;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.rec-hint .rh-tip { font-size: 13px; opacity: .92; white-space: nowrap; }
.rec-hint .rh-timer { font-size: 24px; font-weight: 600; min-width: 70px; text-align: center; }
.rec-hint.cancel { background: rgba(255,77,79,.88); }
.rec-hint.cancel .rh-timer { display: none; }
.rec-hint.hidden { display: none; }

/* ===== 表情面板（微信风格） ===== */
.emoji-panel {
  background: #f7f7f7; border-top: 1px solid #e5e5e5; height: 210px;
  overflow-y: auto; padding: 10px; flex-shrink: 0;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
}
.emoji-panel span { font-size: 26px; text-align: center; cursor: pointer; padding: 4px; }
.emoji-panel.hidden { display: none; }

/* ===== 底部输入栏（微信聊天页样式） ===== */
.wx-inputbar {
  display: flex; align-items: flex-end; gap: 10px;
  background: #f7f7f7; border-top: 1px solid #d6d6d6;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.wx-inputbar .tool { color: #2f2f2f; font-size: 0; line-height: 1; cursor: pointer; padding: 4px 0; }
.wx-inputbar .tool svg { width: 27px; height: 27px; }
.input-wrap {
  flex: 1; background: #fff; border-radius: 6px; min-height: 38px;
  display: flex; align-items: flex-end;
}
textarea {
  flex: 1; border: none; background: transparent; width: 100%;
  min-height: 38px; max-height: 120px;
  padding: 9px 10px; font-size: 16px; resize: none; outline: none; line-height: 1.4;
}

/* 轻提示浮层 */
.kf-hint {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: rgba(0,0,0,.72); color: #fff; font-size: 13px;
  padding: 8px 15px; border-radius: 8px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 999;
}
.kf-hint.show { opacity: 1; }

/* ===== 缩小态：隐藏整个聊天界面 ===== */
body.kf-min .wx-nav, body.kf-min .msgs, body.kf-min .wx-inputbar { display: none; }
/* 缩小态彻底透明，避免在 iframe 嵌入时留下一块底色挡页面 */
html.kf-min, body.kf-min { background: transparent; }

/* 缩小后的悬浮按钮 */
.kf-float {
  position: fixed; inset: 0; width: 100%; height: 100%;
  background: #07c160; color: #fff; border-radius: 22px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
  cursor: pointer; z-index: 1000;
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.kf-float svg { width: 20px; height: 20px; }
.kf-float.hidden { display: none; }
