/* 聊天模块的样式（负责人 2026-11-24：聊天系统解耦，可单独移植到其它应用）。
 * 会话列表、聊天窗口、消息气泡、输入栏、录音、表情、图片、通话界面、底部菜单。
 * index.html 里要放在 css/style.css 前面：style.css 里台球业务的覆盖（助教卡片、礼物气泡、亲密度等）照旧压在它上面。
 * 颜色用到宿主的 --line / --muted / --text / --accent / --accent-ink 变量，别的应用接入时提供这几个变量即可。 */
/* ---- 助教聊天 ---- */
#chatPanel { position: fixed; inset: 0; z-index: var(--z-chat, 100000); background: #14171c; display: flex; flex-direction: column; }
#chatPanel[hidden] { display: none; }
#chatPanel > header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
#chatPanel > header .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#chatPanel > header .x { width: 36px; height: 36px; font-size: 20px; padding: 0; }
.chatState { font-size: 12px; color: var(--muted); } .chatState.on { color: #3ddc84; } .chatState.connecting { color: #ffd23f; }
#chatList { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
#chatList h3 { font-size: 13px; color: var(--muted); margin: 14px 2px 6px; font-weight: 500; }
.chatRow { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 12px; margin-bottom: 6px; border-radius: 10px; }
.chatRow .dot { width: 9px; height: 9px; border-radius: 50%; background: #5b6470; flex: none; } .chatRow .dot.on { background: #3ddc84; }
.chatRow .who { flex: 1; min-width: 0; display: flex; flex-direction: column; } .chatRow .who small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatRow .unread { background: #e0452f; color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 6px; font-weight: 500; }
#chatRoom { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#chatRoom[hidden] { display: none; }
#chatMsgs { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
/* 消息照微信：头像 40px 圆角方形，气泡带小尖角，自己的在右边（绿色），对方的在左边 */
.msgTime { align-self: center; font-size: 12px; color: var(--muted); margin: 2px 0 -4px; }
.sysRoom .chatInput, .sysRoom #chatMore, .sysRoom #chatEmojis { display: none !important; }   /* 系统消息只读（负责人 2026-11-19） */
.sysMsg { align-self: center; max-width: 86%; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.07); font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.sysTip { align-self: center; max-width: 80%; padding: 4px 10px; border-radius: 4px; background: rgba(255,255,255,.06); color: var(--muted); font-size: 12px; line-height: 18px; text-align: center; overflow-wrap: anywhere; }
.sysMsg a { color: #6cb4ff; text-decoration: underline; }
.sysMsg small { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.msg { display: flex; align-items: flex-start; gap: 9px; max-width: 86%; } .msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .ava { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex: none; background: #2a303a; }
.msg .col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; } .msg.mine .col { align-items: flex-end; }
.msg .bubble { position: relative; min-height: 40px; padding: 9px 12px; border-radius: 6px; background: #2c2f34; color: #e9edf1; font-size: 15.5px; line-height: 22px; word-break: break-word; white-space: pre-wrap; }
.msg .bubble::before { content: ''; position: absolute; top: 14px; left: -5px; border: 6px solid transparent; border-left: 0; border-right-color: #2c2f34; }
.msg.mine .bubble { background: #95ec69; color: #111; }
.msg.mine .bubble::before { left: auto; right: -5px; border-left: 6px solid #95ec69; border-right: 0; }
.msg small { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg .bubble.vb { padding: 0; }
.msg .voice { display: flex; align-items: center; gap: 6px; min-height: 40px; background: transparent; border: 0; color: inherit; padding: 0 12px; font-size: 15px; }
.msg.mine .voice { flex-direction: row-reverse; }
@keyframes vw-play { 0% { opacity: .35; } 50% { opacity: .7; } 100% { opacity: 1; } }
#chatHint { margin: 0 12px; min-height: 0; } #chatHint:empty { display: none; }
/* 输入栏照微信：语音/键盘 · 输入框（或"按住 说话"）· 表情/键盘 · 发送 */
.chatInput { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #1b1e23; border-top: 1px solid var(--line); }
#chatPanel.kbOpen .chatInput, #chatRoom:has(#chatEmojis:not([hidden])) .chatInput { padding-bottom: 8px; }
.chatInput .cIco { width: 34px; height: 40px; padding: 0; flex: none; background: transparent; border: 0; color: var(--text); display: flex; align-items: center; justify-content: center; }
.cIco svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.cIco .i-kb, .cIco.kb .i-voice, .cIco.kb .i-emo { display: none; } .cIco.kb .i-kb { display: block; }
#chatText { flex: 1; min-width: 0; height: 40px; max-height: 104px; resize: none; padding: 9px 10px; border-radius: 6px; border: 0; background: #2c2f34; color: var(--text); font: inherit; font-size: 16px; line-height: 22px; outline: none; }
#chatText[hidden] { display: none; }
#chatHold { flex: 1; height: 40px; border-radius: 6px; border: 0; background: #2c2f34; font-weight: 600; font-size: 15px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
#chatHold.rec { background: #3a3f47; }
#chatHold[hidden], #chatSend[hidden] { display: none; }
#chatSend { height: 36px; margin-bottom: 2px; padding: 0 14px; flex: none; background: #07c160; border-color: #07c160; color: #fff; }
/* 录音浮层 */
#chatRecTip { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 3; width: 168px; padding: 18px 10px 14px; border-radius: 12px; background: rgba(0, 0, 0, .78); color: #fff; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#chatRecTip[hidden] { display: none; }
#chatRecTip .wave { display: flex; align-items: center; gap: 4px; height: 36px; } #chatRecTip .wave i { width: 5px; height: 100%; border-radius: 3px; background: #95ec69; animation: rec-wave .9s ease-in-out infinite; }
#chatRecTip .wave i:nth-child(2) { animation-delay: .15s; } #chatRecTip .wave i:nth-child(3) { animation-delay: .3s; } #chatRecTip .wave i:nth-child(4) { animation-delay: .45s; } #chatRecTip .wave i:nth-child(5) { animation-delay: .6s; }
#chatRecTip.cancel { background: rgba(160, 30, 30, .88); } #chatRecTip.cancel .wave i { background: #fff; animation: none; height: 30%; }
#chatRecTip span { font-size: 13px; padding: 2px 6px; border-radius: 4px; } #chatRecTip.cancel span { background: #e0452f; }
@keyframes rec-wave { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }

/* 表情面板占输入法的位置 */
#chatEmojis { height: 260px; display: flex; flex-direction: column; background: #1b1e23; padding-bottom: env(safe-area-inset-bottom); }
#chatEmojis[hidden] { display: none; }
#chatEmojis .grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); align-content: start; gap: 4px; padding: 10px 10px 4px; }
#chatEmojis .grid button { background: transparent; border: 0; font-size: 26px; padding: 4px 0; }
#chatEmojis .act { display: flex; justify-content: flex-end; gap: 8px; padding: 6px 12px 10px; }
#chatEmojis .act button { min-width: 56px; height: 36px; } #chatSend2 { background: #07c160; border-color: #07c160; color: #fff; }

/* ---- 表情动画 ---- */
.emo { display: inline-block; animation: emo-bounce 1.6s ease-in-out infinite; transform-origin: 50% 80%; }
.emo.shake { animation: emo-shake .9s ease-in-out infinite; } .emo.beat { animation: emo-beat 1.1s ease-in-out infinite; transform-origin: 50% 50%; }
.emo.spin { animation: emo-spin 2.4s linear infinite; transform-origin: 50% 50%; } .emo.pop { animation: emo-pop 1.4s ease-in-out infinite; } .emo.clap { animation: emo-clap .7s ease-in-out infinite; }
.msg .bubble:has(.emoBig) { background: transparent !important; padding: 2px 4px; } .msg .bubble:has(.emoBig)::before { display: none; }
.emoBig { font-size: 46px; line-height: 1.15; letter-spacing: 4px; }
#chatEmojis .emo { animation-play-state: paused; } #chatEmojis button:hover .emo, #chatEmojis button:active .emo { animation-play-state: running; }
.chatRow .ava { position: relative; width: 38px; height: 38px; flex: none; } .chatRow .ava img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; display: block; background: #2a303a; }
.chatRow .ava .dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border: 2px solid #1c2128; }
/* ---- 聊天"+"面板（照微信：语音通话、视频通话） ---- */
#chatPlus[hidden] { display: none; }
#chatMore { height: 200px; display: flex; gap: 22px; align-items: flex-start; padding: 20px 22px calc(12px + env(safe-area-inset-bottom)); background: #1b1e23; }
#chatMore[hidden] { display: none; }
#chatMore button { display: flex; flex-direction: column; align-items: center; gap: 6px; background: transparent; border: 0; padding: 0; font-size: 12px; color: var(--muted); }
#chatMore button[hidden] { display: none; }
#chatMore button i { width: 60px; height: 60px; border-radius: 14px; background: #2c2f34; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 28px; }

/* ---- 通话界面（照微信：全屏，语音时头像居中，视频时对方画面铺满、自己小窗在右上角） ---- */
#callPanel { position: fixed; inset: 0; z-index: calc(var(--z-chat, 100000) + 2); background: #1f2329; color: #fff; display: flex; flex-direction: column; align-items: center; }
#callPanel[hidden] { display: none; }
/* 安卓原生视频通话：画面画在网页下面，网页在通话时整体透明，只留通话面板的按钮和文字 */
html.ncall, html.ncall body { background: transparent !important; }
html.ncall body > :not(#callPanel) { visibility: hidden !important; }
html.ncall #callPanel, html.ncall #callPanel video { background: transparent; }
html.ncall #callPanel video { opacity: 0 !important; } /* 只用来定位置、接点击（点小窗换位） */
#callPanel video { background: #000; object-fit: cover; }
#callPanel .remote { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
#callPanel .local { position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 12px; width: 96px; height: 144px; border-radius: 8px; z-index: 2; }
#callPanel.voice .local, #callPanel .local[hidden] { display: none; }
#callPanel.video.on .remote { display: block; }
#callPanel.video.on.swap .remote { inset: auto; top: calc(16px + env(safe-area-inset-top)); right: 12px; width: 96px; height: 144px; border-radius: 8px; z-index: 3; }
#callPanel.video.on.swap .local { top: 0; right: 0; width: 100%; height: 100%; border-radius: 0; z-index: 1; }
#callPanel.video:not(.on) .local { top: 0; right: 0; width: 100%; height: 100%; border-radius: 0; opacity: .55; z-index: 0; } /* 等对方接听时：自己的画面铺底 */
#callPanel .who { position: relative; z-index: 2; margin-top: 18vh; display: flex; flex-direction: column; align-items: center; gap: 10px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
#callPanel .who img { width: 96px; height: 96px; border-radius: 10px; object-fit: cover; }
#callPanel .who b { font-size: 22px; font-weight: 600; } #callPanel .who .st { font-size: 14px; opacity: .85; }
#callPanel.video.on .who { margin-top: calc(18px + env(safe-area-inset-top)); align-self: flex-start; margin-left: 16px; flex-direction: row; } #callPanel.video.on .who img { width: 40px; height: 40px; border-radius: 6px; }
#callPanel.ending .btns { opacity: .4; pointer-events: none; }
#callPanel .btns { position: absolute; z-index: 4; left: 0; right: 0; bottom: calc(40px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; justify-content: space-evenly; row-gap: 18px; padding: 0 12px; }
#callPanel .btns button { display: flex; flex-direction: column; align-items: center; gap: 8px; background: transparent; border: 0; padding: 0; color: #fff; font-size: 12px; min-width: 72px; }
#callPanel .btns button[hidden] { display: none; }
#callPanel .btns i { width: 64px; height: 64px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: #111; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 26px; }
#callPanel .btns .off i { background: rgba(255, 255, 255, .22); color: #fff; }
#callPanel .btns .red i { background: #fa5151; color: #fff; } #callPanel .btns .red svg { transform: rotate(135deg); fill: #fff; stroke: none; } #callPanel .btns .green svg { fill: #fff; stroke: none; } #callPanel .btns .green i { background: #07c160; color: #fff; }

#callPanel .btns i svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

#chatTitleAva { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; background: #2a303a; } #chatTitleAva[hidden] { display: none; } #chatTitleAva.link, .msg [data-prof] { cursor: pointer; }

/* 语音气泡的声波图标（照微信：对方的朝右在左边，自己的朝左在右边）；未听过的语音气泡外有小红点 */
.msg .voice .vw { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; -webkit-mask: none; mask: none; background: none; }
.msg.mine .voice .vw { transform: scaleX(-1); }
.voice.play .vw path:nth-child(2) { animation: vw-a 1s steps(1) infinite; } .voice.play .vw path:nth-child(3) { animation: vw-b 1s steps(1) infinite; }
@keyframes vw-a { 0% { opacity: 0; } 33% { opacity: 1; } } @keyframes vw-b { 0%, 33% { opacity: 0; } 66% { opacity: 1; } }
.msg .col { position: relative; } .msg .unplayed { position: absolute; top: 4px; right: -14px; width: 8px; height: 8px; border-radius: 50%; background: #fa5151; }
.msg.mine .unplayed { display: none; }
.msg .ava[data-prof] { cursor: pointer; }

/* 底部操作菜单（长按消息 / 会话） */
.sheet { position: absolute; inset: 0; z-index: 5; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; }
.sheetBox { width: 100%; background: #1f2329; border-radius: 12px 12px 0 0; padding-bottom: env(safe-area-inset-bottom); overflow: hidden; }
.sheetBox p { margin: 0; padding: 14px 18px; font-size: 13px; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }
.sheetBox button { display: block; width: 100%; padding: 15px; border: 0; border-radius: 0; background: transparent; font-size: 16px; border-bottom: 1px solid var(--line); }
.sheetBox button.danger { color: #fa5151; } .sheetBox button.cancel { border-top: 8px solid #14171c; border-bottom: 0; }
.msg .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; } .chatRow { -webkit-touch-callout: none; }

#chatPanel > header { position: relative; z-index: 3; background: #14171c; } /* 输入法弹出、消息区上移时盖住移上来的内容 */
#chatRoom { transition: transform .18s ease-out; }
.msg .bubble.callRec { cursor: pointer; }
#chatMore button i svg { width: 30px; height: 30px; fill: none; stroke: #c9ced6; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; } /* 照微信：圆角方块里的线条图标 */

.msg .col .who { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
#chatMore { flex-wrap: wrap; row-gap: 14px; }
.msg .bubble.pb { padding: 0; background: transparent !important; min-height: 0; } .msg .bubble.pb::before { display: none; }
.msg .pic { position: relative; display: block; border-radius: 6px; overflow: hidden; background: #2c2f34; }
.msg .pic img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; -webkit-touch-callout: none; }
.msg .pic b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); color: #fff; font-size: 14px; font-weight: 500; }
.msg .retry { position: absolute; top: 10px; left: -30px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: #fa5151; color: #fff; font-size: 14px; font-weight: 700; line-height: 22px; }
.msg:not(.mine) .retry { display: none; }
.sheet.top { position: fixed; z-index: 100001; }
.imgSend .act { display: flex; align-items: center; gap: 10px; padding: 8px 14px 14px; }
.imgSend .act label { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.imgSend .act button { width: auto; display: inline-block; padding: 8px 16px; border: 0; border-radius: 6px; font-size: 15px; }
.imgSend .act .cancel2 { background: #2c2f34; }
.imgSend .act .go { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
#chatMore { height: auto; min-height: 200px; }
.msg:not(.mine) .pic.pre img { filter: blur(3px); transform: scale(1.06); } /* 对方的图还没传完：小缩略图放大后模糊着显示，盖「发送中 / 百分比」 */
/* 位置消息（负责人 2026-11-27：照微信，白色卡片：名称、地址，下面一块地图示意，点开地图导航） */
.msg .bubble.lb { padding: 0; background: transparent !important; } .msg .bubble.lb::before { display: none; }
.msg .locMsg { display: grid; grid-template-columns: 1fr; width: 220px; border-radius: 6px; overflow: hidden; background: #fff; color: #111; cursor: pointer; white-space: normal; }
.msg .locMsg b { padding: 8px 12px 0; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .locMsg small { padding: 0 12px 8px; color: #888; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .locMsg .locPin { height: 84px; display: flex; align-items: center; justify-content: center; font-size: 30px; font-style: normal;
  background: repeating-linear-gradient(0deg, transparent 0 22px, #dfe6ec 22px 24px), repeating-linear-gradient(90deg, transparent 0 30px, #dfe6ec 30px 32px), #eef2f5; }
