/* H5 客服工作台样式 —— 微信风格三栏布局 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --brand: #07c160;
  --brand-dark: #06ad56;
  --brand-soft: #e8f9f0;
  --bg: #f2f3f5;
  --panel: #ffffff;
  --text: #1a1a1a;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #ececec;
  --danger: #fa5151;
  --bubble-agent: #95ec69;
  --bubble-user: #ffffff;
  --radius: 8px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; overflow: hidden;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }

/* ========== 登录页 ========== */
.login-view { height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #07c160 0%, #04904a 100%); }
.login-card { width: 340px; background: #fff; border-radius: 16px; padding: 36px 32px;
  display: flex; flex-direction: column; align-items: center; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--brand);
  color: #fff; font-size: 32px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.login-card h1 { font-size: 20px; }
.login-sub { color: var(--text-2); font-size: 13px; margin: 6px 0 24px; }
.login-card input { width: 100%; height: 44px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 14px; margin-bottom: 12px; font-size: 14px; outline: none; transition: border-color .15s; }
.login-card input:focus { border-color: var(--brand); }
.login-card button { width: 100%; height: 44px; background: var(--brand); color: #fff;
  border-radius: var(--radius); font-size: 16px; letter-spacing: 4px; margin-top: 6px; transition: background .15s; }
.login-card button:hover { background: var(--brand-dark); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ========== 主界面布局 ========== */
.app-view { display: flex; height: 100%; }

/* 左栏 */
.sidebar { width: 300px; min-width: 300px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; }
.agent-card { padding: 14px 14px 12px; border-bottom: 1px solid var(--border); display: flex;
  flex-direction: column; gap: 10px; }
.agent-top { display: flex; align-items: center; gap: 10px; }
.agent-meta { flex: 1; min-width: 0; display: flex; align-items: center; }
.agent-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#agent-card #agent-avatar, #agent-card #agent-name { cursor: pointer; }
#agent-card #agent-name:hover { color: var(--brand); }

/* 接待信息行：左侧状态（单行省略），右侧人数/上限按钮 */
.reception-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agent-status { color: var(--text-2); font-size: 12px; display: flex; align-items: center; gap: 5px; min-width: 0; }
.agent-status #reception-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reception-btns { display: flex; gap: 6px; flex-shrink: 0; }
.reception-edit-btn { padding: 0 9px; height: 22px; line-height: 20px;
  border: 1px solid var(--border, #e5e7eb); background: var(--bg-2, #f7f8fa);
  border-radius: 11px; font-size: 11px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.reception-edit-btn:hover { color: #fff; background: var(--brand); border-color: var(--brand); }
#count-modal .modal, #limit-modal .modal { max-width: 360px; }
#count-modal input[type="number"], #limit-modal input[type="number"] { margin-top: 8px; }
#count-current, #limit-current { margin-top: 8px; font-size: 12px; color: var(--text-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-online { background: var(--brand); }
.agent-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 专属客服码整行入口按钮 */
.qrcode-entry-btn { width: 100%; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--brand-dark); background: var(--brand-soft); border: 1px solid #b9ecd2;
  transition: background .15s; }
.qrcode-entry-btn:hover { background: #d6f5e4; }
.qrcode-entry-btn svg { width: 17px; height: 17px; }
/* 两个入口按钮（专属码 / 自动回复）并排 */
.agent-card .qrcode-entry-btn { width: 100%; }
.agent-card > .qrcode-entry-btn ~ .qrcode-entry-btn { margin-top: -2px; }
.icon-btn { width: 30px; height: 30px; border-radius: 6px; font-size: 15px; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s; }
.icon-btn:hover { background: var(--bg); }

/* 线性图标按钮（专属码 / 修改资料 / 退出 / 快捷回复） */
.tool-icon-btn { width: 34px; height: 34px; border-radius: 8px; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.tool-icon-btn svg { width: 19px; height: 19px; }
.tool-icon-btn:hover { background: var(--brand-soft); color: var(--brand-dark); }
.tool-icon-btn.danger:hover { background: #fff1f1; color: var(--danger); }
.composer-bar .tool-icon-btn { width: 30px; height: 30px; }
.composer-bar .tool-icon-btn svg { width: 17px; height: 17px; }

/* 头像通用 */
.agent-avatar, .target-avatar, .conv-avatar { background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 600; border-radius: 6px;
  overflow: hidden; flex-shrink: 0; }
.agent-avatar { width: 42px; height: 42px; font-size: 17px; }
.agent-avatar.large { width: 72px; height: 72px; font-size: 30px; border-radius: 12px; }
.agent-avatar img, .target-avatar img, .conv-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* 时钟 */
.clock-bar { padding: 8px 14px; display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--border); }
#clock { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--brand-dark); }
#clock-date { font-size: 12px; color: var(--text-3); }

/* 会话筛选 */
.conv-tabs { display: flex; align-items: center; padding: 8px 10px 0; gap: 4px; }
.tab { padding: 6px 10px; border-radius: 6px; font-size: 13px; color: var(--text-2); }
.tab.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.tab:hover:not(.active) { background: var(--bg); }
.conv-refresh-btn { margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--text-2); border-radius: 8px; cursor: pointer; }
.conv-refresh-btn:hover { background: var(--bg); color: var(--brand-dark); }
.conv-refresh-btn.spinning svg { animation: conv-spin .55s linear; }
@keyframes conv-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 会话切换加载态 + 消息区切换动效 */
.chat-loading { display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-2); font-size: 14px; padding: 48px 16px; }
.chat-loading-spin { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--brand); animation: conv-spin .8s linear infinite; }
.msg-pane-flash { animation: msg-pane-in .24s ease; }
@keyframes msg-pane-in { from { opacity: .25; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* 会话列表 */
.conv-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.conv-item { display: flex; gap: 10px; padding: 11px 14px; cursor: pointer; position: relative; }
.conv-item:hover { background: #f7f8fa; }
.conv-item.active { background: var(--brand-soft); }
.conv-avatar { width: 44px; height: 44px; font-size: 16px; position: relative; }
.conv-info { flex: 1; min-width: 0; }
.conv-row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.conv-row2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 3px; }
.conv-last { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.badge { background: var(--danger); color: #fff; font-size: 11px; min-width: 18px; height: 18px;
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.tag-status { font-size: 10px; padding: 1px 6px; border-radius: 4px; flex-shrink: 0; }
.tag-waiting { background: #fff3e0; color: #e8860a; }
.tag-closed { background: #f0f0f0; color: #999; }
.conv-del { position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border-radius: 4px;
  font-size: 12px; color: var(--text-3); display: none; align-items: center; justify-content: center;
  background: rgba(255,255,255,.92); }
.conv-item:hover .conv-del { display: flex; }
.conv-del:hover { color: var(--danger); }

/* ========== 中栏聊天区 ========== */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { height: 60px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px; flex-shrink: 0; }
.chat-target { display: flex; align-items: center; gap: 12px; }
.target-avatar { width: 40px; height: 40px; font-size: 15px; cursor: pointer; }
.target-name { font-weight: 600; font-size: 15px; cursor: pointer; max-width: 38vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.target-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.rename-default { font-size: 12px; color: var(--text-2); margin-top: 8px; }
.target-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.chat-tools { display: flex; gap: 8px; align-items: center; }
.tool-btn { font-size: 13px; color: var(--text-2); padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); display: inline-flex; align-items: center; gap: 4px; }
.tool-btn:hover { background: var(--bg); }
.tool-btn.danger { color: var(--danger); }
#sound-state { font-size: 12px; }

/* 消息区 */
.messages { flex: 1; overflow-y: auto; padding: 18px 24px; background: var(--bg); }
.empty-tip { text-align: center; color: var(--text-3); margin-top: 80px; font-size: 14px; }
.time-divider { text-align: center; margin: 16px 0; }
.time-divider span { background: #dcdcdc; color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 4px; }
.msg-row { display: flex; margin-bottom: 14px; gap: 10px; }
.msg-avatar { width: 38px; height: 38px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; overflow: hidden; }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-body { max-width: 62%; position: relative; }
.msg-sender { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.bubble { padding: 9px 12px; border-radius: 6px; font-size: 14px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap; display: inline-block; }
.bubble.text { box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.msg-row.user .bubble { background: var(--bubble-user); }
.msg-row.agent { flex-direction: row-reverse; }
.msg-row.agent .bubble { background: var(--bubble-agent); }
.bubble.recalled { background: transparent !important; color: var(--text-3); font-size: 13px;
  box-shadow: none; border: 1px dashed #d0d0d0; padding: 6px 12px; }
.bubble.image { padding: 4px; background: transparent !important; box-shadow: none; }
.bubble img.msg-img { max-width: 240px; max-height: 240px; border-radius: 6px; cursor: zoom-in; display: block; }
.msg-time { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.msg-row.agent .msg-time { text-align: right; }
/* 客服端：自己消息的已读 / 未读状态 */
.msg-read-state { margin-left: 6px; font-size: 11px; }
.msg-read-state.is-read { color: var(--brand); }
.msg-read-state.is-unread { color: #e08a1e; }
.msg-actions { position: absolute; top: -14px; display: none; gap: 2px; background: #fff;
  border: 1px solid var(--border); border-radius: 6px; padding: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.1); z-index: 5; }
.msg-row.agent .msg-actions { right: 0; }
.msg-row.user .msg-actions { left: 0; }
.msg-actions button { font-size: 12px; color: var(--text-2); padding: 3px 8px; border-radius: 4px; white-space: nowrap; }
.msg-actions button:hover { background: var(--bg); color: var(--text); }
.msg-actions button.del:hover { color: var(--danger); }
.msg-body:hover .msg-actions { display: flex; }
/* 触屏/点击：点气泡呼出操作条（手机没有 hover） */
.msg-body.show-actions .msg-actions { display: flex; }
.bubble.text { cursor: pointer; }
.msg-body.show-actions .bubble.text { outline: 2px solid rgba(7,193,96,.25); outline-offset: 2px; }

/* 快捷回复面板 */
.quick-panel { background: var(--panel); border-top: 1px solid var(--border); max-height: 200px;
  display: flex; flex-direction: column; flex-shrink: 0; }
.quick-panel.collapsed .quick-list, .quick-panel.collapsed .quick-edit { display: none; }
.quick-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 14px;
  font-size: 13px; font-weight: 600; }
.quick-head > div { display: flex; gap: 6px; }
.mini-btn { font-size: 12px; padding: 4px 10px; border-radius: 5px; border: 1px solid var(--border); color: var(--text-2); }
.mini-btn:hover { background: var(--bg); }
.mini-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.mini-btn.primary:hover { background: var(--brand-dark); }
.mini-btn.danger { color: var(--danger); text-align: center; text-decoration: none; }
.mini-btn.danger:hover { background: #fff1f1; }
.quick-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 14px 12px; overflow-y: auto; }
.quick-chip { background: var(--brand-soft); color: var(--brand-dark); font-size: 13px; padding: 6px 12px;
  border-radius: 16px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-chip:hover { background: #d6f5e4; }
.quick-empty { color: var(--text-3); font-size: 13px; padding: 6px 0; }
/* 快捷回复管理弹窗 */
.quick-edit-tip { font-size: 12px; color: var(--text-2); background: var(--bg);
  padding: 8px 10px; border-radius: 6px; margin-bottom: 12px; line-height: 1.5; }
.quick-modal-list { display: flex; flex-direction: column; gap: 8px;
  max-height: 48vh; overflow-y: auto; padding: 2px 4px 2px 0; }
.quick-add-line-btn { width: 100%; margin-top: 10px; padding: 9px; border-style: dashed;
  color: var(--brand-dark); border-color: var(--brand); background: var(--brand-soft); }
.quick-add-line-btn:hover { background: #d6f5e4; }
.quick-line { display: flex; gap: 8px; align-items: center; }
.quick-line .line-index { width: 18px; font-size: 12px; color: var(--text-3); text-align: center; flex-shrink: 0; }
.quick-line input { flex: 1; height: 34px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 10px; font-size: 13px; outline: none; min-width: 0; }
.quick-line input:focus { border-color: var(--brand); }
.quick-line .line-del { width: 30px; height: 30px; border-radius: 6px; color: var(--text-3); font-size: 16px;
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.quick-line .line-del:hover { background: #fff1f1; color: var(--danger); }

/* 待发送图片预览区 */
.composer-preview { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 14px 0; }
.pending-thumb { position: relative; width: 84px; height: 84px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border); }
.pending-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pending-thumb .thumb-remove { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center; }
.pending-thumb .thumb-remove:hover { background: var(--danger); }
.pending-thumb .thumb-dim { position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 10px; line-height: 1.5;
  text-align: center; pointer-events: none; }
.pending-thumb .thumb-dim.low { background: rgba(214,122,0,.92); font-weight: 600; }

/* 输入区 */
.composer { background: var(--panel); border-top: 1px solid var(--border); flex-shrink: 0; }
/* 上传图片主按钮 */
.upload-btn { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px;
  border-radius: 6px; font-size: 13px; color: var(--brand-dark); background: var(--brand-soft);
  border: 1px solid #b9ecd2; transition: background .15s; }
.upload-btn:hover { background: #d6f5e4; }
.upload-btn svg { flex-shrink: 0; }
.composer-bar { display: flex; align-items: center; gap: 4px; padding: 6px 12px 0; }
.paste-hint { font-size: 12px; color: var(--text-3); margin-left: 6px; }
.composer-input { display: flex; gap: 10px; padding: 8px 14px 14px; }
#msg-input { flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 9px 12px;
  font-size: 14px; font-family: inherit; resize: none; outline: none; line-height: 1.5; }
#msg-input:focus { border-color: var(--brand); }
#send-btn { align-self: flex-end; width: 84px; height: 60px; background: var(--brand); color: #fff;
  border-radius: 6px; font-size: 15px; letter-spacing: 3px; transition: background .15s; }
#send-btn:hover { background: var(--brand-dark); }

/* ========== 弹层 ========== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex;
  align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: min(380px, calc(100vw - 24px)); }
.modal-wide { width: min(620px, calc(100vw - 24px)); max-height: 84vh; overflow-y: auto; }
.qr-tip { font-size: 12px; color: var(--text-2); background: var(--brand-soft); padding: 8px 12px;
  border-radius: 6px; line-height: 1.6; }

/* 管理员折叠管理区 */
.admin-manage-box { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 10px; }
.admin-manage-box summary { cursor: pointer; font-size: 13px; color: var(--brand-dark);
  font-weight: 600; padding: 6px 2px; user-select: none; }
.admin-manage-box[open] summary { margin-bottom: 6px; }

/* 自动回复弹窗 */
.switch-row { display: flex !important; align-items: center; gap: 8px; margin: 14px 0 4px !important;
  font-size: 14px; color: var(--text) !important; cursor: pointer; }
.switch-row input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.modal textarea { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px;
  font-size: 14px; outline: none; resize: vertical; font-family: inherit; line-height: 1.6; }
.modal textarea:focus { border-color: var(--brand); }
.modal select { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 10px; font-size: 14px; outline: none; background: #fff; }
.ar-foot-tip { font-size: 12px; color: var(--danger); margin-top: 6px; min-height: 14px; }
.qr-create { display: flex; gap: 8px; margin: 16px 0; }
.qr-create input { flex: 1; height: 36px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px;
  font-size: 13px; outline: none; }
.qr-create input:focus, .qr-create select:focus { border-color: var(--brand); }
.qr-create select { height: 36px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; font-size: 13px;
  background: #fff; outline: none; }
.qr-list { display: flex; flex-direction: column; gap: 10px; }
.qr-card { display: flex; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 8px;
  align-items: center; }
.qr-card img.qr-img { width: 96px; height: 96px; border: 1px solid var(--border); border-radius: 6px;
  object-fit: cover; cursor: zoom-in; flex-shrink: 0; }
.qr-card .qr-noimg { width: 96px; height: 96px; border: 1px dashed #d0d0d0; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11px;
  color: var(--text-3); padding: 6px; line-height: 1.5; }
.qr-card .qr-info { flex: 1; min-width: 0; }
.qr-card .qr-name { font-weight: 600; font-size: 14px; }
.qr-card .qr-meta { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.7; word-break: break-all; }
.qr-card .qr-scene { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: 1px 6px;
  border-radius: 4px; }
.qr-card .qr-ops { display: flex; flex-direction: column; gap: 6px; }
.qr-empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 30px 0; }
.svc-section { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.svc-section:first-of-type { margin-top: 14px; }
.svc-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.svc-section-head strong { font-size: 14px; }
.svc-section-head span { font-size: 12px; color: var(--text-3); }
.svc-create { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.svc-create input { flex: 1 1 150px; height: 36px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 10px; font-size: 13px; outline: none; background: #fff; }
.svc-create input:focus { border-color: var(--brand); }
.svc-list { display: flex; flex-direction: column; gap: 10px; }
.svc-card .qr-ops { min-width: 96px; }
.svc-card { flex-wrap: wrap; }
.svc-card-mp .svc-mp { flex: 1 1 100%; margin-top: 10px; padding-top: 0; border-top: 0; }
.svc-mp { flex: 1 1 100%; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.svc-mp-head strong { font-size: 13px; color: var(--brand); }
.svc-mp-body { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.svc-mp-body .mp-img { width: 112px; height: 112px; }
.svc-mp-body > .qr-noimg { width: 112px; height: 112px; flex-shrink: 0; }
.svc-mp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.svc-mp-info .qr-ops { flex-direction: row; flex-wrap: wrap; min-width: 0; }
.svc-mp-empty .qr-meta { line-height: 1.6; }
.mp-gen-row { align-items: center; gap: 8px; }
.mp-app-select { padding: 6px 8px; border: 1px solid #cdd8d5; border-radius: 6px; background: #fff; font-size: 13px; color: #14343a; max-width: 150px; }
.svc-badge { display: inline-block; font-size: 11px; font-weight: 500; color: var(--brand);
  border: 1px solid var(--brand); border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }
.svc-link { word-break: break-all; color: var(--text-2); }
.svc-link-line { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 6px; }
.modal input[type=text] { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 12px; font-size: 14px; outline: none; }
.modal input[type=text]:focus { border-color: var(--brand); }
.profile-avatar-edit { display: flex; align-items: center; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal-foot .mini-btn { padding: 7px 18px; }

/* 图片预览 */
.image-viewer { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 200;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.image-viewer img { max-width: 90%; max-height: 90%; border-radius: 8px; }

/* 提示 toast */
.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.78);
  color: #fff; padding: 9px 20px; border-radius: 8px; font-size: 14px; z-index: 300;
  animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }

/* 发送中的图片提示 */
.uploading-tip { color: var(--text-2); font-size: 12px; }

/* 滚动条 */
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-thumb { background: #cfcfcf; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b5b5b5; }

/* ========== 手机端返回按钮（桌面隐藏） ========== */
.mobile-back-btn { display: none; width: 34px; height: 34px; border-radius: 8px;
  color: var(--text); align-items: center; justify-content: center; flex-shrink: 0; }
.mobile-back-btn:active { background: var(--bg); }

/* 手机端会话列表遮罩（桌面隐藏） */
.sidebar-mask { display: none; }

/* ========== 手机端适配（≤768px） ========== */
@media (max-width: 768px) {
  body { font-size: 15px; }

  /* 登录页 */
  .login-card { width: calc(100vw - 40px); max-width: 360px; padding: 30px 24px; }

  /* 主界面：单栏，侧栏改为抽屉 */
  .app-view { position: relative; }
  .chat-area { width: 100%; flex: none; }
  .mobile-back-btn { display: inline-flex; margin-left: -6px; }

  .sidebar-mask {
    display: block; position: fixed; inset: 0; z-index: 110;
    background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 82vw; max-width: 320px;
    min-width: 0; z-index: 120; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 2px 0 14px rgba(0,0,0,.18);
  }
  .app-view.sidebar-open .sidebar { transform: translateX(0); }
  .app-view.sidebar-open .sidebar-mask { opacity: 1; pointer-events: auto; }

  /* 顶栏：紧凑，收起次要操作 */
  .chat-header { height: 54px; padding: 0 10px; gap: 6px; }
  .chat-target { gap: 8px; min-width: 0; flex: 1; }
  .target-avatar { width: 34px; height: 34px; font-size: 13px; }
  .target-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-tools { gap: 5px; flex-shrink: 0; }
  .chat-tools .tool-btn { padding: 6px 8px; font-size: 12px; }
  #clear-msgs-btn { display: none; }

  /* 消息区 */
  .messages { padding: 14px 12px; }
  .empty-tip { margin-top: 60px; padding: 0 20px; line-height: 1.8; }
  .msg-body { max-width: 78%; }
  .bubble { font-size: 15px; }
  .bubble img.msg-img { max-width: 58vw; max-height: 200px; }

  /* 快捷回复 */
  .quick-panel { max-height: 168px; }
  .paste-hint { display: none; }

  /* 输入区 */
  .composer-bar { padding: 6px 10px 0; }
  .composer-input { gap: 8px; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  #msg-input { font-size: 16px; } /* ≥16px 防止 iOS 聚焦自动放大 */
  #send-btn { width: 66px; min-width: 66px; height: 52px; font-size: 15px; letter-spacing: 1px; }

  /* 弹层：近乎全屏（层级需高于侧栏抽屉） */
  .modal-mask { z-index: 130; }
  .modal, .modal-wide { width: calc(100vw - 20px); max-height: 88vh; padding: 18px; border-radius: 10px; }
  .qr-create { flex-wrap: wrap; }
  .qr-create input, .qr-create select { flex: 1 1 100%; }
  .qr-card { flex-wrap: wrap; }
  .qr-card .qr-ops { flex-direction: row; width: 100%; }
  .svc-section-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .modal-foot { flex-wrap: wrap; }
}

/* visitor info bar */
.visitor-info-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border); padding: 7px 18px;
  font-size: 12px; color: var(--text-2); flex-shrink: 0; }
.visitor-info-bar b { color: var(--text); font-weight: 600; }
.vi-item { display: inline-flex; align-items: center; }
.vi-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c0c4cc; margin-right: 5px; }
.vi-dot.online { background: var(--brand); }
.vi-dot.offline { background: #c0c4cc; }
@media (max-width: 900px) { .visitor-info-bar { padding: 6px 10px; gap: 4px 10px; font-size: 11px; } }
