#pchat-root, #pchat-root * { box-sizing: border-box; }
#pchat-root {
  --pc: #1f4e79;
  position: fixed; right: 20px; bottom: 20px; z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
/* Touch devices have no hover: without this, iOS fires :hover on tap and the
   bubble stays stuck at 1.06 scale until the visitor taps elsewhere. */
@media (hover: none) and (pointer: coarse) {
  #pchat-bubble { transition: none; }
  #pchat-bubble:hover { transform: none; }
}
#pchat-bubble {
  width: 60px; height: 60px; border-radius: 50%; background: #2f80ed; color: #fff;
  border: none; cursor: pointer; box-shadow: none; filter: none; outline: none;
  -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center; justify-content: center; transition: transform .15s;
}
#pchat-bubble:hover { transform: scale(1.06); }
#pchat-bubble svg { width: 28px; height: 28px; fill: #fff; }
#pchat-badge {
  position: absolute; top: -4px; right: -4px; background: #e53935; color: #fff;
  min-width: 20px; height: 20px; border-radius: 10px; font-size: 12px; font-weight: 700;
  display: none; align-items: center; justify-content: center; padding: 0 5px;
}
#pchat-greet {
  position: absolute; right: 4px; bottom: 76px; max-width: 240px;
  background: #2f80ed; color: #fff; border-radius: 16px; padding: 12px 34px 12px 16px;
  box-shadow: 0 10px 28px rgba(0,0,0,.22); font-size: 14.5px; font-weight: 600; font-style: italic; line-height: 1.3;
  white-space: nowrap; cursor: pointer;
  opacity: 0; transform: translateY(10px) scale(.94); transform-origin: bottom right;
  transition: opacity .28s ease, transform .28s ease; pointer-events: none;
}
#pchat-greet.in { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
#pchat-greet::after {
  content: ''; position: absolute; right: 20px; bottom: -6px; width: 14px; height: 14px;
  background: #2f80ed; transform: rotate(45deg); border-radius: 0 0 3px 0;
}
#pchat-greet-x {
  position: absolute; top: 3px; right: 7px; width: 20px; height: 20px; padding: 0;
  background: none; border: none; color: rgba(255,255,255,.8); font-size: 18px; line-height: 1; cursor: pointer;
}
#pchat-greet-x:hover { color: #fff; }
#pchat-root.pos-left #pchat-greet { right: auto; left: 4px; transform-origin: bottom left; }
#pchat-root.pos-left #pchat-greet::after { right: auto; left: 20px; }
#pchat-panel {
  position: absolute; right: 0; bottom: 74px; width: 370px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 120px); background: #fff; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.28); display: none; flex-direction: column; overflow: hidden;
}
#pchat-root.open #pchat-panel { display: flex; }
#pchat-head { background: var(--pc); color: #fff; padding: 16px; }
#pchat-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
#pchat-head p { margin: 2px 0 0; font-size: 12px; opacity: .85; }
#pchat-close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
#pchat-msgs { flex: 1; overflow-y: auto; padding: 14px; background: #f5f6f8; position: relative; }
#pchat-root.has-wm #pchat-msgs::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: var(--pc);
  -webkit-mask: var(--pc-wm) center 48% / 80% no-repeat; mask: var(--pc-wm) center 48% / 80% no-repeat;
  opacity: .09;
}
#pchat-msgs > * { position: relative; z-index: 1; }
.pchat-msg { margin-bottom: 10px; display: flex; }
.pchat-msg .b { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.pchat-msg.v { justify-content: flex-end; }
.pchat-msg.v .b { background: var(--pc); color: #fff; border-bottom-right-radius: 4px; }
.pchat-msg.b0 .b, .pchat-msg.a .b { background: #fff; color: #1a1a1a; border: 1px solid #e3e6ea; border-bottom-left-radius: 4px; }
.pchat-msg.s { justify-content: center; }
.pchat-msg.s .b { background: #e8eaed; color: #555; font-size: 12px; border-radius: 10px; }
.pchat-msg .b a { color: inherit; text-decoration: underline; }
.pchat-msg.v .b a { color: #fff; }
/* Agent/bot avatar + message column (2.9.39) */
.pchat-msg.b0, .pchat-msg.a { align-items: flex-end; gap: 8px; flex-wrap: nowrap; }
.pchat-av { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; background: #cdd6e0 center / cover no-repeat; box-shadow: 0 1px 3px rgba(0,0,0,.18); align-self: flex-end; }
.pchat-av.sp { visibility: hidden; box-shadow: none; }
.pchat-col { display: flex; flex-direction: column; min-width: 0; max-width: calc(100% - 44px); }
.pchat-col .b { max-width: 100%; }
#pchat-typing { font-size: 12px; color: #888; padding: 0 14px 6px; height: 18px; }
#pchat-foot { border-top: 1px solid #e3e6ea; padding: 10px; background: #fff; }
#pchat-form { display: flex; gap: 8px; }
#pchat-input { flex: 1; border: 1px solid #cfd4da; border-radius: 20px; padding: 10px 14px; font-size: 14px; outline: none; resize: none; max-height: 90px; font-family: inherit; }
#pchat-input:focus { border-color: var(--pc); }
#pchat-send { background: var(--pc); border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; flex: 0 0 auto; }
#pchat-send svg { width: 18px; height: 18px; fill: #fff; }
#pchat-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
#pchat-human { background: none; border: none; color: var(--pc); font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; }
#pchat-consent { font-size: 10px; color: #9aa0a6; margin: 0; }
#pchat-consent a { color: #9aa0a6; }
.pchat-dots span { display:inline-block; width:6px;height:6px;margin:0 1px;background:#bbb;border-radius:50%;animation:pcb 1s infinite; }
.pchat-dots span:nth-child(2){animation-delay:.2s}.pchat-dots span:nth-child(3){animation-delay:.4s}
@keyframes pcb{0%,60%,100%{opacity:.3}30%{opacity:1}}
@media (max-width:480px){ #pchat-panel{ width: calc(100vw - 24px); height: calc(100vh - 100px); } }
#pchat-root.prechat #pchat-foot { display: none; }
#pchat-prechat { padding: 4px 2px 8px; }
#pchat-prechat h4 { margin: 0 0 4px; font-size: 15px; color: #1a1a1a; }
#pchat-prechat p.i { font-size: 13px; color: #555; margin: 0 0 10px; }
#pchat-prechat input { width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 10px 12px; border: 1px solid #cfd4da; border-radius: 8px; font-size: 14px; font-family: inherit; }
#pchat-prechat input:focus { border-color: var(--pc); outline: none; }
#pchat-prechat button { width: 100%; background: var(--pc); color: #fff; border: none; border-radius: 8px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; }
#pchat-prechat button:disabled { opacity: .6; }
#pchat-prechat .err { color: #e53935; font-size: 12px; margin-bottom: 6px; display: none; }
#pchat-prechat .pc-note { font-size: 10px; color: #9aa0a6; margin-top: 8px; }
.pchat-msg { flex-wrap: wrap; }
.pchat-msg .who { width: 100%; font-size: 11px; font-weight: 600; color: #7a8290; margin: 0 0 3px 2px; letter-spacing: .01em; }
.pchat-msg.v .who { text-align: right; }

/* Bottom-left placement, for sites that already have a bubble bottom-right */
#pchat-root.pos-left { right: auto; left: 20px; }
#pchat-root.pos-left #pchat-panel { right: auto; left: 0; }
@media (max-width:480px){ #pchat-root.pos-left { left: 12px; } }

/* Attach button + file attachments */
#pchat-attach { background: none; border: none; color: #8a97a6; width: 34px; height: 40px; padding: 0; cursor: pointer; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
#pchat-attach:hover { color: var(--pc); }
#pchat-attach:disabled { opacity: .5; cursor: default; }
#pchat-attach svg { width: 20px; height: 20px; }
.pchat-att-img { display: inline-block; margin-top: 4px; }
.pchat-att-img img { max-width: 190px; max-height: 190px; border-radius: 10px; display: block; }
.pchat-att-file { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.16); text-decoration: none !important; max-width: 240px; }
.pchat-msg.b0 .pchat-att-file, .pchat-msg.a .pchat-att-file { background: #eef1f4; }
.pchat-att-file .ic { font-size: 18px; flex: 0 0 auto; }
.pchat-att-file .meta { display: flex; flex-direction: column; min-width: 0; }
.pchat-att-file .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pchat-att-file .sz { font-size: 11px; opacity: .75; }
