/* ============================================================
   访客端 —— Carousell 聊天页面 1:1
   红头 / 圆环 C logo / 状态文案 / Emily 头像名字 / 上午下午分隔
   粉色访客 / 灰色客服 / 回形针输入 / 手机全屏
   ============================================================ */
:root{
  --red:#FF3B30; --red-d:#E63329;
  --pink:#FFD6D3; --gray:#F1F2F4;
  --ink:#111; --muted:#9aa0a6; --line:#ececec;
}
#cw-root,#cw-root *{box-sizing:border-box;}
#cw-root{
  position:fixed; inset:0; z-index:2147483000; pointer-events:none;
  font-family:-apple-system,BlinkMacSystemFont,"PingFang TC","PingFang SC","Hiragino Sans GB","Microsoft JhengHei","Microsoft YaHei","Segoe UI",Arial,sans-serif;
  -webkit-font-smoothing:antialiased; color:var(--ink); text-align:left;
}
#cw-root button,#cw-root input,#cw-root textarea{font-family:inherit;}

/* 启动按钮 */
.cw-launcher{
  position:fixed; right:22px; bottom:22px; width:60px; height:60px; border-radius:50%;
  border:none; background:var(--red); color:#fff; cursor:pointer; display:grid; place-items:center;
  box-shadow:0 8px 22px rgba(255,59,48,.45); transition:.15s; pointer-events:auto;
}
.cw-launcher:hover{background:var(--red-d); transform:translateY(-2px);}
.cw-launcher:active{transform:scale(.94);}
.cw-launcher svg{width:28px;height:28px;}
.cw-launcher.cw-open{display:none;}
.cw-badge{
  position:absolute; top:-4px; right:-4px; min-width:20px; height:20px; padding:0 5px;
  background:#fff; color:var(--red); border-radius:999px; font-size:12px; font-weight:700;
  display:none; align-items:center; justify-content:center; box-shadow:0 2px 6px rgba(0,0,0,.2);
}
.cw-badge.cw-show{display:flex;}

/* 窗口（全屏铺满） */
.cw-window{
  position:fixed; inset:0; width:100vw;
  height:100vh; height:100dvh; height:var(--app-h, 100dvh);
  max-height:100vh; max-height:100dvh; max-height:var(--app-h, 100dvh);
  background:#fff; overflow:hidden; display:flex; flex-direction:column;
  opacity:0; pointer-events:none; transition:opacity .2s;
}
.cw-window.cw-show{opacity:1; pointer-events:auto;}

/* 头部 */
.cw-head{
  flex:0 0 auto; display:flex; justify-content:center;
  padding:13px 16px; padding-top:calc(13px + env(safe-area-inset-top,0px));
  background:var(--red); color:#fff; position:relative;
}
.cw-head-inner{width:100%; max-width:860px; display:flex; align-items:center; gap:11px;}
.cw-logo{width:46px; height:46px; flex:0 0 auto;}
.cw-logo svg{width:100%; height:100%; display:block;}
.cw-logo img{width:100%; height:100%; border-radius:50%; object-fit:cover; display:block;}
.cw-title-wrap{flex:1; min-width:0;}
.cw-title{font-size:19px; font-weight:700; line-height:1.1; letter-spacing:.2px; color:#111;}
.cw-sub{font-size:15px; font-weight:400; margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:#111;}
.cw-menu-btn{
  width:36px; height:36px; border-radius:50%; border:none; background:transparent; color:#111;
  font-size:24px; line-height:1; cursor:pointer; display:grid; place-items:center; flex:0 0 auto;
}
.cw-menu-btn:hover{background:rgba(0,0,0,.08);}
.cw-menu{
  position:absolute; top:60px; right:10px; background:#fff; border-radius:18px;
  box-shadow:0 12px 34px rgba(0,0,0,.18); padding:6px; z-index:5; display:none;
}
.cw-menu.cw-show{display:block;}
.cw-menu .cw-sound-item{
  display:flex; align-items:center; gap:12px; width:100%;
  border:none; background:transparent; padding:12px 20px 12px 16px; border-radius:14px;
  font-size:16px; color:#111; cursor:pointer; white-space:nowrap;
}
.cw-menu .cw-sound-item:hover{background:#f5f5f7;}
.cw-menu .cw-sound-item.off{color:#8a8f96;}
.cw-sound-ic{display:grid; place-items:center; width:24px; height:24px; flex:0 0 auto;}
.cw-sound-ic svg{width:24px; height:24px;}

/* 聊天区 */
.cw-body{flex:1; overflow-y:auto; overflow-x:hidden; background:#fff; padding:6px 0 10px; width:100%; max-width:860px; margin:0 auto;}
.cw-body::-webkit-scrollbar{width:6px;}
.cw-body::-webkit-scrollbar-thumb{background:#e3e3e3; border-radius:3px;}
.cw-time{text-align:center; font-size:14px; color:#9aa0a6; margin:16px 0 10px;}

.cw-msg{display:flex; padding:5px 15px; gap:9px;}
.cw-msg.agent{align-items:flex-start;}
.cw-msg.visitor{justify-content:flex-end;}
.cw-avatar{width:44px; height:44px; border-radius:14px; flex:0 0 auto; overflow:hidden; background:#ffe7e4;}
.cw-avatar svg,.cw-avatar img{width:100%; height:100%; display:block; object-fit:cover;}
.cw-msg-body{max-width:74%; display:flex; flex-direction:column;}
.cw-name{font-size:14px; color:#555; font-weight:600; margin:0 0 6px 4px;}
.cw-bubble{
  padding:11px 15px; border-radius:20px; font-size:16px; line-height:1.45;
  word-break:break-word; white-space:pre-wrap;
}
.cw-msg.agent .cw-bubble{background:var(--gray); color:var(--ink); border-top-left-radius:6px;}
.cw-msg.visitor .cw-bubble{background:var(--pink); color:var(--ink); border-top-right-radius:6px;}
.cw-msg.visitor .cw-msg-body{align-items:flex-end;}
.cw-bubble.cw-img-bubble{padding:0; background:transparent !important;}
.cw-img{max-width:210px; border-radius:16px; display:block;}
.cw-system{text-align:center; margin:9px 18px; font-size:13px; color:#8b8f96; background:#f4f5f7; border-radius:12px; padding:8px 12px;}

.cw-typing{display:none; padding:5px 15px;}
.cw-typing.cw-show{display:flex;}
.cw-typing .cw-bubble{display:flex; gap:4px; align-items:center; padding:14px 16px;}
.cw-tdot{width:7px; height:7px; border-radius:50%; background:#b7b7b7; animation:cwblink 1.2s infinite;}
.cw-tdot:nth-child(2){animation-delay:.2s;}
.cw-tdot:nth-child(3){animation-delay:.4s;}
@keyframes cwblink{0%,60%,100%{opacity:.3;}30%{opacity:1;}}

/* 输入栏 */
.cw-input-wrap{flex:0 0 auto; background:#fff; border-top:1px solid var(--line); padding:10px 12px calc(10px + env(safe-area-inset-bottom,0px));}
.cw-input-pill{display:flex; align-items:center; gap:9px; border:1px solid #dcdcdc; border-radius:26px; padding:5px 8px 5px 13px; background:#fff; width:100%; max-width:820px; margin:0 auto;}
.cw-input-pill:focus-within{border-color:#bbb;}
.cw-attach{width:36px; height:36px; border:none; background:transparent; color:#6f737a; cursor:pointer; display:grid; place-items:center; border-radius:50%; flex:0 0 auto;}
.cw-attach:hover{background:#f1f2f4;}
.cw-attach svg{width:21px; height:21px;}
.cw-textarea{flex:1; border:none; outline:none; font-size:16px; line-height:1.4; resize:none; max-height:100px; min-height:24px; padding:7px 0; background:transparent; color:var(--ink);}
.cw-textarea::placeholder{color:#a9aeb5;}
.cw-send{width:38px; height:38px; border:none; border-radius:50%; background:var(--red); color:#fff; cursor:pointer; display:none; place-items:center; flex:0 0 auto; transition:.15s;}
.cw-send.cw-show{display:grid;}
.cw-send:hover{background:var(--red-d);}
.cw-send svg{width:18px; height:18px;}

/* 被拉黑 / 下班 */
.cw-blocked{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; color:#888; font-size:15px; padding:40px;}
.cw-blocked .ic{font-size:44px;}

/* 移动端 */
@media (max-width:600px){
  .cw-launcher{right:18px; bottom:18px;}
  .cw-head{padding-left:13px; padding-right:13px;}
  .cw-body{max-width:100%;}
  .cw-input-pill{max-width:100%;}
  .cw-input-wrap{padding-bottom:calc(20px + env(safe-area-inset-bottom, 0px));}
}

/* 图片点击查看 */
.cw-img{cursor:pointer;}
#cw-lightbox{position:fixed;inset:0;background:rgba(0,0,0,.88);display:none;align-items:center;justify-content:center;z-index:2147483600;padding:20px;}
#cw-lightbox.show{display:flex;}
#cw-lightbox img{max-width:92vw;max-height:88vh;border-radius:10px;box-shadow:0 10px 40px rgba(0,0,0,.5);}
