:root{
  --cw-green:#4a9b3f;
  --cw-green-dark:#3a7d31;
  --cw-green-pale:#edf7ec;
  --cw-dark:#212529;
  --cw-dark2:#343a40;
  --cw-mid:#868e96;
  --cw-light:#dee2e6;
  --cw-bg:#f8f9fa;
  --cw-white:#ffffff;
  --cw-font:'DM Sans',system-ui,sans-serif;
}

#cw-fab{
  position:fixed;bottom:28px;right:28px;z-index:9999;
  width:58px;height:58px;
  background:var(--cw-green);
  border-radius:50%;border:none;cursor:pointer;
  box-shadow:0 4px 20px rgba(74,155,63,.45);
  display:flex;align-items:center;justify-content:center;
  transition:transform .2s,box-shadow .2s;
}
#cw-fab:hover{transform:scale(1.08);box-shadow:0 6px 28px rgba(74,155,63,.55)}
#cw-fab svg{width:26px;height:26px;position:absolute;transition:opacity .2s,transform .2s}
#cw-fab .cw-ico-chat{opacity:1;transform:scale(1)}
#cw-fab .cw-ico-x{opacity:0;transform:scale(.5)}
#cw-fab.cw-open .cw-ico-chat{opacity:0;transform:scale(.5)}
#cw-fab.cw-open .cw-ico-x{opacity:1;transform:scale(1)}

.cw-badge{
  position:absolute;top:-3px;right:-3px;
  width:17px;height:17px;
  background:#e53e3e;border-radius:50%;
  border:2px solid white;
  font-size:10px;font-weight:700;color:white;
  display:flex;align-items:center;justify-content:center;
  font-family:var(--cw-font);
  transition:opacity .3s;
}
#cw-fab.cw-open .cw-badge{opacity:0;pointer-events:none}

#cw-panel{
  position:fixed;bottom:102px;right:28px;z-index:9998;
  width:360px;height:540px;
  background:var(--cw-white);
  border-radius:16px;
  box-shadow:0 12px 40px rgba(0,0,0,.18);
  border:1px solid var(--cw-light);
  display:flex;flex-direction:column;
  overflow:hidden;
  transform:scale(.88) translateY(24px);
  transform-origin:bottom right;
  opacity:0;pointer-events:none;
  transition:transform .28s cubic-bezier(.34,1.56,.64,1),opacity .2s ease;
  font-family:var(--cw-font);
}
#cw-panel.cw-open{
  transform:scale(1) translateY(0);
  opacity:1;pointer-events:all;
}

/* header */
.cw-head{
  background:var(--cw-dark);
  padding:13px 14px;
  display:flex;align-items:center;gap:11px;
  flex-shrink:0;
}
.cw-head-av{
  width:36px;height:36px;
  background:var(--cw-green);border-radius:50%;
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.cw-head-av svg{width:18px;height:18px;stroke:white;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.cw-head-name{font-size:15px;font-weight:600;color:white;font-family:var(--cw-font)}
.cw-head-status{font-size:13px;color:rgba(255,255,255,.5);display:flex;align-items:center;gap:4px;margin-top:1px}
.cw-dot{width:5px;height:5px;background:#4caf82;border-radius:50%}
.cw-head-x{
  margin-left:auto;background:none;border:none;cursor:pointer;
  color:rgba(255,255,255,.35);padding:4px;border-radius:6px;
  display:flex;align-items:center;justify-content:center;
  transition:color .2s,background .2s;
}
.cw-head-x:hover{color:white;background:rgba(255,255,255,.1)}
.cw-head-x svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round}

/* messages */
.cw-msgs{
  flex:1;overflow-y:auto;
  padding:14px 11px;
  display:flex;flex-direction:column;gap:9px;
  background:var(--cw-bg);
  scroll-behavior:smooth;
}
.cw-msgs::-webkit-scrollbar{width:3px}
.cw-msgs::-webkit-scrollbar-thumb{background:var(--cw-light);border-radius:3px}

.cw-divider{
  text-align:center;font-size:11x;color:var(--cw-mid);
  display:flex;align-items:center;gap:7px;margin:2px 0;
  font-family:var(--cw-font);
}
.cw-divider::before,.cw-divider::after{content:'';flex:1;height:1px;background:var(--cw-light)}

.cw-row{display:flex;align-items:flex-end;gap:6px;animation:cwIn .2s ease forwards}
@keyframes cwIn{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}
.cw-row.cw-user{flex-direction:row-reverse}

.cw-av{
  width:24px;height:24px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  font-size:10px;font-weight:700;flex-shrink:0;
  font-family:var(--cw-font);
}
.cw-av.bot{background:var(--cw-dark);color:var(--cw-green)}
.cw-av.cw-user{background:var(--cw-green);color:white}

.cw-bbl{
  max-width:76%;
  padding:8px 12px;border-radius:13px;
  font-size:14px;line-height:1.5;
  font-family:var(--cw-font);
}
.cw-row.bot .cw-bbl{
  background:var(--cw-white);color:var(--cw-dark);
  border-bottom-left-radius:3px;
  border:1px solid var(--cw-light);
}
.cw-row.cw-user .cw-bbl{
  background:var(--cw-dark);color:white;
  border-bottom-right-radius:3px;
}

.cw-time{
  font-size:9px;color:var(--cw-mid);margin-top:2px;
  font-family:var(--cw-font);
}
.cw-row.bot .cw-time{margin-left:30px}
.cw-row.cw-user .cw-time{text-align:right;margin-right:30px}

/* typing */
.cw-typing{display:flex;align-items:flex-end;gap:6px}
.cw-typing-bbl{
  background:var(--cw-white);border:1px solid var(--cw-light);
  border-radius:13px;border-bottom-left-radius:3px;
  padding:10px 13px;display:flex;gap:4px;align-items:center;
}
.cw-td{width:6px;height:6px;background:var(--cw-green);border-radius:50%;animation:cwTd 1.2s infinite}
.cw-td:nth-child(2){animation-delay:.2s}
.cw-td:nth-child(3){animation-delay:.4s}
@keyframes cwTd{0%,60%,100%{transform:translateY(0);opacity:.45}30%{transform:translateY(-5px);opacity:1}}

/* name form bubble */
.cw-form-bbl{
  background:var(--cw-white);border:1px solid var(--cw-light);
  border-radius:13px;border-bottom-left-radius:3px;
  padding:11px;max-width:78%;
  font-size:13px;color:var(--cw-dark);
  font-family:var(--cw-font);
}
.cw-form-bbl label{display:block;margin-bottom:6px;font-weight:500}
.cw-form-bbl input{
  width:100%;border:1px solid var(--cw-light);
  border-radius:7px;padding:7px 10px;
  font-size:13px;font-family:var(--cw-font);
  color:var(--cw-dark);outline:none;
  transition:border-color .2s;background:var(--cw-bg);
}
.cw-form-bbl input:focus{border-color:var(--cw-green);background:white}
.cw-form-bbl button{
  margin-top:7px;
  background:var(--cw-green);color:white;border:none;
  border-radius:7px;padding:7px 13px;
  font-size:12px;font-weight:600;font-family:var(--cw-font);
  cursor:pointer;transition:background .2s;
}
.cw-form-bbl button:hover{background:var(--cw-green-dark)}

/* input bar */
.cw-bar{
  padding:9px 11px;
  border-top:1px solid var(--cw-light);
  background:var(--cw-white);
  display:flex;gap:7px;align-items:flex-end;
  flex-shrink:0;
}
.cw-input{
  flex:1;border:1px solid var(--cw-light);
  border-radius:18px;padding:7px 13px;
  font-size:14px;font-family:var(--cw-font);
  color:var(--cw-dark);background:var(--cw-bg);
  resize:none;outline:none;max-height:88px;line-height:1.4;
  transition:border-color .2s,background .2s;
}
.cw-input:focus{border-color:var(--cw-green);background:white}
.cw-input::placeholder{color:var(--cw-mid)}
.cw-send{
  width:34px;height:34px;
  background:var(--cw-green);border:none;
  border-radius:50%;cursor:pointer;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  transition:background .2s,transform .1s;
}
.cw-send:hover{background:var(--cw-green-dark)}
.cw-send:active{transform:scale(.91)}
.cw-send:disabled{background:var(--cw-mid);cursor:not-allowed}
.cw-send svg{width:14px;height:14px;stroke:white;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* footer */
.cw-foot{
  padding:5px;text-align:center;
  font-size:10px;color:var(--cw-mid);
  background:var(--cw-white);flex-shrink:0;
  border-top:1px solid #f1f3f5;
  font-family:var(--cw-font);
}

@media(max-width:420px){
  #cw-panel{width:calc(100vw - 24px);right:12px;bottom:90px}
  #cw-fab{right:16px;bottom:16px}
}