.chat-fab {
  position: fixed; right: 20px; bottom: 22px; z-index: 40; display: flex; align-items: center; gap: 10px;
  padding: 10px 18px 10px 14px; border-radius: 999px; border: 1px solid rgba(180, 160, 255, .55); cursor: pointer; color: #fff;
  background: linear-gradient(120deg, #7b5cff, #5a6bff 50%, #2fb6ff);
  font: 600 15px/1.2 var(--font-head, "Prompt", sans-serif); text-align: left;
  box-shadow: 0 16px 40px -10px rgba(123, 92, 255, .8), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .2s, box-shadow .2s;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 20px 46px -8px rgba(123, 92, 255, .95); }
.chat-fab svg { width: 24px; height: 24px; flex: none; }
.chat-fab small { display: block; font: 500 11px var(--font, sans-serif); opacity: .85; }
.chat-fab .live { position: absolute; top: 6px; left: 30px; }
.chat-fab::before { content: ""; position: absolute; inset: -6px; border-radius: 999px; border: 2px solid rgba(123, 92, 255, .5); animation: fabpulse 2.6s ease-out infinite; pointer-events: none; }
@keyframes fabpulse { 0% { transform: scale(.96); opacity: .9; } 100% { transform: scale(1.12); opacity: 0; } }
.chat-panel {
  position: fixed; right: 16px; bottom: 20px; z-index: 41; width: 380px; height: min(600px, calc(100vh - 40px));
  display: none; flex-direction: column; background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
}
.chat-panel.open { display: flex; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.chat-head .av { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #1a1205; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.chat-head b { display: block; font-size: 15px; }
.chat-head small { color: var(--muted); font-size: 12px; }
.chat-head button { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; padding: 4px 8px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: #1f4a8a; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg a { color: var(--gold); text-decoration: underline; }
.msg.typing { color: var(--muted); }
.chat-quick { display: flex; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
.chat-quick button { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 5px 12px; font: 13px "Prompt", sans-serif; cursor: pointer; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; resize: none; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font: 16px "Prompt", sans-serif; max-height: 110px; }
.chat-form button { background: var(--gold); border: 0; border-radius: 12px; padding: 0 16px; font: 600 15px "Prompt", sans-serif; color: #1a1205; cursor: pointer; }
.chat-form button:disabled { opacity: .5; }
@media (max-width: 640px) {
  /* มือถือ: ใช้ปุ่มแชตตรงกลางแถบเมนูล่างแทนปุ่มลอย (ยกเว้นหน้าชำระเงินที่ไม่มีแถบเมนู) */
  body:not([data-page="pay"]) .chat-fab { display: none; }
  .chat-fab { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .chat-panel { inset: 0; width: auto; height: auto; border-radius: 0; z-index: 60; }
}
