/* =====================================================================
   在线客服系统 · 前台聊天样式（Apple 风格）
   ---------------------------------------------------------------------
   设计语言：iOS / macOS 原生质感
     · 字体：SF Pro / PingFang SC 系统字体栈，字重克制
     · 色彩：系统蓝 #0071e3 / #0a84ff，中性灰层次，纯白与 #f5f5f7
     · 结构：1px hairline 分割线、18~22px 大圆角、通透的毛玻璃
     · 交互：轻量位移 + 弹性缓动，尊重 prefers-reduced-motion
     · 适配：PC 三栏 / 移动端全屏 / iframe 嵌套（.embed）/ 暗色模式
   ===================================================================== */

/* ---------------- 设计令牌 ---------------- */
:root{
  --blue:#0071e3;
  --blue-hi:#0a84ff;
  --blue-soft:rgba(0,113,227,.10);
  --blue-ring:rgba(0,113,227,.22);

  --text:#1d1d1f;
  --text-2:#6e6e73;
  --text-3:#86868b;

  --sep:rgba(60,60,67,.13);
  --sep-strong:rgba(60,60,67,.22);

  --bg:#ffffff;
  --bg-canvas:#f5f5f7;
  --surface:#ffffff;
  --surface-2:#f5f5f7;
  --surface-3:#ececef;
  --fill:rgba(120,120,128,.14);

  --bubble-in:#f2f2f7;
  --bubble-in-text:#1d1d1f;
  --bubble-out:linear-gradient(180deg,#2f92ff 0%,#007aff 100%);
  --bubble-out-text:#ffffff;

  --ok:#34c759;
  --warn:#ff9f0a;
  --danger:#ff3b30;

  --radius-xl:22px;
  --radius-lg:18px;
  --radius:14px;
  --radius-sm:10px;

  --shadow-1:0 1px 2px rgba(0,0,0,.05),0 1px 1px rgba(0,0,0,.03);
  --shadow-2:0 8px 30px rgba(0,0,0,.08),0 2px 8px rgba(0,0,0,.04);
  --shadow-3:0 24px 70px rgba(0,0,0,.18),0 6px 20px rgba(0,0,0,.08);

  --ease:cubic-bezier(.32,.72,0,1);
  --font:-apple-system,BlinkMacSystemFont,"SF Pro Text","SF Pro Display","PingFang SC",
         "Hiragino Sans GB","Helvetica Neue","Microsoft YaHei",system-ui,"Segoe UI",Roboto,sans-serif;
  --font-emoji:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji","Android Emoji",sans-serif;
}

/* 暗色模式：跟随系统，无需手动开关 */
@media (prefers-color-scheme: dark){
  :root{
    --blue:#0a84ff;
    --blue-hi:#409cff;
    --blue-soft:rgba(10,132,255,.16);
    --blue-ring:rgba(10,132,255,.35);

    --text:#f5f5f7;
    --text-2:#a1a1a6;
    --text-3:#8e8e93;

    --sep:rgba(255,255,255,.12);
    --sep-strong:rgba(255,255,255,.20);

    --bg:#000000;
    --bg-canvas:#0b0b0d;
    --surface:#1c1c1e;
    --surface-2:#141416;
    --surface-3:#2c2c2e;
    --fill:rgba(120,120,128,.28);

    --bubble-in:#26262a;
    --bubble-in-text:#f5f5f7;

    --shadow-1:0 1px 2px rgba(0,0,0,.5);
    --shadow-2:0 10px 34px rgba(0,0,0,.55);
    --shadow-3:0 26px 70px rgba(0,0,0,.7);
  }
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0;height:100%}
body{
  font-family:var(--font);
  color:var(--text);
  background:var(--bg-canvas);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  font-size:14px;
  overflow:hidden;
  text-rendering:optimizeLegibility;
}
button,input,textarea{font-family:inherit;font-size:inherit;outline:none;border:none;color:inherit}
button{cursor:pointer;background:none}
img{display:block;max-width:100%}
::selection{background:var(--blue-ring)}

::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-thumb{background:rgba(120,120,128,.32);border-radius:99px;border:2px solid transparent;background-clip:content-box}
::-webkit-scrollbar-thumb:hover{background:rgba(120,120,128,.5);background-clip:content-box}
::-webkit-scrollbar-track{background:transparent}

/* =====================================================================
   布局
   ===================================================================== */
.app{display:flex;height:100vh;height:100dvh;width:100%;background:var(--bg)}

/* ---------------- 侧栏（macOS 列表质感） ---------------- */
.side{
  width:312px;flex:0 0 312px;
  background:var(--surface-2);
  border-right:1px solid var(--sep);
  display:flex;flex-direction:column;
  position:relative;z-index:5;
}
.side-head{padding:22px 20px 16px;position:relative}
.sh-top{display:flex;align-items:center;gap:11px}
.logo{
  width:38px;height:38px;border-radius:11px;
  background:linear-gradient(180deg,#4aa3ff,#0071e3);
  color:#fff;display:flex;align-items:center;justify-content:center;
  font-size:18px;box-shadow:0 6px 16px rgba(0,113,227,.28);
}
.sh-title{font-size:16px;font-weight:600;letter-spacing:-.2px}
.sh-sub{font-size:11.5px;color:var(--text-3);margin-top:2px}

.dot{
  width:7px;height:7px;border-radius:50%;background:var(--ok);
  box-shadow:0 0 0 3px rgba(52,199,89,.18);flex:none;display:inline-block;
}
.dot.off{background:var(--warn);box-shadow:0 0 0 3px rgba(255,159,10,.18)}

.st-online{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--text-3);margin-top:4px}
.st-online .dot,.ch-desc .dot,.st-inline .dot{flex:none;display:inline-block;vertical-align:middle}
.ch-desc .st-inline{display:inline-flex;align-items:center;gap:6px}

/* 客服名片 */
.sh-card{
  margin-top:16px;padding:13px 14px;border-radius:var(--radius-lg);
  background:var(--surface);border:1px solid var(--sep);
  display:flex;align-items:center;gap:12px;box-shadow:var(--shadow-1);
}
.sh-card img{width:44px;height:44px;border-radius:50%;object-fit:cover}
.sh-card .n{font-size:14px;font-weight:600;letter-spacing:-.1px}
.sh-card .r{font-size:11.5px;color:var(--text-3);margin-top:2px}

.side-body{flex:1;overflow-y:auto;padding:6px 0 20px;-webkit-overflow-scrolling:touch}
.sec-title{
  font-size:11.5px;color:var(--text-3);font-weight:600;letter-spacing:.4px;
  padding:16px 22px 8px;text-transform:uppercase;
}
.quick-item{
  display:flex;align-items:flex-start;gap:12px;padding:13px 14px;margin:2px 10px;
  border-radius:var(--radius);cursor:pointer;transition:background .2s var(--ease),transform .2s var(--ease);
  border:1px solid transparent;
}
.quick-item:hover{background:var(--surface);border-color:var(--sep);box-shadow:var(--shadow-1)}
.quick-item:active{transform:scale(.985)}
.quick-item .ic{
  width:32px;height:32px;flex:0 0 32px;border-radius:9px;background:var(--blue-soft);
  display:flex;align-items:center;justify-content:center;font-size:15px;
}
.quick-item .q{font-size:13.5px;font-weight:500;line-height:1.45;color:var(--text)}
.quick-item .a{
  font-size:12px;color:var(--text-3);margin-top:3px;line-height:1.5;
  display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden;
}

.side-foot{
  padding:12px 14px calc(14px + env(safe-area-inset-bottom));
  border-top:1px solid var(--sep);display:flex;gap:8px;background:var(--surface-2);
}
.btn-ghost{
  flex:1;height:36px;border-radius:var(--radius-sm);background:var(--surface);
  border:1px solid var(--sep);color:var(--text-2);font-size:12.5px;font-weight:500;
  transition:all .18s var(--ease);
}
.btn-ghost:hover{color:var(--blue);border-color:var(--blue-ring);background:var(--blue-soft)}

/* ---------------- 聊天主区 ---------------- */
.main{
  flex:1;display:flex;flex-direction:column;background:var(--bg);
  position:relative;min-width:0;
}

/* 顶栏：iOS 导航条，毛玻璃 + hairline */
.chat-head{
  height:64px;flex:0 0 64px;
  background:var(--bg);                 /* 老浏览器兜底 */
  background:color-mix(in srgb,var(--bg) 82%,transparent);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
  backdrop-filter:saturate(180%) blur(20px);
  border-bottom:.5px solid var(--sep);
  display:flex;align-items:center;gap:12px;padding:0 18px;
  position:relative;z-index:10;
  padding-top:env(safe-area-inset-top);
  height:calc(64px + env(safe-area-inset-top));
  flex-basis:calc(64px + env(safe-area-inset-top));
}
.menu-btn{
  display:none;width:34px;height:34px;border-radius:50%;align-items:center;justify-content:center;
  color:var(--text-2);font-size:17px;transition:.18s var(--ease);
}
.menu-btn:hover{background:var(--fill);color:var(--text)}
.ch-avatar{position:relative;flex:none}
.ch-avatar img{width:40px;height:40px;border-radius:50%;object-fit:cover}
.ch-avatar .st{
  position:absolute;right:-1px;bottom:-1px;width:12px;height:12px;border-radius:50%;
  border:2.5px solid var(--bg);background:var(--ok);
}
.ch-avatar .st.off{background:var(--warn)}
.ch-info{flex:1;min-width:0}
.ch-name{font-size:15.5px;font-weight:600;letter-spacing:-.2px;display:flex;align-items:center;gap:7px}
.ch-name .tag{
  font-size:10.5px;font-weight:600;padding:2px 7px;border-radius:6px;
  background:var(--blue-soft);color:var(--blue);
}
.ch-desc{
  font-size:11.5px;color:var(--text-3);margin-top:3px;
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
}
.ch-desc .sep{width:1px;height:10px;background:var(--sep-strong)}
.ch-actions{display:flex;gap:6px;flex:none}
.icon-btn{
  width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  color:var(--text-2);font-size:16px;background:var(--fill);transition:.18s var(--ease);
}
.icon-btn:hover{background:var(--blue-soft);color:var(--blue)}
.icon-btn.judge{color:var(--blue);background:var(--blue-soft)}
.icon-btn.judge.done{color:var(--text-3);background:var(--fill);cursor:default}
.icon-btn.danger{color:var(--danger);background:rgba(255,59,48,.10)}
.icon-btn.end-txt{width:auto;border-radius:99px;padding:0 14px;font-size:13px;font-weight:600}
.icon-btn.danger:hover{background:var(--danger);color:#fff}

/* ---------------- 消息区 ---------------- */
.msg-wrap{
  flex:1;overflow-y:auto;padding:20px 20px 12px;
  scroll-behavior:smooth;overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}
.msg-wrap:empty{display:block}

.day-tag{text-align:center;margin:10px 0 18px}
.day-tag span{
  font-size:11.5px;font-weight:500;color:var(--text-3);
  padding:4px 12px;border-radius:99px;background:var(--fill);
}
.sys-msg{text-align:center;margin:14px 0}
.sys-msg span{
  font-size:12px;color:var(--text-3);line-height:1.55;display:inline-block;max-width:78%;
  padding:6px 14px;border-radius:99px;background:var(--fill);
}

.msg{display:flex;gap:10px;margin-bottom:14px;align-items:flex-end;animation:fadeUp .34s var(--ease) both}
@keyframes fadeUp{from{opacity:0;transform:translateY(10px) scale(.985)}to{opacity:1;transform:none}}
.msg .ava{
  width:32px;height:32px;flex:0 0 32px;border-radius:50%;object-fit:cover;
  background:var(--surface-3);
}
.msg .body{max-width:min(560px,74%);min-width:0;display:flex;flex-direction:column;align-items:flex-start}
.msg .meta{
  display:flex;align-items:center;gap:6px;margin:0 0 5px;
  font-size:11px;color:var(--text-3);font-weight:500;
}
.msg .meta .nm{font-weight:600;color:var(--text-2);font-size:11.5px}
.msg .meta .role-tag{
  font-size:9.5px;font-weight:600;padding:1.5px 6px;border-radius:5px;
  background:var(--fill);color:var(--text-3);
}

/* iMessage 气泡：对方灰，自己蓝（渐变），尾巴收角 */
.bubble{
  display:inline-block;width:fit-content;max-width:100%;
  padding:9px 14px;border-radius:19px;
  background:var(--bubble-in);color:var(--bubble-in-text);
  font-size:14.5px;line-height:1.55;letter-spacing:-.1px;
  word-break:break-word;white-space:pre-wrap;
  border-bottom-left-radius:6px;
  box-shadow:none;
  animation:bubbleIn .26s var(--ease) both;
}
@keyframes bubbleIn{from{transform:translateY(6px) scale(.985)}to{transform:none}}

.bubble.emoji{
  font-size:34px;line-height:1.3;background:transparent;box-shadow:none;
  padding:0;border-radius:0;font-family:var(--font-emoji);
}
.bubble img{border-radius:16px;max-width:240px;cursor:zoom-in;display:block}

/* ---- 富媒体 ---- */
.bubble-media{padding:4px !important;background:var(--surface-2) !important;line-height:0;overflow:hidden}
.bubble-media video{
  display:block;border-radius:16px;max-width:260px;max-height:300px;background:#000;
}
.bubble-audio{display:flex;align-items:center;gap:9px;min-width:190px;padding:9px 12px !important}
.bubble-audio .va-ic{
  width:30px;height:30px;border-radius:50%;background:var(--blue-soft);color:var(--blue);
  display:flex;align-items:center;justify-content:center;font-size:14px;flex:0 0 auto;
}
.bubble-audio audio{height:34px;width:100%;min-width:150px;outline:none}

/* 语音条：声波 + 时长 */
.voice-bar{
  display:flex;align-items:center;gap:10px;min-width:88px;max-width:210px;
  padding:10px 14px;border-radius:19px;border-bottom-left-radius:6px;
  background:var(--bubble-in);cursor:pointer;user-select:none;
  transition:transform .16s var(--ease),background .16s var(--ease);
}
.voice-bar:hover{background:var(--surface-3)}
.voice-bar:active{transform:scale(.97)}
.voice-bar .vb-wave{display:flex;align-items:center;gap:2.5px;flex:0 0 auto;height:16px}
.voice-bar .vb-wave i{width:2.5px;border-radius:2px;background:var(--blue);height:6px;transition:.2s}
.voice-bar .vb-wave i:nth-child(2){height:12px}
.voice-bar .vb-wave i:nth-child(3){height:8px}
.voice-bar.playing .vb-wave i{animation:vbWave .85s ease-in-out infinite}
.voice-bar.playing .vb-wave i:nth-child(2){animation-delay:.16s}
.voice-bar.playing .vb-wave i:nth-child(3){animation-delay:.32s}
@keyframes vbWave{0%,100%{transform:scaleY(.5)}50%{transform:scaleY(1.5)}}
.voice-bar .vb-time{font-size:13px;color:var(--text-2);font-weight:500;margin-left:auto;white-space:nowrap}

.msg.mine .voice-bar{
  background:var(--bubble-out);border:none;color:#fff;flex-direction:row-reverse;
  border-bottom-left-radius:19px;border-bottom-right-radius:6px;
}
.msg.mine .voice-bar .vb-wave i{background:#fff}
.msg.mine .voice-bar .vb-time{color:rgba(255,255,255,.9);margin-left:0;margin-right:auto}

/* 文件卡片 */
.bubble-file{
  display:flex;align-items:center;gap:11px;min-width:200px;max-width:260px;
  padding:11px 13px !important;text-decoration:none;cursor:pointer;
  transition:transform .18s var(--ease),background .18s var(--ease);
}
.bubble-file:hover{transform:translateY(-1px);background:var(--surface-3)}
.bubble-file .fi-ic{
  width:38px;height:38px;border-radius:10px;background:var(--blue-soft);color:var(--blue);
  font-size:10px;font-weight:800;letter-spacing:.3px;
  display:flex;align-items:center;justify-content:center;flex:0 0 auto;
}
.bubble-file .fi-tx{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.bubble-file .fi-nm{
  font-size:13px;font-weight:600;color:var(--text);white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;
}
.bubble-file .fi-ds{font-size:11px;color:var(--text-3)}
.bubble-file .fi-dl{
  width:26px;height:26px;border-radius:50%;background:var(--fill);color:var(--text-2);
  display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;flex:0 0 auto;
}
.msg.mine .bubble-file .fi-ic{background:rgba(255,255,255,.22);color:#fff}
.msg.mine .bubble-file .fi-nm{color:#fff}
.msg.mine .bubble-file .fi-ds{color:rgba(255,255,255,.8)}
.msg.mine .bubble-file .fi-dl{background:rgba(255,255,255,.22);color:#fff}

/* 自己发的 */
.msg.mine{flex-direction:row-reverse}
.msg.mine .body{align-items:flex-end}
.msg.mine .meta{flex-direction:row-reverse}
.msg.mine .bubble{
  background:var(--bubble-out);color:var(--bubble-out-text);
  border-bottom-left-radius:19px;border-bottom-right-radius:6px;
  box-shadow:0 2px 10px rgba(0,122,255,.22);
}
.msg.mine .role-tag{background:rgba(255,255,255,.18);color:rgba(255,255,255,.9)}

/* 连续消息压缩 */
.msg-consecutive{margin-top:-6px}
.msg-consecutive .ava{visibility:hidden;height:0}
.msg-consecutive .meta{display:none}

/* 输入中 */
.typing{display:flex;gap:9px;align-items:center;color:var(--text-3);font-size:12.5px;margin-bottom:14px;padding-left:2px}
.typing .d{display:flex;gap:4px}
.typing .d i{width:6px;height:6px;border-radius:50%;background:var(--text-3);animation:bounce 1.2s infinite}
.typing .d i:nth-child(2){animation-delay:.18s}
.typing .d i:nth-child(3){animation-delay:.36s}
@keyframes bounce{0%,60%,100%{transform:translateY(0);opacity:.4}30%{transform:translateY(-5px);opacity:1}}

/* ---------------- 输入区 ---------------- */
.editor{
  flex:0 0 auto;
  background:var(--bg);                 /* 老浏览器兜底 */
  background:color-mix(in srgb,var(--bg) 86%,transparent);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
  backdrop-filter:saturate(180%) blur(20px);
  border-top:.5px solid var(--sep);
  padding:8px 18px calc(12px + env(safe-area-inset-bottom));
  position:relative;   /* ★ 表情/工具面板的定位基准 */
}
.tool-bar{display:flex;align-items:center;gap:2px;margin-bottom:4px}
.tool{
  width:34px;height:34px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  color:var(--text-3);transition:.18s var(--ease);
}
.tool svg{display:block;pointer-events:none}
.tool:hover{background:var(--fill);color:var(--text)}
.tool.active{background:var(--blue-soft);color:var(--blue)}
.tool.recording{background:rgba(255,59,48,.12);color:var(--danger);animation:recPulse 1.1s infinite}
.spacer{flex:1}
.hint-key{font-size:11px;color:var(--text-3);letter-spacing:.2px}

/* 录音条 */
.rec-bar{
  display:none;align-items:center;gap:10px;margin:0 0 8px;padding:10px 14px;
  background:rgba(255,59,48,.08);border:1px solid rgba(255,59,48,.18);
  border-radius:var(--radius);font-size:13px;color:var(--danger);
}
.rec-bar.show{display:flex;animation:popIn .2s var(--ease)}
.rec-dot{width:9px;height:9px;border-radius:50%;background:var(--danger);flex:0 0 auto;animation:recPulse 1s infinite}
@keyframes recPulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.35;transform:scale(.82)}}
.rec-time{font-variant-numeric:tabular-nums;font-weight:700;letter-spacing:.4px}
.rec-tip{flex:1;min-width:0;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;opacity:.85}
.rec-bar button{height:28px;padding:0 14px;border-radius:99px;font-size:12.5px;font-weight:600;transition:.16s}
.rec-stop{background:var(--danger);color:#fff}
.rec-stop:hover{filter:brightness(1.06)}
.rec-cancel{background:var(--fill);color:var(--text-2)}
.rec-cancel:hover{background:var(--surface-3)}

/* 上传进度 */
.up-bar{display:none;position:relative;height:22px;margin:4px 2px 8px;border-radius:99px;background:var(--fill);overflow:hidden}
.up-bar.show{display:block;animation:popIn .16s var(--ease)}
.up-fill{height:100%;width:0;border-radius:99px;transition:width .25s var(--ease);background:var(--blue)}
.up-txt{
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  font-size:11.5px;font-weight:600;color:var(--text-2);letter-spacing:.2px;
}

.input-row{display:flex;gap:9px;align-items:flex-end}
textarea#ta{
  flex:1;min-height:40px;max-height:132px;resize:none;
  border:1px solid var(--sep);border-radius:20px;padding:10px 16px;line-height:1.5;
  background:var(--surface-2);transition:border-color .2s var(--ease),background .2s var(--ease),box-shadow .2s var(--ease);
  font-size:15px;color:var(--text);letter-spacing:-.1px;
}
textarea#ta:focus{border-color:var(--blue-ring);background:var(--surface);box-shadow:0 0 0 4px var(--blue-soft)}
textarea#ta::placeholder{color:var(--text-3)}

/* 发送键：iOS 圆形蓝色箭头 */
.btn-send{
  height:40px;min-width:40px;padding:0 16px;border-radius:99px;
  background:var(--bubble-out);color:#fff;
  font-size:15px;font-weight:600;letter-spacing:.2px;
  box-shadow:0 4px 14px rgba(0,122,255,.32);
  transition:transform .18s var(--ease),box-shadow .18s var(--ease),opacity .18s;
  display:flex;align-items:center;justify-content:center;gap:5px;flex:0 0 auto;
}
.btn-send:hover{transform:translateY(-1px);box-shadow:0 8px 22px rgba(0,122,255,.4)}
.btn-send:active{transform:scale(.95)}
.btn-send:disabled{opacity:.42;cursor:not-allowed;transform:none;box-shadow:none}

/* ---------------- 表情面板 ---------------- */
.emoji-panel{
  position:absolute;bottom:100%;left:18px;margin-bottom:8px;width:312px;
  background:var(--surface);border:.5px solid var(--sep);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-2);padding:12px;display:none;z-index:30;
  max-height:236px;overflow-y:auto;-webkit-overflow-scrolling:touch;
  -webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);
}
.emoji-panel.show{display:block;animation:popIn .2s var(--ease)}
@keyframes popIn{from{opacity:0;transform:translateY(8px) scale(.97)}to{opacity:1;transform:none}}
.emoji-grid{display:grid;grid-template-columns:repeat(8,1fr);gap:2px}
.emoji-grid button{
  font-size:21px;padding:5px 0;border-radius:9px;transition:.14s;line-height:1.2;
  font-family:var(--font-emoji);
}
.emoji-grid button:hover{background:var(--fill);transform:scale(1.14)}

/* ---------------- 弹窗（iOS Sheet / Alert） ---------------- */
.mask{
  position:fixed;inset:0;background:rgba(0,0,0,.38);
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
  display:none;align-items:center;justify-content:center;z-index:100;padding:20px;
}
.mask.show{display:flex;animation:fadeIn .22s ease}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}

.guide-modal{
  width:100%;max-width:520px;background:var(--surface);border-radius:var(--radius-xl);
  overflow:hidden;box-shadow:var(--shadow-3);
  animation:sheetUp .34s var(--ease) both;
  max-height:86vh;display:flex;flex-direction:column;
}
@keyframes sheetUp{from{opacity:0;transform:translateY(24px) scale(.97)}to{opacity:1;transform:none}}
.gm-head{padding:24px 24px 18px;position:relative;border-bottom:.5px solid var(--sep)}
.gm-close{
  position:absolute;right:14px;top:14px;width:30px;height:30px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;color:var(--text-3);
  font-size:15px;background:var(--fill);transition:.18s var(--ease);
}
.gm-close:hover{background:var(--surface-3);color:var(--text)}
.gm-hi{display:flex;align-items:center;gap:14px}
.gm-hi img{width:54px;height:54px;border-radius:50%;object-fit:cover;box-shadow:var(--shadow-1)}
.gm-hi .t1{font-size:18px;font-weight:600;letter-spacing:-.3px}
.gm-hi .t2{font-size:13px;color:var(--text-3);margin-top:4px;line-height:1.5}
.gm-body{padding:16px 20px 18px;overflow-y:auto}
.gm-label{font-size:11.5px;color:var(--text-3);font-weight:600;margin-bottom:10px;letter-spacing:.3px}
.gm-list{display:flex;flex-direction:column;gap:8px}
.gm-item{
  display:flex;align-items:center;gap:12px;padding:13px 15px;
  border:1px solid var(--sep);border-radius:var(--radius);cursor:pointer;
  background:var(--surface-2);transition:.18s var(--ease);
}
.gm-item:hover{background:var(--surface);border-color:var(--blue-ring);transform:translateX(2px)}
.gm-item:active{transform:scale(.99)}
.gm-item .ic{
  width:34px;height:34px;flex:0 0 34px;border-radius:10px;background:var(--surface);
  border:1px solid var(--sep);display:flex;align-items:center;justify-content:center;font-size:16px;
}
.gm-item .tx{flex:1;font-size:13.5px;font-weight:500;line-height:1.5}
.gm-item .ar{color:var(--text-3);font-size:15px;transition:.18s}
.gm-item:hover .ar{color:var(--blue);transform:translateX(2px)}

.gm-foot{padding:0 20px 20px;display:flex;gap:10px}
.btn-primary{
  flex:1;height:46px;border-radius:var(--radius);background:var(--blue);color:#fff;
  font-size:15px;font-weight:600;letter-spacing:.2px;
  box-shadow:0 6px 18px rgba(0,113,227,.26);transition:.18s var(--ease);
}
.btn-primary:hover{filter:brightness(1.06);transform:translateY(-1px)}
.btn-primary:active{transform:scale(.985)}
.btn-line{
  padding:0 20px;height:46px;border-radius:var(--radius);background:var(--fill);
  color:var(--text-2);font-size:15px;font-weight:500;transition:.18s var(--ease);
}
.btn-line:hover{background:var(--surface-3);color:var(--text)}

/* ---------------- 图片预览 ---------------- */
.lightbox{
  position:fixed;inset:0;background:rgba(0,0,0,.92);z-index:200;display:none;
  align-items:center;justify-content:center;padding:30px;
  -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);
}
.lightbox.show{display:flex;animation:fadeIn .2s}
.lightbox img{max-width:92vw;max-height:88vh;border-radius:var(--radius);box-shadow:0 30px 80px rgba(0,0,0,.6)}

/* ---------------- Toast（iOS 浮层） ---------------- */
.toast-box{
  position:fixed;top:calc(16px + env(safe-area-inset-top));left:50%;transform:translateX(-50%);
  z-index:300;display:flex;flex-direction:column;gap:8px;align-items:center;pointer-events:none;
}
.toast{
  padding:10px 18px;border-radius:99px;font-size:13.5px;font-weight:500;
  background:rgba(28,28,30,.86);color:#fff;
  -webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px);
  box-shadow:0 10px 30px rgba(0,0,0,.24);animation:toastIn .26s var(--ease) both;
  max-width:82vw;text-align:center;
}
.toast.ok{background:rgba(52,199,89,.94)}
.toast.err{background:rgba(255,59,48,.94)}
@keyframes toastIn{from{opacity:0;transform:translateY(-12px) scale(.96)}to{opacity:1;transform:none}}

/* ---------------- 遮罩 ---------------- */
.side-mask{position:fixed;inset:0;background:rgba(0,0,0,.3);z-index:4;display:none;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}
.side-mask.show{display:block;animation:fadeIn .2s}

/* ---------------- 登录 / 评价（iOS Alert） ---------------- */
.login-modal{
  width:100%;max-width:400px;background:var(--surface);border-radius:var(--radius-xl);
  padding:28px 26px 24px;box-shadow:var(--shadow-3);
  animation:sheetUp .3s var(--ease) both;
}
.login-modal h3{margin:0 0 6px;font-size:19px;font-weight:600;letter-spacing:-.3px;text-align:center}
.login-modal p.s{margin:0 0 20px;font-size:12.5px;color:var(--text-3);line-height:1.6;text-align:center}
.field{margin-bottom:13px}
.field label{display:block;font-size:12px;color:var(--text-2);font-weight:500;margin-bottom:6px;letter-spacing:.2px}
.field input{
  width:100%;height:44px;padding:0 14px;border:1px solid var(--sep);border-radius:var(--radius);
  background:var(--surface-2);transition:.2s var(--ease);font-size:15px;color:var(--text);
}
.field input:focus{border-color:var(--blue-ring);background:var(--surface);box-shadow:0 0 0 4px var(--blue-soft)}
.field label i{color:var(--danger);font-style:normal}

/* iOS 分段控件 */
.seg-tabs{display:flex;gap:2px;padding:2px;background:var(--fill);border-radius:11px;margin:0 0 18px}
.seg-tabs .seg{
  flex:1;height:34px;border-radius:9px;font-size:13.5px;font-weight:600;color:var(--text-2);
  transition:.2s var(--ease);
}
.seg-tabs .seg.active{background:var(--surface);color:var(--text);box-shadow:var(--shadow-1)}

.row-2{display:grid;grid-template-columns:1fr 1fr;gap:11px}

/* =====================================================================
   响应式
   ===================================================================== */
@media (max-width:900px){
  .side{width:288px;flex-basis:288px}
  .msg .body{max-width:80%}
}

@media (max-width:768px){
  .side{
    position:fixed;left:0;top:0;bottom:0;width:86%;max-width:340px;z-index:20;
    transform:translateX(-102%);transition:transform .34s var(--ease);
    box-shadow:var(--shadow-3);border-right:none;
  }
  .side.open{transform:none}
  .menu-btn{display:flex}
  .chat-head{padding:0 12px;gap:9px;height:60px;flex-basis:60px;
    height:calc(60px + env(safe-area-inset-top));flex-basis:calc(60px + env(safe-area-inset-top))}
  .ch-avatar img{width:36px;height:36px}
  .ch-name{font-size:15px}
  .ch-desc .hide-m{display:none}
  .msg-wrap{padding:14px 12px 8px}
  .msg .ava{width:30px;height:30px;flex-basis:30px}
  .msg .body{max-width:82%}
  .bubble{font-size:15px;padding:8px 13px;border-radius:18px}
  .msg.mine .bubble{border-bottom-right-radius:6px}
  .bubble img{max-width:190px}
  .editor{padding:6px 10px calc(10px + env(safe-area-inset-bottom))}
  .tool-bar{gap:0}
  .hint-key{display:none}
  .btn-send{height:38px;min-width:38px;padding:0 15px}
  .btn-send .txt{display:none}
  textarea#ta{min-height:38px;font-size:16px;padding:9px 14px}
  .emoji-panel{left:10px;right:10px;width:auto}
  .guide-modal{max-width:100%;border-radius:var(--radius-xl)}
  .gm-head{padding:20px 18px 16px}
  .gm-body{padding:16px 16px 18px}
  .gm-foot{padding:0 16px 18px}
  .row-2{grid-template-columns:1fr}
}
@media (max-width:380px){
  .emoji-grid{grid-template-columns:repeat(7,1fr)}
  .ch-desc{font-size:11px}
}
@media (max-height:520px) and (max-width:900px){
  .side-head{padding:12px 16px}
  .sh-card{display:none}
}

/* 尊重「减少动态效果」 */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.001ms !important;animation-iteration-count:1 !important;transition-duration:.001ms !important;scroll-behavior:auto !important}
}

/* =====================================================================
   ★ 嵌套模式（防红嵌套 / iframe 内嵌）
   规则：只保留聊天气泡与输入区，去掉侧栏与外层留白，
        iframe 里就是一个干净的 iOS 聊天窗口。
   ===================================================================== */
.kf-embed body.embed,
body.embed{background:var(--bg)}
body.embed .side,
body.embed .side-mask{display:none !important}
body.embed .main{border-radius:0}
body.embed .chat-head{cursor:default}
body.embed .menu-btn{display:none !important}
body.embed .msg-wrap{padding:12px 12px 6px}
body.embed .editor{padding:6px 12px calc(10px + env(safe-area-inset-bottom))}
body.embed .msg .body{max-width:84%}
body.embed .ch-desc .hide-m{display:none}
body.embed .mask{padding:12px}
body.embed .guide-modal{max-height:94vh}

/* 超窄容器（挂件宽 380px 左右） */
@media (max-width:420px){
  body.embed .chat-head{padding:0 10px}
  body.embed .ch-desc{display:none}
}
