/* ============================================================
   云舟抖音客服 · 共用样式
   蓝白轻玻璃 / 克制 / 移动优先
   ============================================================ */
:root {
  --brand: #2563eb;
  --brand-2: #3b82f6;
  --brand-soft: #eff5ff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #8b9ab0;
  --line: #e6ecf5;
  --line-2: #f1f5fb;
  --bg: #f4f7fc;
  --card: #ffffff;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --r: 16px;
  --r-sm: 11px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .10);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, .04), 0 24px 48px -24px rgba(15, 23, 42, .18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: #dbeafe; }

/* ---------- 通用 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-b { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.hide { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 11px;
  background: #fff; color: var(--ink); cursor: pointer;
  font-size: 14px; font-weight: 500;
  transition: .16s ease; white-space: nowrap;
}
.btn:hover { border-color: #cfdcf0; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px -8px rgba(37, 99, 235, .7);
}
.btn.primary:hover { box-shadow: 0 10px 24px -8px rgba(37, 99, 235, .8); }
.btn.ghost { background: transparent; }
.btn.sm { height: 33px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); border-color: #fbd5d5; }
.btn.danger:hover { background: #fff5f5; }

.inp, .ta, .sel {
  width: 100%; height: 42px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 11px;
  background: #fbfcfe; outline: none; transition: .16s;
}
.ta { height: auto; padding: 11px 13px; resize: vertical; min-height: 84px; line-height: 1.6; }
.inp:focus, .ta:focus, .sel:focus {
  border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
}
label.f { display: block; margin-bottom: 16px; }
label.f > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 7px;
  font-size: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 500;
}
.tag.grey { background: #f1f5f9; color: var(--ink-2); }
.tag.ok { background: #e9f9f2; color: #059669; }
.tag.warn { background: #fef7e8; color: #b45309; }
.tag.red { background: #fef1f1; color: #dc2626; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(16, 185, 129, .16); }

/* ---------- 顶栏 ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-in { height: 62px; display: flex; align-items: center; gap: 18px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #22d3ee);
  display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 700;
}
.nav-links { display: flex; gap: 22px; margin-left: 8px; }
.nav-links a { color: var(--ink-2); font-size: 14px; }
.nav-links a:hover { color: var(--brand); }

/* ---------- 登录 ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.auth-card {
  width: 100%; max-width: 420px; padding: 34px 32px 30px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 20px; box-shadow: var(--shadow-lg);
}
.tabs { display: flex; gap: 4px; padding: 4px; background: #f1f5fb; border-radius: 12px; margin-bottom: 22px; }
.tabs button {
  flex: 1; height: 36px; border: 0; background: transparent; border-radius: 9px;
  cursor: pointer; color: var(--ink-2); font-size: 14px; font-weight: 500; transition: .16s;
}
.tabs button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

/* ---------- 工作台布局 ---------- */
.app { display: grid; grid-template-columns: 214px 1fr; min-height: 100vh; }
.side {
  background: #fff; border-right: 1px solid var(--line);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand { padding: 6px 10px 16px; }
.side-item {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 11px; border-radius: 10px;
  color: var(--ink-2); cursor: pointer; font-size: 14px; transition: .14s;
}
.side-item:hover { background: var(--line-2); color: var(--ink); }
.side-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 550; }
.side-item .ico { width: 18px; height: 18px; flex: none; opacity: .85; }
.side-item .badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--danger); color: #fff; border-radius: 10px;
  font-size: 11px; display: grid; place-items: center; font-weight: 600;
}
.side-sep { height: 1px; background: var(--line-2); margin: 10px 8px; }
.side-foot { margin-top: auto; padding-top: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; padding: 0 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 40;
}
.page { padding: 24px 22px 60px; max-width: 1320px; width: 100%; }

/* ---------- 指标卡 ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { padding: 20px 20px 16px; position: relative; overflow: hidden; }
.kpi .k-label { font-size: 13px; color: var(--ink-3); }
.kpi .k-num {
  font-size: 38px; font-weight: 650; letter-spacing: -.03em; line-height: 1.15; margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
}
.kpi .k-sub { font-size: 12.5px; color: var(--ink-3); }
.kpi .k-spark { position: absolute; right: 0; bottom: 0; left: 0; height: 34px; opacity: .5; }
.kpi.accent .k-num { color: var(--brand); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.sec-title { font-size: 15px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.sec-title .line { flex: 1; height: 1px; background: var(--line-2); }

/* ---------- 会话工作台 ---------- */
.page.inbox-page { padding: 0; max-width: none; }
.inbox { display: grid; grid-template-columns: 306px 1fr; grid-template-rows: minmax(0, 1fr); height: calc(100vh - 60px); }
.conv-col { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; }
.conv-head { padding: 12px; border-bottom: 1px solid var(--line-2); }
.conv-list { overflow-y: auto; flex: 1; }
.conv-item {
  padding: 12px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; transition: .12s;
  display: flex; gap: 11px; align-items: flex-start;
}
.conv-item:hover { background: #fafcff; }
.conv-item.on { background: var(--brand-soft); }
.conv-item .av {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #dbeafe, #eff6ff); color: var(--brand);
  display: grid; place-items: center; font-size: 14px; font-weight: 600;
}
.conv-item .nm { font-size: 14px; font-weight: 550; }
.conv-item .pv { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.conv-item .unread {
  min-width: 18px; height: 18px; padding: 0 5px; background: var(--danger); color: #fff;
  border-radius: 9px; font-size: 11px; display: grid; place-items: center; font-weight: 600;
}
.chat-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #f8fafd; }
.chat-head {
  height: 58px; padding: 0 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; background: #fff;
}
.chat-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 22px 22px 8px; }
.chat-foot { padding: 12px 18px 16px; background: #fff; border-top: 1px solid var(--line); }
.msgs { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 78%; }
.msg .bub {
  padding: 9px 13px; border-radius: 13px; font-size: 14.5px;
  background: #fff; border: 1px solid var(--line); word-break: break-word; white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}
.msg .who { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .bub { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }
.msg.me .who { text-align: right; }
.msg.sys { align-self: center; max-width: 100%; }
.msg.sys .bub { background: transparent; border: 0; color: var(--ink-3); font-size: 12.5px; text-align: center; }
.msg .bub img { border-radius: 9px; max-height: 260px; }
.empty { display: grid; place-items: center; height: 100%; color: var(--ink-3); font-size: 14px; }

/* ---------- 客服卡片 ---------- */
.agent-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.agent-top { display: flex; gap: 12px; align-items: center; }
.agent-av {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  background: linear-gradient(135deg, var(--brand), #60a5fa); color: #fff;
  display: grid; place-items: center; font-size: 17px; font-weight: 600;
}
.qr-box {
  background: #fff; border: 1px dashed var(--line); border-radius: 12px;
  padding: 10px; display: grid; place-items: center; width: 148px; height: 148px;
}
.qr-box img { width: 100%; height: 100%; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(3px); z-index: 200;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); padding: 24px;
}
.modal h3 { margin: 0 0 18px; font-size: 17px; font-weight: 620; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Toast ---------- */
#toasts { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 900; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 10px 18px; border-radius: 11px; font-size: 14px; color: #fff;
  background: #0f172a; box-shadow: var(--shadow-lg); animation: tin .22s ease;
  max-width: 90vw;
}
.toast.ok { background: #059669; }
.toast.err { background: #dc2626; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- 表格 ---------- */
.tb { width: 100%; border-collapse: collapse; font-size: 14px; }
.tb th {
  text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12.5px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tb td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tb tr:hover td { background: #fbfdff; }

/* ---------- 访客聊天页 ---------- */
.guest { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; background: #eef3fa; }
.guest-head {
  height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 11px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.guest-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 14px 10px; }
.guest-foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.g-shell { max-width: 760px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.g-av {
  width: 38px; height: 38px; border-radius: 11px; flex: none; overflow: hidden;
  background: linear-gradient(135deg, var(--brand), #60a5fa); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 15px;
}
.g-msg { display: flex; flex-direction: column; max-width: 82%; margin-bottom: 14px; }
.g-msg .bub {
  padding: 10px 14px; border-radius: 15px; background: #fff; font-size: 15px; line-height: 1.6;
  word-break: break-word; white-space: pre-wrap; box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.g-msg.me { align-self: flex-end; align-items: flex-end; }
.g-msg.me .bub { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.g-msg.sys { align-self: center; max-width: 100%; }
.g-msg.sys .bub { background: rgba(15, 23, 42, .045); color: var(--ink-2); font-size: 13px; box-shadow: none; }
.g-time { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.g-input { display: flex; gap: 9px; align-items: flex-end; }
.g-input textarea {
  flex: 1; min-height: 42px; max-height: 120px; padding: 11px 14px; border-radius: 13px;
  border: 1px solid var(--line); background: #f8fafd; outline: none; resize: none; font-size: 15px;
}
.g-input textarea:focus { border-color: var(--brand); background: #fff; }
.g-send {
  width: 62px; height: 42px; border: 0; border-radius: 13px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); font-size: 14px; font-weight: 550;
}
.g-send:disabled { opacity: .55; }

/* 抖音内置浏览器提示 */
.dy-tip {
  background: #fff7ed; border-bottom: 1px solid #fed7aa; color: #9a3412;
  padding: 10px 16px; font-size: 13.5px; display: flex; align-items: center; gap: 9px;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d7e0ee; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #c3d0e4; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 响应式 ---------- */
@media (max-width: 1040px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: 232px; z-index: 300;
    transform: translateX(-100%); transition: transform .22s ease; height: 100vh;
  }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page { padding: 16px 14px 80px; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox.show-chat .conv-col { display: none; }
  .inbox:not(.show-chat) .chat-col { display: none; }
  .chat-col { height: calc(100vh - 60px); }
  .nav-links { display: none; }
  .kpi .k-num { font-size: 32px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 11px; }
  .kpi { padding: 15px 15px 12px; }
  .kpi .k-num { font-size: 28px; }
  .auth-card { padding: 26px 20px; }
}

/* ============================================================
   多端适配补强（2026-09-22）
   电脑 / 平板 / 手机三端 + 移动端软键盘 + iOS 输入缩放
   ============================================================ */

/* ---------- 1. 动态视口高度：解决手机地址栏/软键盘导致的底部被挡 ---------- */
.app, .auth-wrap, .guest { min-height: 100vh; min-height: 100dvh; }
.side { height: 100vh; height: 100dvh; }
.inbox { height: calc(100vh - 60px); height: calc(100dvh - 60px); }
@media (max-width: 860px) {
  .chat-col { height: calc(100vh - 60px); height: calc(100dvh - 60px); }
}

/* ---------- 2. iOS 聚焦不放大（字号 <16px 会触发自动缩放，整页错位） ---------- */
@media (max-width: 860px) {
  .inp, .ta, .sel, .g-input textarea, #reply, #ta, #username, #password { font-size: 16px; }
}

/* ---------- 3. 触控设备：所有可点元素 ≥ 44px，防误触 ---------- */
@media (pointer: coarse) {
  .btn { height: 44px; padding: 0 18px; }
  .btn.sm { height: 38px; padding: 0 14px; font-size: 13.5px; }
  .inp, .sel { height: 46px; }
  .side-item { height: 46px; }
  .tabs button { height: 42px; }
  .g-send { height: 46px; width: 66px; }
  .g-input textarea { min-height: 46px; padding: 12px 14px; }
  .conv-item { padding: 13px 14px; }
  .side-item, .conv-item, .btn, .g-send { touch-action: manipulation; }
  body { touch-action: manipulation; }
}

/* ---------- 4. 访客聊天页：大屏居中加宽，图片自适应，气泡不撑破 ---------- */
@media (min-width: 1024px) { .g-shell { max-width: 880px; } }
.g-msg .bub img { max-width: min(240px, 62vw); height: auto; }
.g-msg { max-width: 84%; }
.g-msg .bub { overflow-wrap: anywhere; }
.guest-head { padding: 0 14px; }

/* ---------- 5. 客服工作台：桌面更宽裕、1366 笔记本不拥挤 ---------- */
@media (min-width: 1280px) { .inbox { grid-template-columns: 330px 1fr; } }
@media (min-width: 1600px) { .inbox { grid-template-columns: 360px 1fr; } }
.chat-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.guest-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

/* ---------- 6. 顶栏在窄屏不挤爆 ---------- */
@media (max-width: 700px) {
  .topbar { padding: 0 13px; gap: 8px; }
  #clock, #live-tag { display: none; }
  #page-title { font-size: 15px; }
}
@media (max-width: 400px) {
  .guest-head > .tiny.muted.ellip { display: none; }  /* 极窄屏隐藏品牌名 */
  .g-av { width: 34px; height: 34px; font-size: 13px; }
}

/* ---------- 7. 平板（768–1024）：工作台/后台布局收敛 ---------- */
@media (max-width: 1024px) and (min-width: 861px) {
  .inbox { grid-template-columns: 288px 1fr; }
  .page { padding: 20px 18px 60px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
/* 平板竖屏（768–860）：走抽屉式侧栏，会话单栏切换 */
@media (max-width: 860px) {
  .side { width: 248px; }
  .side-item { font-size: 14.5px; }
  .conv-item .av { width: 38px; height: 38px; }
}

/* ---------- 8. 表格：小屏横向可滑且不撑破父容器 ---------- */
.card-pad > div[style*="overflow-x"] { -webkit-overflow-scrolling: touch; }
.tb { min-width: 520px; }
@media (max-width: 700px) {
  .tb { min-width: 460px; font-size: 13px; }
  .tb th, .tb td { padding: 9px 10px; }
}

/* ---------- 9. 二维码页在窄屏自适应 ---------- */
@media (max-width: 400px) {
  #qrwrap img, .card img[src^="/qr/"] { width: 200px !important; height: 200px !important; }
}

/* ---------- 10. 弹层在小屏不超出 ---------- */
@media (max-width: 520px) {
  .mask { padding: 12px; }
  .modal { padding: 20px; border-radius: 16px; max-height: 90vh; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

/* ---------- 11. 修复：会话工作台 grid 行高被消息内容撑破 ----------
   grid 隐式行默认 auto，消息一多 .inbox 的行高就被内容顶开，
   导致聊天区高度远超视口、发送按钮被推到屏幕外。必须钳住行高与子项最小高度。 */
.inbox { grid-template-rows: minmax(0, 1fr); }
.conv-col, .chat-col { min-height: 0; }
.chat-body { min-height: 0; overflow-y: auto; }
.conv-list { min-height: 0; overflow-y: auto; }
.chat-foot { flex: none; }
.chat-head { flex: none; }
.conv-head { flex: none; }

/* ---------- 12. 修复：访客聊天页消息一多整页被撑高、输入框被顶出屏幕 ----------
   原来 .guest 用 min-height，内容会撑破容器导致整页滚动、底部输入区出屏。
   改为固定高度 + 内部消息区滚动，输入框永远钉在屏幕底部。 */
.guest {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.g-shell { height: 100%; min-height: 0; flex: 1 1 auto; }
.guest-head, .guest-foot, .dy-tip { flex: none; }
.guest-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 13. 分享卡片弹层在小屏更紧凑 ---------- */
@media (max-width: 560px) {
  #cprev { max-height: 210px !important; }
  .modal h3 { font-size: 16px; margin-bottom: 12px; }
  #ctabs button { font-size: 13px; }
}

/* ---------- 14. 访客在线状态标识 ---------- */
.live-dot {
  position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px;
  border-radius: 50%; background: #cbd5e1; border: 2px solid #fff; display: block;
}
.live-dot.on { background: #10b981; box-shadow: 0 0 0 2px rgba(16,185,129,.18); }
.conv-item .av { position: relative; overflow: visible; }
.chat-head .g-av { position: relative; }
.dot-tag { display: inline-flex; align-items: center; gap: 4px; }
.dot-tag::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85;
}
.tag.kf-online { background: #e9f9f2; color: #059669; }
@media (max-width: 560px) {
  .conv-item .tiny.muted { font-size: 11.5px; }
}

/* ---------- 15. 会话列表：来源标签 / 图片预览 / 置顶 ---------- */
.src-tag {
  font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 5px; flex: none;
  background: var(--brand-soft); color: var(--brand); font-weight: 500;
}
.pv-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pv-tag {
  font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 5px; flex: none;
  background: #eef2f7; color: var(--ink-2);
}
.pv-thumb { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; flex: none;
  border: 1px solid var(--line); background: #fff; }
.conv-item { position: relative; }
.pin-btn {
  position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-3);
  display: grid; place-items: center; cursor: pointer; opacity: 0; transition: .15s;
}
.conv-item:hover .pin-btn { opacity: 1; }
.pin-btn:hover { background: var(--brand-soft); color: var(--brand); }
.conv-item.pinned { background: linear-gradient(90deg, rgba(37,99,235,.055), rgba(37,99,235,.01) 60%, transparent); }
.conv-item.pinned .pin-btn { opacity: 1; color: var(--brand); }
.conv-item.pinned.on { background: var(--brand-soft); }
.pin-ico { color: var(--brand); flex: none; }
@media (pointer: coarse) { .pin-btn { opacity: 1; width: 32px; height: 32px; } }

/* ============================================================
   运营驾驶舱（平台后台）
   克制科技感：3D 倾斜 + 指针高光 + 细网格 + oversized 数字
   ============================================================ */
.cockpit { position: relative; }
.cockpit::before {
  content: ''; position: absolute; inset: -8px -10px 0; pointer-events: none; z-index: 0;
  background-image: linear-gradient(rgba(37,99,235,.045) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(37,99,235,.045) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(680px 320px at 22% -6%, #000 0%, transparent 72%);
  mask-image: radial-gradient(680px 320px at 22% -6%, #000 0%, transparent 72%);
  opacity: .9;
}
.cockpit > * { position: relative; z-index: 1; }

.hero-bar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.hero-bar h1 { margin: 0; font-size: 24px; letter-spacing: -.025em; font-weight: 640; }
.hero-bar .sub { color: var(--ink-3); font-size: 13.5px; margin-top: 5px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px;
  border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2);
  box-shadow: var(--shadow);
}
.live-pill .dot { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.16); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* 3D KPI */
.kpi3-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; perspective: 1400px; }
.kpi3 {
  position: relative; background: linear-gradient(160deg, #ffffff 0%, #fbfdff 100%);
  border: 1px solid var(--line); border-radius: 18px; padding: 20px 20px 16px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 14px 32px -20px rgba(15,23,42,.22);
  transition: box-shadow .22s, transform .22s; transform-style: preserve-3d;
  will-change: transform;
}
.kpi3:hover { box-shadow: 0 2px 4px rgba(15,23,42,.05), 0 22px 44px -22px rgba(15,23,42,.30); }
.kpi3::after {   /* 指针跟随高光 */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), rgba(37,99,235,.10), transparent 62%);
}
.kpi3:hover::after { opacity: 1; }
.kpi3 .k-top { display: flex; align-items: center; gap: 9px; }
.kpi3 .k-ic {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand);
}
.kpi3 .k-label { font-size: 13px; color: var(--ink-3); }
.kpi3 .k-num {
  font-size: 44px; font-weight: 660; letter-spacing: -.045em; line-height: 1.05;
  margin: 10px 0 3px; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #0f172a, #334155); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi3.accent .k-num { background: linear-gradient(180deg, #2563eb, #60a5fa); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi3 .k-foot { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi3 .k-spark { margin-top: 10px; height: 30px; }
.kpi3 .k-float { position: absolute; right: 16px; top: 16px; font-size: 11.5px; color: var(--ok); font-weight: 600; }

/* 模块全景 */
.mod-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; perspective: 1400px; }
.mod {
  background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 15px 14px 13px;
  cursor: pointer; transition: .18s; position: relative; overflow: hidden; transform-style: preserve-3d;
}
.mod:hover { border-color: #cfe0f7; transform: translateY(-2px); box-shadow: 0 16px 30px -20px rgba(15,23,42,.30); }
.mod .m-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 11px; }
.mod .m-n { font-size: 27px; font-weight: 650; letter-spacing: -.035em; line-height: 1;
  font-variant-numeric: tabular-nums; }
.mod .m-t { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.mod .m-dot { width: 6px; height: 6px; border-radius: 50%; background: #cbd5e1; }
.mod .m-dot.on { background: #10b981; animation: pulse 2.4s infinite; }
.mod.warn { background: linear-gradient(160deg, #fffdf7, #fff); border-color: #fde9c7; }
.mod.warn .m-n { color: #b45309; }
.mod.danger { background: linear-gradient(160deg, #fff8f8, #fff); border-color: #fbd9d9; }
.mod.danger .m-n { color: #dc2626; }
.mod .m-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--brand); opacity: .55; }

/* 驾驶舱面板 */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 20px;
  box-shadow: 0 1px 2px rgba(15,23,42,.035), 0 12px 28px -22px rgba(15,23,42,.20); }
.panel-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel-hd .t { font-size: 14.5px; font-weight: 600; }
.panel-hd .line { flex: 1; height: 1px; background: var(--line-2); }

.alert-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .a-ic { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: #fff7ed; color: #b45309; }
.alert-row .a-ic.red { background: #fef2f2; color: #dc2626; }
.alert-row .a-ic.grey { background: #f1f5f9; color: var(--ink-3); }

.src-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.src-row .s-name { width: 62px; font-size: 13px; flex: none; }
.src-row .s-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.src-row .s-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2563eb, #60a5fa); }
.src-row .s-n { width: 46px; text-align: right; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.rank-row:last-child { border-bottom: 0; }
.rank-row .r-no { width: 20px; height: 20px; border-radius: 6px; flex: none; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); }
.rank-row .r-no.top { background: linear-gradient(135deg,#2563eb,#60a5fa); color: #fff; }

.health-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.health-item { background: #fbfdff; border: 1px solid var(--line-2); border-radius: 12px; padding: 11px 12px; }
.health-item .h-l { font-size: 12px; color: var(--ink-3); }
.health-item .h-v { font-size: 15px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }

@media (max-width: 1280px) { .mod-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1040px) { .kpi3-grid { grid-template-columns: repeat(2, 1fr); } .mod-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) {
  .kpi3 .k-num { font-size: 34px; }
  .mod-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .mod .m-n { font-size: 23px; }
  .health-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .kpi3, .mod { transition: none; } }


/* 16. 用户端：未开通租用时锁定功能菜单（2026-09-22） */
.side-item.locked{opacity:.45;cursor:not-allowed}
.side-item.locked::after{content:'锁';font-size:10px;margin-left:6px;padding:1px 5px;border-radius:6px;
  background:rgba(148,163,184,.18);color:var(--ink-3);font-weight:500}

/* ============================================================
   17. 布局修复（2026-09-22）：输入框钉底 · 只有消息区滚动 · 图片不撑破布局
   根因：
     ① `.app{min-height:100vh}` + `.inbox{height:calc(100dvh - 60px)}` + 页面内边距
        → 总高超出视口，body 产生滚动，底部输入区被推到屏幕外（工作台实测 bottom 924 > 900）。
     ② `.app,.auth-wrap,.guest{min-height:100vh}` 在手机上 100vh > 可视高度，
        `.guest` 被撑高 → 整页可滚、输入框跟随滚动。
     ③ 访客聊天图片只有 max-width 没有 max-height，720×2400 长图渲染成 733px 高，
        一张图占满整个视口，滚动观感就是「输入框在跑」。
   方案：外层锁定为视口高度并禁止页面滚动，滚动只发生在消息容器内；
        图片钳制高度 + 固定占位背景，加载/尺寸变化都不推动布局。
   ============================================================ */

/* ---- 17.1 应用外壳：锁定视口高度，禁止整页滚动 ---- */
html, body { height: 100%; }
.app {
  height: 100vh; height: 100dvh;
  min-height: 0;                 /* 覆盖旧规则里的 min-height:100vh */
  overflow: hidden;
}
.main { min-height: 0; overflow: hidden; }
.page { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.side { height: 100%; position: sticky; top: 0; }

/* ---- 17.2 工作台聊天：会话列表与消息区各自滚动，输入区常驻视口底部 ---- */
.page.inbox-page { display: flex; flex-direction: column; overflow: hidden; }
.inbox { height: 100%; min-height: 0; }
.chat-col { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-head { flex: 0 0 auto; }
.chat-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
             -webkit-overflow-scrolling: touch; }
.chat-foot { flex: 0 0 auto; position: sticky; bottom: 0; z-index: 5; }

/* ---- 17.3 访客聊天页：整页固定，输入框全程不动 ---- */
.guest {
  position: fixed; inset: 0;            /* 脱离文档流：页面永远不产生滚动条 */
  width: 100%; height: auto; min-height: 0;
  overflow: hidden; display: flex; flex-direction: column;
}
.g-shell { height: 100%; min-height: 0; }
.guest-head { flex: 0 0 auto; position: relative; }
.guest-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
              -webkit-overflow-scrolling: touch; }
.guest-foot { flex: 0 0 auto; position: sticky; bottom: 0; z-index: 5; }

/* ---- 17.4 图片：高度钳制 + 占位底色，加载完成不推动布局 ---- */
.g-msg .bub img,
.msg .bub img,
.chat-body .bub img {
  display: block;
  width: auto; height: auto;
  max-width: min(240px, 62vw);
  max-height: min(300px, 38vh);         /* 关键：长图不再撑满整屏 */
  object-fit: contain;
  border-radius: 10px;
  background: #eef2f8;                  /* 加载期间的占位，避免高度从 0 突变 */
  cursor: pointer;
}
.g-msg .bub { padding: 6px; }
@media (max-width: 420px) {
  .g-msg .bub img, .msg .bub img { max-height: min(260px, 34vh); }
}
/* 气泡内图片只按内容高度排布，不参与 flex 拉伸 */
.g-msg, .msg { flex: 0 0 auto; }
.g-msg .bub, .msg .bub { max-width: 100%; }

/* ---- 17.5 移动端软键盘：输入区仍在可视区内 ---- */


/* ============================================================
   18. 聊天增强（2026-09-22）：头像 / 语音气泡 / 撤回 / 按住说话浮层
   说明：只新增行内元素样式，不改 .guest / .guest-body / .guest-foot 的布局约束，
        输入框依旧钉在视口底部，滚动仍然只发生在消息容器内。
   ============================================================ */

/* ---- 18.1 消息行：头像 + 内容列 ---- */
.g-msg { display: flex; align-items: flex-start; gap: 9px; }
.g-msg .g-avv {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 34px;
  background: #e8eef7; object-fit: cover; user-select: none;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}
.g-msg .g-col { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.g-msg .g-col .bub { max-width: 100%; }
.g-msg.sys, .g-msg.sys .bub { display: block; }
.g-msg.sys .g-avv { display: none; }
.g-msg.me { flex-direction: row-reverse; }
.g-msg.me .g-col { align-items: flex-end; }
.g-msg .g-time { margin-top: 5px; }

/* ---- 18.2 已撤回 ---- */
.bub.revoked{ background: rgba(15,23,42,.04); color: var(--ink-3); font-size: 13px; font-style: normal;
  border: 1px dashed var(--line); box-shadow: none; }
.g-msg.me .bub.revoked{ background: rgba(15,23,42,.04); color: var(--ink-3); }

/* ---- 18.3 语音气泡 ---- */
.bub.vbub{ display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer;
  user-select: none; -webkit-tap-highlight-color: transparent; }
.vbub .vplay{ width: 26px; height: 26px; flex: none; border: 0; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; background: rgba(37,99,235,.10); color: var(--brand); padding: 0; }
.vbub .vplay.on{ background: var(--brand); color: #fff; }
.vbub .vbar{ flex: 1 1 auto; height: 4px; min-width: 34px; border-radius: 3px; background: rgba(15,23,42,.10); overflow: hidden; }
.vbub .vbar i{ display: block; height: 100%; width: 0; background: currentColor; opacity: .55; border-radius: 3px; }
.vbub .vsec{ font-size: 12.5px; opacity: .72; flex: none; font-variant-numeric: tabular-nums; }
.g-msg.me .vbub .vplay{ background: rgba(255,255,255,.22); color: #fff; }
.g-msg.me .vbub .vplay.on{ background: #fff; color: var(--brand); }
.g-msg.me .vbub .vbar{ background: rgba(255,255,255,.28); }

/* ---- 18.4 按住说话：按钮态 + 浮层（fixed，不参与文档流，绝不影响布局） ---- */
#voice.rec-on{ background: var(--brand); color: #fff; border-color: transparent; }
.vrec{ position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center;
  background: rgba(15,23,42,.18); backdrop-filter: blur(2px); }
.vrec-card{ width: 210px; padding: 22px 18px 18px; border-radius: 20px; text-align: center;
  background: rgba(17,24,39,.92); color: #fff; box-shadow: 0 20px 45px -20px rgba(0,0,0,.6); }
.vrec-card .vwave{ display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 30px; margin-bottom: 12px; }
.vrec-card .vwave i{ width: 4px; border-radius: 2px; background: #7dd3fc; animation: yzWave 1s infinite ease-in-out; }
.vrec-card .vwave i:nth-child(1){ height: 12px; animation-delay: 0s; }
.vrec-card .vwave i:nth-child(2){ height: 22px; animation-delay: .12s; }
.vrec-card .vwave i:nth-child(3){ height: 30px; animation-delay: .24s; }
.vrec-card .vwave i:nth-child(4){ height: 20px; animation-delay: .36s; }
.vrec-card .vwave i:nth-child(5){ height: 13px; animation-delay: .48s; }
.vrec.danger .vrec-card{ background: rgba(153,27,27,.94); }
.vrec.danger .vrec-card .vwave i{ background: #fecaca; }
@keyframes yzWave{ 0%,100%{ transform: scaleY(.55) } 50%{ transform: scaleY(1) } }
.vrec-card .vrec-t{ font-size: 15px; font-weight: 550; letter-spacing: .02em; }
.vrec-card .vrec-h{ font-size: 12.5px; opacity: .72; margin-top: 5px; }
@media (prefers-reduced-motion: reduce){ .vrec-card .vwave i{ animation: none } }

/* ---- 18.5 工作台：消息头像与撤回按钮 ---- */
.msg{ display: flex; align-items: flex-start; gap: 9px; }
.msg .m-avv{ width: 32px; height: 32px; border-radius: 10px; flex: 0 0 32px; background: #e8eef7;
  object-fit: cover; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.msg .m-col{ display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.msg.me{ flex-direction: row-reverse; }
.msg.me .m-col{ align-items: flex-end; }
.msg .m-tools{ display: flex; gap: 6px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg:hover .m-tools, .msg.show-tools .m-tools{ opacity: 1; }
.m-tools button{ font-size: 12px; padding: 2px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); cursor: pointer; }
.m-tools button:hover{ color: var(--brand); border-color: var(--brand); }
@media (max-width: 860px){ .msg .m-tools{ opacity: 1; } }

/* ============================================================
   19. 聊天页定版布局（2026-09-22 第五轮修复）
   需求：上方独立滚动聊天容器 + 下方输入框 position:fixed 钉在视口底部；
        图片加载/多图/图片变大只在聊天容器内部撑开，永不改变页面高度。
   本块**不再依赖 100dvh**（抖音/微信内置浏览器旧内核不支持 dvh 会整页塌掉）：
        · 外层用 position:fixed; inset:0 → 高度直接等于视口，与 vh/dvh 无关
        · 工作台用 height:100vh 打底 + @supports 升级 dvh + JS --app-h 兜底
        · 输入区真正 fixed，用 --foot-h 给滚动容器留出底部内边距
   ============================================================ */

/* ---- 19.1 访客聊天页：上下两块，输入框 fixed ---- */
.guest {
  position: fixed;            /* 关键：脱离文档流，页面高度永远等于视口 */
  inset: 0;
  width: 100%; height: auto; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.g-shell { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.guest-head { flex: 0 0 auto; position: relative; z-index: 25; }

/* 上方：唯一滚动容器 */
.guest-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  /* 给 fixed 输入区留位：JS 实测输入区高度写进 --foot-h（未测量时按 99px 兜底） */
  padding-bottom: calc(var(--foot-h, 99px) + 8px + env(safe-area-inset-bottom));
  scroll-padding-bottom: calc(var(--foot-h, 99px) + 8px);
}

/* 下方：输入框固定在浏览器视口底部，任何滚动都不动 */
.guest-foot {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 30; flex: none;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  /* 桌面加宽时与消息列对齐 */
  padding-left: max(12px, calc((100vw - 880px) / 2));
  padding-right: max(12px, calc((100vw - 880px) / 2));
  box-shadow: 0 -6px 18px -14px rgba(15, 23, 42, .28);
}
body.guest-page { overflow: hidden; height: 100%; }

/* ---- 19.2 工作台/后台外壳：视口高度锁定（不依赖 dvh） ---- */
.app { height: 100vh; min-height: 0; overflow: hidden; }
@supports (height: 100dvh) { .app { height: 100dvh; } }
.app { height: var(--app-h, 100vh); }        /* JS 兜底：旧内核也能锁死 */
.main { height: 100%; min-height: 0; overflow: hidden; }

/* 工作台：会话列表与消息区各自滚动，输入区贴面板底（面板已锁定视口高度） */
.page.inbox-page { display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.inbox { height: 100%; min-height: 0; }
.chat-col { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
             -webkit-overflow-scrolling: touch; }
.chat-foot { flex: 0 0 auto; }

/* 移动端单栏工作台：聊天区占满，输入区仍在可视区内 */
@media (max-width: 860px) {
  .page.inbox-page { height: 100%; }
  .inbox { height: 100%; grid-template-rows: minmax(0, 1fr); }
  .chat-col { height: 100%; }
}

/* ---- 19.3 多图场景：图片只影响聊天容器内部高度 ---- */
.g-msg .bub img, .msg .bub img {
  max-height: min(300px, 38vh);
  max-width: min(240px, 62vw);
  object-fit: contain;
  contain: content;                 /* 图片重排不外溢到容器 */
}
@media (max-width: 420px) {
  .g-msg .bub img, .msg .bub img { max-height: min(240px, 32vh); }
}

/* touch */

/* ============================================================
   20. 移动端软键盘定版（2026-09-22）：只压缩聊天滚动区，输入框贴键盘上沿
   背景：iOS Safari 弹键盘时不会重排 fixed 元素，浏览器会把整个页面向上顶
        （visualViewport.offsetTop 变化），于是「输入框跑到屏幕顶部」。
   方案：
     · 聊天页外壳 body 固定（position:fixed + overflow:hidden）→ 页面本身不可能滚动
     · 用 visualViewport 的真实 height/offsetTop 驱动三个 CSS 变量：
         --vvh 可视高度  --vvy 可视区顶偏移  --kb-h 键盘占去的高度
     · 键盘打开时：外壳 top 跟随 --vvy、高度 = --vvh；输入框 bottom = --kb-h
       → 输入框永远紧贴键盘上沿，页面不产生任何位移
   ============================================================ */

/* ---- 20.1 聊天外壳禁止页面滚动（iOS 上必须，否则会被整体顶走） ---- */
body.guest-page { position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; }
body.app-page   { position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; }
body.guest-page .guest { height: 100%; }
body.app-page .app { height: var(--app-h, 100vh); }

/* ---- 20.2 键盘打开：外壳贴住可视区，输入区贴住键盘 ---- */
body.kb-open .guest,
body.kb-open .app {
  top: var(--vvy, 0px);
  height: var(--vvh, 100%);
  bottom: auto;
  min-height: 0;
}
body.kb-open .guest-foot {
  position: fixed;                          /* 显式声明：压过历史遗留的 sticky 规则 */
  bottom: var(--kb-h, 0px);
  left: 0; right: 0;
  padding-bottom: 8px;                      /* 键盘上沿不需要 safe-area 余量 */
}
body.kb-open .guest-body { padding-bottom: calc(var(--foot-h, 99px) + 6px); }
body.kb-open .g-msg .bub img { max-height: min(190px, 26vh); }

/* 工作台：外壳变矮后，输入区随 flex 自动贴到可视底部（即键盘上沿） */
body.kb-open .page.inbox-page { height: 100%; }
body.kb-open .chat-body { padding-bottom: 6px; }
body.kb-open .chat-foot { padding-bottom: 8px; }

/* ---- 20.3 兜底：任何情况下都不让页面整体位移 ---- */
html { overflow: hidden; }
body.guest-page, body.app-page { overscroll-behavior: none; }

/* ============================================================
   21. 头像与消息对齐定版（2026-09-22）
   需求：两端都显示客服头像 + 用户头像；统一圆形、固定尺寸、不变形；
        头像在外侧、气泡在内侧，对齐整齐。
   ============================================================ */

/* ---- 21.1 头像：圆形 + 固定尺寸（宽高锁定，矢量/位图都不变形）---- */
.g-msg .g-avv,
.msg .m-avv {
  width: 38px; height: 38px;
  flex: 0 0 38px;                 /* 固定占位，绝不随内容缩放 */
  min-width: 38px; max-width: 38px;
  border-radius: 50%;             /* 圆形裁切 */
  object-fit: cover;
  aspect-ratio: 1 / 1;
  background: #e8eef7;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- 21.2 消息行：头像在外侧、气泡在内侧，顶对齐 ---- */
.g-msg, .msg {
  display: flex;
  flex-direction: row;            /* 关键：头像与气泡左右排列（原来是 column，会上下堆叠） */
  align-items: flex-start;        /* 与气泡顶对齐，长文换行不会把头像拉下去 */
  gap: 10px;
  max-width: 100%;
}
.g-msg.me, .msg.me { flex-direction: row-reverse; }   /* 自己的消息：头像贴最右 */

/* 内容列：给头像留出固定宽度，气泡不会被挤到对面 */
.g-msg .g-col, .msg .m-col {
  max-width: calc(100% - 48px);
  min-width: 0;
}
.g-msg.me .g-col, .msg.me .m-col { align-items: flex-end; }
.g-msg .g-time, .msg .who { margin-top: 4px; }

/* 系统提示：不显示头像 */
.g-msg.sys .g-avv, .msg.sys .m-avv { display: none; }

/* ---- 21.3 移动端：略小一号，仍为圆形固定尺寸 ---- */
@media (max-width: 420px) {
  .g-msg .g-avv, .msg .m-avv { width: 33px; height: 33px; flex: 0 0 33px; min-width: 33px; max-width: 33px; }
  .g-msg .g-col, .msg .m-col { max-width: calc(100% - 43px); }
}

/* ---- 21.4 后台侧栏/顶栏固定：右侧内容滚动不影响左侧菜单 ---- */
.side { position: sticky; top: 0; align-self: start; height: 100%; }
.topbar { position: sticky; top: 0; z-index: 10; }
.page { overscroll-behavior: contain; }

/* ============================================================
   22. 会话置顶按钮改版（2026-09-22）
   原来是一个只在鼠标悬停时才出现的图钉图标，触屏看不到、也认不出是什么；
   现在改成常显的、带文字的按钮：「置顶」/「已置顶」。
   ============================================================ */
.pin-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  width: auto !important;
  height: auto !important;
  min-height: 30px;
  padding: 6px 10px !important;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  background: #fff !important;
  color: var(--ink-2) !important;
  opacity: 1 !important;
  flex: none;
  white-space: nowrap;
  align-self: flex-start;
  cursor: pointer;
}
.pin-btn svg { flex: none; opacity: .75; }
.pin-btn:hover {
  border-color: var(--brand) !important;
  color: var(--brand) !important;
  background: var(--brand-soft) !important;
}
.pin-btn.on,
.conv-item.pinned .pin-btn {
  border-color: var(--brand) !important;
  color: var(--brand) !important;
  background: var(--brand-soft) !important;
}
.pin-btn.on svg,
.conv-item.pinned .pin-btn svg { opacity: 1; }
/* 触屏：保证按钮够大、位置常显 */
@media (pointer: coarse) {
  .pin-btn { min-height: 32px; padding: 7px 11px !important; }
}
/* 窄屏会话列表：文字按钮略收紧，避免挤压访客名 */
@media (max-width: 1180px) {
  .pin-btn { padding: 5px 8px !important; font-size: 11.5px; }
}
