#cr-chat-bubble{position:fixed;bottom:24px;right:24px;width:58px;height:58px;border-radius:50%;background:#F5A623;color:#060B18;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 8px 24px -8px rgba(0,0,0,.4);z-index:9999;border:none}
#cr-chat-bubble:hover{background:#D98D12}
#cr-chat-bubble svg{width:26px;height:26px}

#cr-chat-badge{position:absolute;top:-4px;right:-4px;min-width:20px;height:20px;padding:0 5px;border-radius:10px;background:#E0393E;color:#fff;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center;border:2px solid #fff;font-family:'Inter',sans-serif}

#cr-chat-panel{position:fixed;bottom:96px;right:24px;width:360px;max-width:calc(100vw - 32px);height:500px;max-height:calc(100vh - 140px);background:#fff;border-radius:14px;box-shadow:0 20px 50px -12px rgba(0,0,0,.35);display:none;flex-direction:column;overflow:hidden;z-index:9999;font-family:'Inter',sans-serif}
#cr-chat-panel.open{display:flex}

.cr-chat-head{background:#060B18;color:#fff;padding:14px 16px;display:flex;justify-content:space-between;align-items:center;flex:0 0 auto}
.cr-chat-head strong{font-family:'Space Grotesk',sans-serif;font-size:14.5px}
.cr-chat-close{background:none;border:none;color:#8592B4;cursor:pointer;font-size:22px;line-height:1;padding:4px 6px}

.cr-chat-body{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:16px;background:#F7F9FC;display:flex;flex-direction:column}
.cr-chat-msgs{display:flex;flex-direction:column;gap:8px;flex:1}

.cr-msg{max-width:82%;padding:8px 12px;border-radius:11px;font-size:14px;line-height:1.45;word-break:break-word}
.cr-msg-visitor{background:#2F7FEE;color:#fff;align-self:flex-end}
.cr-msg-staff{background:#fff;border:1px solid #EBEFF7;align-self:flex-start;color:#1B2437}
.cr-msg-time{font-size:10px;opacity:.7;margin-top:3px;display:flex;justify-content:flex-end;gap:4px;align-items:center;min-height:12px}
.cr-tick{opacity:.85}
.cr-tick-delivered{opacity:.95}
.cr-tick-read{color:#7ED0FF;opacity:1}

.cr-msg-attach-img{max-width:200px;border-radius:8px;display:block;margin-bottom:6px}
.cr-msg-attach-file{display:inline-block;margin-bottom:6px;color:inherit;text-decoration:underline;font-size:13px}

.cr-chat-start{padding:16px;overflow-y:auto}
.cr-chat-start input,.cr-chat-start textarea{width:100%;padding:10px 12px;border:1.5px solid #DCE2EE;border-radius:7px;font-size:16px;margin-bottom:10px;font-family:inherit;box-sizing:border-box}
.cr-chat-start textarea{min-height:64px;resize:vertical}
.cr-chat-start button,#cr-reply-btn{background:#F5A623;color:#060B18;border:none;border-radius:7px;padding:10px 16px;font-weight:700;font-size:14px;cursor:pointer}
.cr-chat-start button:disabled{opacity:.6;cursor:default}
.cr-chat-err{color:#B3261E;font-size:12.5px;margin-bottom:8px}

.cr-attach-row{display:flex;align-items:center;gap:8px;margin-bottom:12px;flex-wrap:wrap}
.cr-attach-label{font-size:13px;color:#2F7FEE;cursor:pointer;font-weight:600}
.cr-attach-name{font-size:12px;color:#8992A8;word-break:break-all}

.cr-chat-foot{padding:10px 12px;border-top:1px solid #EBEFF7;display:flex;gap:8px;align-items:flex-end;flex:0 0 auto}
.cr-chat-foot textarea{flex:1;min-height:40px;max-height:100px;padding:9px 10px;border:1.5px solid #DCE2EE;border-radius:7px;font-size:16px;font-family:inherit;resize:none}
.cr-attach-btn{border:1px solid #DCE2EE;background:#fff;border-radius:7px;width:40px;height:40px;font-size:17px;cursor:pointer;flex:0 0 auto}
.cr-attach-btn.cr-attach-armed{border-color:#F5A623;background:#FFFBF0}
#cr-reply-btn{flex:0 0 auto;height:40px}

/* Mobile: the panel becomes a true full-screen sheet rather than a small
   floating box — matches how a native chat app behaves on a phone, and
   avoids the tiny cramped box a fixed 360px width would otherwise force
   on a ~375px viewport. */
@media (max-width: 640px){
  #cr-chat-panel{
    top:0; left:0; right:0; bottom:0;
    width:100%; height:100%; max-width:100%; max-height:100%;
    border-radius:0;
  }
  #cr-chat-panel.open{ display:flex; }
  .cr-chat-head{ padding-top:max(14px, env(safe-area-inset-top)); }
  .cr-chat-foot{ padding-bottom:max(10px, env(safe-area-inset-bottom)); }
  #cr-chat-bubble{
    bottom:max(20px, env(safe-area-inset-bottom)); right:20px;
    width:54px; height:54px;
  }
  body.cr-chat-locked{ overflow:hidden; }
  .cr-msg{ max-width:88%; }
}
