/* ================================ Variables ================================ */
:root {
  --rt-head: 52px;
  --rt-tabs: 46px;
  --rt-min: 50px; /* height of bottom Minimize bar */
}

/* ================================ Floating bubble ================================ */
#rt-launcher {
  position: fixed;
  right: 20px;
  bottom: 19px;
  z-index: 9998;
}
#rt-launcher .fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  background: #111;
  color: #fff;
  font-size: 22px;
}
#rt-launcher .badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #e11;
  color: #fff;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 12px;
  display: none;
}

/* ================================ Bottom sheet ================================ */
/* Bottom sheet (flex-based layout) */
#rt-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 92vh;
  max-height: 100dvh;
  background: #fff;
  color: #111;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .25);
  z-index: 10000;
  display: none;
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column; /* stack head, body, tabs, minimize */
}
/* Header stays fixed height */
#rt-sheet .rt-head {
  height: var(--rt-head);
  flex: 0 0 var(--rt-head);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  z-index: 2000;
}
/* Body now flexes automatically */
#rt-sheet .rt-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* smooth iOS scroll */
  padding: 0 12px 0px; /* adjust bottom space if needed */
  overscroll-behavior: contain;
}
/* Tabs + minimize now fixed height at bottom */
#rt-sheet .rt-tabs {
  flex: 0 0 var(--rt-tabs);
  display: flex;
  align-items: center;
  justify-content: stretch;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  z-index: 4;
}
#rt-sheet .rt-minimize {
  flex: 0 0 var(--rt-min);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  z-index: 5;
  padding-bottom: calc(env(safe-area-inset-bottom) + 0px);
}
#rt-sheet .rt-tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  font-weight: 600;
  border-right: 1px solid #e5e7eb;
  margin: 0 2px;
}
#rt-sheet .rt-tab:last-child {
  border-right: none;
}
#rt-sheet .rt-tab.active {
  background: #111;
  color: #fff;
}
#rt-sheet .tab-badge {
  display: none;
  position: relative;
  top: -1px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
/* Jump-to-latest */
.rt-jump {
  position: sticky;
  bottom: 12px;
  margin: 8px auto 0;
  display: none;
  padding: 8px 12px;
  border: none;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
  z-index: 3;
}

/* ================================ Lists ================================ */
.rt-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rt-list li {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.muted {
  padding: 12px;
  color: #6b7280;
}
.mini-unread {
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

/* ================================ Desktop adjustments ================================ */
@media (min-width: 900px) {
  #rt-sheet {
    left: auto;
    right: 18px;
    bottom: 18px;
    width: 420px;
    height: 80vh;
    max-height: calc(100vh - 36px);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
  }
}

/* ================================ Online list ================================ */
#rt-online {
  padding-top: 8px;
}
#rt-online .title {
  font-weight: 700;
  font-size: 18px;
  margin: 4px 0 10px;
}
#rt-online-list {
  margin-left: -12px;
  margin-right: -12px;
  padding-bottom: 50px;
}
#rt-online-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 6px;
}
.rt-dot-online {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2ecc71;
  display: inline-block;
  margin-left: auto;
  margin-right: 6px;
}

/* ================================ Avatars ================================ */
.rt-avatar, .rt-initial {
  width: 39px;
  height: 39px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 39px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
  color: #111;
  font-weight: 700;
}
.rt-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ================================ DM view ================================ */
#rt-dm-back {
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: #111;
  cursor: pointer;
}
#rt-dm-chats-back {
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: #111;
  cursor: pointer;
}
#rt-dm {
  padding-top: 8px;
}
#rt-dm .title {
  font-weight: 700;
  font-size: 18px;
  margin: 4px 0 10px;
}
.dm-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e6e6e6;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1000;
}
.dm-head .dm-who {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.dm-head .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #f8f8f8;
  line-height: 1;
  cursor: pointer;
}
.dm-body {
  padding: 12px 12px 8px;
}
.dm-item {
  display: flex;
  align-items: flex-start;
  max-width: 100%;
}
.dm-bubble {
  background: #f3f4f6;
  padding: 8px 10px;
  border-radius: 12px;
  flex: 0 1 auto;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.dm-meta {
  font-size: 11px;
  opacity: .7;
  margin-top: 2px;
}
.dm-input {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #e6e6e6;
}
.dm-input textarea {
  flex: 1 1 auto;
  max-height: 110px;
  height: 44px;
  line-height: 20px;
  padding: 10px 12px;
  border: 1px solid #e1e1e1;
  border-radius: 12px;
  font-size: 16px;
  resize: none;
  overflow: auto;
}
.dm-input button {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: #111;
  color: #fff;
  font-weight: 600;
}
/* Threads */
#rt-dm-threads .rt-list {
  margin-left: -12px !important;
  margin-right: -12px !important;
}
#rt-dm-threads .rt-list li {
  padding-left: 6px !important;
  padding-right: 12px;
}

/* ================================ Toast ================================ */
.rt-toast-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, .22);
}
.rt-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 92%;
  width: 520px;
  background: #111;
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  padding: 14px 16px;
}
.rt-toast-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.rt-toast-text {
  font-weight: 700;
  line-height: 1.3;
}
.rt-toast-x {
  border: none;
  background: #000;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ================================ DM thumbnails & lightbox ================================ */
#rt-sheet .dm-item.dm-img {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}
#rt-sheet .dm-item img.rt-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #ddd;
  display: block;
}
#rt-sheet .dm-item.dm-img .rt-thumb--pending {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: #fafafa;
  color: #888;
}
#rt-sheet .dm-item.dm-img.pending .rt-pending-note {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.2;
  font-weight: 500;
}
#rt-sheet .dm-item .rt-attachments {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
/* Lightbox */
#rt-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999999;
}
#rt-lightbox.show {
  display: block;
}
#rt-lightbox .rt-lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .85);
}
#rt-lightbox .rt-lb-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#rt-lightbox img {
  max-width: 96vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
#rt-lightbox .rt-lb-close {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

/* ================================ Filter bar ================================ */
.rt-filterbar {
  position: absolute;
  bottom: calc(var(--rt-tabs) + var(--rt-min));
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 6px 3px;
}
.rt-filterbar .rt-btn {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  border: none;
  border-right: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  font-weight: 600;
  color: #111;
  cursor: pointer;
}
.rt-filterbar .rt-btn:last-child {
  border-right: none;
}
.rt-filterbar .rt-btn.active {
  background: #111;
  color: #fff;
}

/* ================================ Menus ================================ */
.dm-menu {
  position: relative;
  margin-left: auto;
}
.dm-menu-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  color: #555;
}
.dm-menu-btn:hover {
  color: #000;
}
.dm-menu-drop {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  min-width: 160px;
  z-index: 9999;
}
.dm-menu-drop .item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
}
.dm-menu-drop .item:hover {
  background: #f5f5f5;
}
.dm-menu-drop .separator {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 0;
}
/* Header main menu */
.main-menu {
  position: relative;
}
.main-menu-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.main-menu-drop {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-width: 140px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 3000;
}
.main-menu-drop .item {
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}
.main-menu-drop .item:hover,
.main-menu-drop .item:active {
  background: #f0f0f0;
}

/* ================================ Misc ================================ */
.rt-trash {
  margin: 0 12px;
  cursor: pointer;
  font-size: 19px;
  display: inline-block;
  opacity: 0.8;
}
.rt-trash:hover {
  opacity: 1;
}
.dm-subtitle {
  font-size: 12px;
  color: #666;
  font-weight: normal;
}

/* DM placeholder hint */
#rt-dm-hint {
  text-align: center;
  color: #777;         /* subtle gray */
  font-style: italic;  /* "hint" style */
  padding: 20px 3px 50px 3px;  /* breathing room */
  font-size: 14px;
  display: none;       /* hidden until shown by JS */
}

.rt-member-badge {
  margin-left: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* Paid */
.rt-member-badge.paid {
  color: blue;
  background: black;
}

/* PREMIUM */
.rt-member-badge.premium {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid #28A828;
  font-size: 11px;
  color: #ffffff;
  background: #28A828;
}


/* PREMIUM PLUS */
.rt-member-badge.plus {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid #0074D9;
  font-size: 11px;
  color: #ffffff;
  background: #0074D9;
}


/* Lifetime */
.rt-member-badge.lifetime {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid #F87431;
  font-size: 11px;
  color: #ffffff;
  background: #F87431;
   white-space: nowrap;
}
