#pbtg-chat {
  --pbtg-primary: #2035f2;
  --pbtg-accent: #f28c28;
  --pbtg-ink: #14182b;
  --pbtg-muted: #6b7489;
  --pbtg-line: #e6e9f2;
  --pbtg-bg: #f5f7fc;
  --pbtg-deep: color-mix(in srgb, var(--pbtg-primary) 62%, #050a30);
  position: fixed; right: 22px; bottom: 22px; z-index: 999999;
  font-family: Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--pbtg-ink);
  -webkit-font-smoothing: antialiased;
}
#pbtg-chat *, #pbtg-chat *::before, #pbtg-chat *::after { box-sizing: border-box; }
#pbtg-chat button { font-family: inherit; cursor: pointer; margin: 0; }
#pbtg-chat img { max-width: none; }

/* ---------- Launcher ---------- */
#pbtg-chat .pbtg-launcher {
  position: relative; width: 64px; height: 64px; border-radius: 50%; border: 0; padding: 0;
  background: linear-gradient(140deg, var(--pbtg-primary), var(--pbtg-deep));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--pbtg-primary) 70%, transparent), 0 4px 10px rgba(10, 20, 60, .18);
  transition: transform .25s cubic-bezier(.3, 1.4, .5, 1), box-shadow .25s;
}
#pbtg-chat .pbtg-launcher:hover { transform: translateY(-2px) scale(1.05); }
#pbtg-chat .pbtg-launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--pbtg-primary) 40%, #fff); outline-offset: 3px; }
#pbtg-chat .pbtg-launcher > span { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .3s, opacity .2s; }
#pbtg-chat .pbtg-launcher-open img { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; background: #fff; border: 2px solid rgba(255, 255, 255, .9); }
#pbtg-chat .pbtg-launcher-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
#pbtg-chat.pbtg-open .pbtg-launcher-open { opacity: 0; transform: rotate(90deg) scale(.6); }
#pbtg-chat.pbtg-open .pbtg-launcher-close { opacity: 1; transform: none; }
#pbtg-chat .pbtg-launcher::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--pbtg-primary); opacity: 0; pointer-events: none;
}
#pbtg-chat .pbtg-launcher.pbtg-unread::before { animation: pbtgRing 2.2s ease-out infinite; }
@keyframes pbtgRing { 0% { transform: scale(1); opacity: .55; } 80%, 100% { transform: scale(1.55); opacity: 0; } }
#pbtg-chat .pbtg-badge {
  inset: auto !important; top: -2px !important; right: -2px !important; width: 21px; height: 21px;
  display: none !important; place-items: center; border-radius: 50%;
  background: var(--pbtg-accent); color: #fff; font-size: 11.5px; font-weight: 700; border: 2px solid #fff;
}
#pbtg-chat .pbtg-launcher.pbtg-unread .pbtg-badge { display: grid !important; }
#pbtg-chat.pbtg-open .pbtg-badge { display: none !important; }

/* ---------- Teaser ---------- */
#pbtg-chat .pbtg-teaser {
  position: absolute; right: 4px; bottom: 78px; width: max-content; max-width: 250px;
  background: #fff; color: var(--pbtg-ink); padding: 12px 30px 12px 14px; border-radius: 14px 14px 4px 14px;
  box-shadow: 0 12px 32px -8px rgba(15, 25, 70, .28), 0 0 0 1px rgba(15, 25, 70, .05);
  font-size: 13.5px; font-weight: 500; opacity: 0; transform: translateY(8px) scale(.96);
  transform-origin: bottom right; pointer-events: none; transition: opacity .3s, transform .3s cubic-bezier(.3, 1.3, .5, 1);
}
#pbtg-chat .pbtg-teaser span { cursor: pointer; }
#pbtg-chat .pbtg-teaser.pbtg-show { opacity: 1; transform: none; pointer-events: auto; }
#pbtg-chat.pbtg-open .pbtg-teaser { display: none; }
#pbtg-chat .pbtg-teaser-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: transparent; color: var(--pbtg-muted); font-size: 17px; line-height: 1; padding: 0;
}
#pbtg-chat .pbtg-teaser-x:hover { background: var(--pbtg-bg); color: var(--pbtg-ink); }

/* ---------- Panel ---------- */
#pbtg-chat .pbtg-panel {
  position: absolute; right: 0; bottom: 80px;
  display: flex; flex-direction: column; width: 384px; max-width: calc(100vw - 28px);
  height: 610px; max-height: calc(100vh - 120px);
  background: #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 60px -12px rgba(10, 20, 70, .35), 0 0 0 1px rgba(10, 20, 70, .06);
  opacity: 0; transform: translateY(14px) scale(.97); transform-origin: bottom right;
  visibility: hidden; transition: opacity .22s, transform .28s cubic-bezier(.3, 1.2, .5, 1), visibility 0s .28s;
}
#pbtg-chat.pbtg-open .pbtg-panel { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }

#pbtg-chat .pbtg-head {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 16px 14px 16px 16px; color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--pbtg-accent) 35%, transparent) 0%, transparent 45%),
    linear-gradient(135deg, var(--pbtg-primary), var(--pbtg-deep));
}
#pbtg-chat .pbtg-head::after { /* subtle blueprint grid */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .12;
  background-image: linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: linear-gradient(90deg, transparent, #000 70%);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 70%);
}
#pbtg-chat .pbtg-head > * { position: relative; z-index: 1; }
#pbtg-chat .pbtg-head-av { position: relative; flex: none; }
#pbtg-chat .pbtg-av-lg { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: #fff; border: 2px solid rgba(255, 255, 255, .85); display: grid; place-items: center; }
#pbtg-chat .pbtg-online { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }
#pbtg-chat .pbtg-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#pbtg-chat .pbtg-title strong { font-size: 16px; font-weight: 700; letter-spacing: .1px; }
#pbtg-chat .pbtg-title span { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; }
#pbtg-chat .pbtg-dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .25); }
#pbtg-chat .pbtg-icon-btn {
  width: 34px; height: 34px; border: 0; border-radius: 10px; padding: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); color: #fff; transition: background .15s;
}
#pbtg-chat .pbtg-icon-btn:hover { background: rgba(255, 255, 255, .24); }

/* ---------- Messages ---------- */
#pbtg-chat .pbtg-body {
  flex: 1; overflow-y: auto; padding: 18px 14px 10px; background: var(--pbtg-bg);
  display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}
#pbtg-chat .pbtg-body::-webkit-scrollbar { width: 6px; }
#pbtg-chat .pbtg-body::-webkit-scrollbar-thumb { background: #cfd5e3; border-radius: 6px; }

#pbtg-chat .pbtg-intro { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 4px 0 10px; }
#pbtg-chat .pbtg-av-xl { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 4px 14px rgba(15, 25, 70, .12); display: grid; place-items: center; margin-bottom: 4px; }
#pbtg-chat .pbtg-intro strong { font-size: 15px; }
#pbtg-chat .pbtg-intro span { font-size: 12px; color: var(--pbtg-muted); }

#pbtg-chat .pbtg-row { display: flex; align-items: flex-end; gap: 8px; animation: pbtgIn .28s ease-out; }
@keyframes pbtgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#pbtg-chat .pbtg-row-user { justify-content: flex-end; }
#pbtg-chat .pbtg-row.pbtg-grouped { margin-top: -6px; }
#pbtg-chat .pbtg-av-sm { flex: none; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 1px 4px rgba(15, 25, 70, .15); display: grid; place-items: center; font-size: 12px; }
#pbtg-chat .pbtg-row.pbtg-grouped .pbtg-av-sm { visibility: hidden; }
#pbtg-chat .pbtg-av-letter { background: linear-gradient(135deg, var(--pbtg-primary), var(--pbtg-deep)) !important; color: #fff; font-weight: 700; }

#pbtg-chat .pbtg-msg { max-width: 80%; padding: 10px 13px 6px; border-radius: 18px; word-wrap: break-word; overflow-wrap: anywhere; }
#pbtg-chat .pbtg-msg time { display: block; font-size: 10.5px; margin-top: 3px; opacity: .55; text-align: right; }
#pbtg-chat .pbtg-bot { background: #fff; color: var(--pbtg-ink); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(15, 25, 70, .06), 0 0 0 1px rgba(15, 25, 70, .04); }
#pbtg-chat .pbtg-user { background: linear-gradient(135deg, var(--pbtg-primary), var(--pbtg-deep)); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--pbtg-primary) 60%, transparent); }
#pbtg-chat .pbtg-text strong { font-weight: 650; }
#pbtg-chat .pbtg-msg a { color: var(--pbtg-primary); font-weight: 600; text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--pbtg-primary) 35%, transparent); }
#pbtg-chat .pbtg-msg a:hover { border-bottom-color: var(--pbtg-primary); }
#pbtg-chat .pbtg-user a { color: #fff; border-bottom-color: rgba(255, 255, 255, .6); }

#pbtg-chat .pbtg-typing { display: flex; gap: 4px; padding: 14px 15px; }
#pbtg-chat .pbtg-typing span { width: 7px; height: 7px; border-radius: 50%; background: #a3acc2; animation: pbtgDot 1.2s infinite; }
#pbtg-chat .pbtg-typing span:nth-child(2) { animation-delay: .15s; }
#pbtg-chat .pbtg-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes pbtgDot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-4px); } }

/* ---------- Quick replies ---------- */
#pbtg-chat .pbtg-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 0 50px; background: var(--pbtg-bg); }
#pbtg-chat .pbtg-chips:not(:empty) { padding-bottom: 12px; }
#pbtg-chat .pbtg-chips button {
  border: 1px solid color-mix(in srgb, var(--pbtg-primary) 30%, #fff); background: #fff; color: var(--pbtg-primary);
  border-radius: 999px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; line-height: 1.2;
  transition: background .15s, color .15s, transform .15s, border-color .15s;
}
#pbtg-chat .pbtg-chips button:hover { background: var(--pbtg-primary); border-color: var(--pbtg-primary); color: #fff; transform: translateY(-1px); }

/* ---------- Composer ---------- */
#pbtg-chat .pbtg-form { display: flex; align-items: center; gap: 8px; padding: 12px; border-top: 1px solid var(--pbtg-line); background: #fff; margin: 0; }
#pbtg-chat .pbtg-form input {
  flex: 1; min-width: 0; height: 44px; margin: 0; padding: 0 16px; border: 1px solid var(--pbtg-line); border-radius: 999px;
  background: var(--pbtg-bg); font: inherit; font-size: 14px; color: var(--pbtg-ink); outline: none; box-shadow: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
#pbtg-chat .pbtg-form input:focus { border-color: var(--pbtg-primary); background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--pbtg-primary) 14%, transparent); }
#pbtg-chat .pbtg-form button {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--pbtg-primary), var(--pbtg-deep)); color: #fff; transition: transform .15s, opacity .15s;
}
#pbtg-chat .pbtg-form button:hover:not(:disabled) { transform: scale(1.06); }
#pbtg-chat .pbtg-form button:disabled { opacity: .35; cursor: default; }

#pbtg-chat .pbtg-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px 10px; background: #fff; font-size: 11.5px; color: var(--pbtg-muted); }
#pbtg-chat .pbtg-foot a { display: inline-flex; align-items: center; gap: 5px; color: #1fa855 !important; font-weight: 600; text-decoration: none; }
#pbtg-chat .pbtg-foot a:hover { text-decoration: underline; }


/* ---------- Hard reset against theme button/input styles ---------- */
#pbtg-chat button {
  text-transform: none !important; letter-spacing: normal !important; text-shadow: none !important;
  min-width: 0 !important; min-height: 0 !important; margin: 0 !important; line-height: 1.2 !important;
  font-family: inherit !important; text-decoration: none !important; box-sizing: border-box !important;
}
#pbtg-chat button svg { flex: none; width: auto; height: auto; }
#pbtg-chat .pbtg-icon-btn { width: 34px !important; height: 34px !important; padding: 0 !important; border: 0 !important; border-radius: 10px !important; background: rgba(255,255,255,.14) !important; color: #fff !important; display: grid !important; place-items: center; }
#pbtg-chat .pbtg-icon-btn:hover { background: rgba(255,255,255,.26) !important; }
#pbtg-chat .pbtg-icon-btn svg { width: 18px; height: 18px; }
#pbtg-chat .pbtg-close svg { width: 20px; height: 20px; }
#pbtg-chat .pbtg-launcher { padding: 0 !important; border: 0 !important; border-radius: 50% !important; width: 64px !important; height: 64px !important; background: linear-gradient(140deg, var(--pbtg-primary), var(--pbtg-deep)) !important; color: #fff !important; }
#pbtg-chat .pbtg-chips button { width: auto !important; height: auto !important; padding: 7px 12px !important; border-radius: 999px !important; font-size: 12.5px !important; font-weight: 600 !important; display: inline-flex !important; background: #fff !important; color: var(--pbtg-primary) !important; border: 1px solid color-mix(in srgb, var(--pbtg-primary) 30%, #fff) !important; }
#pbtg-chat .pbtg-chips button:hover { background: var(--pbtg-primary) !important; color: #fff !important; border-color: var(--pbtg-primary) !important; }
#pbtg-chat .pbtg-form button { width: 44px !important; height: 44px !important; padding: 0 !important; border: 0 !important; border-radius: 50% !important; background: linear-gradient(135deg, var(--pbtg-primary), var(--pbtg-deep)) !important; color: #fff !important; display: grid !important; place-items: center; }
#pbtg-chat .pbtg-form input { height: 44px !important; margin: 0 !important; padding: 0 16px !important; border: 1px solid var(--pbtg-line) !important; border-radius: 999px !important; background: var(--pbtg-bg) !important; box-shadow: none !important; font-size: 14px !important; line-height: normal !important; width: auto !important; }
#pbtg-chat .pbtg-form input:focus { border-color: var(--pbtg-primary) !important; background: #fff !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--pbtg-primary) 14%, transparent) !important; }
#pbtg-chat .pbtg-teaser-x { width: 22px !important; height: 22px !important; padding: 0 !important; border: 0 !important; border-radius: 50% !important; background: transparent !important; color: var(--pbtg-muted) !important; font-size: 17px !important; line-height: 1 !important; }
@media (max-width: 480px) { #pbtg-chat .pbtg-launcher { width: 58px !important; height: 58px !important; } }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  #pbtg-chat { right: 14px; bottom: 14px; }
  #pbtg-chat .pbtg-launcher { width: 58px; height: 58px; }
  #pbtg-chat .pbtg-launcher-open img { width: 48px; height: 48px; }
  #pbtg-chat .pbtg-panel { position: fixed; inset: 0; width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  #pbtg-chat.pbtg-open .pbtg-launcher { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #pbtg-chat * { animation: none !important; transition: none !important; }
}
