*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden;font-family:"PingFang SC","Microsoft YaHei",sans-serif;background:#f3f4f8}
.kefu-page{height:100vh;display:flex}
.kefu-wrap{display:flex;flex-direction:column;height:100vh;max-width:640px;margin:0 auto;width:100%;background:#fff;box-shadow:0 0 40px rgba(0,0,0,.06)}

/* Header */
.kefu-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;background:linear-gradient(135deg,#4f46e5,#6366f1);color:#fff;box-shadow:0 2px 14px rgba(79,70,229,.3);z-index:10}
.kh-back{color:#fff;font-size:24px;width:32px;text-align:left;cursor:pointer}
.kh-title{font-size:16px;font-weight:600;display:flex;align-items:center;gap:8px}
.kh-status-dot{width:8px;height:8px;border-radius:50%;background:#22c55e;box-shadow:0 0 8px #22c55e;display:inline-block}
.kh-status-dot.offline{background:#94a3b8;box-shadow:none}
.kh-close{color:rgba(255,255,255,.85);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:6px;transition:.2s}
.kh-close:hover{background:rgba(255,255,255,.15);color:#fff}

/* Body */
.kefu-body{flex:1;overflow-y:auto;padding:14px 14px 8px;background:linear-gradient(180deg,#f7f8fe 0,#f3f4f8 100%);scroll-behavior:smooth}
.kefu-body::-webkit-scrollbar{width:4px}
.kefu-body::-webkit-scrollbar-thumb{background:#c7cbdf;border-radius:2px}
.kefu-loading{text-align:center;color:#94a3b8;font-size:13px;padding:20px 0}

/* Message bubble */
.msg-row{display:flex;gap:8px;margin-bottom:14px;animation:msgIn .25s ease-out}
.msg-row.system{justify-content:center}
.msg-row.admin{justify-content:flex-start}
.msg-row.user{justify-content:flex-end}
.msg-avatar{width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,#4f46e5,#6366f1);color:#fff;display:flex;align-items:center;justify-content:center;font-size:14px;flex-shrink:0}
.msg-row.user .msg-avatar{background:linear-gradient(135deg,#3aa0ff,#5cbcff)}
.msg-content{max-width:75%;display:flex;flex-direction:column}
.msg-bubble{padding:10px 14px;border-radius:14px;font-size:14px;line-height:1.55;word-break:break-word;white-space:pre-wrap;box-shadow:0 1px 3px rgba(0,0,0,.04)}
.msg-row.system .msg-bubble{background:rgba(79,70,229,.08);color:#6366f1;font-size:12px;border-radius:8px;padding:6px 12px;max-width:none}
.msg-row.admin .msg-bubble{background:#fff;color:#1f2430;border-top-left-radius:4px}
.msg-row.user .msg-bubble{background:linear-gradient(135deg,#4f46e5,#6366f1);color:#fff;border-top-right-radius:4px}
.msg-time{font-size:11px;color:#94a3b8;margin-top:4px;text-align:right}
.msg-row.admin .msg-time{text-align:left}

/* Quick replies */
.kefu-quick{padding:8px 14px;background:#fff;border-top:1px solid #f1f2f6;display:flex;gap:8px;overflow-x:auto;-webkit-overflow-scrolling:touch}
.kq-item{padding:6px 12px;background:#f1f5ff;color:#4f46e5;border-radius:14px;font-size:12.5px;cursor:pointer;white-space:nowrap;border:1px solid #e0e7ff;transition:.2s;flex-shrink:0}
.kq-item:hover{background:#4f46e5;color:#fff;border-color:#4f46e5}
.kq-item:active{transform:scale(.95)}

/* Input */
.kefu-input{display:flex;gap:8px;padding:10px 12px;background:#fff;border-top:1px solid #f1f2f6}
#kefuInput{flex:1;height:42px;border:1.5px solid #e5e7eb;border-radius:21px;padding:0 18px;font-size:14px;background:#f8fafc;outline:none;transition:.2s}
#kefuInput:focus{border-color:#4f46e5;background:#fff;box-shadow:0 0 0 3px rgba(79,70,229,.12)}
#kefuSend{width:42px;height:42px;border-radius:50%;border:none;background:linear-gradient(135deg,#4f46e5,#6366f1);color:#fff;font-size:15px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:.2s;flex-shrink:0}
#kefuSend:hover{box-shadow:0 4px 12px rgba(79,70,229,.4)}
#kefuSend:disabled{background:#c7cbdf;cursor:not-allowed;box-shadow:none}
#kefuSend.sending{opacity:.7}

/* Offline tip */
.kefu-tip-bar{padding:8px 14px;background:#fef3c7;color:#92400e;font-size:12px;text-align:center;border-radius:8px;margin:0 14px 8px}

@keyframes msgIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}

@media (max-width:480px){
    .kefu-header{padding:12px}
    .kh-title{font-size:15px}
    .kefu-body{padding:10px}
    .msg-content{max-width:80%}
}
