#pgs-root { position: fixed; right: 24px; bottom: 0; z-index: 9990; font-family: Poppins, system-ui, sans-serif; }
#pgs-root *, #pgs-root *::before, #pgs-root *::after { box-sizing: border-box; }

.pgs-box {
  background: #fff; color: #0a0a0a; border-radius: 10px 10px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden;
}
#pgs-root.open .pgs-box { width: 340px; }

.pgs-tab {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 16px;
  background: #fff; color: #0a0a0a; border: none; cursor: pointer; text-align: left;
  font: inherit; font-size: 13.5px; font-weight: 500; white-space: nowrap;
}
#pgs-root.open .pgs-tab { border-bottom: 1px solid #ececec; }
.pgs-tab__icon { width: 22px; height: 22px; flex-shrink: 0; }
.pgs-tab__label { flex: 1; }
.pgs-tab__chev { width: 16px; height: 16px; flex-shrink: 0; display: none; color: #6b7280; }
#pgs-root.open .pgs-tab__chev { display: block; }
.pgs-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #0a0a0a; color: #fff;
  font-size: 10.5px; font-weight: 700; display: none; align-items: center; justify-content: center;
}
.pgs-badge.on { display: inline-flex; }

.pgs-panel { display: none; flex-direction: column; height: min(420px, calc(100vh - 120px)); }
#pgs-root.open .pgs-panel { display: flex; }

.pgs-body { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 8px; background: #fafafa; }
.pgs-body::-webkit-scrollbar { width: 6px; }
.pgs-body::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 3px; }

.pgs-msg { max-width: 85%; display: flex; flex-direction: column; gap: 2px; }
.pgs-msg__meta { font-size: 10.5px; color: #9ca3af; padding: 0 4px; }
.pgs-msg__body { padding: 8px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.pgs-msg--visitor { align-self: flex-end; align-items: flex-end; }
.pgs-msg--visitor .pgs-msg__body { background: #0a0a0a; color: #fff; border-bottom-right-radius: 4px; }
.pgs-msg--staff, .pgs-msg--ai { align-self: flex-start; }
.pgs-msg--staff .pgs-msg__body, .pgs-msg--ai .pgs-msg__body { background: #fff; color: #0a0a0a; border: 1px solid #ececec; border-bottom-left-radius: 4px; }
.pgs-msg__body a { color: inherit; text-decoration: underline; }
.pgs-msg--staff { max-width: 90%; }
.pgs-msg--staff .pgs-msg__meta { padding-left: 36px; }
.pgs-msg__row { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.pgs-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; overflow: hidden; background: #0a0a0a; color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.pgs-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pgs-system { align-self: center; font-size: 12px; color: #6b7280; text-align: center; padding: 2px 8px; line-height: 1.5; }

.pgs-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid #ececec; background: #fff; }
.pgs-textarea {
  flex: 1; max-height: 110px; resize: none; border: 1px solid #e5e5e5; border-radius: 10px; padding: 9px 11px;
  font: inherit; font-size: 13.5px; color: #0a0a0a; background: #fff; outline: none;
}
.pgs-textarea:focus { border-color: #0a0a0a; }
.pgs-textarea::placeholder { color: #9ca3af; }
.pgs-send { width: 38px; height: 38px; flex-shrink: 0; border: none; border-radius: 10px; background: #0a0a0a; color: #fff; cursor: pointer; display: grid; place-items: center; }
.pgs-send:disabled { opacity: .4; cursor: default; }
.pgs-send svg { width: 17px; height: 17px; }
.pgs-closed { padding: 12px; border-top: 1px solid #ececec; text-align: center; background: #fff; }
.pgs-closed p { color: #6b7280; font-size: 12.5px; margin: 0 0 8px; }
.pgs-btn { width: 100%; padding: 10px; border: none; border-radius: 10px; background: #0a0a0a; color: #fff; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }

@media (max-width: 480px) {
  #pgs-root { right: 12px; }
  .pgs-tab__label { font-size: 13px; }
  #pgs-root.open { inset: 0; right: 0; }
  #pgs-root.open .pgs-box { width: 100%; height: 100%; border-radius: 0; }
  #pgs-root.open .pgs-panel { height: auto; flex: 1; min-height: 0; }
}
