/* ── Messenger-Style Floating Provider Chat ────────────── */

/* ── Chat Head Tray ─────────────────────────────────────── */
.messenger-tray {
  position: fixed;
  bottom: 80px; /* above the input bar */
  right: 16px;
  z-index: 900;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-direction: row-reverse; /* newest = rightmost */
  pointer-events: none;
  /* Item 6: horizontal scroll for 4+ heads */
  max-width: calc(4 * 52px + 16px); /* 4 heads at 44px + 8px gap each */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}
.messenger-tray::-webkit-scrollbar { display: none; }
.messenger-tray > * {
  pointer-events: auto;
  scroll-snap-align: end;
}
.messenger-tray.messenger-tray--hidden { display: none; }

/* Individual chat head bubble */
/* Item 4: 48→44px per plan spec */
.chat-head {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--card-bg, #fffdf8);
  background: var(--chip-bg, #f0ece2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  flex-shrink: 0;
  animation: chatHeadPop 0.3s ease-out;
}
.chat-head:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}
.chat-head:active { transform: scale(0.95); }

.chat-head img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.chat-head__initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--chip-bg, #f0ece2);
}

/* Unread badge */
/* Item 14: badge pulse animation */
.chat-head__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--card-bg, #fffdf8);
  line-height: 1;
  animation: badgePulse 0.3s ease-out;
}

/* Online indicator */
.chat-head__online {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #43a047;
  border: 2px solid var(--card-bg, #fffdf8);
}

@keyframes chatHeadPop {
  0%   { opacity: 0; transform: scale(0.5) translateY(10px); }
  60%  { transform: scale(1.1) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Item 14: badge pulse keyframe */
@keyframes badgePulse {
  0%   { opacity: 0; transform: scale(0.5); }
  60%  { transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Floating Chat Window ───────────────────────────────── */
/* Item 4: bottom updated from 136→132px (80+44+8) */
.chat-window {
  position: fixed;
  bottom: 132px; /* above tray (80+44+8) */
  right: 16px;
  width: 360px;
  height: 480px;
  background: var(--card-bg, #fffdf8);
  border: 1px solid var(--border, #e0dcd4);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 950;
  animation: chatWindowSlideUp 0.25s ease-out;
}
.chat-window--minimized {
  display: none;
}
/* Item 3: close/minimize animation */
.chat-window--closing {
  animation: chatWindowSlideDown 0.2s ease-in forwards;
  pointer-events: none;
}
/* Window stacking: second window is positioned via JS inline style */

@keyframes chatWindowSlideUp {
  0%   { opacity: 0; transform: translateY(20px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Item 3: reverse animation for close/minimize */
@keyframes chatWindowSlideDown {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(20px) scale(0.95); }
}

/* Window header */
.cw-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg, #faf8f4);
  border-bottom: 1px solid var(--border, #e0dcd4);
  min-height: 44px;
  flex-shrink: 0;
  cursor: grab;
}
.cw-header:active { cursor: grabbing; }

.cw-header__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--chip-bg);
}
.cw-header__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cw-header__avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.cw-header__info {
  flex: 1;
  min-width: 0;
}
.cw-header__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cw-header__status {
  font-size: 11px;
  color: var(--text-muted);
}

.cw-header__milestone {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.cw-header__milestone--scoping { background: var(--chip-bg); color: var(--text-muted); }
.cw-header__milestone--quote { background: var(--gold-light, #fdf3d5); color: var(--gold-dark, #8B6914); }
.cw-header__milestone--payment { background: #e8f5e9; color: #2e7d32; }
.cw-header__milestone--booked { background: var(--gold-light, #fdf3d5); color: var(--gold-dark, #8B6914); }

.cw-header__actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.cw-header__btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}
.cw-header__btn:hover { background: var(--chip-bg); }

/* Quick actions bar */
/* Item 5: min-height→36px, larger buttons */
.cw-actions {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border, #e0dcd4);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  min-height: 36px;
  align-items: center;
}
.cw-actions::-webkit-scrollbar { display: none; }

/* Item 5: larger action buttons */
.cw-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border, #e0dcd4);
  border-radius: 16px;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.cw-action-btn:hover {
  background: var(--chip-bg);
  border-color: var(--accent);
}
.cw-action-btn__icon { font-size: 13px; }

/* Message thread */
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Message bubbles */
.cw-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}
.cw-msg--client {
  align-self: flex-end;
  background: var(--accent, #8B6914);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cw-msg--provider {
  align-self: flex-start;
  background: var(--chip-bg, #f0ece2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.cw-msg--system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
  text-align: center;
  padding: 4px 8px;
  max-width: 90%;
}
.cw-msg--ai {
  align-self: flex-start;
  background: var(--gold-light, #fdf3d5);
  color: var(--text);
  border: 1px solid var(--accent-light, rgba(139,105,20,0.15));
  border-bottom-left-radius: 4px;
}
.cw-msg--ai::before {
  content: '\1F4A1';
  margin-right: 4px;
}

.cw-msg__time {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  margin-top: 2px;
  text-align: right;
}
.cw-msg--provider .cw-msg__time,
.cw-msg--ai .cw-msg__time {
  color: var(--text-muted);
}

/* Typing indicator in chat window */
.cw-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 8px 14px;
  background: var(--chip-bg);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.cw-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.cw-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.cw-typing__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Input area */
.cw-input {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border, #e0dcd4);
  background: var(--bg, #faf8f4);
  flex-shrink: 0;
}
.cw-input__field {
  flex: 1;
  border: 1px solid var(--border, #e0dcd4);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  background: var(--card-bg, #fffdf8);
  color: var(--text);
  outline: none;
  min-height: 32px;
  resize: none;
  font-family: inherit;
}
.cw-input__field:focus { border-color: var(--accent); }
.cw-input__field::placeholder { color: var(--text-muted); }

.cw-input__send {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--accent, #8B6914);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: opacity 0.1s;
}
.cw-input__send:disabled { opacity: 0.4; cursor: not-allowed; }
.cw-input__send:hover:not(:disabled) { opacity: 0.85; }

/* ── Quick Action Panels (slide-in overlays) ────────────── */
.cw-panel {
  position: absolute;
  top: 44px; /* below header */
  left: 0;
  right: 0;
  bottom: 44px; /* above input */
  background: var(--card-bg, #fffdf8);
  z-index: 5;
  overflow-y: auto;
  padding: 16px;
  animation: panelSlideIn 0.2s ease-out;
}
.cw-panel--hidden { display: none; }

@keyframes panelSlideIn {
  0%   { opacity: 0; transform: translateX(20px); }
  100% { opacity: 1; transform: translateX(0); }
}

.cw-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cw-panel__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.cw-panel__close {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  border-radius: 4px;
}
.cw-panel__close:hover { background: var(--chip-bg); }

/* Quote panel */
.cw-quote-summary {
  background: var(--bg, #faf8f4);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.cw-quote-total {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.cw-quote-status {
  font-size: 12px;
  color: var(--text-muted);
}
.cw-quote-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border, #e0dcd4);
}
.cw-quote-line:last-child { border-bottom: none; }

.cw-quote-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.cw-quote-actions button {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.1s;
}
.cw-quote-actions .cw-btn-accept {
  background: var(--accent, #8B6914);
  color: #fff;
  border-color: var(--accent);
}
.cw-quote-actions .cw-btn-negotiate {
  background: transparent;
  color: var(--text);
}

/* Contact panel */
.cw-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.1s;
}
.cw-contact-item:hover { background: var(--chip-bg); }
.cw-contact-item__icon { font-size: 18px; }
.cw-contact-item__label { font-size: 12px; color: var(--text-muted); }
.cw-contact-item__value { font-size: 14px; font-weight: 500; color: var(--text); }

/* Quick questions */
.cw-quick-q {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  margin-bottom: 6px;
  transition: background 0.1s, border-color 0.1s;
}
.cw-quick-q:hover {
  background: var(--chip-bg);
  border-color: var(--accent);
}

/* ── Item 16: Scope Change Form ────────────────────────── */
.cw-scope-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cw-scope-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border, #e0dcd4);
}
.cw-scope-field:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.cw-scope-field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.cw-scope-input {
  padding: 8px 10px;
  border: 1px solid var(--border, #e0dcd4);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg, #fffdf8);
  outline: none;
  transition: border-color 0.15s;
}
.cw-scope-input:focus {
  border-color: var(--accent, #8B6914);
}
.cw-scope-input--number {
  width: 60px;
  text-align: center;
  -moz-appearance: textfield;
}
.cw-scope-input--number::-webkit-outer-spin-button,
.cw-scope-input--number::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.cw-scope-textarea {
  padding: 8px 10px;
  border: 1px solid var(--border, #e0dcd4);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg, #fffdf8);
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.15s;
}
.cw-scope-textarea:focus {
  border-color: var(--accent, #8B6914);
}
.cw-scope-counter {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cw-scope-counter__btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border, #e0dcd4);
  border-radius: 8px;
  background: var(--bg, #faf8f4);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s;
  -webkit-user-select: none;
  user-select: none;
}
.cw-scope-counter__btn:hover {
  background: var(--chip-bg, #f0ece2);
  border-color: var(--accent, #8B6914);
}
.cw-scope-counter__btn:active {
  transform: scale(0.95);
}
.cw-scope-submit {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent, #8B6914);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.cw-scope-submit:hover {
  opacity: 0.9;
}
.cw-scope-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Item 11: Star Rating Panel ────────────────────────── */
.cw-rate-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}
.cw-stars {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.cw-star {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  padding: 0;
  transition: transform 0.12s ease;
  color: var(--text-muted, #999);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cw-star:hover {
  transform: scale(1.2);
}
.cw-star:active {
  transform: scale(0.9);
}
.cw-star--filled {
  color: #f5a623;
}
.cw-rate-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  min-height: 20px;
}
.cw-rate-comment {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border, #e0dcd4);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg, #fffdf8);
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.15s;
}
.cw-rate-comment:focus {
  border-color: var(--accent, #8B6914);
}
.cw-rate-comment::placeholder {
  color: var(--text-muted);
}
.cw-rate-submit {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent, #8B6914);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.cw-rate-submit:hover {
  opacity: 0.9;
}
.cw-rate-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── AI Suggestion Card (inline in message thread) ──────── */
.cw-ai-suggestion {
  align-self: flex-start;
  background: var(--gold-light, #fdf3d5);
  border: 1px dashed var(--accent, #8B6914);
  border-radius: 10px;
  padding: 8px 12px;
  max-width: 85%;
  cursor: pointer;
  transition: background 0.1s;
}
.cw-ai-suggestion:hover { background: #fceed0; }
.cw-ai-suggestion__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.cw-ai-suggestion__text {
  font-size: 12px;
  color: var(--text);
}

/* ── Suggestion Block (bottom of message thread) ─────────── */
.cw-suggestions {
  padding: 8px 12px;
  margin-top: 8px;
  border-top: 1px dashed var(--accent, #8B6914);
}
.cw-suggestions__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent, #8B6914);
  margin-bottom: 6px;
}
.cw-suggestion-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: var(--gold-light, #fdf3d5);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.cw-suggestion-btn:hover {
  border-color: var(--accent, #8B6914);
  background: #fceed0;
}

/* ── Summary Card (in main AI conversation) ─────────────── */
.provider-summary-card {
  background: var(--card-bg, #fffdf8);
  border: 1px solid var(--border, #e0dcd4);
  border-radius: var(--radius-md, 12px);
  margin: 8px 0;
  overflow: hidden;
}
.psc-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  background: var(--success, #2d8a56);
  padding: 10px 16px;
}
.psc-header-icon { font-size: 16px; }
.psc-body { padding: 14px 16px; }
.psc-provider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.psc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--chip-bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  object-fit: cover;
}
.psc-avatar--initials {
  display: flex;
}
.psc-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.psc-provider-info { flex: 1; }
.psc-provider-name { font-size: 14px; font-weight: 600; color: var(--text); }
.psc-provider-status { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.psc-chat-btn {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: 1px solid var(--accent, #b8860b);
  border-radius: 8px;
  background: transparent;
  color: var(--accent, #b8860b);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}
.psc-chat-btn:hover { background: var(--chip-bg, #f5f0e8); }

/* ── Notification Toast ─────────────────────────────────── */
.msg-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--card-bg, #fffdf8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  animation: toastSlideIn 0.25s ease-out;
  cursor: pointer;
  max-width: 320px;
}
.msg-toast__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.msg-toast__avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-toast__name { font-size: 12px; font-weight: 600; color: var(--text); }
.msg-toast__text { font-size: 12px; color: var(--text-muted); }
.msg-toast--exiting { animation: toastSlideOut 0.2s ease-in forwards; }

@keyframes toastSlideIn {
  0% { opacity: 0; transform: translateX(40px); }
  100% { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
  0% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(40px); }
}

/* ── Mobile Responsive ──────────────────────────────────── */
@media (max-width: 480px) {
  .messenger-tray {
    bottom: 72px;
    right: 12px;
  }

  /* Collapse to FAB */
  .messenger-tray--mobile-collapsed .chat-head { display: none; }
  .messenger-tray--mobile-collapsed .chat-head:first-child { display: block; }
  .messenger-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent, #8B6914);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
  }
  /* Item 14: badge pulse on mobile FAB badge */
  .messenger-fab__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--card-bg);
    animation: badgePulse 0.3s ease-out;
  }

  /* Full-width bottom sheet */
  .chat-window {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 85vh;
    border-radius: 16px 16px 0 0;
    animation: sheetSlideUp 0.25s ease-out;
  }
  /* Item 3: mobile close animation */
  .chat-window--closing {
    animation: sheetSlideDown 0.25s ease-in forwards;
    pointer-events: none;
  }
  .chat-window:nth-of-type(2) { right: 0; } /* override desktop stacking */

  @keyframes sheetSlideUp {
    0% { transform: translateY(100%); }
    100% { transform: translateY(0); }
  }
  /* Item 3: reverse for mobile close */
  @keyframes sheetSlideDown {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
  }

  /* Item 7: Mobile backdrop/scrim */
  .messenger-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 940;
    animation: backdropFadeIn 0.2s ease-out;
  }
  .messenger-backdrop--closing {
    animation: backdropFadeOut 0.2s ease-in forwards;
  }
  @keyframes backdropFadeIn {
    0%   { opacity: 0; }
    100% { opacity: 1; }
  }
  @keyframes backdropFadeOut {
    0%   { opacity: 1; }
    100% { opacity: 0; }
  }

  .msg-toast { right: 12px; left: 12px; max-width: none; }

  .messenger-mobile-picker {
    position: absolute;
    bottom: 64px;
    right: 0;
    background: var(--card-bg, #fff);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 200px;
    overflow: hidden;
    z-index: 10001;
  }
  .messenger-mobile-picker__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
    border-bottom: 1px solid var(--border, #e0dcd4);
  }
  .messenger-mobile-picker__item:last-child { border-bottom: none; }
  .messenger-mobile-picker__item:hover { background: var(--chip-bg, #f5f0e8); }
}

@media (min-width: 481px) and (max-width: 768px) {
  .chat-window {
    width: 320px;
    height: 420px;
    bottom: 128px;
  }
}
