/* ============================================================================
   ReelPip Live Support Messenger — 100% Pixel-Matched Modern Messenger UI
   Compact Grouped Bubbles, Settings Modal, Typing Dots, Read Receipts & RTL/LTR
   ============================================================================ */
:root {
  --rpm-bg-side: #ffffff;
  --rpm-bg-main: #f3f6fb;
  --rpm-bg-head: #ffffff;
  --rpm-bg-input: #f1f4f9;
  --rpm-border: #e2e8f0;
  --rpm-border2: #cbd5e1;
  --rpm-ink: #0f172a;
  --rpm-ink2: #475569;
  --rpm-ink3: #64748b;
  --rpm-row-hover: #f1f5f9;
  --rpm-row-active: #e6f2ff;
  --rpm-in-bg: #ffffff;
  --rpm-in-border: #e2e8f0;
  --rpm-in-ink: #0f172a;
  --rpm-out-bg: #2580cc;
  --rpm-out-ink: #ffffff;
  --rpm-accent: #3898f3;
  --rpm-accent-h: #2583de;
  --rpm-menu-bg: #ffffff;
  --rpm-menu-hover: #f1f5f9;
  --rpm-shadow: 0 24px 64px rgba(15, 23, 42, .22), 0 4px 16px rgba(15, 23, 42, .08);
}

html[data-theme="dark"] {
  --rpm-bg-side: #111419;
  --rpm-bg-main: #1f232b;
  --rpm-bg-head: #15181e;
  --rpm-bg-input: #1d2129;
  --rpm-border: #262b35;
  --rpm-border2: #343b49;
  --rpm-ink: #f1f5f9;
  --rpm-ink2: #cbd5e1;
  --rpm-ink3: #838e9f;
  --rpm-row-hover: #1b1f27;
  --rpm-row-active: #272d38;
  --rpm-in-bg: #15181e;
  --rpm-in-border: rgba(255, 255, 255, .06);
  --rpm-in-ink: #edf2f7;
  --rpm-out-bg: #2480cc;
  --rpm-out-ink: #ffffff;
  --rpm-accent: #3fa2ff;
  --rpm-accent-h: #2588eb;
  --rpm-menu-bg: #1b1f27;
  --rpm-menu-hover: #262c37;
  --rpm-shadow: 0 28px 75px rgba(0, 0, 0, .64), 0 0 0 1px rgba(255, 255, 255, .07);
}

/* Floating Launcher Button */
.rpm-fab {
  position: fixed;
  inset-inline-end: 22px;
  bottom: 22px;
  z-index: 950;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #42a5ff 0%, #1d7de0 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(30, 125, 224, .45), 0 0 0 1px rgba(255, 255, 255, .16) inset;
  transition: transform .18s ease, box-shadow .18s ease;
}
.rpm-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 16px 36px rgba(30, 125, 224, .58);
}
.rpm-fab-dot {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #0f172a;
}
.rpm-fab-dot.is-offline { background: #64748b; }
.rpm-fab.rpm-hidden { display: none !important; }
.rpm-head-close-btn { display: none; }
.rpm-disabled-card {
  max-width: 540px;
  margin: 48px auto;
  padding: 28px 24px;
  border-radius: 14px;
  border: 1px solid var(--rpm-border2);
  background: var(--rpm-bg-head);
  color: var(--rpm-ink);
  text-align: center;
  box-shadow: var(--rpm-shadow);
}
.rpm-disabled-card h2 { margin: 0 0 8px; font-size: 19px; font-weight: 800; }
.rpm-disabled-card p { margin: 0 0 18px; font-size: 13.5px; color: var(--rpm-ink3); line-height: 1.6; }
.rpm-disabled-acts { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.rpm-disabled-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 9px;
  background: var(--rpm-accent); color: #fff; font-size: 13px; font-weight: 700; text-decoration: none;
}
.rpm-disabled-btn.ghost { background: var(--rpm-bg-input); color: var(--rpm-ink); border: 1px solid var(--rpm-border2); }

/* Pixel-Matched Dark Waveform Voice Note Player & Mic Recorder */
.rpm-voice-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 245px;
  max-width: 318px;
  padding: 4px 2px 2px;
}
.rpm-voice-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  flex-shrink: 0;
  background: rgba(148, 163, 184, .22);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .13s, background .15s;
}
.rpm-msg-row.out .rpm-voice-play { background: rgba(255, 255, 255, .22); }
html[data-theme="light"] .rpm-msg-row.in .rpm-voice-play { background: #e2e8f0; color: #0f172a; }
.rpm-voice-play:hover { transform: scale(1.06); background: rgba(148, 163, 184, .34); }
.rpm-msg-row.out .rpm-voice-play:hover { background: rgba(255, 255, 255, .32); }
.rpm-voice-wave {
  flex: 1;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 2.5px;
  cursor: pointer;
  user-select: none;
  min-width: 110px;
}
.rpm-voice-bar {
  flex: 1;
  min-width: 2.5px;
  max-width: 4px;
  border-radius: 99px;
  background: rgba(148, 163, 184, .48);
  transition: background .1s;
}
.rpm-msg-row.out .rpm-voice-bar { background: rgba(255, 255, 255, .42); }
.rpm-voice-bar.played { background: #e2e8f0; }
html[data-theme="light"] .rpm-msg-row.in .rpm-voice-bar.played { background: #2580cc; }
.rpm-msg-row.out .rpm-voice-bar.played { background: #ffffff; }
.rpm-voice-dur {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: .88;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 32px;
  text-align: end;
}
.rpm-rec-bar {
  display: none;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: rgba(239, 68, 68, .13);
  border: 1px solid rgba(239, 68, 68, .38);
  color: var(--rpm-ink);
}
.rpm-rec-bar.active { display: flex; }
.rpm-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: rpmRecPulse 1s infinite ease-in-out;
}
@keyframes rpmRecPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.82); } }
.rpm-rec-timer { font-size: 12.8px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 40px; color: #f87171; }
.rpm-rec-bars { flex: 1; height: 22px; display: flex; align-items: center; gap: 2.5px; overflow: hidden; }
.rpm-rec-bars span { flex: 1; min-width: 2px; border-radius: 99px; background: #f87171; height: 22%; transition: height .09s linear; }
.rpm-rec-cancel {
  border: 1px solid var(--rpm-border2);
  background: transparent;
  color: var(--rpm-ink2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.rpm-rec-cancel:hover { border-color: #f87171; color: #f87171; }
.rpm-rec-send {
  border: none;
  background: #22c55e;
  color: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
}
.rpm-rec-send:hover { filter: brightness(1.08); }
.rpm-pill-btn.recording { color: #ef4444; background: rgba(239, 68, 68, .15); }
.rpm-fab-badge {
  position: absolute;
  top: -4px;
  inset-inline-start: -4px;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(239, 68, 68, .55);
}
.rpm-fab-badge.hidden { display: none !important; }

/* Corner Away-From-Messenger Notification Card */
.rpm-corner-note {
  position: fixed;
  inset-inline-end: 22px;
  bottom: 88px;
  z-index: 955;
  width: 310px;
  max-width: calc(100vw - 32px);
  background: var(--rpm-menu-bg);
  border: 1px solid var(--rpm-border2);
  border-radius: 12px;
  padding: 11px 13px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  display: none;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--rpm-ink);
  font-family: "Inter", "IBM Plex Sans Arabic", -apple-system, sans-serif;
}
.rpm-corner-note.open { display: flex; }
.rpm-corner-body { flex: 1; min-width: 0; }
.rpm-corner-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rpm-corner-txt { font-size: 12px; color: var(--rpm-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.rpm-corner-x { border: none; background: transparent; color: var(--rpm-ink3); font-size: 16px; cursor: pointer; padding: 2px 4px; }

/* Backdrop & Wide Floating Popup Container */
.rpm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 960;
  background: rgba(5, 8, 14, .58);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.rpm-backdrop.open { display: flex; }

.rpm-shell {
  width: 100%;
  max-width: min(1220px, calc(100vw - 32px));
  height: min(740px, calc(100vh - 36px));
  background: var(--rpm-bg-side);
  border: 1px solid var(--rpm-border);
  border-radius: 14px;
  box-shadow: var(--rpm-shadow);
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  overflow: hidden;
  font-family: "Inter", "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--rpm-ink);
  position: relative;
}
.rpm-shell.rpm-fullpage {
  max-width: 1400px;
  height: min(790px, calc(100vh - 135px));
  min-height: 560px;
  margin: 0 auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
}
.rpm-shell.rpm-expanded {
  max-width: min(1400px, calc(100vw - 20px));
  height: calc(100vh - 24px);
}

/* Left Sidebar */
.rpm-side {
  background: var(--rpm-bg-side);
  border-inline-end: 1px solid var(--rpm-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.rpm-side-head {
  padding: 15px 15px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rpm-side-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--rpm-ink);
}
.rpm-icon-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rpm-ibtn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--rpm-ink3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .14s, color .14s;
}
.rpm-ibtn:hover, .rpm-ibtn.active {
  background: var(--rpm-row-hover);
  color: var(--rpm-ink);
}

/* Search + Filter + Blue Circular Compose Row (Exact Image 7!) */
.rpm-search-row {
  padding: 4px 14px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rpm-search-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
.rpm-search-inp {
  width: 100%;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--rpm-border);
  background: var(--rpm-bg-input);
  color: var(--rpm-ink);
  font-family: inherit;
  font-size: 13px;
  padding: 0 15px;
  outline: none;
  transition: border-color .15s;
}
.rpm-search-inp::placeholder { color: var(--rpm-ink3); }
.rpm-search-inp:focus { border-color: var(--rpm-accent); }

.rpm-new-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #48a7ff 0%, #2686e8 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(45, 142, 224, .38);
  transition: transform .14s, filter .14s;
}
.rpm-new-btn:hover { transform: scale(1.06); filter: brightness(1.08); }

/* Segmented Tabs: Inbox | Archived */
.rpm-tabs {
  padding: 0 14px 11px;
  border-bottom: 1px solid var(--rpm-border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.rpm-tab {
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--rpm-ink2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.rpm-tab:hover { background: var(--rpm-row-hover); color: var(--rpm-ink); }
.rpm-tab.active {
  background: linear-gradient(135deg, #47a6ff 0%, #2d8df0 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(45, 141, 240, .32);
}
.rpm-tab-cnt {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .2);
}
.rpm-tab:not(.active) .rpm-tab-cnt {
  background: var(--rpm-bg-input);
  color: var(--rpm-ink3);
}

/* Conversation List */
.rpm-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rpm-list::-webkit-scrollbar, .rpm-thread::-webkit-scrollbar, .rpm-set-body::-webkit-scrollbar { width: 6px; }
.rpm-list::-webkit-scrollbar-thumb, .rpm-thread::-webkit-scrollbar-thumb, .rpm-set-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, .24);
  border-radius: 999px;
}

.rpm-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 11px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .14s, border-color .14s;
}
.rpm-row:hover { background: var(--rpm-row-hover); }
.rpm-row.active {
  background: var(--rpm-row-active);
  border-color: transparent;
}
.rpm-row.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 10px;
  bottom: 10px;
  width: 3.5px;
  border-radius: 4px;
  background: var(--rpm-accent);
}
.rpm-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8 0%, #0ea5e9 100%);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, .12);
}
.rpm-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rpm-av-sm { width: 38px; height: 38px; font-size: 13px; }
.rpm-av-xs { width: 30px; height: 30px; font-size: 11px; }
.rpm-av-spacer { width: 30px; height: 30px; flex-shrink: 0; }
.rpm-av-wrap { position: relative; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.rpm-online-dot {
  position: absolute;
  bottom: 1px;
  inset-inline-end: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--rpm-bg-side);
}
.rpm-row-body { flex: 1; min-width: 0; }
.rpm-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}
.rpm-row-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--rpm-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.rpm-row-time {
  font-size: 11px;
  color: var(--rpm-ink3);
  white-space: nowrap;
  flex-shrink: 0;
}
.rpm-row-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.rpm-row-prev {
  font-size: 12.2px;
  color: var(--rpm-ink3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rpm-row.unread .rpm-row-prev { color: var(--rpm-ink); font-weight: 600; }
.rpm-unread-pill {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--rpm-accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rpm-pin-ico { font-size: 11px; opacity: .75; }

/* Right Main Pane */
.rpm-main {
  background: var(--rpm-bg-main);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.rpm-main.wp-dots {
  background-image: radial-gradient(rgba(148, 163, 184, .11) 1px, transparent 1px);
  background-size: 18px 18px;
}
.rpm-main.wp-grid {
  background-image:
    linear-gradient(rgba(148, 163, 184, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .06) 1px, transparent 1px);
  background-size: 26px 26px;
}
.rpm-main.wp-glow {
  background-image:
    radial-gradient(circle at 20% 20%, rgba(56, 152, 243, .11), transparent 45%),
    radial-gradient(circle at 80% 75%, rgba(20, 184, 166, .09), transparent 45%);
}

.rpm-head {
  padding: 11px 16px;
  background: var(--rpm-bg-head);
  border-bottom: 1px solid var(--rpm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 60px;
  position: relative;
}
.rpm-head-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.rpm-back-btn { display: none; }
.rpm-head-meta { min-width: 0; }
.rpm-head-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--rpm-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rpm-head-sub {
  font-size: 11.8px;
  color: var(--rpm-ink3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rpm-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  flex-shrink: 0;
}
.rpm-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

/* In-Chat Search Strip */
.rpm-inchat-search {
  display: none;
  padding: 8px 16px;
  background: var(--rpm-bg-head);
  border-bottom: 1px solid var(--rpm-border);
  align-items: center;
  gap: 8px;
}
.rpm-inchat-search.open { display: flex; }
.rpm-inchat-search input {
  flex: 1;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--rpm-border2);
  background: var(--rpm-bg-input);
  color: var(--rpm-ink);
  padding: 0 11px;
  font-size: 12.5px;
  outline: none;
}

/* 3-Dots Context Menu (Exact Image 5 & 11 Style!) */
.rpm-menu {
  position: absolute;
  top: 46px;
  inset-inline-end: 0;
  width: 248px;
  background: var(--rpm-menu-bg);
  border: 1px solid var(--rpm-border2);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .48);
  z-index: 60;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.rpm-menu.open { display: flex; }
.rpm-menu-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--rpm-ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: start;
  transition: background .12s;
}
.rpm-menu-item:hover { background: var(--rpm-menu-hover); }
.rpm-menu-item svg { width: 16px; height: 16px; color: var(--rpm-ink3); flex-shrink: 0; }
.rpm-menu-item.danger { color: #f87171; }
.rpm-menu-item.danger svg { color: #f87171; }
.rpm-menu-sep {
  height: 1px;
  background: var(--rpm-border);
  margin: 4px 6px;
}

/* Thread Messages — COMPACT, TIGHT, GROUPED (100% Match to Images 1, 2, 5, 6!) */
.rpm-thread-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rpm-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
}
.rpm-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  max-width: 78%;
}
.rpm-msg-row.grp-start { margin-top: 10px; }
.rpm-msg-row:first-child { margin-top: 0; }
.rpm-msg-row.in { align-self: flex-start; }
.rpm-msg-row.out { align-self: flex-end; flex-direction: row-reverse; }

/* CRITICAL: NO white-space: pre-wrap on .rpm-bubble! Only on .rpm-bubble-text! */
.rpm-bubble {
  padding: 9px 14px 7px;
  border-radius: 16px;
  font-size: 13.8px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  min-width: 0;
}
.rpm-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.rpm-msg-row.in .rpm-bubble {
  background: var(--rpm-in-bg);
  border: 1px solid var(--rpm-in-border);
  color: var(--rpm-in-ink);
}
.rpm-msg-row.in.grp-mid .rpm-bubble { border-start-start-radius: 5px; border-end-start-radius: 5px; }
.rpm-msg-row.in.grp-first .rpm-bubble { border-end-start-radius: 5px; }
.rpm-msg-row.in.grp-last .rpm-bubble { border-start-start-radius: 5px; border-end-start-radius: 4px; }
.rpm-msg-row.in.grp-single .rpm-bubble { border-end-start-radius: 4px; }

.rpm-msg-row.out .rpm-bubble {
  background: var(--rpm-out-bg);
  color: var(--rpm-out-ink);
}
.rpm-msg-row.out.grp-mid .rpm-bubble { border-start-end-radius: 5px; border-end-end-radius: 5px; }
.rpm-msg-row.out.grp-first .rpm-bubble { border-end-end-radius: 5px; }
.rpm-msg-row.out.grp-last .rpm-bubble { border-start-end-radius: 5px; border-end-end-radius: 4px; }
.rpm-msg-row.out.grp-single .rpm-bubble { border-end-end-radius: 4px; }

.rpm-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rpm-msg-row.in .rpm-bubble a { color: #5eb2ff; }
html[data-theme="light"] .rpm-msg-row.in .rpm-bubble a { color: #0b74de; }

.rpm-bubble-foot {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 11px;
  line-height: 1.2;
  opacity: .72;
}
.rpm-msg-row.in .rpm-bubble-foot { justify-content: flex-start; }
.rpm-msg-more {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0 3px;
  font-size: 12px;
  line-height: 1;
  opacity: .7;
  border-radius: 4px;
}
.rpm-msg-more:hover { opacity: 1; background: rgba(255, 255, 255, .14); }
.rpm-ticks { display: inline-flex; align-items: center; vertical-align: middle; opacity: .92; }
.rpm-ticks.read { opacity: 1; }
.rpm-tick-svg { display: block; }
.rpm-msg-match .rpm-bubble { outline: 2px solid #f59e0b; outline-offset: 2px; }

/* Animated 3-dot Typing Indicator Bubble */
.rpm-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
}
.rpm-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rpm-ink3);
  animation: rpmBounce 1.2s infinite ease-in-out;
}
.rpm-typing-dots span:nth-child(2) { animation-delay: .18s; }
.rpm-typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes rpmBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Floating Scroll-to-Bottom Button (Exact Image 2!) */
.rpm-scroll-down {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--rpm-border2);
  background: rgba(21, 24, 30, .92);
  color: #f1f5f9;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .42);
  z-index: 25;
  transition: transform .14s;
}
.rpm-scroll-down.show { display: inline-flex; }
.rpm-scroll-down:hover { transform: translateX(-50%) scale(1.07); }

.rpm-att-grid {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.rpm-att-img {
  max-width: 240px;
  max-height: 180px;
  border-radius: 10px;
  cursor: zoom-in;
  display: block;
  border: 1px solid rgba(255, 255, 255, .12);
}
.rpm-att-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .2);
  color: inherit;
  font-size: 12px;
  text-decoration: none !important;
}
html[data-theme="light"] .rpm-msg-row.in .rpm-att-file { background: #f1f5f9; }

/* Compact Optional Visitor Info Strip */
.rpm-visitor-bar {
  padding: 8px 16px;
  background: var(--rpm-bg-head);
  border-top: 1px solid var(--rpm-border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rpm-visitor-bar input {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--rpm-border2);
  background: var(--rpm-bg-input);
  color: var(--rpm-ink);
  font-family: inherit;
  font-size: 12.5px;
  padding: 0 11px;
  outline: none;
}
.rpm-visitor-bar input:focus { border-color: var(--rpm-accent); }

/* Bottom Composer */
.rpm-composer-wrap {
  padding: 10px 16px 12px;
  background: var(--rpm-bg-head);
  border-top: 1px solid var(--rpm-border);
  position: relative;
}
.rpm-staged {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.rpm-staged:empty { display: none; }
.rpm-staged-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--rpm-bg-input);
  border: 1px solid var(--rpm-border2);
  font-size: 11.8px;
  color: var(--rpm-ink);
}
.rpm-staged-chip img { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; }
.rpm-staged-chip button {
  border: none;
  background: transparent;
  color: #ef4444;
  font-weight: 800;
  cursor: pointer;
  padding: 0 2px;
}

.rpm-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.rpm-pill {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--rpm-bg-input);
  border: 1px solid var(--rpm-border2);
  border-radius: 22px;
  padding: 5px 10px 5px 12px;
  transition: border-color .15s;
}
.rpm-pill:focus-within { border-color: var(--rpm-accent); }
.rpm-ta {
  flex: 1;
  min-height: 28px;
  max-height: 130px;
  border: none;
  background: transparent;
  color: var(--rpm-ink);
  font-family: inherit;
  font-size: 13.6px;
  line-height: 1.45;
  padding: 4px 4px;
  resize: none;
  outline: none;
}
.rpm-ta::placeholder { color: var(--rpm-ink3); }
.rpm-pill-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--rpm-ink3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .14s, background .14s;
}
.rpm-pill-btn:hover, .rpm-pill-btn.active {
  color: var(--rpm-accent);
  background: rgba(63, 162, 255, .12);
}

.rpm-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #252b36;
  color: #8b95a7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .14s, background .16s, color .16s, box-shadow .16s, opacity .14s;
}
html[data-theme="light"] .rpm-send-btn {
  background: #e2e8f0;
  color: #64748b;
}
.rpm-send-btn.ready, .rpm-send-btn:hover {
  background: #3898f3;
  color: #ffffff;
  box-shadow: 0 5px 16px rgba(56, 152, 243, .38);
}
.rpm-send-btn:hover { transform: scale(1.05); }
.rpm-send-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Categorized Dark Emoji Picker Popover */
.rpm-emoji-pop {
  position: absolute;
  bottom: 64px;
  inset-inline-end: 58px;
  width: 316px;
  max-width: calc(100% - 24px);
  background: #14171d;
  border: 1px solid #2b313e;
  border-radius: 13px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, .58);
  z-index: 80;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
html[data-theme="light"] .rpm-emoji-pop {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 18px 44px rgba(15, 23, 42, .22);
}
.rpm-emoji-pop.open { display: flex; }
.rpm-emoji-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, .16);
  gap: 2px;
}
.rpm-emoji-tab {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .68;
  transition: background .12s, opacity .12s;
}
.rpm-emoji-tab:hover { background: rgba(148, 163, 184, .14); opacity: 1; }
.rpm-emoji-tab.active { background: #3898f3; opacity: 1; }
.rpm-emoji-cat-lbl {
  padding: 7px 12px 4px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--rpm-ink3);
}
.rpm-emoji-grid {
  padding: 4px 8px 10px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 215px;
  overflow-y: auto;
}
.rpm-emoji-btn {
  height: 34px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, transform .1s;
}
.rpm-emoji-btn:hover { background: rgba(148, 163, 184, .16); transform: scale(1.16); }

/* Messenger Settings Modal (EXACT MATCH to Images 8 & 9!) */
.rpm-submodal {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 14, .74);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.rpm-submodal.open { display: flex; }
.rpm-subcard {
  width: 100%;
  max-width: 560px;
  max-height: 90%;
  background: var(--rpm-bg-head);
  border: 1px solid var(--rpm-border2);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .58);
}
.rpm-subhead {
  padding: 15px 18px;
  border-bottom: 1px solid var(--rpm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 15.5px;
  color: var(--rpm-ink);
}
.rpm-subbody, .rpm-set-body {
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.rpm-subbody { padding: 14px 16px; gap: 10px; }
.rpm-set-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--rpm-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rpm-set-lbl { font-size: 13.8px; font-weight: 700; color: var(--rpm-ink); }
.rpm-set-desc { font-size: 12.2px; color: var(--rpm-ink3); line-height: 1.45; }
.rpm-set-sec {
  padding: 14px 18px 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--rpm-ink);
  border-bottom: 1px solid var(--rpm-border);
  background: rgba(255, 255, 255, .015);
}
.rpm-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.rpm-switch input { opacity: 0; width: 0; height: 0; }
.rpm-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #374151;
  border-radius: 999px;
  transition: background .18s;
}
.rpm-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.rpm-switch input:checked + .rpm-slider { background: #22c55e; }
.rpm-switch input:checked + .rpm-slider::before { transform: translateX(20px); }
.rpm-set-select {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--rpm-border2);
  background: var(--rpm-bg-input);
  color: var(--rpm-ink);
  font-family: inherit;
  font-size: 13.5px;
  padding: 0 12px;
  outline: none;
}
.rpm-set-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--rpm-border);
  display: flex;
  justify-content: center;
  background: var(--rpm-bg-head);
}
.rpm-set-save {
  min-width: 96px;
  height: 38px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #47a6ff 0%, #2686e8 100%);
  color: #ffffff;
  font-family: inherit;
  font-size: 13.8px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 22px;
  box-shadow: 0 4px 14px rgba(38, 134, 232, .35);
}
.rpm-set-save:hover { filter: brightness(1.07); }

.rpm-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.rpm-media-grid img {
  width: 100%;
  height: 94px;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
  border: 1px solid var(--rpm-border);
}

.rpm-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(0, 0, 0, .86);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.rpm-lightbox.open { display: flex; }
.rpm-lightbox img {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .7);
}

.rpm-toast {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.2px;
  font-weight: 600;
  z-index: 95;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .4);
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
}
.rpm-toast.show { opacity: 1; }
.rpm-empty {
  padding: 36px 18px;
  text-align: center;
  color: var(--rpm-ink3);
  font-size: 13px;
}

/* Quick Question Chips in Visitor/Customer Messenger */
.rpm-quick-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 0 0 8px 0;
  scrollbar-width: none;
}
.rpm-quick-row::-webkit-scrollbar { display: none; }
.rpm-quick-chip {
  flex-shrink: 0;
  border: 1px solid var(--rpm-border2);
  background: var(--rpm-bg-input);
  color: var(--rpm-ink2);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .14s, color .14s, background .14s;
  white-space: nowrap;
}
.rpm-quick-chip:hover {
  border-color: var(--rpm-accent);
  color: var(--rpm-accent);
  background: rgba(56, 152, 243, .10);
}

/* Clickable Support Agent Avatar & Profile Popover Card */
.rpm-av-clickable {
  cursor: pointer;
  border-radius: 50%;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s ease;
}
.rpm-av-clickable:hover {
  transform: scale(1.05);
}
.rpm-av-clickable:focus,
.rpm-av-clickable:active,
.rpm-av-clickable:focus-visible {
  outline: none;
  box-shadow: none;
}
.rpm-prof-pop {
  position: fixed;
  z-index: 1200;
  width: 680px;
  max-width: calc(100vw - 24px);
  border-radius: 14px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #f3f8ff 0%, #ffffff 100%);
  border: 1px solid #d5e2f2;
  box-shadow: 0 18px 46px rgba(15, 23, 42, .16);
  color: #0f172a;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: "Inter", "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  animation: rpmProfIn .16s cubic-bezier(.16, 1, .3, 1);
}
html[data-theme="dark"] .rpm-prof-pop {
  background: linear-gradient(135deg, #212b3b 0%, #1a2332 58%, #151c29 100%);
  border: 1px solid rgba(255, 255, 255, .10);
  box-shadow: 0 22px 54px rgba(0, 0, 0, .64), 0 0 0 1px rgba(255, 255, 255, .04) inset;
  color: #f1f5f9;
}
.rpm-prof-pop.open { display: flex; }
@keyframes rpmProfIn { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.rpm-prof-left {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
  flex: 1;
}
.rpm-prof-av {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  flex-shrink: 0;
  padding: 2px;
  background: linear-gradient(135deg, #2dd4bf, #3898f3);
  box-shadow: 0 5px 18px rgba(45, 212, 191, .22);
}
.rpm-prof-av-in {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: #0f172a;
  color: #5eead4;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rpm-prof-av-in img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rpm-prof-dot {
  position: absolute;
  bottom: 1px;
  inset-inline-end: 1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid #f5f9ff;
}
html[data-theme="dark"] .rpm-prof-dot { border-color: #1c2534; }
.rpm-prof-dot.is-offline { background: #64748b; }
.rpm-prof-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; text-align: start; }
.rpm-prof-top {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.rpm-prof-name {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: .01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rpm-prof-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.4px;
  font-weight: 700;
  letter-spacing: .015em;
  line-height: 1.2;
  background: rgba(6, 111, 209, .09);
  border: 1px solid rgba(6, 111, 209, .24);
  color: #055fb3;
  white-space: nowrap;
}
html[data-theme="dark"] .rpm-prof-badge {
  background: linear-gradient(135deg, rgba(56, 152, 243, .18) 0%, rgba(99, 102, 241, .14) 100%);
  border: 1px solid rgba(96, 165, 250, .32);
  color: #93c5fd;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .20), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.rpm-prof-sub {
  font-size: 12.6px;
  font-weight: 500;
  color: #475569;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
html[data-theme="dark"] .rpm-prof-sub { color: #94a3b8; }
.rpm-prof-sub b { color: #0f172a; font-weight: 700; }
html[data-theme="dark"] .rpm-prof-sub b { color: #e2e8f0; }
.rpm-prof-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 9px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 12.6px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
html[data-theme="dark"] .rpm-prof-status-pill {
  background: #333e4f;
  border-color: rgba(255, 255, 255, .10);
  color: #e2e8f0;
}
.rpm-prof-status-pill.is-online {
  border-color: rgba(34, 197, 94, .34);
  color: #15803d;
  background: rgba(34, 197, 94, .10);
}
html[data-theme="dark"] .rpm-prof-status-pill.is-online {
  background: rgba(34, 197, 94, .14);
  border-color: rgba(34, 197, 94, .34);
  color: #4ade80;
}

@media (max-width: 960px) {
  .rpm-fab { display: none !important; }
  .rpm-corner-note { bottom: calc(74px + env(safe-area-inset-bottom)); }
}

@media (max-width: 780px) {
  .rpm-backdrop {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    height: 100dvh;
    height: 100svh;
    max-height: 100dvh;
  }
  .rpm-shell {
    height: 100%;
    max-height: 100dvh;
    max-width: 100%;
    border-radius: 0;
    border: 0;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .rpm-shell.rpm-fullpage {
    height: calc(100dvh - 142px - env(safe-area-inset-bottom));
    min-height: 400px;
    border-radius: 10px;
  }
  .rpm-side, .rpm-main {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .rpm-main {
    display: flex;
    flex-direction: column;
  }
  .rpm-head {
    flex-shrink: 0;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  }
  .rpm-head-close-btn { display: inline-flex; }
  .rpm-thread-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }
  .rpm-thread {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px;
  }
  .rpm-visitor-bar {
    flex-shrink: 0;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 7px 10px;
  }
  .rpm-visitor-bar input {
    height: 32px;
    font-size: 12px;
    padding: 0 9px;
  }
  .rpm-composer-wrap {
    flex-shrink: 0;
    padding: 8px 10px max(12px, env(safe-area-inset-bottom));
  }
  .rpm-shell.mob-chat-open .rpm-side { display: none; }
  .rpm-shell:not(.mob-chat-open) .rpm-main { display: none; }
  .rpm-back-btn { display: inline-flex; }
  .rpm-msg-row { max-width: 90%; }
}

@media (max-width: 620px) {
  .rpm-prof-pop {
    width: calc(100vw - 24px);
    padding: 13px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .rpm-prof-left { gap: 12px; }
  .rpm-prof-av { width: 52px; height: 52px; }
  .rpm-prof-name { font-size: 17px; }
  .rpm-prof-badge { font-size: 10.8px; padding: 2.5px 9px; }
  .rpm-prof-sub { font-size: 11.8px; }
  .rpm-prof-status-pill { width: 100%; height: 34px; font-size: 12px; }
}
